mesh: bugfix and add two APIs

1. new APIs: esp_mesh_get_subnet_nodes_num() and esp_mesh_get_subnet_nodes_list().
2. fix hard to find the parent during connect.
3. disable Wi-Fi channel switch function.
4. fix a typo of MESH_EVENT_NO_PARENT_FOUND.
This commit is contained in:
qiyuexia 2018-08-27 15:08:54 +08:00 committed by qiyueixa
parent 147b349799
commit 91dd05662d
6 changed files with 44 additions and 21 deletions

View file

@ -166,7 +166,7 @@ typedef enum {
MESH_EVENT_ROUTING_TABLE_REMOVE, /**< routing table is changed by removing leave children */
MESH_EVENT_PARENT_CONNECTED, /**< parent is connected on station interface */
MESH_EVENT_PARENT_DISCONNECTED, /**< parent is disconnected on station interface */
MESH_EVENT_NO_PARNET_FOUND, /**< no parent found */
MESH_EVENT_NO_PARENT_FOUND, /**< no parent found */
MESH_EVENT_LAYER_CHANGE, /**< layer changes over the mesh network */
MESH_EVENT_TODS_STATE, /**< state represents if root is able to access external IP network */
MESH_EVENT_VOTE_STARTED, /**< the process of voting a new root is started either by children or by root */
@ -771,9 +771,13 @@ esp_err_t esp_mesh_set_id(const mesh_addr_t *id);
esp_err_t esp_mesh_get_id(mesh_addr_t *id);
/**
* @brief set device type over the mesh network(Unimplemented)
* @brief specify device type over the mesh network
* - MESH_ROOT: designates the root node for a mesh network
* - MESH_LEAF: designates a device as a standalone Wi-Fi station
*
* @param type device type
* @attention This API shall be called before esp_mesh_start().
*
* @param type device type (only support MESH_ROOT, MESH_LEAF)
*
* @return
* - ESP_OK
@ -782,9 +786,7 @@ esp_err_t esp_mesh_get_id(mesh_addr_t *id);
esp_err_t esp_mesh_set_type(mesh_type_t type);
/**
* @brief get device type over mesh network
*
* @attention This API shall be called after having received the event MESH_EVENT_PARENT_CONNECTED.
* @brief get device type over the mesh network
*
* @return mesh type
*
@ -792,7 +794,7 @@ esp_err_t esp_mesh_set_type(mesh_type_t type);
mesh_type_t esp_mesh_get_type(void);
/**
* @brief set max layer configuration(max:15, default:15)
* @brief set max layer configuration(max:25, default:25)
*
* @attention This API shall be called before esp_mesh_start().
*
@ -1320,6 +1322,33 @@ esp_err_t esp_mesh_scan_get_ap_record(wifi_ap_record_t *ap_record, void *buffer)
*/
esp_err_t esp_mesh_flush_upstream_packets(void);
/**
* @brief get the number of nodes in the subnet of a specific child
*
* @param child_mac an associated child address of this device
* @param nodes_num pointer to the number of nodes in the subnet of a specific child
*
* @return
* - ESP_OK
* - ESP_ERR_MESH_NOT_START
* - ESP_ERR_MESH_ARGUMENT
*/
esp_err_t esp_mesh_get_subnet_nodes_num(const mesh_addr_t *child_mac, int *nodes_num);
/**
* @brief get nodes in the subnet of a specific child
*
* @param child_mac an associated child address of this device
* @param nodes pointer to nodes in the subnet of a specific child
* @param nodes_num the number of nodes in the subnet of a specific child
*
* @return
* - ESP_OK
* - ESP_ERR_MESH_NOT_START
* - ESP_ERR_MESH_ARGUMENT
*/
esp_err_t esp_mesh_get_subnet_nodes_list(const mesh_addr_t *child_mac, mesh_addr_t *nodes, int nodes_num);
#ifdef __cplusplus
}
#endif

@ -1 +1 @@
Subproject commit 2cb4ce3da5abf2ed51a1aa79b119625b02e521a2
Subproject commit 4c69c1ad8da7a9cbe8e27598b8c91780ac0b5068

View file

@ -21,7 +21,7 @@ config MESH_ROUTER_PASSWD
choice
bool "Mesh AP Authentication Mode"
default MAP_AUTH_MODE_OPEN
default WIFI_AUTH_WPA2_PSK
help
Authentication mode.
@ -70,11 +70,5 @@ config MESH_ROUTE_TABLE_SIZE
default 50
help
The number of devices over the network(max: 300).
config MESH_PARENT_SSID
string "Parent SSID"
default "PARENT_SSID"
help
Parent SSID.
endmenu

View file

@ -217,8 +217,8 @@ void mesh_event_handler(mesh_event_t event)
event.info.routing_table.rt_size_change,
event.info.routing_table.rt_size_new);
break;
case MESH_EVENT_NO_PARNET_FOUND:
ESP_LOGI(MESH_TAG, "<MESH_EVENT_NO_PARNET_FOUND>scan times:%d",
case MESH_EVENT_NO_PARENT_FOUND:
ESP_LOGI(MESH_TAG, "<MESH_EVENT_NO_PARENT_FOUND>scan times:%d",
event.info.no_parent.scan_times);
/* TODO handler for the failure */
break;
@ -350,7 +350,6 @@ void app_main(void)
/* mesh initialization */
ESP_ERROR_CHECK(esp_mesh_init());
ESP_ERROR_CHECK(esp_mesh_set_max_layer(CONFIG_MESH_MAX_LAYER));
ESP_ERROR_CHECK(esp_mesh_set_ap_authmode(CONFIG_MESH_AP_AUTHMODE));
ESP_ERROR_CHECK(esp_mesh_set_vote_percentage(1));
ESP_ERROR_CHECK(esp_mesh_set_ap_assoc_expire(10));
#ifdef MESH_FIX_ROOT
@ -368,6 +367,7 @@ void app_main(void)
memcpy((uint8_t *) &cfg.router.password, CONFIG_MESH_ROUTER_PASSWD,
strlen(CONFIG_MESH_ROUTER_PASSWD));
/* mesh softAP */
ESP_ERROR_CHECK(esp_mesh_set_ap_authmode(CONFIG_MESH_AP_AUTHMODE));
cfg.mesh_ap.max_connection = CONFIG_MESH_AP_CONNECTIONS;
memcpy((uint8_t *) &cfg.mesh_ap.password, CONFIG_MESH_AP_PASSWD,
strlen(CONFIG_MESH_AP_PASSWD));

View file

@ -21,7 +21,7 @@ config MESH_ROUTER_PASSWD
choice
bool "Mesh AP Authentication Mode"
default MAP_AUTH_MODE_OPEN
default WIFI_AUTH_WPA2_PSK
help
Authentication mode.

View file

@ -173,8 +173,8 @@ void mesh_event_handler(mesh_event_t event)
event.info.routing_table.rt_size_change,
event.info.routing_table.rt_size_new);
break;
case MESH_EVENT_NO_PARNET_FOUND:
ESP_LOGI(MESH_TAG, "<MESH_EVENT_NO_PARNET_FOUND>scan times:%d",
case MESH_EVENT_NO_PARENT_FOUND:
ESP_LOGI(MESH_TAG, "<MESH_EVENT_NO_PARENT_FOUND>scan times:%d",
event.info.no_parent.scan_times);
/* TODO handler for the failure */
break;