...
|
...
|
@@ -15,8 +15,8 @@ WebServer server(PORT);
|
15
|
15
|
|
16
|
16
|
String message="";
|
17
|
17
|
|
18
|
|
-String page_header="<!DOCTYPE HTML><html>\n<head>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <link rel=\"stylesheet\" href=\"https://use.fontawesome.com/releases/v5.7.2/css/all.css\" integrity=\"sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr\" crossorigin=\"anonymous\">\n <title>"+String(APPNAME)+"</title>\n<style>\nhtml{font-family:Arial;display:inline-block;margin:0px auto;text-align:center;}h2{font-size:2.0rem;}p{font-size:3.0rem;}ul,li {list-style-type: none; margin: 0; padding: 0;text-align: left;}li { display: inline-block; color:#00add6;padding-left: 10px; }.results {width: 80%;word-wrap: break-word;font-family: monospace;text-align: left;}.app {font-size:0.8rem;font-style: italic; padding-top: 20px; padding-bottom: 20px;}.dht-labels{font-size:1.0rem;vertical-align:middle;padding-bottom:15px;}\n</style>\n</head>\n<body>\n";
|
19
|
|
-String page_links="<ul class=\"links\">\n<li><a href=\"/\"><i class=\"fas fa-home\"></i></a></li>\n<li><a href=\"/json\"><i class=\"fas fa-clipboard-list\"></i></a></li>\n<li><a href=\"/status\"><i class=\"fas fa-question-circle\"></i></a></li>\n<li><a href=\"/ota\"><i class=\"fas fa-toolbox\"></i></a></li>\n<li><a href=\"/config\"><i class=\"fas fa-cog\"></i></a></li>\n</ul>";
|
|
18
|
+String page_header="<!DOCTYPE HTML><html>\n<head>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <link rel=\"stylesheet\" href=\"https://use.fontawesome.com/releases/v5.7.2/css/all.css\" integrity=\"sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr\" crossorigin=\"anonymous\">\n <title>"+String(APPNAME)+"</title>\n<style>\nhtml{font-family:Arial;display:inline-block;margin:0px auto;text-align:left;}h2{font-size:1.5rem;}p{font-size:1.2rem;}ul,li,.prg {list-style-type: none; margin: 0; padding: 0;text-align: left;}li{display:inline-block;color:#00add6;padding-top:10px;padding-left:10px;font-size:1.5em;}.results {width: 80%;word-wrap: break-word;font-family: monospace;text-align: left;}.app {font-size:0.8rem;font-style: italic; padding-top: 20px; padding-bottom: 20px;}.dht-labels{font-size:1.0rem;vertical-align:middle;padding-bottom:15px;}\n</style>\n</head>\n<body>\n";
|
|
19
|
+String page_links="<ul class=\"links\">\n<li><a href=\"/\"><i class=\"fas fa-home\"></i></a></li>\n<li><a href=\"/status\"><i class=\"fas fa-question-circle\"></i></a></li>\n<li><a href=\"/ota\"><i class=\"fas fa-toolbox\"></i></a></li>\n<li><a href=\"/config\"><i class=\"fas fa-cog\"></i></a></li>\n<li><a href=\"/json\"><i class=\"fas fa-clipboard-list\"></i></a></li>\n</ul>";
|
20
|
20
|
String page_footer="</body></html>";
|
21
|
21
|
|
22
|
22
|
String getMACstr() {
|
...
|
...
|
@@ -30,13 +30,13 @@ String getMACstr() {
|
30
|
30
|
void handleRoot() {
|
31
|
31
|
server.sendHeader("Connection", "close");
|
32
|
32
|
message = page_header;
|
|
33
|
+ message += page_links;
|
33
|
34
|
message += "<h2>esp32-"+getMACstr()+"</h2>";
|
34
|
35
|
message += "<p><i class=\"fas fa-clock\" style=\"color:#00add6;\"></i><span class=\"dht-labels\">Date</span> <span id=\"temperature\">"+String(acTimeStringTZ)+"</span></p>";
|
35
|
36
|
message += "<div class=\"results\">\n";
|
36
|
37
|
message += ss.str().c_str();
|
37
|
38
|
message += "</div>\n";
|
38
|
39
|
message += "<div class=\"app\">"+String(compile_date)+"</div>";
|
39
|
|
- message += page_links;
|
40
|
40
|
message += page_footer;
|
41
|
41
|
server.send(200, "text/html", message );
|
42
|
42
|
}
|
...
|
...
|
@@ -55,6 +55,7 @@ void handleJSON() {
|
55
|
55
|
void handleSTATUS() {
|
56
|
56
|
server.sendHeader("Connection", "close");
|
57
|
57
|
message = page_header;
|
|
58
|
+ message += page_links;
|
58
|
59
|
message += "<h2>esp32-"+getMACstr()+" Status</h2>";
|
59
|
60
|
message += "{";
|
60
|
61
|
message += "\"app_name\": \""+String(APPNAME)+"\",";
|
...
|
...
|
@@ -65,12 +66,14 @@ void handleSTATUS() {
|
65
|
66
|
message += "\"ota_name\": \"esp32-"+getMACstr()+"\",";
|
66
|
67
|
message += "\"uptime\": "+String(millis())+",";
|
67
|
68
|
message += "\"countMeasures\": "+String(countMeasures)+",";
|
|
69
|
+ message += "\"BLEscanTime\": "+String(gScanTime)+",";
|
|
70
|
+ message += "\"BLEwindow\": "+String(gWindow)+",";
|
|
71
|
+ message += "\"BLEinterval\": "+String(gInterval)+",";
|
68
|
72
|
message += "\"period\": "+String(UPDATE_PERIOD)+",";
|
69
|
73
|
message += "\"loop_delay\": "+String(LOOP_DELAY)+",";
|
70
|
74
|
message += "\"last_update\": \""+String(acTimeStringTZ)+"\",";
|
71
|
75
|
message += "\"epoch\":" +String(acTimeEpoch);
|
72
|
76
|
message += "}";
|
73
|
|
- message += page_links;
|
74
|
77
|
message += page_footer;
|
75
|
78
|
server.send(200, "text/html", String(message) );
|
76
|
79
|
}
|
...
|
...
|
@@ -84,6 +87,7 @@ void handleOTA() {
|
84
|
87
|
} else {
|
85
|
88
|
message += "<script src='http://"+String(mqtt_server_ext)+"/jquery.min.js'></script>\n";
|
86
|
89
|
}
|
|
90
|
+ message += page_links;
|
87
|
91
|
message += "<h2>esp32-"+getMACstr()+" OTA</h2>";
|
88
|
92
|
message += "<form method='POST' action='#' enctype='multipart/form-data' id='upload_form'>\n";
|
89
|
93
|
message += "Firmware:<br>\n";
|
...
|
...
|
@@ -91,13 +95,13 @@ void handleOTA() {
|
91
|
95
|
message += "</form>\n";
|
92
|
96
|
message += "<div id='prg'>progress: 0%</div>\n";
|
93
|
97
|
message += otaScript;
|
94
|
|
- message += page_links;
|
95
|
98
|
message += page_footer;
|
96
|
99
|
server.send(200, "text/html", String(message) );
|
97
|
100
|
}
|
98
|
101
|
void handleCONFIG() {
|
99
|
102
|
server.sendHeader("Connection", "close");
|
100
|
103
|
message = page_header;
|
|
104
|
+ message += page_links;
|
101
|
105
|
message += "<h2>esp32-"+getMACstr()+" Configuration</h2>";
|
102
|
106
|
message += "<form action=\"\">\n";
|
103
|
107
|
message += "<label for=\"gInterval\">Interval:</label><br>\n";
|
...
|
...
|
@@ -126,7 +130,6 @@ void handleCONFIG() {
|
126
|
130
|
}
|
127
|
131
|
}
|
128
|
132
|
}
|
129
|
|
- message += page_links;
|
130
|
133
|
message += page_footer;
|
131
|
134
|
server.send(200, "text/html", String(message) );
|
132
|
135
|
}
|
...
|
...
|
@@ -186,6 +189,7 @@ void http_set() {
|
186
|
189
|
}
|
187
|
190
|
} else if (upload.status == UPLOAD_FILE_END) {
|
188
|
191
|
if (Update.end(true)) { //true to set the size to the current progress
|
|
192
|
+ Serial.printf("Update: 100%%\n");
|
189
|
193
|
Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize);
|
190
|
194
|
} else {
|
191
|
195
|
Update.printError(Serial);
|