Skip to content

Commit 6aede04

Browse files
committed
Set persistant WiFi opmode to WIFI_OFF if not already configured that way
1 parent a9e6bd4 commit 6aede04

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/framework/WiFiSettingsService.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
#include <WiFiSettingsService.h>
22

33
WiFiSettingsService::WiFiSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager) : AdminSettingsService(server, fs, securityManager, WIFI_SETTINGS_SERVICE_PATH, WIFI_SETTINGS_FILE) {
4+
// We want the device to come up in opmode=0 (WIFI_OFF), when erasing the flash this is not the default.
5+
// If needed, we save opmode=0 before disabling persistence so the device boots with WiFi disabled in the future.
6+
if (WiFi.getMode() != WIFI_OFF) {
7+
WiFi.mode(WIFI_OFF);
8+
}
9+
410
// Disable WiFi config persistance and auto reconnect
511
WiFi.persistent(false);
612
WiFi.setAutoReconnect(false);
7-
13+
814
#if defined(ESP8266)
915
_onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected(std::bind(&WiFiSettingsService::onStationModeDisconnected, this, std::placeholders::_1));
1016
#elif defined(ESP_PLATFORM)

0 commit comments

Comments
 (0)