Skip to content

Commit fdb4197

Browse files
sarveshb14jack0c
authored andcommitted
fix(esp_wifi): Add some bugfixes and cleanup in softAP
1. Fix wrong reason code in 'WIFI_EVENT_AP_STADISCONNECTED' event 2. cleanup in softAP for disconnecting connected station 3. Update examples to display reason while processing WIFI_EVENT_AP_STADISCONNECTED event
1 parent e11f030 commit fdb4197

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

components/esp_rom/esp32c2/ld/esp32c2.rom.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ ieee80211_alloc_tx_buf = 0x40002108;
18491849
/* ieee80211_send_nulldata = 0x40002110; */
18501850
/* ieee80211_setup_robust_mgmtframe = 0x40002114; */
18511851
ieee80211_encap_null_data = 0x4000211c;
1852-
ieee80211_send_deauth = 0x40002120;
1852+
ieee80211_send_deauth_no_bss = 0x40002120;
18531853
ieee80211_alloc_deauth = 0x40002124;
18541854
ieee80211_send_proberesp = 0x40002128;
18551855
ieee80211_getcapinfo = 0x40002130;

components/esp_wifi/include/esp_wifi_types_generic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ typedef struct {
903903
uint8_t mac[6]; /**< MAC address of the station disconnects to soft-AP */
904904
uint8_t aid; /**< the aid that soft-AP gave to the station disconnects to */
905905
bool is_mesh_child; /**< flag to identify mesh child */
906-
uint8_t reason; /**< reason of disconnection */
906+
uint16_t reason; /**< reason of disconnection */
907907
} wifi_event_ap_stadisconnected_t;
908908

909909
/** Argument structure for WIFI_EVENT_AP_PROBEREQRECVED event */

examples/bluetooth/blufi/main/blufi_example_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base,
246246
}
247247
case WIFI_EVENT_AP_STADISCONNECTED: {
248248
wifi_event_ap_stadisconnected_t* event = (wifi_event_ap_stadisconnected_t*) event_data;
249-
BLUFI_INFO("station "MACSTR" leave, AID=%d", MAC2STR(event->mac), event->aid);
249+
BLUFI_INFO("station "MACSTR" leave, AID=%d, reason=%d", MAC2STR(event->mac), event->aid, event->reason);
250250
break;
251251
}
252252

examples/protocols/http_server/captive_portal/main/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base,
3939
MAC2STR(event->mac), event->aid);
4040
} else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) {
4141
wifi_event_ap_stadisconnected_t *event = (wifi_event_ap_stadisconnected_t *)event_data;
42-
ESP_LOGI(TAG, "station " MACSTR " leave, AID=%d",
43-
MAC2STR(event->mac), event->aid);
42+
ESP_LOGI(TAG, "station " MACSTR " leave, AID=%d, reason=%d",
43+
MAC2STR(event->mac), event->aid, event->reason);
4444
}
4545
}
4646

examples/wifi/getting_started/softAP/main/softap_example_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base,
3939
MAC2STR(event->mac), event->aid);
4040
} else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) {
4141
wifi_event_ap_stadisconnected_t* event = (wifi_event_ap_stadisconnected_t*) event_data;
42-
ESP_LOGI(TAG, "station "MACSTR" leave, AID=%d",
43-
MAC2STR(event->mac), event->aid);
42+
ESP_LOGI(TAG, "station "MACSTR" leave, AID=%d, reason=%d",
43+
MAC2STR(event->mac), event->aid, event->reason);
4444
}
4545
}
4646

examples/wifi/softap_sta/main/softap_sta.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base,
9090
MAC2STR(event->mac), event->aid);
9191
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_AP_STADISCONNECTED) {
9292
wifi_event_ap_stadisconnected_t *event = (wifi_event_ap_stadisconnected_t *) event_data;
93-
ESP_LOGI(TAG_AP, "Station "MACSTR" left, AID=%d",
94-
MAC2STR(event->mac), event->aid);
93+
ESP_LOGI(TAG_AP, "Station "MACSTR" left, AID=%d, reason:%d",
94+
MAC2STR(event->mac), event->aid, event->reason);
9595
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
9696
esp_wifi_connect();
9797
ESP_LOGI(TAG_STA, "Station started");
@@ -145,7 +145,7 @@ esp_netif_t *wifi_init_sta(void)
145145
.password = EXAMPLE_ESP_WIFI_STA_PASSWD,
146146
.scan_method = WIFI_ALL_CHANNEL_SCAN,
147147
.failure_retry_cnt = EXAMPLE_ESP_MAXIMUM_RETRY,
148-
/* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (pasword len => 8).
148+
/* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (password len => 8).
149149
* If you want to connect the device to deprecated WEP/WPA networks, Please set the threshold value
150150
* to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with length and format matching to
151151
* WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK standards.

examples/wifi/wps_softap_registrar/main/wps.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Unlicense OR CC0-1.0
55
*/
@@ -62,8 +62,8 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base,
6262
{
6363
ESP_LOGI(TAG, "WIFI_EVENT_AP_STADISCONNECTED");
6464
wifi_event_ap_stadisconnected_t* event = (wifi_event_ap_stadisconnected_t*) event_data;
65-
ESP_LOGI(TAG, "station "MACSTR" leave, AID=%d",
66-
MAC2STR(event->mac), event->aid);
65+
ESP_LOGI(TAG, "station "MACSTR" leave, AID=%d, reason=%d",
66+
MAC2STR(event->mac), event->aid, event->reason);
6767
}
6868
break;
6969
case WIFI_EVENT_AP_STACONNECTED:

tools/test_apps/peripherals/i2c_wifi/main/i2c_wifi_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base,
5656
ESP_LOGI(TAG, "station "MACSTR" join, AID=%d", MAC2STR(event->mac), event->aid);
5757
} else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) {
5858
wifi_event_ap_stadisconnected_t *event = (wifi_event_ap_stadisconnected_t *) event_data;
59-
ESP_LOGI(TAG, "station "MACSTR" leave, AID=%d", MAC2STR(event->mac), event->aid);
59+
ESP_LOGI(TAG, "station "MACSTR" leave, AID=%d, reason=%d", MAC2STR(event->mac), event->aid, event->reason);
6060
}
6161
}
6262

0 commit comments

Comments
 (0)