File tree 1 file changed +16
-12
lines changed
1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -960,22 +960,20 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
960
960
WiFiSTAClass::_setStatus (WL_DISCONNECTED);
961
961
}
962
962
clearStatusBits (STA_CONNECTED_BIT | STA_HAS_IP_BIT | STA_HAS_IP6_BIT);
963
- if (first_connect && ((reason == WIFI_REASON_AUTH_EXPIRE) ||
964
- (reason >= WIFI_REASON_BEACON_TIMEOUT)))
965
- {
963
+
964
+ bool DoReconnect = false ;
965
+
966
+ if (first_connect && (reason != WIFI_REASON_ASSOC_LEAVE)) {
967
+ first_connect = false ;
966
968
log_d (" WiFi Reconnect Running" );
967
969
WiFi.disconnect ();
968
970
WiFi.begin ();
969
- first_connect = false ;
971
+
970
972
}
971
- else if (WiFi.getAutoReconnect ()){
972
- if ((reason == WIFI_REASON_AUTH_EXPIRE) ||
973
- (reason >= WIFI_REASON_BEACON_TIMEOUT && reason != WIFI_REASON_AUTH_FAIL))
974
- {
975
- log_d (" WiFi AutoReconnect Running" );
976
- WiFi.disconnect ();
977
- WiFi.begin ();
978
- }
973
+ else if (WiFi.getAutoReconnect () && _isReconnectableReason () ) {
974
+ log_d (" WiFi AutoReconnect Running" );
975
+ WiFi.disconnect ();
976
+ WiFi.begin ();
979
977
}
980
978
else if (reason == WIFI_REASON_ASSOC_FAIL){
981
979
WiFiSTAClass::_setStatus (WL_CONNECT_FAILED);
@@ -1063,6 +1061,12 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
1063
1061
return ESP_OK;
1064
1062
}
1065
1063
1064
+ bool WiFiGenericClass::_isReconnectableReason (uint8_t reason) {
1065
+ return (reason == WIFI_REASON_AUTH_EXPIRE) ||
1066
+ (reason == WIFI_REASON_ASSOC_EXPIRE) ||
1067
+ (reason >= WIFI_REASON_BEACON_TIMEOUT);
1068
+ }
1069
+
1066
1070
/* *
1067
1071
* Return the current channel associated with the network
1068
1072
* @return channel (1-13)
You can’t perform that action at this time.
0 commit comments