From 03849a609b5621acb6a2c9ec8c7e04d28b8715a7 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Thu, 9 Feb 2023 16:24:55 +0100 Subject: [PATCH] Added web reset functionality --- firmware/firmware.ino | 8 ++++---- firmware/webUpdater.ino | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/firmware/firmware.ino b/firmware/firmware.ino index d99ac1d..49d08f2 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -88,10 +88,6 @@ void setup() { Serial.begin(SERIAL_BAUD_RATE); #endif -#ifdef DEBUG_RESET_REASON - debugResetReason(); -#endif - // Pin settings pinMode(BAT_CHARGED_PIN, INPUT); pinMode(BAT_CHARGING_PIN, INPUT); @@ -121,6 +117,10 @@ void setup() { //It's magic! leave in delay(100); +#ifdef DEBUG_RESET_REASON + debugResetReason(); +#endif + #ifdef BATTERY_POWERED debug("battery powered"); diff --git a/firmware/webUpdater.ino b/firmware/webUpdater.ino index 40d4d84..36cd83b 100644 --- a/firmware/webUpdater.ino +++ b/firmware/webUpdater.ino @@ -54,6 +54,9 @@ void setupWebUpdater(String device, String ip) #ifdef DEBUG_WINDSPEED_MEASUREMENT httpServer.on("/measWind", measureWindspeed); #endif +#ifdef WEB_RESET + httpServer.on("/resetESP", resetESP); +#endif #ifdef USE_LOGGER httpServer.on("/showlog", showLog); #endif @@ -125,6 +128,9 @@ void showHTMLMain(void) #ifdef HOMEBRIDGE_WEBSTAT "
homebridge websatt
" #endif +#ifdef WEB_RESET + "
reset ESP
" +#endif #ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE "

" TR_TD_START_STR + "temperature" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_TEMPERATURE]) + TR_TD_END_STR @@ -182,6 +188,27 @@ void hb_webstat_send(void) //*************************************************************************// +#ifdef WEB_RESET + +void resetESP() +{ + + String message = "OKO Weatherstation - " + String(_webUpdater_dev) + " - reset WiFi manager" + "" + "" + "Rebooting...
" + ""; + + httpServer.send(200, "text/html", message); + + delay(5000); + + // manual reset after restart is required + ESP.restart(); +} + +#endif + #ifndef DISABLE_WIFIMANAGER void resetWifiManager()