mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-31 07:06:40 +00:00
Fix for wifi reconnection issues, delay retry for 30 sec #919
This commit is contained in:
parent
f08eafc07f
commit
acebfb980a
@ -509,7 +509,7 @@ void wifiSetup()
|
||||
|
||||
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
|
||||
wifiReconnect();
|
||||
WiFi.setAutoReconnect(true); // done in wifiEvery5Seconds
|
||||
WiFi.setAutoReconnect(false); // done in wifiEvery5Seconds
|
||||
LOG_TRACE(TAG_WIFI, F(D_WIFI_CONNECTING_TO), wifiSsid);
|
||||
}
|
||||
#endif
|
||||
@ -517,6 +517,8 @@ void wifiSetup()
|
||||
|
||||
bool wifiEvery5Seconds()
|
||||
{
|
||||
static uint8_t disconnectionPeriod = 0; // WiFi disconnection period counter
|
||||
|
||||
#if defined(STM32F4xx)
|
||||
if(wifiShowAP()) { // no ssid is set yet wait for user on-screen input
|
||||
return false;
|
||||
@ -529,15 +531,16 @@ bool wifiEvery5Seconds()
|
||||
#endif
|
||||
|
||||
if(WiFi.status() == WL_CONNECTED && WiFi.localIP() > 0) {
|
||||
disconnectionPeriod = 0; // Reset the counter if connection was established
|
||||
return true;
|
||||
}
|
||||
|
||||
// Issue #919 : Reconnects happens to quickly
|
||||
// if(wifiEnabled) {
|
||||
// LOG_WARNING(TAG_WIFI, F("No Connection... retry %d"), network_reconnect_counter);
|
||||
// wifiReconnect();
|
||||
// }
|
||||
|
||||
if(WiFi.status() != WL_CONNECTED) { // If WiFi disconnected...
|
||||
if(++disconnectionPeriod >= 6) { // If 30 seconds have passed since the disconnection...
|
||||
disconnectionPeriod = 0; // Restart timeout period
|
||||
wifiReconnect(); // Reconnect to WiFi
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user