diff --git a/src/network_manager.cpp b/src/network_manager.cpp index 933d8f2..d40e5c8 100644 --- a/src/network_manager.cpp +++ b/src/network_manager.cpp @@ -11,21 +11,19 @@ NetworkManager::~NetworkManager() { } // Private methods void NetworkManager::_processAPTimeout() { - if (!_wifiAPmode || _apTimeout == 0 || !_wifiSTAmode) { + if (!_wifiAPmode || _apTimeout == 0) { + return; + } + + // If any station is connected, reset the timer + if (WiFi.softAPgetStationNum() > 0) { + _apStartup = millis(); return; } if (millis() - _apStartup > _apTimeout) { - // Time expired, switch to client mode if successfully connected - if (isWiFiConnected()) { - Serial.println("AP timeout reached. Switching to client mode only."); - disableAP(); - } - else { - // Not connected as a client, keep AP running - Serial.println("AP timeout reached but WiFi client still not connected. Keeping AP mode active."); - _apStartup = millis(); // Reset timer - } + Serial.println("AP timeout reached. Disabling AP mode."); + disableAP(); } }