From 14d3608e999a109bc1a47952c7a837a3314fc8ab Mon Sep 17 00:00:00 2001 From: jens Date: Tue, 18 Oct 2022 21:52:25 +0200 Subject: [PATCH] =?UTF-8?q?restart=20eingef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformio.ini | 2 +- src/main.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index 3127af3..1a21c07 100644 --- a/platformio.ini +++ b/platformio.ini @@ -19,4 +19,4 @@ lib_deps = knolleary/PubSubClient@^2.8 tobiasschuerg/ESP8266 Influxdb@^3.12.1 monitor_speed = 115200 -;upload_port = COM3 \ No newline at end of file +;upload_port = 192.168.2.157 \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 5d6b2fb..7cda8ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -102,7 +102,7 @@ void setHtml(){ } else { htmltext += "

Server 2 ist offline

"; } - + htmltext += "

"; } String SendHTML(String addtext){ @@ -110,7 +110,7 @@ String SendHTML(String addtext){ ptr += "\n"; ptr += "\n"; ptr += "\n"; - ptr += "Gaszaehler Webserver\n"; + ptr += "ServerWatch Webserver\n"; ptr += "\n"; ptr += "\n"; ptr += "\n"; @@ -160,6 +160,9 @@ void printStatus(){ display.drawString(0,0,"IP: "+WiFi.localIP().toString()+" ;)"); long rssi = WiFi.RSSI(); char rssiStr[255]; + if (rssi == 0){ + ESP.restart(); + } sprintf(rssiStr,"RSSID: %d dBm",rssi); display.drawString(0,11,rssiStr); time(&now); // read the current time @@ -226,6 +229,11 @@ void pw2off(){ server.send(303); } +void restart(){ + server.sendHeader("Location","/"); + server.send(200, "text/html", SendHTML("Boot")); + ESP.restart(); +} void setup() { Serial.begin(115200); Serial.println("Booting"); @@ -256,6 +264,7 @@ void setup() { server.on("/auto2/off",auto2off); server.on("/pw2/on",pw2on); server.on("/pw2/off",pw2off); + server.on("/restart",restart); server.begin();