Skip to content

Commit

Permalink
extract reboot response into html file
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasfaust committed Oct 9, 2024
1 parent 07edcb6 commit ddab093
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 32 deletions.
19 changes: 19 additions & 0 deletions data/web/reboot.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/web/Style.css">
<script language="javascript" type="text/javascript">
setTimeout(GoBack, 10000);
function GoBack() {
top.location.href="/";
}
</script>
<title>Solar Inverter Modbus MQTT Gateway</title></head>
<body>
Success! Rebooting...
<p/>
<input class='button' type='button' value='Go Back' onclick="top.location.href='/';" />
</body>
</html>
9 changes: 2 additions & 7 deletions src/MyWebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ void MyWebServer::handle_update_page(AsyncWebServerRequest *request) {
}

void MyWebServer::handle_update_response(AsyncWebServerRequest *request) {
AsyncWebServerResponse *response = request->beginResponse(200, "text/html", HTML_UPDATERESPONSE);
response->addHeader("Server","ESP Async Web Server");
request->send(response);
request->send(LittleFS, "/web/reboot.html", "text/html");
}

void MyWebServer::handle_update_progress(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
Expand Down Expand Up @@ -112,10 +110,7 @@ void MyWebServer::handleFavIcon(AsyncWebServerRequest *request) {
}

void MyWebServer::handleReboot(AsyncWebServerRequest *request) {
AsyncWebServerResponse *response = request->beginResponse(200, "text/html", HTML_UPDATERESPONSE);
response->addHeader("Server","ESP Async Web Server");
request->send(response);

request->send(LittleFS, "/web/reboot.html", "text/html");
this->DoReboot = true;
}

Expand Down
25 changes: 0 additions & 25 deletions src/html_update.h
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
#ifndef HTMLUPDATE_H
#define HTMLUPDATE_H

const char HTML_UPDATERESPONSE[] PROGMEM = R"=====(

<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/web/Style.css">
<script language="javascript" type="text/javascript">
setTimeout(GoBack, 10000);
function GoBack() {
window.location.href="/";
}
</script>
<title>Solar Inverter Modbus MQTT Gateway</title></head>
<body>
Success! Rebooting...
<p/>
<input class='button' type='button' value='Go Back' onclick="window.location.href='/';" />
</body>
</html>

)=====";


// https://jsfiddle.net/tobiasfaust/Lc1earnz/
const char HTML_UPDATEPAGE[] PROGMEM = R"=====(

Expand Down

0 comments on commit ddab093

Please sign in to comment.