Просмотр исходного кода

mesh: support set new type

If the root is specified (FIXED-ROOT) by set type or set parent, change ie.mesh_type to MESH_ROOT before connect to router
Release emesh_recv_toDS when the root becomes non-root
esp_mesh_set_type now supports MESH_IDLE and MESH_STA
chenyudong 5 лет назад
Родитель
Сommit
040f4be2a7

+ 3 - 0
components/esp_common/src/esp_err_to_name.c

@@ -472,6 +472,9 @@ static const esp_err_msg_t esp_err_msg_table[] = {
 #   endif
 #   ifdef      ESP_ERR_MESH_PS
     ERR_TBL_IT(ESP_ERR_MESH_PS),                                /* 16409 0x4019 */
+#   endif
+#   ifdef      ESP_ERR_MESH_RECV_RELEASE
+    ERR_TBL_IT(ESP_ERR_MESH_RECV_RELEASE),                      /* 16410 0x401a */
 #   endif
     // components/esp_netif/include/esp_netif_types.h
 #   ifdef      ESP_ERR_ESP_NETIF_BASE

+ 7 - 1
components/esp_wifi/include/esp_mesh.h

@@ -128,6 +128,7 @@ extern "C" {
 #define ESP_ERR_MESH_XMIT                 (ESP_ERR_MESH_BASE + 23)   /**< XMIT */
 #define ESP_ERR_MESH_QUEUE_READ           (ESP_ERR_MESH_BASE + 24)   /**< error in reading queue */
 #define ESP_ERR_MESH_PS                   (ESP_ERR_MESH_BASE + 25)   /**< mesh PS is not specified as enable or disable */
+#define ESP_ERR_MESH_RECV_RELEASE         (ESP_ERR_MESH_BASE + 26)   /**< release esp_mesh_recv_toDS */
 
 /**
  * @brief Flags bitmap for esp_mesh_send() and esp_mesh_recv()
@@ -225,6 +226,7 @@ typedef enum {
     MESH_ROOT,    /**< the only sink of the mesh network. Has the ability to access external IP network */
     MESH_NODE,    /**< intermediate device. Has the ability to forward packets over the mesh network */
     MESH_LEAF,    /**< has no forwarding ability */
+    MESH_STA,     /**< connect to router with a standlone Wi-Fi station mode, no network expansion capability */
 } mesh_type_t;
 
 /**
@@ -753,6 +755,7 @@ esp_err_t esp_mesh_recv(mesh_addr_t *from, mesh_data_t *data, int timeout_ms,
  *    - ESP_ERR_MESH_NOT_START
  *    - ESP_ERR_MESH_TIMEOUT
  *    - ESP_ERR_MESH_DISCARD
+ *    - ESP_ERR_MESH_RECV_RELEASE
  */
 esp_err_t esp_mesh_recv_toDS(mesh_addr_t *from, mesh_addr_t *to,
                              mesh_data_t *data, int timeout_ms, int *flag, mesh_opt_t opt[],
@@ -848,8 +851,10 @@ esp_err_t esp_mesh_get_id(mesh_addr_t *id);
 
 /**
  * @brief      Designate device type over the mesh network
+ *            - MESH_IDLE: designates a device as a self-organized node for a mesh network
  *            - MESH_ROOT: designates the root node for a mesh network
- *            - MESH_LEAF: designates a device as a standalone Wi-Fi station
+ *            - MESH_LEAF: designates a device as a standalone Wi-Fi station that connects to a parent
+ *            - MESH_STA: designates a device as a standalone Wi-Fi station that connects to a router
  *
  * @param[in]  type  device type
  *
@@ -1356,6 +1361,7 @@ bool esp_mesh_is_root_fixed(void);
  * @param[in]  parent_mesh_id  parent mesh ID,
  *             - If this value is not set, the original mesh ID is used.
  * @param[in]  my_type  mesh type
+ *             - MESH_STA is not supported.
  *             - If the parent set for the device is the same as the router in the network configuration,
  *            then my_type shall set MESH_ROOT and my_layer shall set MESH_ROOT_LAYER.
  * @param[in]  my_layer  mesh layer

+ 1 - 1
components/esp_wifi/lib

@@ -1 +1 @@
-Subproject commit 063d254fda8017ef4ddbe0de216324008344e8df
+Subproject commit fc602534d328ef33085d45ce97c81a8942a06aad