]> granicus.if.org Git - esp-idf/commitdiff
mesh: bugfix and add two APIs
authorqiyuexia <qiyuexia@espressif.com>
Mon, 27 Aug 2018 07:08:54 +0000 (15:08 +0800)
committerqiyueixa <qiyuexia@espressif.com>
Mon, 27 Aug 2018 11:12:40 +0000 (19:12 +0800)
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.

components/esp32/include/esp_mesh.h
components/esp32/lib
examples/mesh/internal_communication/main/Kconfig.projbuild
examples/mesh/internal_communication/main/mesh_main.c
examples/mesh/manual_networking/main/Kconfig.projbuild
examples/mesh/manual_networking/main/mesh_main.c

index 8fea167de14cb8a1ca24597c326a296837f7481b..0adb5912463830f1288ad14982f254bc401e483c 100644 (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
index 2cb4ce3da5abf2ed51a1aa79b119625b02e521a2..4c69c1ad8da7a9cbe8e27598b8c91780ac0b5068 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 2cb4ce3da5abf2ed51a1aa79b119625b02e521a2
+Subproject commit 4c69c1ad8da7a9cbe8e27598b8c91780ac0b5068
index a3bad4bfd08fa6d1c324c04c00b2340140a0c9e6..d8de07e5bcbd5184dd52ac7d96b99624b299c572 100644 (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
 
index 4e6b10901f6d1fc8e074c56e3557118fb6f10c2b..fae5fa27998a17b597129ff06c2ecc2a0ca8b10b 100644 (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));
index a3bad4bfd08fa6d1c324c04c00b2340140a0c9e6..32dd4719748442e34112ed85628bc2866d9b1f21 100644 (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.
 
index 2703dd5b63d0372feb5c1c950235109939d22a2c..79b547a189fd50a4f795f11d1bd469bfc80004e5 100644 (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;