From e202db236e9263d68b63449f5e95256ac3585ce9 Mon Sep 17 00:00:00 2001 From: technyon Date: Sun, 1 Jan 2023 16:33:00 +0100 Subject: [PATCH] fix reboot to wifi manager --- networkDevices/WifiDevice.cpp | 10 ++++++++-- networkDevices/WifiDevice.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/networkDevices/WifiDevice.cpp b/networkDevices/WifiDevice.cpp index dfe2f14..9d57ab9 100644 --- a/networkDevices/WifiDevice.cpp +++ b/networkDevices/WifiDevice.cpp @@ -9,9 +9,7 @@ RTC_NOINIT_ATTR char WiFiDevice_reconfdetect[17]; WifiDevice::WifiDevice(const String& hostname, Preferences* _preferences) : NetworkDevice(hostname) { - WiFiDevice_reconfdetect[16] = 0x00; _startAp = strcmp(WiFiDevice_reconfdetect, "reconfigure_wifi") == 0; - memset(WiFiDevice_reconfdetect, 0, sizeof WiFiDevice_reconfdetect); _restartOnDisconnect = _preferences->getBool(preference_restart_on_disconnect); @@ -69,6 +67,8 @@ void WifiDevice::initialize() _wm.setMenu(wm_menu); _wm.setHostname(_hostname); + _wm.setAPCallback(clearRtcInitVar); + bool res = false; if(_startAp) @@ -105,6 +105,7 @@ void WifiDevice::initialize() void WifiDevice::reconfigure() { strcpy(WiFiDevice_reconfdetect, "reconfigure_wifi"); + delay(200); ESP.restart(); } @@ -148,3 +149,8 @@ int8_t WifiDevice::signalStrength() { return WiFi.RSSI(); } + +void WifiDevice::clearRtcInitVar(WiFiManager *) +{ + memset(WiFiDevice_reconfdetect, 0, sizeof WiFiDevice_reconfdetect); +} diff --git a/networkDevices/WifiDevice.h b/networkDevices/WifiDevice.h index f359761..72e72bd 100644 --- a/networkDevices/WifiDevice.h +++ b/networkDevices/WifiDevice.h @@ -25,6 +25,8 @@ public: virtual PubSubClient *mqttClient(); private: + static void clearRtcInitVar(WiFiManager*); + void onDisconnected(); WiFiManager _wm;