check more states for wifi reconnect

This commit is contained in:
MichaelDvP
2023-10-10 13:24:59 +02:00
parent 3ecea985ad
commit 99992db9ac

View File

@@ -32,9 +32,6 @@ void NetworkSettingsService::begin() {
} }
void NetworkSettingsService::reconfigureWiFiConnection() { void NetworkSettingsService::reconfigureWiFiConnection() {
// reset last connection attempt to force loop to reconnect immediately
_lastConnectionAttempt = 0;
// disconnect and de-configure wifi // disconnect and de-configure wifi
if (WiFi.disconnect(true)) { if (WiFi.disconnect(true)) {
_stopping = true; _stopping = true;
@@ -91,6 +88,8 @@ void NetworkSettingsService::manageSTA() {
// esp_wifi_set_max_tx_power(_state.tx_power * 4); // esp_wifi_set_max_tx_power(_state.tx_power * 4);
WiFi.setTxPower((wifi_power_t)(_state.tx_power * 4)); WiFi.setTxPower((wifi_power_t)(_state.tx_power * 4));
#endif #endif
} else { // not connected but STA-mode active => disconnect
reconfigureWiFiConnection();
} }
} }
@@ -102,8 +101,8 @@ void NetworkSettingsService::WiFiEvent(WiFiEvent_t event) {
_stopping = false; _stopping = false;
} }
} }
// wait 3 seconds before reconnecting if (!_stopping
// if (event == ARDUINO_EVENT_WIFI_STA_DISCONNECTED) { && (event == ARDUINO_EVENT_WIFI_STA_LOST_IP || event == ARDUINO_EVENT_WIFI_STA_DISCONNECTED || event == ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE)) {
// _lastConnectionAttempt = millis(); reconfigureWiFiConnection();
// } }
} }