diff --git a/firmware/README.md b/firmware/README.md old mode 100644 new mode 100755 diff --git a/firmware/firmware.ino b/firmware/firmware.ino old mode 100755 new mode 100644 index 4146769..b8442a1 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -35,11 +35,6 @@ void debug(String x) { void setup() { - // Erase WiFi Credentials, enable, compile, flash, disable and reflash. - //WiFi.disconnect(true); - //delay(2000); - //ESP.reset(); - #if defined(DEBUG) || defined(SERIAL_FEATURE) Serial.begin(115200); #endif @@ -69,11 +64,12 @@ void setup() { wifiManager.setConnectTimeout(WIFI_AUTOCONNECT_TIMEOUT_S); // the time in seconds to wait for the known wifi connection wifiManager.setTimeout(WIFI_CONFIG_PORTAL_TIMEOUT_S); // the time in seconds to wait for the user to configure the device - if (!wifiManager.autoConnect(wifiName.c_str(), "DEADBEEF")) { - debug("WiFi connection failed, going into deep sleep ..."); + while (!wifiManager.autoConnect(wifiName.c_str(), "DEADBEEF")) + { + debug("WiFi connection failed, try again in 5 seconds..."); // If autoconnect to WLAN failed and no client connected, go to deep sleep - ESP.deepSleep(POWERSAVING_SLEEP_S * 1000000, WAKE_RF_DEFAULT); - delay(100); + //ESP.deepSleep(POWERSAVING_SLEEP_S * 1000000, WAKE_RF_DEFAULT); + delay(5000); } debug("Connected!"); diff --git a/firmware/webUpdater.ino b/firmware/webUpdater.ino old mode 100755 new mode 100644 index 82b264d..3f440a2 --- a/firmware/webUpdater.ino +++ b/firmware/webUpdater.ino @@ -27,7 +27,8 @@ void setupWebUpdater(String device, String ip) httpUpdater.setup(&httpServer); - httpServer.on("/", showHTMLMain); // oko specific site + httpServer.on("/", showHTMLMain); + httpServer.on("/resetWifiManager", resetWifiManager); httpServer.begin(); @@ -63,3 +64,23 @@ void showHTMLMain(void) { httpServer.send(200, "text/html", message); } + +void resetWifiManager() +{ + + String message = "OKO Weatherstation - " + String(_webUpdater_dev) + "" +"" +"" +"Reset WifiManager config.
" +"Rebooting...
" +""; + + httpServer.send(200, "text/html", message); + + // Erase WiFi Credentials, enable, compile, flash, disable and reflash. + WiFiManager.resetSettings() + + delay(5000); + + ESP.restart(); +}