** Function: cleanlyStopWebUiForWiFiFeature ** Cleanly stop WebUI and AP mode before starting a WiFi feature ** This prevents WiFi mode conflicts when features need exclusive control **********************************************************************/
| 59 | ** This prevents WiFi mode conflicts when features need exclusive control |
| 60 | **********************************************************************/ |
| 61 | void cleanlyStopWebUiForWiFiFeature() { |
| 62 | // Only proceed if WebUI is active |
| 63 | if (!isWebUIActive && !server) { return; } |
| 64 | |
| 65 | // Brief notification (non-blocking) |
| 66 | Serial.println("Stopping WebUI for WiFi feature..."); |
| 67 | |
| 68 | // Stop the WebUI |
| 69 | if (server) { |
| 70 | stopWebUi(); |
| 71 | // Give the web server time to fully shut down |
| 72 | vTaskDelay(pdMS_TO_TICKS(100)); |
| 73 | } |
| 74 | |
| 75 | // Disconnect WiFi AP mode if it's the WebUI's AP |
| 76 | // Check if we're in AP or APSTA mode (used by WebUI) |
| 77 | wifi_mode_t currentMode = WiFi.getMode(); |
| 78 | if (currentMode == WIFI_MODE_AP || currentMode == WIFI_MODE_APSTA) { |
| 79 | wifiDisconnect(); |
| 80 | // Give WiFi time to fully disconnect |
| 81 | vTaskDelay(pdMS_TO_TICKS(250)); |
| 82 | } |
| 83 | |
| 84 | Serial.println("WebUI stopped, starting WiFi feature..."); |
| 85 | } |
| 86 | /********************************************************************** |
| 87 | ** Function: loopOptionsWebUi |
| 88 | ** Display options to launch the WebUI |
no test coverage detected