mirror of
https://github.com/wled/WLED.git
synced 2025-07-22 18:26:32 +00:00
Add JSON API for AP toggle
This commit is contained in:
parent
27532a4237
commit
6f3b5fc559
@ -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;
|
||||
|
||||
|
@ -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("");
|
||||
|
Loading…
x
Reference in New Issue
Block a user