mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-06 06:04:33 +02:00
Merge branch 'bugfix/eth2ap' into 'master'
example/eth2ap: Fix station multi-connection problem See merge request espressif/esp-idf!8051
This commit is contained in:
@@ -143,6 +143,13 @@ menu "Example Configuration"
|
|||||||
help
|
help
|
||||||
Set the password of Wi-Fi ap interface.
|
Set the password of Wi-Fi ap interface.
|
||||||
|
|
||||||
|
config EXAMPLE_WIFI_CHANNEL
|
||||||
|
int "WiFi channel"
|
||||||
|
range 1 13
|
||||||
|
default 1
|
||||||
|
help
|
||||||
|
Set the channel of Wi-Fi ap.
|
||||||
|
|
||||||
config EXAMPLE_MAX_STA_CONN
|
config EXAMPLE_MAX_STA_CONN
|
||||||
int "Maximum STA connections"
|
int "Maximum STA connections"
|
||||||
default 4
|
default 4
|
||||||
|
@@ -124,16 +124,23 @@ static void eth_event_handler(void *arg, esp_event_base_t event_base,
|
|||||||
static void wifi_event_handler(void *arg, esp_event_base_t event_base,
|
static void wifi_event_handler(void *arg, esp_event_base_t event_base,
|
||||||
int32_t event_id, void *event_data)
|
int32_t event_id, void *event_data)
|
||||||
{
|
{
|
||||||
|
static uint8_t s_con_cnt = 0;
|
||||||
switch (event_id) {
|
switch (event_id) {
|
||||||
case WIFI_EVENT_AP_STACONNECTED:
|
case WIFI_EVENT_AP_STACONNECTED:
|
||||||
ESP_LOGI(TAG, "Wi-Fi AP got a station connected");
|
ESP_LOGI(TAG, "Wi-Fi AP got a station connected");
|
||||||
s_sta_is_connected = true;
|
if (!s_con_cnt) {
|
||||||
esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_AP, pkt_wifi2eth);
|
s_sta_is_connected = true;
|
||||||
|
esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_AP, pkt_wifi2eth);
|
||||||
|
}
|
||||||
|
s_con_cnt++;
|
||||||
break;
|
break;
|
||||||
case WIFI_EVENT_AP_STADISCONNECTED:
|
case WIFI_EVENT_AP_STADISCONNECTED:
|
||||||
ESP_LOGI(TAG, "Wi-Fi AP got a station disconnected");
|
ESP_LOGI(TAG, "Wi-Fi AP got a station disconnected");
|
||||||
s_sta_is_connected = false;
|
s_con_cnt--;
|
||||||
esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_AP, NULL);
|
if (!s_con_cnt) {
|
||||||
|
s_sta_is_connected = false;
|
||||||
|
esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_AP, NULL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -205,7 +212,8 @@ static void initialize_wifi(void)
|
|||||||
.ssid_len = strlen(CONFIG_EXAMPLE_WIFI_SSID),
|
.ssid_len = strlen(CONFIG_EXAMPLE_WIFI_SSID),
|
||||||
.password = CONFIG_EXAMPLE_WIFI_PASSWORD,
|
.password = CONFIG_EXAMPLE_WIFI_PASSWORD,
|
||||||
.max_connection = CONFIG_EXAMPLE_MAX_STA_CONN,
|
.max_connection = CONFIG_EXAMPLE_MAX_STA_CONN,
|
||||||
.authmode = WIFI_AUTH_WPA_WPA2_PSK
|
.authmode = WIFI_AUTH_WPA_WPA2_PSK,
|
||||||
|
.channel = CONFIG_EXAMPLE_WIFI_CHANNEL // default: channel 1
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if (strlen(CONFIG_EXAMPLE_WIFI_PASSWORD) == 0) {
|
if (strlen(CONFIG_EXAMPLE_WIFI_PASSWORD) == 0) {
|
||||||
|
Reference in New Issue
Block a user