fix reboot to wifi manager
This commit is contained in:
@@ -9,9 +9,7 @@ RTC_NOINIT_ATTR char WiFiDevice_reconfdetect[17];
|
|||||||
WifiDevice::WifiDevice(const String& hostname, Preferences* _preferences)
|
WifiDevice::WifiDevice(const String& hostname, Preferences* _preferences)
|
||||||
: NetworkDevice(hostname)
|
: NetworkDevice(hostname)
|
||||||
{
|
{
|
||||||
WiFiDevice_reconfdetect[16] = 0x00;
|
|
||||||
_startAp = strcmp(WiFiDevice_reconfdetect, "reconfigure_wifi") == 0;
|
_startAp = strcmp(WiFiDevice_reconfdetect, "reconfigure_wifi") == 0;
|
||||||
memset(WiFiDevice_reconfdetect, 0, sizeof WiFiDevice_reconfdetect);
|
|
||||||
|
|
||||||
_restartOnDisconnect = _preferences->getBool(preference_restart_on_disconnect);
|
_restartOnDisconnect = _preferences->getBool(preference_restart_on_disconnect);
|
||||||
|
|
||||||
@@ -69,6 +67,8 @@ void WifiDevice::initialize()
|
|||||||
_wm.setMenu(wm_menu);
|
_wm.setMenu(wm_menu);
|
||||||
_wm.setHostname(_hostname);
|
_wm.setHostname(_hostname);
|
||||||
|
|
||||||
|
_wm.setAPCallback(clearRtcInitVar);
|
||||||
|
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
if(_startAp)
|
if(_startAp)
|
||||||
@@ -105,6 +105,7 @@ void WifiDevice::initialize()
|
|||||||
void WifiDevice::reconfigure()
|
void WifiDevice::reconfigure()
|
||||||
{
|
{
|
||||||
strcpy(WiFiDevice_reconfdetect, "reconfigure_wifi");
|
strcpy(WiFiDevice_reconfdetect, "reconfigure_wifi");
|
||||||
|
delay(200);
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,3 +149,8 @@ int8_t WifiDevice::signalStrength()
|
|||||||
{
|
{
|
||||||
return WiFi.RSSI();
|
return WiFi.RSSI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WifiDevice::clearRtcInitVar(WiFiManager *)
|
||||||
|
{
|
||||||
|
memset(WiFiDevice_reconfdetect, 0, sizeof WiFiDevice_reconfdetect);
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ public:
|
|||||||
virtual PubSubClient *mqttClient();
|
virtual PubSubClient *mqttClient();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static void clearRtcInitVar(WiFiManager*);
|
||||||
|
|
||||||
void onDisconnected();
|
void onDisconnected();
|
||||||
|
|
||||||
WiFiManager _wm;
|
WiFiManager _wm;
|
||||||
|
|||||||
Reference in New Issue
Block a user