Add rescan & selection on disconnect

This commit is contained in:
Blaz Kristan 2024-01-26 18:38:56 +01:00
parent 8817d41275
commit 3eb412b750

View File

@ -889,6 +889,7 @@ void WLED::initInterfaces()
void WLED::handleConnection() void WLED::handleConnection()
{ {
static bool scanDone = true;
static byte stacO = 0; static byte stacO = 0;
static uint32_t lastHeap = UINT32_MAX; static uint32_t lastHeap = UINT32_MAX;
static unsigned long heapTime = 0; static unsigned long heapTime = 0;
@ -949,10 +950,17 @@ void WLED::handleConnection()
if (!Network.isConnected()) { if (!Network.isConnected()) {
if (interfacesInited) { if (interfacesInited) {
DEBUG_PRINTLN(F("Disconnected!")); if (scanDone) {
initConnection(); DEBUG_PRINTLN(F("WiFi scan initiated on disconnect."));
findWiFi(true); // reinit scan findWiFi(true); // reinit scan
scanDone = false;
return; // try to connect in next iteration
}
DEBUG_PRINTLN(F("Disconnected!"));
selectedWiFi = findWiFi();
initConnection();
interfacesInited = false; interfacesInited = false;
scanDone = true;
} }
//send improv failed 6 seconds after second init attempt (24 sec. after provisioning) //send improv failed 6 seconds after second init attempt (24 sec. after provisioning)
if (improvActive > 2 && now - lastReconnectAttempt > 6000) { if (improvActive > 2 && now - lastReconnectAttempt > 6000) {