Fix Wifi AP shutdown during client WiFi reconnect attempt

This commit is contained in:
Ulrich Meine
2026-04-23 23:06:05 +02:00
parent 3b2f73e22a
commit cfac5b0a05
+24 -20
View File
@@ -143,30 +143,34 @@ void GwWifi::loop(){
delay(300); delay(300);
if (acquireMutex()){ if (!apActive) {
esp_err_t stopErr=esp_wifi_stop(); if (acquireMutex()){
releaseMutex(); esp_err_t stopErr=esp_wifi_stop();
if (stopErr != ESP_OK){ releaseMutex();
LOG_DEBUG(GwLog::ERROR,"GwWifi: esp_wifi_stop failed: %d",(int)stopErr); if (stopErr != ESP_OK){
LOG_DEBUG(GwLog::ERROR,"GwWifi: esp_wifi_stop failed: %d",(int)stopErr);
}
} }
} else{
else{ LOG_DEBUG(GwLog::ERROR,"GwWifi: mutex timeout in loop (stop)");
LOG_DEBUG(GwLog::ERROR,"GwWifi: mutex timeout in loop (stop)");
}
delay(100);
if (acquireMutex()){
esp_err_t startErr=esp_wifi_start();
releaseMutex();
if (startErr != ESP_OK){
LOG_DEBUG(GwLog::ERROR,"GwWifi: esp_wifi_start failed: %d",(int)startErr);
} }
delay(100);
if (acquireMutex()){
esp_err_t startErr=esp_wifi_start();
releaseMutex();
if (startErr != ESP_OK){
LOG_DEBUG(GwLog::ERROR,"GwWifi: esp_wifi_start failed: %d",(int)startErr);
}
connectInternal();
}
else{
LOG_DEBUG(GwLog::ERROR,"GwWifi: mutex timeout in loop (start)");
}
} else {
connectInternal(); connectInternal();
} }
else{
LOG_DEBUG(GwLog::ERROR,"GwWifi: mutex timeout in loop (start)");
}
} }
} }
else{ else{