diff --git a/wled00/json.cpp b/wled00/json.cpp index d3b1ca250..67f4de609 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -466,6 +466,19 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId) } } + JsonObject wifi = root[F("wifi")]; + if (!wifi.isNull()) { + bool apMode = getBoolVal(wifi[F("ap")], apActive); + if (!apActive && apMode) WLED::instance().initAP(); // start AP mode immediately + else if (apActive && !apMode) { // stop AP mode immediately + dnsServer.stop(); + WiFi.softAPdisconnect(true); + apActive = false; + } + //bool restart = wifi[F("restart")] | false; + //if (restart) forceReconnect = true; + } + stateUpdated(callMode); if (presetToRestore) currentPreset = presetToRestore; diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 0ad0ad716..3158cb31d 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -889,11 +889,14 @@ void WLED::handleConnection() DEBUG_PRINTLN(F("Not connected AP.")); initAP(); // start AP only within first 5min } - } if (apActive && apBehavior == AP_BEHAVIOR_BOOT_NO_CONN_5MIN && now > 300000 && stac == 0) { // disconnect AP after 5min - dnsServer.stop(); - WiFi.softAPdisconnect(true); - apActive = false; - DEBUG_PRINTLN(F("Access point disabled (after 5min).")); + } if (apActive && apBehavior == AP_BEHAVIOR_BOOT_NO_CONN_5MIN && now > 300000 && stac == 0) { // disconnect AP after 5min if no clients connected + // if AP was enabled more than 10min after boot or if client was connected more than 10min after boot do not disconnect AP mode + if (now < 600000) { + dnsServer.stop(); + WiFi.softAPdisconnect(true); + apActive = false; + DEBUG_PRINTLN(F("Access point disabled (after 5min).")); + } } } else if (!interfacesInited) { //newly connected DEBUG_PRINTLN("");