Added web reset functionality

This commit is contained in:
Kai Lauterbach 2023-02-09 16:24:55 +01:00
parent 76d8416a41
commit 03849a609b
2 changed files with 31 additions and 4 deletions

View file

@ -88,10 +88,6 @@ void setup() {
Serial.begin(SERIAL_BAUD_RATE); Serial.begin(SERIAL_BAUD_RATE);
#endif #endif
#ifdef DEBUG_RESET_REASON
debugResetReason();
#endif
// Pin settings // Pin settings
pinMode(BAT_CHARGED_PIN, INPUT); pinMode(BAT_CHARGED_PIN, INPUT);
pinMode(BAT_CHARGING_PIN, INPUT); pinMode(BAT_CHARGING_PIN, INPUT);
@ -121,6 +117,10 @@ void setup() {
//It's magic! leave in //It's magic! leave in
delay(100); delay(100);
#ifdef DEBUG_RESET_REASON
debugResetReason();
#endif
#ifdef BATTERY_POWERED #ifdef BATTERY_POWERED
debug("battery powered"); debug("battery powered");

View file

@ -54,6 +54,9 @@ void setupWebUpdater(String device, String ip)
#ifdef DEBUG_WINDSPEED_MEASUREMENT #ifdef DEBUG_WINDSPEED_MEASUREMENT
httpServer.on("/measWind", measureWindspeed); httpServer.on("/measWind", measureWindspeed);
#endif #endif
#ifdef WEB_RESET
httpServer.on("/resetESP", resetESP);
#endif
#ifdef USE_LOGGER #ifdef USE_LOGGER
httpServer.on("/showlog", showLog); httpServer.on("/showlog", showLog);
#endif #endif
@ -125,6 +128,9 @@ void showHTMLMain(void)
#ifdef HOMEBRIDGE_WEBSTAT #ifdef HOMEBRIDGE_WEBSTAT
"<br><a href=\"http://" + _webUpdater_ip + ":8080/hbWebstat\">homebridge websatt</a><br>" "<br><a href=\"http://" + _webUpdater_ip + ":8080/hbWebstat\">homebridge websatt</a><br>"
#endif #endif
#ifdef WEB_RESET
"<br><a href=\"http://" + _webUpdater_ip + ":8080/resetESP\">reset ESP</a><br>"
#endif
#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE #ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE
"<br><br><table>" "<br><br><table>"
TR_TD_START_STR + "temperature" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_TEMPERATURE]) + TR_TD_END_STR 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 = "<html><head><title>OKO Weatherstation - " + String(_webUpdater_dev) + " - reset WiFi manager</title>"
"<meta http-equiv=\"refresh\" content=\"20\">"
"</head><body>"
"Rebooting...<br>"
"</body></html>";
httpServer.send(200, "text/html", message);
delay(5000);
// manual reset after restart is required
ESP.restart();
}
#endif
#ifndef DISABLE_WIFIMANAGER #ifndef DISABLE_WIFIMANAGER
void resetWifiManager() void resetWifiManager()