esp_wifi_mesh: add non mesh connections access

This commit is contained in:
shenjun 2021-07-30 22:17:30 +08:00
parent 1871b35df0
commit 42a1be10db
9 changed files with 50 additions and 10 deletions

View File

@ -506,7 +506,12 @@ typedef struct {
*/
typedef struct {
uint8_t password[64]; /**< mesh softAP password */
uint8_t max_connection; /**< max number of stations allowed to connect in, max 10 */
/**
* 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
*

View File

@ -272,7 +272,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 */
@ -669,12 +670,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 */

@ -1 +1 @@
Subproject commit efd23cbed56567b3c6ef03c26adbf4f13e46addc
Subproject commit 484521faaa48cd9c9713eb65c93964cad50c439b

View File

@ -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"

View File

@ -432,6 +432,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));

View File

@ -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"

View File

@ -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));

View File

@ -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"

View File

@ -322,6 +322,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));