diff --git a/components/esp32/include/esp_mesh.h b/components/esp32/include/esp_mesh.h index 8fea167de..0adb59124 100644 --- a/components/esp32/include/esp_mesh.h +++ b/components/esp32/include/esp_mesh.h @@ -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 diff --git a/components/esp32/lib b/components/esp32/lib index 2cb4ce3da..4c69c1ad8 160000 --- a/components/esp32/lib +++ b/components/esp32/lib @@ -1 +1 @@ -Subproject commit 2cb4ce3da5abf2ed51a1aa79b119625b02e521a2 +Subproject commit 4c69c1ad8da7a9cbe8e27598b8c91780ac0b5068 diff --git a/examples/mesh/internal_communication/main/Kconfig.projbuild b/examples/mesh/internal_communication/main/Kconfig.projbuild index a3bad4bfd..d8de07e5b 100644 --- a/examples/mesh/internal_communication/main/Kconfig.projbuild +++ b/examples/mesh/internal_communication/main/Kconfig.projbuild @@ -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 diff --git a/examples/mesh/internal_communication/main/mesh_main.c b/examples/mesh/internal_communication/main/mesh_main.c index 4e6b10901..fae5fa279 100644 --- a/examples/mesh/internal_communication/main/mesh_main.c +++ b/examples/mesh/internal_communication/main/mesh_main.c @@ -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, "scan times:%d", + case MESH_EVENT_NO_PARENT_FOUND: + ESP_LOGI(MESH_TAG, "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)); diff --git a/examples/mesh/manual_networking/main/Kconfig.projbuild b/examples/mesh/manual_networking/main/Kconfig.projbuild index a3bad4bfd..32dd47197 100644 --- a/examples/mesh/manual_networking/main/Kconfig.projbuild +++ b/examples/mesh/manual_networking/main/Kconfig.projbuild @@ -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. diff --git a/examples/mesh/manual_networking/main/mesh_main.c b/examples/mesh/manual_networking/main/mesh_main.c index 2703dd5b6..79b547a18 100644 --- a/examples/mesh/manual_networking/main/mesh_main.c +++ b/examples/mesh/manual_networking/main/mesh_main.c @@ -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, "scan times:%d", + case MESH_EVENT_NO_PARENT_FOUND: + ESP_LOGI(MESH_TAG, "scan times:%d", event.info.no_parent.scan_times); /* TODO handler for the failure */ break;