Skip to content

Commit 47943c4

Browse files
Set WIFI_OFF when no SSID is set and when AP is set to never (which is in fact button activated)
1 parent b91b340 commit 47943c4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

wled00/wled.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,14 @@ void WLED::initConnection()
633633

634634
if (!WLED_WIFI_CONFIGURED) {
635635
DEBUG_PRINTLN(F("No connection configured."));
636-
if (!apActive) initAP(); // instantly go to ap mode
637-
return;
636+
if (*clientSSID == '\0') {
637+
DEBUG_PRINTLN(F("But user don't want connection, WIFI_OFF"));
638+
WiFi.mode(WIFI_OFF);
639+
return;
640+
} else {
641+
if (!apActive) initAP(); // instantly go to ap mode
642+
return;
643+
}
638644
} else if (!apActive) {
639645
if (apBehavior == AP_BEHAVIOR_ALWAYS) {
640646
DEBUG_PRINTLN(F("Access point ALWAYS enabled."));
@@ -801,12 +807,12 @@ void WLED::handleConnection()
801807
sendImprovStateResponse(0x03, true);
802808
improvActive = 2;
803809
}
804-
if (now - lastReconnectAttempt > ((stac) ? 300000 : 18000) && WLED_WIFI_CONFIGURED) {
810+
if (now - lastReconnectAttempt > ((stac) ? 300000 : 18000) && WLED_WIFI_CONFIGURED && *clientSSID != '\0') {
805811
if (improvActive == 2) improvActive = 3;
806812
DEBUG_PRINTLN(F("Last reconnect too old."));
807813
initConnection();
808814
}
809-
if (!apActive && now - lastReconnectAttempt > 12000 && (!wasConnected || apBehavior == AP_BEHAVIOR_NO_CONN)) {
815+
if (!apActive && now - lastReconnectAttempt > 12000 && apBehavior != AP_BEHAVIOR_BUTTON_ONLY && (!wasConnected || apBehavior == AP_BEHAVIOR_NO_CONN)) {
810816
DEBUG_PRINTLN(F("Not connected AP."));
811817
initAP();
812818
}

0 commit comments

Comments
 (0)