ESP8266 Centre + NB
结构体 | 枚举 | 函数
Mesh APIs

Mesh APIs. 更多...

结构体

struct  mesh_scan_para_type
 

枚举

enum  mesh_status {
  MESH_DISABLE = 0, MESH_WIFI_CONN, MESH_NET_CONN, MESH_LOCAL_AVAIL,
  MESH_ONLINE_AVAIL
}
 
enum  mesh_node_type { MESH_NODE_PARENT = 0, MESH_NODE_CHILD, MESH_NODE_ALL }
 

函数

bool espconn_mesh_local_addr (struct ip_addr *ip)
 Check whether the IP address is mesh local IP address or not. 更多...
 
bool espconn_mesh_get_router (struct station_config *router)
 Get the information of router used by mesh network. 更多...
 
bool espconn_mesh_set_router (struct station_config *router)
 Set the information of router used by mesh network. 更多...
 
bool espconn_mesh_server_init (struct ip_addr *ip, uint16_t port)
 Set server setup by user. 更多...
 
bool espconn_mesh_get_node_info (enum mesh_node_type type, uint8_t **info, uint8_t *count)
 Get the information of mesh node. 更多...
 
bool espconn_mesh_encrypt_init (AUTH_MODE mode, uint8_t *passwd, uint8_t passwd_len)
 Set WiFi cryption algrithm and password for mesh node. 更多...
 
bool espconn_mesh_set_ssid_prefix (uint8_t *prefix, uint8_t prefix_len)
 Set prefix of SSID for mesh node. 更多...
 
bool espconn_mesh_set_max_hops (uint8_t max_hops)
 Set max hop for mesh network. 更多...
 
bool espconn_mesh_group_id_init (uint8_t *grp_id, uint16_t gid_len)
 Set group ID of mesh node. 更多...
 
bool espconn_mesh_set_dev_type (uint8_t dev_type)
 Set the curent device type. 更多...
 
uint8_t espconn_mesh_get_dev_type ()
 Get the curent device type. 更多...
 
int8_t espconn_mesh_connect (struct espconn *usr_esp)
 Try to establish mesh connection to server. 更多...
 
int8_t espconn_mesh_disconnect (struct espconn *usr_esp)
 Disconnect a mesh connection. 更多...
 
int8_t espconn_mesh_get_status ()
 Get current mesh status. 更多...
 
int8_t espconn_mesh_sent (struct espconn *usr_esp, uint8 *pdata, uint16 len)
 Send data through mesh network. 更多...
 
uint8_t espconn_mesh_get_max_hops ()
 Get max hop of mesh network. 更多...
 
void espconn_mesh_enable (espconn_mesh_callback enable_cb, enum mesh_type type)
 To enable mesh network. 更多...
 
void espconn_mesh_disable (espconn_mesh_callback disable_cb)
 To disable mesh network. 更多...
 
void espconn_mesh_print_ver ()
 To print version of mesh. 更多...
 
void espconn_mesh_scan (struct mesh_scan_para_type *para)
 To get AP around node. 更多...
 

详细描述

Mesh APIs.

枚举类型说明

枚举值
MESH_DISABLE 
MESH_WIFI_CONN 
MESH_NET_CONN 
MESH_LOCAL_AVAIL 
MESH_ONLINE_AVAIL 
56  {
57  MESH_DISABLE = 0,
62 };
Definition: mesh.h:61
Definition: mesh.h:57
Definition: mesh.h:59
Definition: mesh.h:60
Definition: mesh.h:58
枚举值
MESH_NODE_PARENT 
MESH_NODE_CHILD 
MESH_NODE_ALL 
64  {
65  MESH_NODE_PARENT = 0,
68 };
Definition: mesh.h:66
Definition: mesh.h:65
Definition: mesh.h:67

函数说明

bool espconn_mesh_local_addr ( struct ip_addr ip)

Check whether the IP address is mesh local IP address or not.

注意
1. The range of mesh local IP address is 2.255.255.* ~ max_hop.255.255.*.
2. IP pointer should not be NULL. If the IP pointer is NULL, it will return false.
参数
structip_addr *ip : IP address
返回
true : the IP address is mesh local IP address
false : the IP address is not mesh local IP address
bool espconn_mesh_get_router ( struct station_config router)

Get the information of router used by mesh network.

注意
1. The function should be called after mesh_enable_done
参数
structstation_config *router: router inforamtion
返回
true : succeed
false : fail
bool espconn_mesh_set_router ( struct station_config router)

Set the information of router used by mesh network.

注意
The function must be called before espconn_mesh_enable.
参数
structstation_config *router: router information. user should initialize the ssid and password.
返回
true : succeed
false : fail
bool espconn_mesh_server_init ( struct ip_addr ip,
uint16_t  port 
)

Set server setup by user.

注意
If users wants to use themself server, they use the function. but the function must be called before espconn_mesh_enable. at the same time, users need to implement the server.
参数
structip_addr *ip : ip address of server.
uint16_tport : port used by server.
返回
true : succeed
false : fail
bool espconn_mesh_get_node_info ( enum mesh_node_type  type,
uint8_t **  info,
uint8_t count 
)

Get the information of mesh node.

参数
enummesh_node_type typ : mesh node type.
uint8_t**info : the information will be saved in *info.
uint8_t*count : the node count in *info.
返回
true : succeed
false : fail
bool espconn_mesh_encrypt_init ( AUTH_MODE  mode,
uint8_t passwd,
uint8_t  passwd_len 
)

Set WiFi cryption algrithm and password for mesh node.

注意
The function must be called before espconn_mesh_enable.
参数
AUTH_MODEmode : cryption algrithm (WPA/WAP2/WPA_WPA2).
uint8_t*passwd : password of WiFi.
uint8_tpasswd_len : length of password (8 <= passwd_len <= 64).
返回
true : succeed
false : fail
bool espconn_mesh_set_ssid_prefix ( uint8_t prefix,
uint8_t  prefix_len 
)

Set prefix of SSID for mesh node.

注意
The function must be called before espconn_mesh_enable.
参数
uint8_t*prefix : prefix of SSID.
uint8_tprefix_len : length of prefix (0 < passwd_len <= 22).
返回
true : succeed
false : fail
bool espconn_mesh_set_max_hops ( uint8_t  max_hops)

Set max hop for mesh network.

注意
The function must be called before espconn_mesh_enable.
参数
uint8_tmax_hops : max hop of mesh network (1 <= max_hops < 10, 4 is recommended).
返回
true : succeed
false : fail
bool espconn_mesh_group_id_init ( uint8_t grp_id,
uint16_t  gid_len 
)

Set group ID of mesh node.

注意
The function must be called before espconn_mesh_enable.
参数
uint8_t*grp_id : group ID.
uint16_tgid_len: length of group ID, now gid_len = 6.
返回
true : succeed
false : fail
bool espconn_mesh_set_dev_type ( uint8_t  dev_type)

Set the curent device type.

参数
uint8_tdev_type : device type of mesh node
返回
true : succeed
false : fail
uint8_t espconn_mesh_get_dev_type ( )

Get the curent device type.

参数
none
返回
device type
int8_t espconn_mesh_connect ( struct espconn usr_esp)

Try to establish mesh connection to server.

注意
If espconn_mesh_connect fail, returns non-0 value, there is no connection, so it won't enter any espconn callback.
参数
structespconn *usr_esp : the network connection structure, the usr_esp to listen to the connection
返回
0 : succeed
Non-0 : error code
  • ESPCONN_RTE - Routing Problem
  • ESPCONN_MEM - Out of memory
  • ESPCONN_ISCONN - Already connected
  • ESPCONN_ARG - Illegal argument, can't find the corresponding connection according to structure espconn
int8_t espconn_mesh_disconnect ( struct espconn usr_esp)

Disconnect a mesh connection.

注意
Do not call this API in any espconn callback. If needed, please use system task to trigger espconn_mesh_disconnect.
参数
structespconn *usr_esp : the network connection structure
返回
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
int8_t espconn_mesh_get_status ( )

Get current mesh status.

参数
null
返回
the current mesh status, please refer to enum mesh_status.
int8_t espconn_mesh_sent ( struct espconn usr_esp,
uint8 pdata,
uint16  len 
)

Send data through mesh network.

注意
Please call espconn_mesh_sent after espconn_sent_callback of the pre-packet.
参数
structespconn *usr_esp : the network connection structure
uint8*pdata : pointer of data
uint16len : data length
返回
0 : succeed
Non-0 : error code
  • ESPCONN_MEM - out of memory
  • ESPCONN_ARG - illegal argument, can't find the corresponding network transmission according to structure espconn
  • ESPCONN_MAXNUM - buffer of sending data is full
  • ESPCONN_IF - send UDP data fail
uint8_t espconn_mesh_get_max_hops ( )

Get max hop of mesh network.

参数
null.
返回
the current max hop of mesh
void espconn_mesh_enable ( espconn_mesh_callback  enable_cb,
enum mesh_type  type 
)

To enable mesh network.

注意
1. the function should be called in user_init.
2. if mesh node can not scan the mesh AP, it will be isolate node without trigger enable_cb. user can use espconn_mesh_get_status to get current status of node.
3. if user try to enable online mesh, but node fails to establish mesh connection the node will work with local mesh.
参数
espconn_mesh_callbackenable_cb : callback function of mesh-enable
enummesh_type type : type of mesh, local or online.
返回
null
void espconn_mesh_disable ( espconn_mesh_callback  disable_cb)

To disable mesh network.

注意
When mesh network is disabed, the system will trigger disable_cb.
参数
espconn_mesh_callbackdisable_cb : callback function of mesh-disable
enummesh_type type : type of mesh, local or online.
返回
null
void espconn_mesh_print_ver ( )

To print version of mesh.

参数
null
返回
null
void espconn_mesh_scan ( struct mesh_scan_para_type para)

To get AP around node.

注意
User can get normal AP or mesh AP using the function. If user plans to get normal AP, he/she needs to clear grp_set flag in para. If user plans to get mesh AP, he/she needs to set grp_set and grp_id;
参数
structmesh_scan_para_type *para : callback function of mesh-disable
返回
null