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);
#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");

View File

@ -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
"<br><a href=\"http://" + _webUpdater_ip + ":8080/hbWebstat\">homebridge websatt</a><br>"
#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
"<br><br><table>"
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
void resetWifiManager()