restart eingefügt

This commit is contained in:
jens 2022-10-18 21:52:25 +02:00
parent 75213be1aa
commit 14d3608e99
2 changed files with 12 additions and 3 deletions

View File

@ -19,4 +19,4 @@ lib_deps =
knolleary/PubSubClient@^2.8
tobiasschuerg/ESP8266 Influxdb@^3.12.1
monitor_speed = 115200
;upload_port = COM3
;upload_port = 192.168.2.157

View File

@ -102,7 +102,7 @@ void setHtml(){
} else {
htmltext += "<h2>Server 2 ist offline</h2>";
}
htmltext += "<p><a href=\"/restart\"><button class=\"button\">Restart</button></a></p>";
}
String SendHTML(String addtext){
@ -110,7 +110,7 @@ String SendHTML(String addtext){
ptr += "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n";
ptr += "<html lang='de'>\n";
ptr += "<head>\n";
ptr += "<title>Gaszaehler Webserver</title>\n";
ptr += "<title>ServerWatch Webserver</title>\n";
ptr += "<link rel='stylesheet' type='text/css' href='/f.css'>\n";
ptr += "<meta content='text/html; charset=UTF-8' http-equiv='content-type'>\n";
ptr += "</head>\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();