Network manager: AutoAP Disable

This commit is contained in:
Petr Kracik 2026-03-05 23:23:34 +01:00
parent 1ff5504956
commit 1668fc1412

View file

@ -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();
}
}