Skip to content

Commit d1ac395

Browse files
committed
Wi-Fi: prevent saving settings into flash; save power during startup
1 parent 3dea728 commit d1ac395

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

VanLiveConnect/Sleep.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ void GoToSleep()
6464
);
6565
Serial.flush();
6666

67+
WiFi.disconnect(true);
68+
delay(1);
69+
6770
IrDisable();
6871
VanBusRx.Disable();
6972

VanLiveConnect/VanLiveConnect.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ void setup()
331331
digitalWrite(LED_BUILTIN, LED_OFF);
332332
#endif
333333

334+
WiFi.mode(WIFI_OFF);
335+
WiFi.forceSleepBegin();
336+
delay(1);
337+
334338
md5Checksum = ESP.getSketchMD5();
335339

336340
SetupSleep();
@@ -537,4 +541,6 @@ void loop()
537541
VanBusRx.DumpStats(Serial);
538542
} // if
539543
#endif // SHOW_VAN_RX_STATS
544+
545+
delay(9);
540546
} // loop

VanLiveConnect/Wifi.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ const char* SetupWifi()
168168

169169
static const char* wifiSsid = WIFI_SSID;
170170

171+
WiFi.forceSleepWake();
172+
delay(1);
173+
174+
// Disable the WiFi persistence. The ESP8266 will not load and save WiFi settings in the flash memory.
175+
WiFi.persistent(false);
176+
171177
#ifdef WIFI_AP_MODE
172178

173179
#ifdef ON_DESK_MFD_ESP_MAC
@@ -224,7 +230,6 @@ const char* SetupWifi()
224230

225231
WiFi.mode(WIFI_STA); // Otherwise it may be in WIFI_AP_STA mode, broadcasting an SSID like AI_THINKER_XXXXXX
226232
WiFi.disconnect(); // After reset via HW button sometimes cannot seem to reconnect without this
227-
WiFi.persistent(false);
228233
#ifdef ARDUINO_ARCH_ESP32
229234
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
230235
WiFi.setAutoReconnect(true);

0 commit comments

Comments
 (0)