Skip to content

Commit 41d9725

Browse files
authored
Proposed fix for espressif#2501 (espressif#6113)
Reliability fix for autoReconnect when assoc_fail, autoReconnect did not work before for these failures. Changes behavior of WIFI_REASON_ASSOC_FAIL event when autoReconnect is set, removes WIFI_REASON_ASSOC_FAIL/WL_CONNECT_FAILED so retry waitforconnectresult loop stays active for the retry, was not working before.
1 parent a0beb81 commit 41d9725

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

libraries/WiFi/src/WiFiGeneric.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
852852
log_w("Reason: %u - %s", reason, reason2str(reason));
853853
if(reason == WIFI_REASON_NO_AP_FOUND) {
854854
WiFiSTAClass::_setStatus(WL_NO_SSID_AVAIL);
855-
} else if(reason == WIFI_REASON_AUTH_FAIL || reason == WIFI_REASON_ASSOC_FAIL) {
855+
} else if(reason == WIFI_REASON_AUTH_FAIL) {
856856
WiFiSTAClass::_setStatus(WL_CONNECT_FAILED);
857857
} else if(reason == WIFI_REASON_BEACON_TIMEOUT || reason == WIFI_REASON_HANDSHAKE_TIMEOUT) {
858858
WiFiSTAClass::_setStatus(WL_CONNECTION_LOST);
@@ -862,12 +862,17 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
862862
WiFiSTAClass::_setStatus(WL_DISCONNECTED);
863863
}
864864
clearStatusBits(STA_CONNECTED_BIT | STA_HAS_IP_BIT | STA_HAS_IP6_BIT);
865-
if(((reason == WIFI_REASON_AUTH_EXPIRE) ||
866-
(reason >= WIFI_REASON_BEACON_TIMEOUT && reason != WIFI_REASON_AUTH_FAIL)) &&
867-
WiFi.getAutoReconnect())
868-
{
869-
WiFi.disconnect();
870-
WiFi.begin();
865+
if(WiFi.getAutoReconnect()){
866+
if((reason == WIFI_REASON_AUTH_EXPIRE) ||
867+
(reason >= WIFI_REASON_BEACON_TIMEOUT && reason != WIFI_REASON_AUTH_FAIL))
868+
{
869+
log_d("WiFi AutoReconnect Running");
870+
WiFi.disconnect();
871+
WiFi.begin();
872+
}
873+
}
874+
else if (reason == WIFI_REASON_ASSOC_FAIL){
875+
WiFiSTAClass::_setStatus(WL_CONNECT_FAILED);
871876
}
872877
} else if(event->event_id == ARDUINO_EVENT_WIFI_STA_GOT_IP) {
873878
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy