Unverified Commit 52575d63 authored by P-R-O-C-H-Y's avatar P-R-O-C-H-Y Committed by GitHub

Fixed wifiBegin to fail wfile connecting to same AP without previous disconnecting (#6359)

parent d1f0d6c0
......@@ -835,6 +835,8 @@ const char * system_event_reasons[] = { "UNSPECIFIED", "AUTH_EXPIRE", "AUTH_LEAV
#endif
esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
{
static bool first_connect = true;
if(event->event_id < ARDUINO_EVENT_MAX) {
log_d("Arduino Event: %d - %s", event->event_id, arduino_event_names[event->event_id]);
}
......@@ -860,7 +862,7 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
log_w("Reason: %u - %s", reason, reason2str(reason));
if(reason == WIFI_REASON_NO_AP_FOUND) {
WiFiSTAClass::_setStatus(WL_NO_SSID_AVAIL);
} else if(reason == WIFI_REASON_AUTH_FAIL) {
} else if((reason == WIFI_REASON_AUTH_FAIL) && !first_connect){
WiFiSTAClass::_setStatus(WL_CONNECT_FAILED);
} else if(reason == WIFI_REASON_BEACON_TIMEOUT || reason == WIFI_REASON_HANDSHAKE_TIMEOUT) {
WiFiSTAClass::_setStatus(WL_CONNECTION_LOST);
......@@ -870,7 +872,15 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
WiFiSTAClass::_setStatus(WL_DISCONNECTED);
}
clearStatusBits(STA_CONNECTED_BIT | STA_HAS_IP_BIT | STA_HAS_IP6_BIT);
if(WiFi.getAutoReconnect()){
if(first_connect && ((reason == WIFI_REASON_AUTH_EXPIRE) ||
(reason >= WIFI_REASON_BEACON_TIMEOUT)))
{
log_d("WiFi Reconnect Running");
WiFi.disconnect();
WiFi.begin();
first_connect = false;
}
else if(WiFi.getAutoReconnect()){
if((reason == WIFI_REASON_AUTH_EXPIRE) ||
(reason >= WIFI_REASON_BEACON_TIMEOUT && reason != WIFI_REASON_AUTH_FAIL))
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment