Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 52575d6

Browse filesBrowse files
authored
Fixed wifiBegin to fail wfile connecting to same AP without previous disconnecting (espressif#6359)
1 parent d1f0d6c commit 52575d6
Copy full SHA for 52575d6

File tree

Expand file treeCollapse file tree

1 file changed

+12
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-2
lines changed

‎libraries/WiFi/src/WiFiGeneric.cpp

Copy file name to clipboardExpand all lines: libraries/WiFi/src/WiFiGeneric.cpp
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,8 @@ const char * system_event_reasons[] = { "UNSPECIFIED", "AUTH_EXPIRE", "AUTH_LEAV
835835
#endif
836836
esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
837837
{
838+
static bool first_connect = true;
839+
838840
if(event->event_id < ARDUINO_EVENT_MAX) {
839841
log_d("Arduino Event: %d - %s", event->event_id, arduino_event_names[event->event_id]);
840842
}
@@ -860,7 +862,7 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
860862
log_w("Reason: %u - %s", reason, reason2str(reason));
861863
if(reason == WIFI_REASON_NO_AP_FOUND) {
862864
WiFiSTAClass::_setStatus(WL_NO_SSID_AVAIL);
863-
} else if(reason == WIFI_REASON_AUTH_FAIL) {
865+
} else if((reason == WIFI_REASON_AUTH_FAIL) && !first_connect){
864866
WiFiSTAClass::_setStatus(WL_CONNECT_FAILED);
865867
} else if(reason == WIFI_REASON_BEACON_TIMEOUT || reason == WIFI_REASON_HANDSHAKE_TIMEOUT) {
866868
WiFiSTAClass::_setStatus(WL_CONNECTION_LOST);
@@ -870,7 +872,15 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
870872
WiFiSTAClass::_setStatus(WL_DISCONNECTED);
871873
}
872874
clearStatusBits(STA_CONNECTED_BIT | STA_HAS_IP_BIT | STA_HAS_IP6_BIT);
873-
if(WiFi.getAutoReconnect()){
875+
if(first_connect && ((reason == WIFI_REASON_AUTH_EXPIRE) ||
876+
(reason >= WIFI_REASON_BEACON_TIMEOUT)))
877+
{
878+
log_d("WiFi Reconnect Running");
879+
WiFi.disconnect();
880+
WiFi.begin();
881+
first_connect = false;
882+
}
883+
else if(WiFi.getAutoReconnect()){
874884
if((reason == WIFI_REASON_AUTH_EXPIRE) ||
875885
(reason >= WIFI_REASON_BEACON_TIMEOUT && reason != WIFI_REASON_AUTH_FAIL))
876886
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.