Skip to content

Commit d53ee8c

Browse files
committed
Merge branch 'bugfix/fix_compatibility_issues_with_AP_which_configured_to_11n_only' into 'master'
fix(wifi): fix compatibility issues with AP which configured to 11n only See merge request sdk/ESP8266_RTOS_SDK!985
2 parents e5c02e2 + af0fcc0 commit d53ee8c

File tree

47 files changed

+328
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+328
-47
lines changed

components/esp8266/include/esp_wifi.h

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ extern "C" {
9090

9191
#define ESP_WIFI_PARAM_USE_NVS 0
9292

93+
#define WIFI_PROTOCAL_11B 1
94+
#define WIFI_PROTOCAL_11G 2
95+
#define WIFI_PROTOCAL_11N 4
9396
/**
9497
* @brief WiFi stack configuration parameters passed to esp_wifi_init call.
9598
*/

components/esp8266/include/esp_wifi_types.h

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ typedef enum {
9292
WIFI_REASON_AUTH_FAIL = 202,
9393
WIFI_REASON_ASSOC_FAIL = 203,
9494
WIFI_REASON_HANDSHAKE_TIMEOUT = 204,
95+
WIFI_REASON_BASIC_RATE_NOT_SUPPORT = 205,
9596
} wifi_err_reason_t;
9697

9798
typedef enum {

components/esp8266/lib/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
gwen:
22
core: 0dd3307
3-
net80211: 381d974
3+
net80211: aceeb79
44
pp: 522f8df
55
wpa: 33a48e5
66
espnow: da96924

components/esp8266/lib/libnet80211.a

76 Bytes
Binary file not shown.
76 Bytes
Binary file not shown.

components/mqtt/esp-mqtt/examples/emitter-client/main/app_main.c

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ const static int CONNECTED_BIT = BIT0;
2929

3030
static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
3131
{
32+
/* For accessing reason codes in case of disconnection */
33+
system_event_info_t *info = &event->event_info;
34+
3235
switch (event->event_id) {
3336
case SYSTEM_EVENT_STA_START:
3437
esp_wifi_connect();
@@ -38,6 +41,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
3841

3942
break;
4043
case SYSTEM_EVENT_STA_DISCONNECTED:
44+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
45+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
46+
/*Switch to 802.11 bgn mode */
47+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
48+
}
4149
esp_wifi_connect();
4250
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
4351
break;

docs/en/general-notes/index.rst

100644100755
+6
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ and now upgrade to the new SDK, please disable the following configuration in th
1919
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020

2121
ESP8285 or ESP8266 + 1MB flash can use "Copy OTA Mode" for OTA, more details are in the `examples/system/ota <https://github.com/espressif/ESP8266_RTOS_SDK/tree/master/examples/system/ota/>`_.
22+
23+
24+
3. 802.11n only AP
25+
^^^^^^^^^^^^^^^^^^
26+
27+
For better compatibility, the SDK is in bg mode by default. And application can set it to be bgn mode for reconnecting when it fails to connect some 11n only APs, refer to the `examples/wifi/simple_wifi <https://github.com/espressif/ESP8266_RTOS_SDK/tree/master/examples/wifi/simple_wifi/>`_.

examples/protocols/aws_iot/subscribe_publish/main/subscribe_publish_sample.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ static void get_time()
151151

152152
static esp_err_t event_handler(void *ctx, system_event_t *event)
153153
{
154+
/* For accessing reason codes in case of disconnection */
155+
system_event_info_t *info = &event->event_info;
156+
154157
switch(event->event_id) {
155158
case SYSTEM_EVENT_STA_START:
156159
esp_wifi_connect();
@@ -159,8 +162,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
159162
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
160163
break;
161164
case SYSTEM_EVENT_STA_DISCONNECTED:
162-
/* This is a workaround as ESP32 WiFi libs don't currently
163-
auto-reassociate. */
165+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
166+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
167+
/*Switch to 802.11 bgn mode */
168+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
169+
}
164170
esp_wifi_connect();
165171
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
166172
break;

examples/protocols/aws_iot/thing_shadow/main/thing_shadow_sample.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ static void get_time()
170170

171171
static esp_err_t event_handler(void *ctx, system_event_t *event)
172172
{
173+
/* For accessing reason codes in case of disconnection */
174+
system_event_info_t *info = &event->event_info;
175+
173176
switch(event->event_id) {
174177
case SYSTEM_EVENT_STA_START:
175178
esp_wifi_connect();
@@ -178,8 +181,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
178181
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
179182
break;
180183
case SYSTEM_EVENT_STA_DISCONNECTED:
181-
/* This is a workaround as ESP32 WiFi libs don't currently
182-
auto-reassociate. */
184+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
185+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
186+
/*Switch to 802.11 bgn mode */
187+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
188+
}
183189
esp_wifi_connect();
184190
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
185191
break;

examples/protocols/coap_client/main/coap_client_example_main.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ static void coap_example_task(void *p)
159159

160160
static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
161161
{
162+
/* For accessing reason codes in case of disconnection */
163+
system_event_info_t *info = &event->event_info;
164+
162165
switch(event->event_id) {
163166
case SYSTEM_EVENT_STA_START:
164167
esp_wifi_connect();
@@ -167,8 +170,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
167170
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
168171
break;
169172
case SYSTEM_EVENT_STA_DISCONNECTED:
170-
/* This is a workaround as ESP32 WiFi libs don't currently
171-
auto-reassociate. */
173+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
174+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
175+
/*Switch to 802.11 bgn mode */
176+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
177+
}
172178
esp_wifi_connect();
173179
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
174180
break;

examples/protocols/coap_server/main/coap_server_example_main.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ static void coap_example_thread(void *p)
145145

146146
static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
147147
{
148+
/* For accessing reason codes in case of disconnection */
149+
system_event_info_t *info = &event->event_info;
150+
148151
switch(event->event_id) {
149152
case SYSTEM_EVENT_STA_START:
150153
esp_wifi_connect();
@@ -153,8 +156,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
153156
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
154157
break;
155158
case SYSTEM_EVENT_STA_DISCONNECTED:
156-
/* This is a workaround as ESP32 WiFi libs don't currently
157-
auto-reassociate. */
159+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
160+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
161+
/*Switch to 802.11 bgn mode */
162+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
163+
}
158164
esp_wifi_connect();
159165
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
160166
break;

examples/protocols/esp-mqtt/ssl/main/app_main.c

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ const static int CONNECTED_BIT = BIT0;
2929

3030
static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
3131
{
32+
/* For accessing reason codes in case of disconnection */
33+
system_event_info_t *info = &event->event_info;
34+
3235
switch (event->event_id) {
3336
case SYSTEM_EVENT_STA_START:
3437
esp_wifi_connect();
@@ -38,6 +41,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
3841

3942
break;
4043
case SYSTEM_EVENT_STA_DISCONNECTED:
44+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
45+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
46+
/*Switch to 802.11 bgn mode */
47+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
48+
}
4149
esp_wifi_connect();
4250
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
4351
break;

examples/protocols/esp-mqtt/ssl_mutual_auth/main/app_main.c

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ const static int CONNECTED_BIT = BIT0;
2929

3030
static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
3131
{
32+
/* For accessing reason codes in case of disconnection */
33+
system_event_info_t *info = &event->event_info;
34+
3235
switch (event->event_id) {
3336
case SYSTEM_EVENT_STA_START:
3437
esp_wifi_connect();
@@ -38,6 +41,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
3841

3942
break;
4043
case SYSTEM_EVENT_STA_DISCONNECTED:
44+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
45+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
46+
/*Switch to 802.11 bgn mode */
47+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
48+
}
4149
esp_wifi_connect();
4250
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
4351
break;

examples/protocols/esp-mqtt/tcp/main/app_main.c

+8
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ static esp_err_t mqtt_event_handler(esp_mqtt_event_handle_t event)
7575

7676
static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
7777
{
78+
/* For accessing reason codes in case of disconnection */
79+
system_event_info_t *info = &event->event_info;
80+
7881
switch (event->event_id) {
7982
case SYSTEM_EVENT_STA_START:
8083
esp_wifi_connect();
@@ -84,6 +87,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
8487

8588
break;
8689
case SYSTEM_EVENT_STA_DISCONNECTED:
90+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
91+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
92+
/*Switch to 802.11 bgn mode */
93+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
94+
}
8795
esp_wifi_connect();
8896
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
8997
break;

examples/protocols/esp-mqtt/ws/main/app_main.c

+8
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ static esp_err_t mqtt_event_handler(esp_mqtt_event_handle_t event)
7272

7373
static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
7474
{
75+
/* For accessing reason codes in case of disconnection */
76+
system_event_info_t *info = &event->event_info;
77+
7578
switch (event->event_id) {
7679
case SYSTEM_EVENT_STA_START:
7780
esp_wifi_connect();
@@ -81,6 +84,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
8184

8285
break;
8386
case SYSTEM_EVENT_STA_DISCONNECTED:
87+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
88+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
89+
/*Switch to 802.11 bgn mode */
90+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
91+
}
8492
esp_wifi_connect();
8593
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
8694
break;

examples/protocols/esp-mqtt/wss/main/app_main.c

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ const static int CONNECTED_BIT = BIT0;
2929

3030
static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
3131
{
32+
/* For accessing reason codes in case of disconnection */
33+
system_event_info_t *info = &event->event_info;
34+
3235
switch (event->event_id) {
3336
case SYSTEM_EVENT_STA_START:
3437
esp_wifi_connect();
@@ -38,6 +41,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
3841

3942
break;
4043
case SYSTEM_EVENT_STA_DISCONNECTED:
44+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
45+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
46+
/*Switch to 802.11 bgn mode */
47+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
48+
}
4149
esp_wifi_connect();
4250
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
4351
break;

examples/protocols/esp_http_client/main/app_wifi.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ const int CONNECTED_BIT = BIT0;
2929

3030
static esp_err_t event_handler(void *ctx, system_event_t *event)
3131
{
32+
/* For accessing reason codes in case of disconnection */
33+
system_event_info_t *info = &event->event_info;
34+
3235
switch (event->event_id) {
3336
case SYSTEM_EVENT_STA_START:
3437
esp_wifi_connect();
@@ -37,8 +40,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
3740
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
3841
break;
3942
case SYSTEM_EVENT_STA_DISCONNECTED:
40-
/* This is a workaround as ESP32 WiFi libs don't currently
41-
auto-reassociate. */
43+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
44+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
45+
/*Switch to 802.11 bgn mode */
46+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
47+
}
4248
esp_wifi_connect();
4349
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
4450
break;

examples/protocols/http_request/main/http_request_example_main.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ static const char *REQUEST = "GET " WEB_URL " HTTP/1.0\r\n"
5353

5454
static esp_err_t event_handler(void *ctx, system_event_t *event)
5555
{
56+
/* For accessing reason codes in case of disconnection */
57+
system_event_info_t *info = &event->event_info;
58+
5659
switch(event->event_id) {
5760
case SYSTEM_EVENT_STA_START:
5861
esp_wifi_connect();
@@ -61,8 +64,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
6164
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
6265
break;
6366
case SYSTEM_EVENT_STA_DISCONNECTED:
64-
/* This is a workaround as ESP32 WiFi libs don't currently
65-
auto-reassociate. */
67+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
68+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
69+
/*Switch to 802.11 bgn mode */
70+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
71+
}
6672
esp_wifi_connect();
6773
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
6874
break;

examples/protocols/http_server/advanced_tests/main/main.c

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ static const char *TAG="TEST_WIFI";
2020
static esp_err_t event_handler(void *ctx, system_event_t *event)
2121
{
2222
httpd_handle_t *hd = (httpd_handle_t *) ctx;
23+
/* For accessing reason codes in case of disconnection */
24+
system_event_info_t *info = &event->event_info;
2325

2426
switch(event->event_id) {
2527
case SYSTEM_EVENT_STA_START:
@@ -39,6 +41,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
3941
break;
4042
case SYSTEM_EVENT_STA_DISCONNECTED:
4143
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_DISCONNECTED");
44+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
45+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
46+
/*Switch to 802.11 bgn mode */
47+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
48+
}
4249
ESP_ERROR_CHECK(esp_wifi_connect());
4350

4451
// Stop webserver tests

examples/protocols/http_server/persistent_sockets/main/main.c

+7
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ void stop_webserver(httpd_handle_t server)
193193
static esp_err_t event_handler(void *ctx, system_event_t *event)
194194
{
195195
httpd_handle_t *server = (httpd_handle_t *) ctx;
196+
/* For accessing reason codes in case of disconnection */
197+
system_event_info_t *info = &event->event_info;
196198

197199
switch(event->event_id) {
198200
case SYSTEM_EVENT_STA_START:
@@ -211,6 +213,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
211213
break;
212214
case SYSTEM_EVENT_STA_DISCONNECTED:
213215
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_DISCONNECTED");
216+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
217+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
218+
/*Switch to 802.11 bgn mode */
219+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
220+
}
214221
ESP_ERROR_CHECK(esp_wifi_connect());
215222

216223
/* Stop the webserver */

examples/protocols/http_server/simple/main/main.c

+7
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ void stop_webserver(httpd_handle_t server)
220220
static esp_err_t event_handler(void *ctx, system_event_t *event)
221221
{
222222
httpd_handle_t *server = (httpd_handle_t *) ctx;
223+
/* For accessing reason codes in case of disconnection */
224+
system_event_info_t *info = &event->event_info;
223225

224226
switch(event->event_id) {
225227
case SYSTEM_EVENT_STA_START:
@@ -238,6 +240,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
238240
break;
239241
case SYSTEM_EVENT_STA_DISCONNECTED:
240242
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_DISCONNECTED");
243+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
244+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
245+
/*Switch to 802.11 bgn mode */
246+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
247+
}
241248
ESP_ERROR_CHECK(esp_wifi_connect());
242249

243250
/* Stop the web server */

examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ extern const uint8_t server_root_cert_pem_end[] asm("_binary_server_root_cert_
9090

9191
static esp_err_t event_handler(void *ctx, system_event_t *event)
9292
{
93+
/* For accessing reason codes in case of disconnection */
94+
system_event_info_t *info = &event->event_info;
95+
9396
switch(event->event_id) {
9497
case SYSTEM_EVENT_STA_START:
9598
esp_wifi_connect();
@@ -98,8 +101,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
98101
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
99102
break;
100103
case SYSTEM_EVENT_STA_DISCONNECTED:
101-
/* This is a workaround as ESP32 WiFi libs don't currently
102-
auto-reassociate. */
104+
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
105+
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
106+
/*Switch to 802.11 bgn mode */
107+
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
108+
}
103109
esp_wifi_connect();
104110
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
105111
break;

0 commit comments

Comments
 (0)