From af0fcc0492daad685805d9df1ca2d4eec68ad434 Mon Sep 17 00:00:00 2001 From: Chen Wen Date: Thu, 13 Jun 2019 21:37:28 +0800 Subject: [PATCH] fix(wifi): fix compatibility issues with AP which configured to 11n only --- components/esp8266/include/esp_wifi.h | 3 +++ components/esp8266/include/esp_wifi_types.h | 1 + components/esp8266/lib/VERSION | 2 +- components/esp8266/lib/libnet80211.a | Bin 372524 -> 372600 bytes components/esp8266/lib/libnet80211_dbg.a | Bin 405408 -> 405484 bytes .../examples/emitter-client/main/app_main.c | 8 ++++++++ docs/en/general-notes/index.rst | 6 ++++++ .../main/subscribe_publish_sample.c | 10 ++++++++-- .../thing_shadow/main/thing_shadow_sample.c | 10 ++++++++-- .../main/coap_client_example_main.c | 10 ++++++++-- .../main/coap_server_example_main.c | 10 ++++++++-- .../protocols/esp-mqtt/ssl/main/app_main.c | 8 ++++++++ .../esp-mqtt/ssl_mutual_auth/main/app_main.c | 8 ++++++++ .../protocols/esp-mqtt/tcp/main/app_main.c | 8 ++++++++ .../protocols/esp-mqtt/ws/main/app_main.c | 8 ++++++++ .../protocols/esp-mqtt/wss/main/app_main.c | 8 ++++++++ .../protocols/esp_http_client/main/app_wifi.c | 10 ++++++++-- .../main/http_request_example_main.c | 10 ++++++++-- .../http_server/advanced_tests/main/main.c | 7 +++++++ .../persistent_sockets/main/main.c | 7 +++++++ .../protocols/http_server/simple/main/main.c | 7 +++++++ .../main/https_mbedtls_example_main.c | 10 ++++++++-- .../main/https_request_example_main.c | 10 ++++++++-- .../main/https_wolfssl_example_main.c | 10 ++++++++-- examples/protocols/ibm-mqtt/main/MQTTEcho.c | 10 ++++++++-- .../protocols/mdns/main/mdns_example_main.c | 8 ++++++++ .../main/openssl_client_example_main.c | 10 ++++++++-- .../main/openssl_demo_example_main.c | 10 ++++++++-- .../main/openssl_server_example_main.c | 10 ++++++++-- .../protocols/sntp/main/sntp_example_main.c | 10 ++++++++-- .../sockets/tcp_client/main/tcp_client.c | 9 ++++++++- .../sockets/tcp_server/main/tcp_server.c | 9 ++++++++- .../sockets/udp_client/main/udp_client.c | 9 ++++++++- .../main/udp_multicast_example_main.c | 10 ++++++++-- .../sockets/udp_server/main/udp_server.c | 9 ++++++++- .../custom_config/main/app_prov.c | 4 ++++ .../provisioning/softap_prov/main/app_prov.c | 4 ++++ examples/system/console/main/cmd_wifi.c | 8 ++++++++ .../new_to_new_no_old/main/ota_example_main.c | 10 ++++++++-- .../main/ota_example_main.c | 10 ++++++++-- .../main/ota_example_main.c | 10 ++++++++-- .../new_to_new_no_old/main/ota_example_main.c | 10 ++++++++-- .../main/ota_example_main.c | 10 ++++++++-- .../main/simple_ota_example.c | 10 ++++++++-- examples/wifi/simple_wifi/main/simple_wifi.c | 8 ++++++++ .../wifi/smart_config/main/smartconfig_main.c | 8 ++++++++ examples/wifi/wps/main/wps.c | 8 ++++++++ 47 files changed, 328 insertions(+), 47 deletions(-) mode change 100644 => 100755 docs/en/general-notes/index.rst diff --git a/components/esp8266/include/esp_wifi.h b/components/esp8266/include/esp_wifi.h index 4fc2b319..8379a19a 100644 --- a/components/esp8266/include/esp_wifi.h +++ b/components/esp8266/include/esp_wifi.h @@ -90,6 +90,9 @@ extern "C" { #define ESP_WIFI_PARAM_USE_NVS 0 +#define WIFI_PROTOCAL_11B 1 +#define WIFI_PROTOCAL_11G 2 +#define WIFI_PROTOCAL_11N 4 /** * @brief WiFi stack configuration parameters passed to esp_wifi_init call. */ diff --git a/components/esp8266/include/esp_wifi_types.h b/components/esp8266/include/esp_wifi_types.h index 72b24fc6..5e525ab8 100755 --- a/components/esp8266/include/esp_wifi_types.h +++ b/components/esp8266/include/esp_wifi_types.h @@ -92,6 +92,7 @@ typedef enum { WIFI_REASON_AUTH_FAIL = 202, WIFI_REASON_ASSOC_FAIL = 203, WIFI_REASON_HANDSHAKE_TIMEOUT = 204, + WIFI_REASON_BASIC_RATE_NOT_SUPPORT = 205, } wifi_err_reason_t; typedef enum { diff --git a/components/esp8266/lib/VERSION b/components/esp8266/lib/VERSION index 0f59d208..5c01ef87 100644 --- a/components/esp8266/lib/VERSION +++ b/components/esp8266/lib/VERSION @@ -1,6 +1,6 @@ gwen: core: 0dd3307 - net80211: 381d974 + net80211: aceeb79 pp: 522f8df wpa: 33a48e5 espnow: da96924 diff --git a/components/esp8266/lib/libnet80211.a b/components/esp8266/lib/libnet80211.a index c3b0797775ac35c81cbb60081c987c049c86a1b4..f85f007c0a52d149e9a9d1af6d202da00bae5f28 100644 GIT binary patch delta 10046 zcmb`Nd303Omd5Y7b*chXk%S~9kT6u;Kn9XPQVB`a0H%Nn$RI=v_yi@94x%7~D7H^6 z3>s_&7KGsh1PzG7dtfsN1{5(277kHn;SC^z(mV$qsEyi^)Z1TWU%c_Z?$u|ls{K3P z-exd)pn_|Jx`3|5n-3Grd>5 zb;Z7`t2q{RZLgm2*1_aOH%Hf^%;=xe<7UjWZS9@j+F6lQEOOsE`r6=UZaPr7KF<)Z z^lB|#9WLVSqOV#q&~~SK@~~}C{i;$?*!Fip_ln5hNnQR;c-ys(nmS!nN3@or=ZGuz z)>4+}v* zy;J?`>-520OsSq`rGw4Pg{QOLy}IU=Wit07}1w{qFNx!F1SYUXs2CdSl9 zz9@H#z7J{FbLDDV_4`_7uI_(TtGr7OzM%!*)hhezjx6o^$aa;zb$@@&U$1Fe%6;~f zXY}eF>c&fQjWE=z1v1m`kXq#k`?2DT>Nu^7k-DahvE@^vIK$CFGq!vZyb+>up65bo zK108pVnn!nLWLSMZCIvQ0c$k6kDT_1Wh)lSxDkt?cpeWKx>gpG=qgPY-o}Z(I)|~Z zr+6{!n-R*CAL_$AFBOUT5YoCB#XX`uZt)y)@%!V8r-X8*gj_M=SyjGJ4h)P7ojRrm z2WzglESGo$LDfF(_Uze4-PY9DSfj2XHMYA^SC<;AR~KnPscG5>J4H@H+Kfff#P0#SH>je^b5HpNT0VL#!;`k zzW>Rq`?u+7?H`O;=g{ihaSLLCThzhD@+n7+z92TZSoxR8`#VZkTgM#Tr)%E2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OKKCKRUGUN7T;Oqna$%HYr{^rV_=7m1`_kXr>oc~PX|53G>`ofo1k|VYMGgbOm P)^@w2^q0;t>t6bAwfuJ= diff --git a/components/esp8266/lib/libnet80211_dbg.a b/components/esp8266/lib/libnet80211_dbg.a index 5e8a95456d0e34d578066e2c2307ac42579e9695..22cfa8c713925614b533762e292c3440ce4e9455 100644 GIT binary patch delta 8062 zcmb`MdwdjCmdEQ>syYeX2_Xr2L%J)kj!7r!PDp|fmOShbLV!d?d@vA@s0gkif--1_ zpzXNJio)o{RWKkvb{J6xhGy^;9L?YgF5vsKC=BbkjIR+CFp#9@{JKvk<$m~Q_p|r& zsk-0$JLjHz>)u;+tGc_7r+srg?U9U_%CZX2`0DcVokpkTo1UxatrP!u$1+XP|DTSk z|6`yHpOrkm>pOk#n4zoLwIgTS@U?B&k(09P_DT7rg{fSC#Ncv0G108&{>2Ed9qD+n2SM%$?hD*KG^t&dsf=s;&&IS{1dg zZK!5o(tkvKV;d?`>#2dJV^Mvk>DxR%HPC)O>Y?F2h6gV;RuhFoHN#yf^k@r54rv=u z^~G9ER;P}?L~lG59(nyrEtlrEbEP)=+HsfgDKERET5&1WQ(1Y52%f5nz;`RP$;*ek zMJq)2lvj6I6fvQ~-Sb18jQ>$-P&Q)8Us_uPLQIw8q)xSyUn5|l#Q~a+}d6H^z zDd(n-=qORWla$^+kWcGL`O%^P?cFnvutgJ!gFw5UAM*9pC?v@Z1aM}PVIo&?D*%2;vOi@ETc9z!C@E6 zQA+7bue~@9oG7u289*@|=Z?fo zcS+EuL2ia%(>%|dI#Cj57fmR-Y&9cAqja9r+!+%g_#MiglJ-5*V~zJN?(wYjj;7|~ z-t2oUwa6S&knEo$5{VlUoM{ zYX=71X9n+$SrSh}o+ZEEDzf&R*A58#UbUxi&DuoE9@Tc{yhruEtUBXvPTXoyy6wqp z6MJ{aQ$J~|ERU*dlX}<5MSa==v0T2_r`3uMnQ%dCNV{5H@5nfqZn;vu<|WnNs&+Xt z^PQ@9hFp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ubi2ZT*o~=+Ky{UW^B!Z;PyYwmokku2 diff --git a/components/mqtt/esp-mqtt/examples/emitter-client/main/app_main.c b/components/mqtt/esp-mqtt/examples/emitter-client/main/app_main.c index 756e8985..f8e64817 100755 --- a/components/mqtt/esp-mqtt/examples/emitter-client/main/app_main.c +++ b/components/mqtt/esp-mqtt/examples/emitter-client/main/app_main.c @@ -29,6 +29,9 @@ const static int CONNECTED_BIT = BIT0; static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -38,6 +41,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) break; case SYSTEM_EVENT_STA_DISCONNECTED: + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/docs/en/general-notes/index.rst b/docs/en/general-notes/index.rst old mode 100644 new mode 100755 index 01ae81be..b18e03bf --- a/docs/en/general-notes/index.rst +++ b/docs/en/general-notes/index.rst @@ -19,3 +19,9 @@ and now upgrade to the new SDK, please disable the following configuration in th ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ESP8285 or ESP8266 + 1MB flash can use "Copy OTA Mode" for OTA, more details are in the `examples/system/ota `_. + + +3. 802.11n only AP +^^^^^^^^^^^^^^^^^^ + +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 `_. diff --git a/examples/protocols/aws_iot/subscribe_publish/main/subscribe_publish_sample.c b/examples/protocols/aws_iot/subscribe_publish/main/subscribe_publish_sample.c index 947ea441..15eaf8ff 100644 --- a/examples/protocols/aws_iot/subscribe_publish/main/subscribe_publish_sample.c +++ b/examples/protocols/aws_iot/subscribe_publish/main/subscribe_publish_sample.c @@ -151,6 +151,9 @@ static void get_time() static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -159,8 +162,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/aws_iot/thing_shadow/main/thing_shadow_sample.c b/examples/protocols/aws_iot/thing_shadow/main/thing_shadow_sample.c index 70d82701..c8001447 100644 --- a/examples/protocols/aws_iot/thing_shadow/main/thing_shadow_sample.c +++ b/examples/protocols/aws_iot/thing_shadow/main/thing_shadow_sample.c @@ -170,6 +170,9 @@ static void get_time() static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -178,8 +181,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/coap_client/main/coap_client_example_main.c b/examples/protocols/coap_client/main/coap_client_example_main.c index 98f003e1..f28df68d 100644 --- a/examples/protocols/coap_client/main/coap_client_example_main.c +++ b/examples/protocols/coap_client/main/coap_client_example_main.c @@ -159,6 +159,9 @@ static void coap_example_task(void *p) static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -167,8 +170,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/coap_server/main/coap_server_example_main.c b/examples/protocols/coap_server/main/coap_server_example_main.c index b3ea7030..9ec2be39 100644 --- a/examples/protocols/coap_server/main/coap_server_example_main.c +++ b/examples/protocols/coap_server/main/coap_server_example_main.c @@ -145,6 +145,9 @@ static void coap_example_thread(void *p) static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -153,8 +156,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/esp-mqtt/ssl/main/app_main.c b/examples/protocols/esp-mqtt/ssl/main/app_main.c index 913ba6cf..17818e4e 100644 --- a/examples/protocols/esp-mqtt/ssl/main/app_main.c +++ b/examples/protocols/esp-mqtt/ssl/main/app_main.c @@ -29,6 +29,9 @@ const static int CONNECTED_BIT = BIT0; static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -38,6 +41,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) break; case SYSTEM_EVENT_STA_DISCONNECTED: + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/esp-mqtt/ssl_mutual_auth/main/app_main.c b/examples/protocols/esp-mqtt/ssl_mutual_auth/main/app_main.c index 2ebce48b..adf5db9a 100644 --- a/examples/protocols/esp-mqtt/ssl_mutual_auth/main/app_main.c +++ b/examples/protocols/esp-mqtt/ssl_mutual_auth/main/app_main.c @@ -29,6 +29,9 @@ const static int CONNECTED_BIT = BIT0; static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -38,6 +41,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) break; case SYSTEM_EVENT_STA_DISCONNECTED: + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/esp-mqtt/tcp/main/app_main.c b/examples/protocols/esp-mqtt/tcp/main/app_main.c index 0d294bd4..ea37a740 100644 --- a/examples/protocols/esp-mqtt/tcp/main/app_main.c +++ b/examples/protocols/esp-mqtt/tcp/main/app_main.c @@ -75,6 +75,9 @@ static esp_err_t mqtt_event_handler(esp_mqtt_event_handle_t event) static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -84,6 +87,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) break; case SYSTEM_EVENT_STA_DISCONNECTED: + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/esp-mqtt/ws/main/app_main.c b/examples/protocols/esp-mqtt/ws/main/app_main.c index 1db33278..6b1e18c8 100644 --- a/examples/protocols/esp-mqtt/ws/main/app_main.c +++ b/examples/protocols/esp-mqtt/ws/main/app_main.c @@ -72,6 +72,9 @@ static esp_err_t mqtt_event_handler(esp_mqtt_event_handle_t event) static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -81,6 +84,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) break; case SYSTEM_EVENT_STA_DISCONNECTED: + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/esp-mqtt/wss/main/app_main.c b/examples/protocols/esp-mqtt/wss/main/app_main.c index e337ea10..06f6307d 100644 --- a/examples/protocols/esp-mqtt/wss/main/app_main.c +++ b/examples/protocols/esp-mqtt/wss/main/app_main.c @@ -29,6 +29,9 @@ const static int CONNECTED_BIT = BIT0; static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -38,6 +41,11 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) break; case SYSTEM_EVENT_STA_DISCONNECTED: + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/esp_http_client/main/app_wifi.c b/examples/protocols/esp_http_client/main/app_wifi.c index da5ac44d..7d8d8d97 100644 --- a/examples/protocols/esp_http_client/main/app_wifi.c +++ b/examples/protocols/esp_http_client/main/app_wifi.c @@ -29,6 +29,9 @@ const int CONNECTED_BIT = BIT0; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -37,8 +40,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/http_request/main/http_request_example_main.c b/examples/protocols/http_request/main/http_request_example_main.c index 37b92679..23266c33 100644 --- a/examples/protocols/http_request/main/http_request_example_main.c +++ b/examples/protocols/http_request/main/http_request_example_main.c @@ -53,6 +53,9 @@ static const char *REQUEST = "GET " WEB_URL " HTTP/1.0\r\n" static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -61,8 +64,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/http_server/advanced_tests/main/main.c b/examples/protocols/http_server/advanced_tests/main/main.c index de32966c..48dead08 100644 --- a/examples/protocols/http_server/advanced_tests/main/main.c +++ b/examples/protocols/http_server/advanced_tests/main/main.c @@ -20,6 +20,8 @@ static const char *TAG="TEST_WIFI"; static esp_err_t event_handler(void *ctx, system_event_t *event) { httpd_handle_t *hd = (httpd_handle_t *) ctx; + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; switch(event->event_id) { case SYSTEM_EVENT_STA_START: @@ -39,6 +41,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) break; case SYSTEM_EVENT_STA_DISCONNECTED: ESP_LOGI(TAG, "SYSTEM_EVENT_STA_DISCONNECTED"); + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } ESP_ERROR_CHECK(esp_wifi_connect()); // Stop webserver tests diff --git a/examples/protocols/http_server/persistent_sockets/main/main.c b/examples/protocols/http_server/persistent_sockets/main/main.c index b3535592..4bebbed8 100644 --- a/examples/protocols/http_server/persistent_sockets/main/main.c +++ b/examples/protocols/http_server/persistent_sockets/main/main.c @@ -193,6 +193,8 @@ void stop_webserver(httpd_handle_t server) static esp_err_t event_handler(void *ctx, system_event_t *event) { httpd_handle_t *server = (httpd_handle_t *) ctx; + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; switch(event->event_id) { case SYSTEM_EVENT_STA_START: @@ -211,6 +213,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) break; case SYSTEM_EVENT_STA_DISCONNECTED: ESP_LOGI(TAG, "SYSTEM_EVENT_STA_DISCONNECTED"); + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } ESP_ERROR_CHECK(esp_wifi_connect()); /* Stop the webserver */ diff --git a/examples/protocols/http_server/simple/main/main.c b/examples/protocols/http_server/simple/main/main.c index d4b7b386..d29ccaac 100644 --- a/examples/protocols/http_server/simple/main/main.c +++ b/examples/protocols/http_server/simple/main/main.c @@ -220,6 +220,8 @@ void stop_webserver(httpd_handle_t server) static esp_err_t event_handler(void *ctx, system_event_t *event) { httpd_handle_t *server = (httpd_handle_t *) ctx; + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; switch(event->event_id) { case SYSTEM_EVENT_STA_START: @@ -238,6 +240,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) break; case SYSTEM_EVENT_STA_DISCONNECTED: ESP_LOGI(TAG, "SYSTEM_EVENT_STA_DISCONNECTED"); + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } ESP_ERROR_CHECK(esp_wifi_connect()); /* Stop the web server */ diff --git a/examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c b/examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c index f455080a..c2879f55 100644 --- a/examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c +++ b/examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c @@ -90,6 +90,9 @@ extern const uint8_t server_root_cert_pem_end[] asm("_binary_server_root_cert_ static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -98,8 +101,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/https_request/main/https_request_example_main.c b/examples/protocols/https_request/main/https_request_example_main.c index d270eb57..027ca28e 100644 --- a/examples/protocols/https_request/main/https_request_example_main.c +++ b/examples/protocols/https_request/main/https_request_example_main.c @@ -88,6 +88,9 @@ extern const uint8_t server_root_cert_pem_end[] asm("_binary_server_root_cert_ static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -96,8 +99,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/https_wolfssl/main/https_wolfssl_example_main.c b/examples/protocols/https_wolfssl/main/https_wolfssl_example_main.c index 6c62760f..560e3efb 100644 --- a/examples/protocols/https_wolfssl/main/https_wolfssl_example_main.c +++ b/examples/protocols/https_wolfssl/main/https_wolfssl_example_main.c @@ -71,6 +71,9 @@ char recv_data[1024] = {0}; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -79,8 +82,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/ibm-mqtt/main/MQTTEcho.c b/examples/protocols/ibm-mqtt/main/MQTTEcho.c index eab14d5f..dcddaaf7 100644 --- a/examples/protocols/ibm-mqtt/main/MQTTEcho.c +++ b/examples/protocols/ibm-mqtt/main/MQTTEcho.c @@ -46,6 +46,9 @@ static const char *TAG = "example"; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -56,8 +59,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/mdns/main/mdns_example_main.c b/examples/protocols/mdns/main/mdns_example_main.c index 1cfcf3e2..6023c0b4 100755 --- a/examples/protocols/mdns/main/mdns_example_main.c +++ b/examples/protocols/mdns/main/mdns_example_main.c @@ -46,6 +46,9 @@ static bool auto_reconnect = true; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -64,6 +67,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) /* This is a workaround as ESP32 WiFi libs don't currently auto-reassociate. */ if (auto_reconnect) { + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); } xEventGroupClearBits(wifi_event_group, IP4_CONNECTED_BIT | IP6_CONNECTED_BIT); diff --git a/examples/protocols/openssl_client/main/openssl_client_example_main.c b/examples/protocols/openssl_client/main/openssl_client_example_main.c index 5a3f2775..a0e63b8e 100644 --- a/examples/protocols/openssl_client/main/openssl_client_example_main.c +++ b/examples/protocols/openssl_client/main/openssl_client_example_main.c @@ -79,6 +79,9 @@ static char recv_buf[OPENSSL_CLIENT_RECV_BUF_LEN]; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -87,8 +90,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/openssl_demo/main/openssl_demo_example_main.c b/examples/protocols/openssl_demo/main/openssl_demo_example_main.c index f4a995eb..a5242542 100644 --- a/examples/protocols/openssl_demo/main/openssl_demo_example_main.c +++ b/examples/protocols/openssl_demo/main/openssl_demo_example_main.c @@ -60,6 +60,9 @@ static char recv_buf[OPENSSL_DEMO_RECV_BUF_LEN]; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -70,8 +73,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/openssl_server/main/openssl_server_example_main.c b/examples/protocols/openssl_server/main/openssl_server_example_main.c index db62ef49..4eef63c3 100644 --- a/examples/protocols/openssl_server/main/openssl_server_example_main.c +++ b/examples/protocols/openssl_server/main/openssl_server_example_main.c @@ -79,6 +79,9 @@ static char recv_buf[OPENSSL_SERVER_RECV_BUF_LEN]; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -87,8 +90,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/sntp/main/sntp_example_main.c b/examples/protocols/sntp/main/sntp_example_main.c index b6e8c903..50687a26 100644 --- a/examples/protocols/sntp/main/sntp_example_main.c +++ b/examples/protocols/sntp/main/sntp_example_main.c @@ -72,6 +72,9 @@ static void obtain_time(void) static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -82,8 +85,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP8266 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/protocols/sockets/tcp_client/main/tcp_client.c b/examples/protocols/sockets/tcp_client/main/tcp_client.c index f2ab52e5..cd546ddb 100644 --- a/examples/protocols/sockets/tcp_client/main/tcp_client.c +++ b/examples/protocols/sockets/tcp_client/main/tcp_client.c @@ -52,6 +52,9 @@ static const char *payload = "Message from ESP32 "; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -68,7 +71,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) ESP_LOGI(TAG, "SYSTEM_EVENT_STA_GOT_IP"); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, IPV4_GOTIP_BIT); #ifdef CONFIG_EXAMPLE_IPV6 diff --git a/examples/protocols/sockets/tcp_server/main/tcp_server.c b/examples/protocols/sockets/tcp_server/main/tcp_server.c index 597c4e36..d7c6472a 100644 --- a/examples/protocols/sockets/tcp_server/main/tcp_server.c +++ b/examples/protocols/sockets/tcp_server/main/tcp_server.c @@ -45,6 +45,9 @@ static const char *TAG = "example"; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -61,7 +64,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) ESP_LOGI(TAG, "SYSTEM_EVENT_STA_GOT_IP"); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, IPV4_GOTIP_BIT); #ifdef CONFIG_EXAMPLE_IPV6 diff --git a/examples/protocols/sockets/udp_client/main/udp_client.c b/examples/protocols/sockets/udp_client/main/udp_client.c index 187f33d5..79f9aaa5 100644 --- a/examples/protocols/sockets/udp_client/main/udp_client.c +++ b/examples/protocols/sockets/udp_client/main/udp_client.c @@ -52,6 +52,9 @@ static const char *payload = "Message from ESP32 "; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -68,7 +71,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) ESP_LOGI(TAG, "SYSTEM_EVENT_STA_GOT_IP"); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, IPV4_GOTIP_BIT); #ifdef CONFIG_EXAMPLE_IPV6 diff --git a/examples/protocols/sockets/udp_multicast/main/udp_multicast_example_main.c b/examples/protocols/sockets/udp_multicast/main/udp_multicast_example_main.c index a21c24a6..5dea3f6a 100644 --- a/examples/protocols/sockets/udp_multicast/main/udp_multicast_example_main.c +++ b/examples/protocols/sockets/udp_multicast/main/udp_multicast_example_main.c @@ -61,6 +61,9 @@ static const char *V6TAG = "mcast-ipv6"; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -73,8 +76,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, IPV4_GOTIP_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, IPV4_GOTIP_BIT); xEventGroupClearBits(wifi_event_group, IPV6_GOTIP_BIT); diff --git a/examples/protocols/sockets/udp_server/main/udp_server.c b/examples/protocols/sockets/udp_server/main/udp_server.c index eb02fdea..2e81d0c5 100644 --- a/examples/protocols/sockets/udp_server/main/udp_server.c +++ b/examples/protocols/sockets/udp_server/main/udp_server.c @@ -45,6 +45,9 @@ static const char *TAG = "example"; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -61,7 +64,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) ESP_LOGI(TAG, "SYSTEM_EVENT_STA_GOT_IP"); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, IPV4_GOTIP_BIT); #ifdef CONFIG_EXAMPLE_IPV6 diff --git a/examples/provisioning/custom_config/main/app_prov.c b/examples/provisioning/custom_config/main/app_prov.c index f183f644..ad7253e3 100644 --- a/examples/provisioning/custom_config/main/app_prov.c +++ b/examples/provisioning/custom_config/main/app_prov.c @@ -215,6 +215,10 @@ esp_err_t app_prov_event_handler(void *ctx, system_event_t *event) /* If none of the expected reasons, * retry connecting to host SSID */ g_prov->wifi_state = WIFI_PROV_STA_CONNECTING; + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); } break; diff --git a/examples/provisioning/softap_prov/main/app_prov.c b/examples/provisioning/softap_prov/main/app_prov.c index 69aed5a5..864fe7fc 100644 --- a/examples/provisioning/softap_prov/main/app_prov.c +++ b/examples/provisioning/softap_prov/main/app_prov.c @@ -198,6 +198,10 @@ esp_err_t app_prov_event_handler(void *ctx, system_event_t *event) g_prov->wifi_disconnect_reason = WIFI_PROV_STA_AP_NOT_FOUND; break; default: + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } /* If none of the expected reasons, * retry connecting to host SSID */ g_prov->wifi_state = WIFI_PROV_STA_CONNECTING; diff --git a/examples/system/console/main/cmd_wifi.c b/examples/system/console/main/cmd_wifi.c index 52be40ef..c60f1e81 100644 --- a/examples/system/console/main/cmd_wifi.c +++ b/examples/system/console/main/cmd_wifi.c @@ -25,11 +25,19 @@ const int CONNECTED_BIT = BIT0; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_GOT_IP: xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: + ESP_LOGI(__func__, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/system/ota/native_ota/1MB_flash/new_to_new_no_old/main/ota_example_main.c b/examples/system/ota/native_ota/1MB_flash/new_to_new_no_old/main/ota_example_main.c index e53d94ca..4f1838da 100644 --- a/examples/system/ota/native_ota/1MB_flash/new_to_new_no_old/main/ota_example_main.c +++ b/examples/system/ota/native_ota/1MB_flash/new_to_new_no_old/main/ota_example_main.c @@ -78,6 +78,9 @@ const int CONNECTED_BIT = BIT0; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -86,8 +89,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/system/ota/native_ota/1MB_flash/new_to_new_no_old_copy/main/ota_example_main.c b/examples/system/ota/native_ota/1MB_flash/new_to_new_no_old_copy/main/ota_example_main.c index 8024c22b..4df5a494 100644 --- a/examples/system/ota/native_ota/1MB_flash/new_to_new_no_old_copy/main/ota_example_main.c +++ b/examples/system/ota/native_ota/1MB_flash/new_to_new_no_old_copy/main/ota_example_main.c @@ -78,6 +78,9 @@ const int CONNECTED_BIT = BIT0; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -86,8 +89,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/system/ota/native_ota/1MB_flash/new_to_new_with_old/main/ota_example_main.c b/examples/system/ota/native_ota/1MB_flash/new_to_new_with_old/main/ota_example_main.c index 159aa1b6..a8188b9c 100644 --- a/examples/system/ota/native_ota/1MB_flash/new_to_new_with_old/main/ota_example_main.c +++ b/examples/system/ota/native_ota/1MB_flash/new_to_new_with_old/main/ota_example_main.c @@ -78,6 +78,9 @@ const int CONNECTED_BIT = BIT0; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -86,8 +89,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/system/ota/native_ota/2+MB_flash/new_to_new_no_old/main/ota_example_main.c b/examples/system/ota/native_ota/2+MB_flash/new_to_new_no_old/main/ota_example_main.c index 8024c22b..4df5a494 100644 --- a/examples/system/ota/native_ota/2+MB_flash/new_to_new_no_old/main/ota_example_main.c +++ b/examples/system/ota/native_ota/2+MB_flash/new_to_new_no_old/main/ota_example_main.c @@ -78,6 +78,9 @@ const int CONNECTED_BIT = BIT0; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -86,8 +89,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/system/ota/native_ota/2+MB_flash/new_to_new_with_old/main/ota_example_main.c b/examples/system/ota/native_ota/2+MB_flash/new_to_new_with_old/main/ota_example_main.c index 159aa1b6..a8188b9c 100644 --- a/examples/system/ota/native_ota/2+MB_flash/new_to_new_with_old/main/ota_example_main.c +++ b/examples/system/ota/native_ota/2+MB_flash/new_to_new_with_old/main/ota_example_main.c @@ -78,6 +78,9 @@ const int CONNECTED_BIT = BIT0; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -86,8 +89,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/system/ota/simple_ota_example/main/simple_ota_example.c b/examples/system/ota/simple_ota_example/main/simple_ota_example.c index 880cf7f3..039b1dbe 100644 --- a/examples/system/ota/simple_ota_example/main/simple_ota_example.c +++ b/examples/system/ota/simple_ota_example/main/simple_ota_example.c @@ -101,6 +101,9 @@ esp_err_t _http_event_handler(esp_http_client_event_t *evt) static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -109,8 +112,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: - /* This is a workaround as ESP32 WiFi libs don't currently - auto-reassociate. */ + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/wifi/simple_wifi/main/simple_wifi.c b/examples/wifi/simple_wifi/main/simple_wifi.c index 11571dde..975d393e 100644 --- a/examples/wifi/simple_wifi/main/simple_wifi.c +++ b/examples/wifi/simple_wifi/main/simple_wifi.c @@ -39,6 +39,9 @@ static const char *TAG = "simple wifi"; static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_START: esp_wifi_connect(); @@ -59,6 +62,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) event->event_info.sta_disconnected.aid); break; case SYSTEM_EVENT_STA_DISCONNECTED: + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, WIFI_CONNECTED_BIT); break; diff --git a/examples/wifi/smart_config/main/smartconfig_main.c b/examples/wifi/smart_config/main/smartconfig_main.c index 0839c4ce..5bca3459 100644 --- a/examples/wifi/smart_config/main/smartconfig_main.c +++ b/examples/wifi/smart_config/main/smartconfig_main.c @@ -35,6 +35,9 @@ void smartconfig_example_task(void * parm); static esp_err_t event_handler(void *ctx, system_event_t *event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch(event->event_id) { case SYSTEM_EVENT_STA_START: xTaskCreate(smartconfig_example_task, "smartconfig_example_task", 4096, NULL, 3, NULL); @@ -43,6 +46,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); break; diff --git a/examples/wifi/wps/main/wps.c b/examples/wifi/wps/main/wps.c index efbd9f27..bef9ebb8 100644 --- a/examples/wifi/wps/main/wps.c +++ b/examples/wifi/wps/main/wps.c @@ -41,6 +41,9 @@ static esp_wps_config_t config = WPS_CONFIG_INIT_DEFAULT(WPS_TEST_MODE); static esp_err_t event_handler(void* ctx, system_event_t* event) { + /* For accessing reason codes in case of disconnection */ + system_event_info_t *info = &event->event_info; + switch (event->event_id) { case SYSTEM_EVENT_STA_START: ESP_LOGI(TAG, "SYSTEM_EVENT_STA_START"); @@ -54,6 +57,11 @@ static esp_err_t event_handler(void* ctx, system_event_t* event) case SYSTEM_EVENT_STA_DISCONNECTED: ESP_LOGI(TAG, "SYSTEM_EVENT_STA_DISCONNECTED"); + ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason); + if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) { + /*Switch to 802.11 bgn mode */ + esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N); + } ESP_ERROR_CHECK(esp_wifi_connect()); break;