From b408043d7ef1cc221f50d6301046ab36cbd811ad Mon Sep 17 00:00:00 2001 From: shenjun Date: Thu, 30 Jun 2022 21:19:23 +0800 Subject: [PATCH] esp_wifi_mesh: add non mesh connections access --- components/esp_wifi/include/esp_mesh.h | 23 +++++++++++++++---- components/esp_wifi/include/esp_wifi_types.h | 5 +++- components/esp_wifi/lib | 2 +- .../main/Kconfig.projbuild | 9 +++++++- .../internal_communication/main/mesh_main.c | 1 + .../main/Kconfig.projbuild | 9 +++++++- .../mesh/ip_internal_network/main/mesh_main.c | 1 + .../manual_networking/main/Kconfig.projbuild | 9 +++++++- .../mesh/manual_networking/main/mesh_main.c | 1 + 9 files changed, 50 insertions(+), 10 deletions(-) diff --git a/components/esp_wifi/include/esp_mesh.h b/components/esp_wifi/include/esp_mesh.h index b813b16348..5e528610e9 100644 --- a/components/esp_wifi/include/esp_mesh.h +++ b/components/esp_wifi/include/esp_mesh.h @@ -505,8 +505,13 @@ typedef struct { * @brief Mesh softAP configuration */ typedef struct { - uint8_t password[64]; /**< mesh softAP password */ - uint8_t max_connection; /**< max number of stations allowed to connect in, max 10 */ + uint8_t password[64]; /**< mesh softAP password */ + /** + * max number of stations allowed to connect in, default 6, max 10 + * = max_connection + nonmesh_max_connection + */ + uint8_t max_connection; /**< max mesh connections */ + uint8_t nonmesh_max_connection; /**< max non-mesh connections */ } mesh_ap_cfg_t; /** @@ -947,7 +952,8 @@ esp_err_t esp_mesh_set_ap_authmode(wifi_auth_mode_t authmode); wifi_auth_mode_t esp_mesh_get_ap_authmode(void); /** - * @brief Set mesh softAP max connection value + * @brief Set mesh max connection value + * - Set mesh softAP max connection = mesh max connection + non-mesh max connection * * @attention This API shall be called before mesh is started. * @@ -960,12 +966,19 @@ wifi_auth_mode_t esp_mesh_get_ap_authmode(void); esp_err_t esp_mesh_set_ap_connections(int connections); /** - * @brief Get mesh softAP max connection configuration + * @brief Get mesh max connection configuration * - * @return the number of max connections + * @return the number of mesh max connections */ int esp_mesh_get_ap_connections(void); +/** + * @brief Get non-mesh max connection configuration + * + * @return the number of non-mesh max connections + */ +int esp_mesh_get_non_mesh_connections(void); + /** * @brief Get current layer value over the mesh network * diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index 10b4340642..20f5eca154 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -256,7 +256,8 @@ typedef struct { uint32_t phy_11g:1; /**< bit: 1 flag to identify if 11g mode is enabled or not */ uint32_t phy_11n:1; /**< bit: 2 flag to identify if 11n mode is enabled or not */ uint32_t phy_lr:1; /**< bit: 3 flag to identify if low rate is enabled or not */ - uint32_t reserved:28; /**< bit: 4..31 reserved */ + uint32_t is_mesh_child:1;/**< bit: 4 flag to identify mesh child */ + uint32_t reserved:27; /**< bit: 5..31 reserved */ } wifi_sta_info_t; #define ESP_WIFI_MAX_CONN_NUM (10) /**< max number of stations which can connect to ESP32 soft-AP */ @@ -600,12 +601,14 @@ typedef struct { typedef struct { uint8_t mac[6]; /**< MAC address of the station connected to ESP32 soft-AP */ uint8_t aid; /**< the aid that ESP32 soft-AP gives to the station connected to */ + bool is_mesh_child; /**< flag to identify mesh child */ } wifi_event_ap_staconnected_t; /** Argument structure for WIFI_EVENT_AP_STADISCONNECTED event */ typedef struct { uint8_t mac[6]; /**< MAC address of the station disconnects to ESP32 soft-AP */ uint8_t aid; /**< the aid that ESP32 soft-AP gave to the station disconnects to */ + bool is_mesh_child; /**< flag to identify mesh child */ } wifi_event_ap_stadisconnected_t; /** Argument structure for WIFI_EVENT_AP_PROBEREQRECVED event */ diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 3712c028c0..90fa34580f 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 3712c028c0c0791008dbf7317df9d6218211f7e7 +Subproject commit 90fa34580fc0067bf580b6b37ffcf8e3f8fd37ee diff --git a/examples/mesh/internal_communication/main/Kconfig.projbuild b/examples/mesh/internal_communication/main/Kconfig.projbuild index c8aa139a17..b3c530c041 100644 --- a/examples/mesh/internal_communication/main/Kconfig.projbuild +++ b/examples/mesh/internal_communication/main/Kconfig.projbuild @@ -154,7 +154,14 @@ menu "Example Configuration" range 1 10 default 6 help - The number of stations allowed to connect in. + The number of mesh stations allowed to connect in. + + config MESH_NON_MESH_AP_CONNECTIONS + int "Mesh Non Mesh AP Connections" + range 0 9 + default 0 + help + The number of non-mesh stations allowed to connect in. config MESH_ROUTE_TABLE_SIZE int "Mesh Routing Table Size" diff --git a/examples/mesh/internal_communication/main/mesh_main.c b/examples/mesh/internal_communication/main/mesh_main.c index 38ad6f5cc5..722aa693cc 100644 --- a/examples/mesh/internal_communication/main/mesh_main.c +++ b/examples/mesh/internal_communication/main/mesh_main.c @@ -433,6 +433,7 @@ void app_main(void) /* mesh softAP */ ESP_ERROR_CHECK(esp_mesh_set_ap_authmode(CONFIG_MESH_AP_AUTHMODE)); cfg.mesh_ap.max_connection = CONFIG_MESH_AP_CONNECTIONS; + cfg.mesh_ap.nonmesh_max_connection = CONFIG_MESH_NON_MESH_AP_CONNECTIONS; memcpy((uint8_t *) &cfg.mesh_ap.password, CONFIG_MESH_AP_PASSWD, strlen(CONFIG_MESH_AP_PASSWD)); ESP_ERROR_CHECK(esp_mesh_set_config(&cfg)); diff --git a/examples/mesh/ip_internal_network/main/Kconfig.projbuild b/examples/mesh/ip_internal_network/main/Kconfig.projbuild index f0d29f381d..0b6d927aca 100644 --- a/examples/mesh/ip_internal_network/main/Kconfig.projbuild +++ b/examples/mesh/ip_internal_network/main/Kconfig.projbuild @@ -55,7 +55,14 @@ menu "Example Configuration" range 1 10 default 6 help - The number of stations allowed to connect in. + The number of mesh stations allowed to connect in. + + config MESH_NON_MESH_AP_CONNECTIONS + int "Mesh Non Mesh AP Connections" + range 0 9 + default 0 + help + The number of non-mesh stations allowed to connect in. config MESH_MAX_LAYER int "Mesh Max Layer" diff --git a/examples/mesh/ip_internal_network/main/mesh_main.c b/examples/mesh/ip_internal_network/main/mesh_main.c index 6282c1aa8f..aaad3c9e94 100644 --- a/examples/mesh/ip_internal_network/main/mesh_main.c +++ b/examples/mesh/ip_internal_network/main/mesh_main.c @@ -416,6 +416,7 @@ void app_main(void) /* mesh softAP */ ESP_ERROR_CHECK(esp_mesh_set_ap_authmode(CONFIG_MESH_AP_AUTHMODE)); cfg.mesh_ap.max_connection = CONFIG_MESH_AP_CONNECTIONS; + cfg.mesh_ap.nonmesh_max_connection = CONFIG_MESH_NON_MESH_AP_CONNECTIONS; memcpy((uint8_t *) &cfg.mesh_ap.password, CONFIG_MESH_AP_PASSWD, strlen(CONFIG_MESH_AP_PASSWD)); ESP_ERROR_CHECK(esp_mesh_set_config(&cfg)); diff --git a/examples/mesh/manual_networking/main/Kconfig.projbuild b/examples/mesh/manual_networking/main/Kconfig.projbuild index 36f77e4f73..55c5a8c2dd 100644 --- a/examples/mesh/manual_networking/main/Kconfig.projbuild +++ b/examples/mesh/manual_networking/main/Kconfig.projbuild @@ -67,7 +67,14 @@ menu "Example Configuration" range 1 10 default 6 help - The number of stations allowed to connect in. + The number of mesh stations allowed to connect in. + + config MESH_NON_MESH_AP_CONNECTIONS + int "Mesh Non Mesh AP Connections" + range 0 9 + default 0 + help + The number of non-mesh stations allowed to connect in. config MESH_MAX_LAYER int "Mesh Max Layer" diff --git a/examples/mesh/manual_networking/main/mesh_main.c b/examples/mesh/manual_networking/main/mesh_main.c index 3a174c89a0..ff419acc42 100644 --- a/examples/mesh/manual_networking/main/mesh_main.c +++ b/examples/mesh/manual_networking/main/mesh_main.c @@ -323,6 +323,7 @@ void app_main(void) /* mesh softAP */ ESP_ERROR_CHECK(esp_mesh_set_ap_authmode(CONFIG_MESH_AP_AUTHMODE)); cfg.mesh_ap.max_connection = CONFIG_MESH_AP_CONNECTIONS; + cfg.mesh_ap.nonmesh_max_connection = CONFIG_MESH_NON_MESH_AP_CONNECTIONS; memcpy((uint8_t *) &cfg.mesh_ap.password, CONFIG_MESH_AP_PASSWD, strlen(CONFIG_MESH_AP_PASSWD)); ESP_ERROR_CHECK(esp_mesh_set_config(&cfg));