Constant & override

This commit is contained in:
Blaz Kristan 2024-01-26 15:31:09 +01:00
parent 07495f6621
commit 5c7b7e4182
3 changed files with 10 additions and 6 deletions

View File

@ -157,7 +157,10 @@
#define AP_BEHAVIOR_NO_CONN 1 //Open when no connection (either after boot or if connection is lost) #define AP_BEHAVIOR_NO_CONN 1 //Open when no connection (either after boot or if connection is lost)
#define AP_BEHAVIOR_ALWAYS 2 //Always open #define AP_BEHAVIOR_ALWAYS 2 //Always open
#define AP_BEHAVIOR_BUTTON_ONLY 3 //Only when button pressed for 6 sec #define AP_BEHAVIOR_BUTTON_ONLY 3 //Only when button pressed for 6 sec
#define AP_BEHAVIOR_BOOT_NO_CONN_5MIN 4 //Open AP when no connection after boot but only for 5min #define AP_BEHAVIOR_TEMPORARY 4 //Open AP when no connection after boot but only temporary
#ifndef WLED_AP_TIMEOUT
#define WLED_AP_TIMEOUT 300000 //Temporary AP timeout
#endif
//Notifier callMode //Notifier callMode
#define CALL_MODE_INIT 0 //no updates on init, can be used to disable updates #define CALL_MODE_INIT 0 //no updates on init, can be used to disable updates

View File

@ -190,7 +190,7 @@
<option value="1">Disconnected</option> <option value="1">Disconnected</option>
<option value="2">Always</option> <option value="2">Always</option>
<option value="3">Never (not recommended)</option> <option value="3">Never (not recommended)</option>
<option value="4">No connection after boot (5min)</option> <option value="4">Temporary (no connection after boot)</option>
</select><br> </select><br>
AP IP: <span class="sip"> Not active </span><br> AP IP: <span class="sip"> Not active </span><br>
<h3>Experimental</h3> <h3>Experimental</h3>

View File

@ -913,17 +913,18 @@ void WLED::handleConnection()
initConnection(); initConnection();
} }
if (!apActive && now - lastReconnectAttempt > 12000 && (!wasConnected || apBehavior == AP_BEHAVIOR_NO_CONN)) { if (!apActive && now - lastReconnectAttempt > 12000 && (!wasConnected || apBehavior == AP_BEHAVIOR_NO_CONN)) {
if (!(apBehavior == AP_BEHAVIOR_BOOT_NO_CONN_5MIN && now > 300000)) { if (!(apBehavior == AP_BEHAVIOR_TEMPORARY && now > WLED_AP_TIMEOUT)) {
DEBUG_PRINTLN(F("Not connected AP.")); DEBUG_PRINTLN(F("Not connected AP."));
initAP(); // start AP only within first 5min initAP(); // start AP only within first 5min
} }
} if (apActive && apBehavior == AP_BEHAVIOR_BOOT_NO_CONN_5MIN && now > 300000 && stac == 0) { // disconnect AP after 5min if no clients connected }
if (apActive && apBehavior == AP_BEHAVIOR_TEMPORARY && now > WLED_AP_TIMEOUT && 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 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) { if (now < 2*WLED_AP_TIMEOUT) {
dnsServer.stop(); dnsServer.stop();
WiFi.softAPdisconnect(true); WiFi.softAPdisconnect(true);
apActive = false; apActive = false;
DEBUG_PRINTLN(F("Access point disabled (after 5min).")); DEBUG_PRINTLN(F("Temporary AP disabled."));
} }
} }
} else if (!interfacesInited) { //newly connected } else if (!interfacesInited) { //newly connected