|
@@ -1,3 +1,18 @@
|
|
|
+
|
|
|
+#include "html.h"
|
|
|
+#include "html_conf.h"
|
|
|
+#include "html_confAdd.h"
|
|
|
+#include "html_confAdv.h"
|
|
|
+#include "html_confBas.h"
|
|
|
+#include "html_confDevWiFi.h"
|
|
|
+#include "html_confMqtt.h"
|
|
|
+#include "html_confWeb.h"
|
|
|
+#include "html_confTime.h"
|
|
|
+#include "html_confLog.h"
|
|
|
+#include "html_main.h"
|
|
|
+#include "html_redTemps.h"
|
|
|
+#include "html_console.h"
|
|
|
+
|
|
|
void httpServerHandleMainPage() {
|
|
|
httpServerSendHtmlHeadChunked();
|
|
|
httpServer.sendContent_P(html_main_script);
|
|
@@ -5,7 +20,10 @@ void httpServerHandleMainPage() {
|
|
|
httpServer.sendContent_P(html_bodytag_jsinit);
|
|
|
httpServerSendHtmlBodyPageheadChunked();
|
|
|
httpServer.sendContent_P(html_main_body);
|
|
|
- if (httpIsAuthenticatedAdmin()) httpServer.sendContent_P(html_main_body_adminonly);
|
|
|
+ if (httpIsAuthenticatedAdmin()) {
|
|
|
+ httpServer.sendContent_P(html_main_body_adminonly);
|
|
|
+ if(confWeb.enableConsole) httpServer.sendContent_P(html_main_body_adminonly_console);
|
|
|
+ }
|
|
|
httpServer.sendContent_P(html_main_body2);
|
|
|
httpServerSendHtmlFooterChunked();
|
|
|
}
|
|
@@ -26,6 +44,8 @@ void httpServerHandleConfPage() {
|
|
|
httpServer.sendContent_P(html_bodytag);
|
|
|
httpServerSendHtmlBodyPageheadChunked();
|
|
|
httpServer.sendContent_P(html_conf_body);
|
|
|
+ if(confWeb.enableConsole) httpServer.sendContent_P(html_conf_body_console);
|
|
|
+ httpServer.sendContent_P(html_conf_body_end);
|
|
|
httpServerSendHtmlFooterChunked();
|
|
|
}
|
|
|
|
|
@@ -89,6 +109,35 @@ void httpServerHandleConfAddPage() {
|
|
|
httpServerSendHtmlFooterChunked();
|
|
|
}
|
|
|
|
|
|
+void httpServerHandleConfTimePage() {
|
|
|
+ httpServerSendHtmlHeadChunked();
|
|
|
+ httpServer.sendContent_P(html_conftime_script);
|
|
|
+ httpServer.sendContent_P(html_head_end);
|
|
|
+ httpServer.sendContent_P(html_bodytag_jsinit);
|
|
|
+ httpServerSendHtmlBodyPageheadChunked();
|
|
|
+ httpServer.sendContent_P(html_conftime_body);
|
|
|
+ httpServerSendHtmlFooterChunked();
|
|
|
+}
|
|
|
+
|
|
|
+void httpServerHandleConfLogPage() {
|
|
|
+ httpServerSendHtmlHeadChunked();
|
|
|
+ httpServer.sendContent_P(html_conflog_script);
|
|
|
+ httpServer.sendContent_P(html_head_end);
|
|
|
+ httpServer.sendContent_P(html_bodytag_jsinit);
|
|
|
+ httpServerSendHtmlBodyPageheadChunked();
|
|
|
+ httpServer.sendContent_P(html_conflog_body);
|
|
|
+ httpServerSendHtmlFooterChunked();
|
|
|
+}
|
|
|
+
|
|
|
+void httpServerHandleConsolePage() {
|
|
|
+ httpServerSendHtmlHeadChunked();
|
|
|
+ httpServer.sendContent_P(html_head_end);
|
|
|
+ httpServer.sendContent_P(html_bodytag);
|
|
|
+ httpServerSendHtmlBodyPageheadChunked();
|
|
|
+ httpServer.sendContent_P(html_console_body);
|
|
|
+ httpServerSendHtmlFooterChunked();
|
|
|
+}
|
|
|
+
|
|
|
void httpServerHandleConfSavedPage() {
|
|
|
httpServerSendHtmlHeadChunked();
|
|
|
httpServer.sendContent_P(html_head_end);
|
|
@@ -242,56 +291,66 @@ void httpServerInit() {
|
|
|
httpServer.send_P(200, "text/css", html_stylesheet);
|
|
|
});
|
|
|
|
|
|
+ httpServer.on("/wsapp.js", []() {
|
|
|
+ httpServer.sendHeader("cache-control", "max-age=86400", false);
|
|
|
+ httpServer.send_P(200, "text/javascript", js_wsapp);
|
|
|
+ });
|
|
|
+
|
|
|
httpServer.on("/api", []() {
|
|
|
if (!httpIsAuthenticated()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
- DEBUG_PRINT("httpServer.on /api");
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /api (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+ //sendLog("WEB: /api", LOGLEVEL_INFO);
|
|
|
if (httpServer.hasArg("BtnPlus")) {
|
|
|
setTempStepUp();
|
|
|
- DEBUG_PRINT(P("web BtnPlus"));
|
|
|
+ sendLog(F("WEB: Btn +"), LOGLEVEL_INFO);
|
|
|
} //if
|
|
|
if (httpServer.hasArg("BtnMinus")) {
|
|
|
setTempStepDown();
|
|
|
- DEBUG_PRINT(P("web BtnMinus"));
|
|
|
+ sendLog(F("WEB: Btn -"), LOGLEVEL_INFO);
|
|
|
} //if
|
|
|
if (httpServer.hasArg("BtnPset0")) {
|
|
|
setPresetTo(0);
|
|
|
- DEBUG_PRINT(P("web BtnPset0"));
|
|
|
+ sendLog(F("WEB: Btn PSet0"), LOGLEVEL_INFO);
|
|
|
} //if
|
|
|
if (httpServer.hasArg("BtnPset1")) {
|
|
|
setPresetTo(1);
|
|
|
- DEBUG_PRINT(P("web BtnPset1"));
|
|
|
+ sendLog(F("WEB: Btn PSet1"), LOGLEVEL_INFO);
|
|
|
} //if
|
|
|
if (httpServer.hasArg("BtnPset2")) {
|
|
|
setPresetTo(2);
|
|
|
- DEBUG_PRINT(P("web BtnPset2"));
|
|
|
+ sendLog(F("WEB: Btn PSet2"), LOGLEVEL_INFO);
|
|
|
} //if
|
|
|
if (httpServer.hasArg("BtnOn")) {
|
|
|
setHeatingmodeTo(1);
|
|
|
- DEBUG_PRINT(P("web BtnOn"));
|
|
|
+ sendLog(F("WEB: Btn ON"), LOGLEVEL_INFO);
|
|
|
} //if
|
|
|
if (httpServer.hasArg("BtnOff")) {
|
|
|
setHeatingmodeTo(0);
|
|
|
- DEBUG_PRINT(P("web BtnOff"));
|
|
|
+ sendLog(F("WEB: Btn OFF"), LOGLEVEL_INFO);
|
|
|
} //if
|
|
|
if (httpServer.hasArg("BtnL1Plus")) {
|
|
|
setTempLowStepUp();
|
|
|
- DEBUG_PRINT(P("web BtnL1Plus"));
|
|
|
+ sendLog(F("WEB: Btn L1+"), LOGLEVEL_INFO);
|
|
|
} //if
|
|
|
if (httpServer.hasArg("BtnL1Minus")) {
|
|
|
setTempLowStepDown();
|
|
|
- DEBUG_PRINT(P("web BtnL1Minus"));
|
|
|
+ sendLog(F("WEB: Btn L1-"), LOGLEVEL_INFO);
|
|
|
} //if
|
|
|
if (httpServer.hasArg("BtnL2Plus")) {
|
|
|
setTempLow2StepUp();
|
|
|
- DEBUG_PRINT(P("web BtnL2Plus"));
|
|
|
+ sendLog(F("WEB: Btn L2+"), LOGLEVEL_INFO);
|
|
|
} //if
|
|
|
if (httpServer.hasArg("BtnL2Minus")) {
|
|
|
setTempLow2StepDown();
|
|
|
- DEBUG_PRINT(P("web BtnL2Minus"));
|
|
|
+ sendLog(F("WEB: Btn L2-"), LOGLEVEL_INFO);
|
|
|
} //if
|
|
|
|
|
|
if (httpServer.hasArg("setTemp")) {
|
|
|
+ sendLog(F("WEB: api?setTemp"), LOGLEVEL_INFO);
|
|
|
char bufVal[20];
|
|
|
httpServer.arg("setTemp").toCharArray(bufVal, 20);
|
|
|
float valueFloat = round(atof(bufVal) * 2.0) / 2.0;
|
|
@@ -299,6 +358,7 @@ void httpServerInit() {
|
|
|
}
|
|
|
|
|
|
if (httpServer.hasArg("setMode")) {
|
|
|
+ sendLog(F("WEB: api?setMode"), LOGLEVEL_INFO);
|
|
|
char bufVal[20];
|
|
|
httpServer.arg("setMode").toCharArray(bufVal, 20);
|
|
|
int valueInt = atoi(bufVal);
|
|
@@ -306,6 +366,7 @@ void httpServerInit() {
|
|
|
}
|
|
|
|
|
|
if (httpServer.hasArg("setPreset")) {
|
|
|
+ sendLog(F("WEB: api?setPreset"), LOGLEVEL_INFO);
|
|
|
char bufVal[20];
|
|
|
httpServer.arg("setPreset").toCharArray(bufVal, 20);
|
|
|
int valueInt = atoi(bufVal);
|
|
@@ -318,24 +379,46 @@ void httpServerInit() {
|
|
|
//dtostrf(setTemp, 1, 1, ch_currSetTemp );
|
|
|
|
|
|
//build json object of program data
|
|
|
- StaticJsonDocument<500> json;
|
|
|
+ StaticJsonDocument<700> json;
|
|
|
|
|
|
json["devname"] = confDevWiFi.deviceName;
|
|
|
json["ssid"] = WiFi.SSID();
|
|
|
json["WiFiNum"] = persWM.getActiveWiFiNum();
|
|
|
json["uptime"] = uptimeStr;
|
|
|
+ //json["uptime"] = NTP.getUptimeString();
|
|
|
+
|
|
|
+ if(confTime.ntpEnable) {
|
|
|
+ char buf[13];
|
|
|
+ updateTime();
|
|
|
+ strftime(buf, sizeof(buf), "%H:%M", <);
|
|
|
+ json["time"] = buf;
|
|
|
+ strftime(buf, sizeof(buf), "%d.%m.%Y", <);
|
|
|
+ json["date"] = buf;
|
|
|
+ }
|
|
|
json["freeheap"] = ESP.getFreeHeap();
|
|
|
|
|
|
- if (mqttclient.state() == -4) json["mqttstate"] = "CONNECTION_TIMEOUT";
|
|
|
- else if (mqttclient.state() == -3) json["mqttstate"] = "CONNECTION_LOST";
|
|
|
- else if (mqttclient.state() == -2) json["mqttstate"] = "CONNECT_FAILED";
|
|
|
- else if (mqttclient.state() == -1) json["mqttstate"] = "DISCONNECTED";
|
|
|
- else if (mqttclient.state() == 0) json["mqttstate"] = "CONNECTED";
|
|
|
- else if (mqttclient.state() == 1) json["mqttstate"] = "CONNECT_BAD_PROTOCOL";
|
|
|
- else if (mqttclient.state() == 2) json["mqttstate"] = "CONNECT_BAD_CLIENT_ID";
|
|
|
- else if (mqttclient.state() == 3) json["mqttstate"] = "CONNECT_UNAVAILABLE";
|
|
|
- else if (mqttclient.state() == 4) json["mqttstate"] = "CONNECT_BAD_CREDENTIALS";
|
|
|
- else if (mqttclient.state() == 5) json["mqttstate"] = "CONNECT_UNAUTHORIZED";
|
|
|
+ mqtt_updateCurrentStateName();
|
|
|
+ json["mqttstate"] = mqttCurrentStateName;
|
|
|
+ //if (mqttclient.state() == -4) json["mqttstate"] = "CONNECTION_TIMEOUT";
|
|
|
+ //else if (mqttclient.state() == -3) json["mqttstate"] = "CONNECTION_LOST";
|
|
|
+ //else if (mqttclient.state() == -2) json["mqttstate"] = "CONNECT_FAILED";
|
|
|
+ //else if (mqttclient.state() == -1) json["mqttstate"] = "DISCONNECTED";
|
|
|
+ //else if (mqttclient.state() == 0) json["mqttstate"] = "CONNECTED";
|
|
|
+ //else if (mqttclient.state() == 1) json["mqttstate"] = "CONNECT_BAD_PROTOCOL";
|
|
|
+ //else if (mqttclient.state() == 2) json["mqttstate"] = "CONNECT_BAD_CLIENT_ID";
|
|
|
+ //else if (mqttclient.state() == 3) json["mqttstate"] = "CONNECT_UNAVAILABLE";
|
|
|
+ //else if (mqttclient.state() == 4) json["mqttstate"] = "CONNECT_BAD_CREDENTIALS";
|
|
|
+ //else if (mqttclient.state() == 5) json["mqttstate"] = "CONNECT_UNAUTHORIZED";
|
|
|
+ //if (mqttclient.state() == -4) json["mqttstate"] = PGMStr_MQTTStateM4;
|
|
|
+ //else if (mqttclient.state() == -3) json["mqttstate"] = PGMStr_MQTTStateM3;
|
|
|
+ //else if (mqttclient.state() == -2) json["mqttstate"] = PGMStr_MQTTStateM2;
|
|
|
+ //else if (mqttclient.state() == -1) json["mqttstate"] = PGMStr_MQTTStateM1;
|
|
|
+ //else if (mqttclient.state() == 0) json["mqttstate"] = PGMStr_MQTTState0;
|
|
|
+ //else if (mqttclient.state() == 1) json["mqttstate"] = PGMStr_MQTTState1;
|
|
|
+ //else if (mqttclient.state() == 2) json["mqttstate"] = PGMStr_MQTTState2;
|
|
|
+ //else if (mqttclient.state() == 3) json["mqttstate"] = PGMStr_MQTTState3;
|
|
|
+ //else if (mqttclient.state() == 4) json["mqttstate"] = PGMStr_MQTTState4;
|
|
|
+ //else if (mqttclient.state() == 5) json["mqttstate"] = PGMStr_MQTTState5;
|
|
|
|
|
|
json["mqtthost"] = confMqtt.mqtt_server;
|
|
|
|
|
@@ -344,7 +427,7 @@ void httpServerInit() {
|
|
|
|
|
|
json["setTemp"] = setTemp;
|
|
|
json["currSetTemp"] = currSetTemp;
|
|
|
- json["temp"] = currTemp;
|
|
|
+ json["temp"] = round1(currTemp);
|
|
|
json["hum"] = int(currHum);
|
|
|
json["heating"] = turnHeatingOn;
|
|
|
json["mode"] = heatingMode;
|
|
@@ -356,6 +439,8 @@ void httpServerInit() {
|
|
|
json["psetName2"] = confAdv.psetName2;
|
|
|
json["tempLow"] = setTempLow;
|
|
|
json["tempLow2"] = setTempLow2;
|
|
|
+ json["outTemp"] = round1(outTemp);
|
|
|
+ json["outHum"] = outHum;
|
|
|
|
|
|
char jsonchar[500];
|
|
|
serializeJson(json, jsonchar);
|
|
@@ -363,52 +448,61 @@ void httpServerInit() {
|
|
|
}
|
|
|
}); //httpServer.on /api
|
|
|
|
|
|
- httpServer.on("/setTemp", []() {
|
|
|
- if ( httpIsAuthenticated() || (!httpIsAuthenticated() && httpCheckToken()) ) {
|
|
|
- //Serial.println("web triggered setTemp");
|
|
|
- if (httpServer.hasArg("value")) {
|
|
|
- char bufVal[20];
|
|
|
- httpServer.arg("value").toCharArray(bufVal, 20);
|
|
|
- float valueFloat = round(atof(bufVal) * 2.0) / 2.0;
|
|
|
- setTempTo(valueFloat);
|
|
|
- httpSend200OK();
|
|
|
- }
|
|
|
- } //if
|
|
|
- else httpSendUnauthorized();
|
|
|
- });
|
|
|
-
|
|
|
- httpServer.on("/setMode", []() {
|
|
|
- if ( httpIsAuthenticated() || (!httpIsAuthenticated() && httpCheckToken()) ) {
|
|
|
- //Serial.println("web triggered setMode");
|
|
|
- if (httpServer.hasArg("value")) {
|
|
|
- char bufVal[20];
|
|
|
- httpServer.arg("value").toCharArray(bufVal, 20);
|
|
|
- int valueInt = atoi(bufVal);
|
|
|
- if (valueInt >= 0 && valueInt <= 1) setHeatingmodeTo(valueInt);
|
|
|
- httpSend200OK();
|
|
|
- }
|
|
|
- } //if
|
|
|
- else httpSendUnauthorized();
|
|
|
- });
|
|
|
-
|
|
|
- httpServer.on("/setPreset", []() {
|
|
|
- if ( httpIsAuthenticated() || (!httpIsAuthenticated() && httpCheckToken()) ) {
|
|
|
- //Serial.println("web triggered setPreset");
|
|
|
- if (httpServer.hasArg("value")) {
|
|
|
- char bufVal[20];
|
|
|
- httpServer.arg("value").toCharArray(bufVal, 20);
|
|
|
- int valueInt = atoi(bufVal);
|
|
|
- if (valueInt >= 0 && valueInt <= 2) setPresetTo(valueInt);
|
|
|
- httpSend200OK();
|
|
|
- }
|
|
|
- } //if
|
|
|
- else httpSendUnauthorized();
|
|
|
- });
|
|
|
+ //httpServer.on("/setTemp", []() {
|
|
|
+ // if ( httpIsAuthenticated() || (!httpIsAuthenticated() && httpCheckToken()) ) {
|
|
|
+ // //Serial.println("web triggered setTemp");
|
|
|
+ // sendLog(F("WEB: /setTemp"), LOGLEVEL_INFO);
|
|
|
+ // if (httpServer.hasArg("value")) {
|
|
|
+ // char bufVal[20];
|
|
|
+ // httpServer.arg("value").toCharArray(bufVal, 20);
|
|
|
+ // float valueFloat = round(atof(bufVal) * 2.0) / 2.0;
|
|
|
+ // setTempTo(valueFloat);
|
|
|
+ // httpSend200OK();
|
|
|
+ // }
|
|
|
+ // } //if
|
|
|
+ // else httpSendUnauthorized();
|
|
|
+ //});
|
|
|
+
|
|
|
+ //httpServer.on("/setMode", []() {
|
|
|
+ // if ( httpIsAuthenticated() || (!httpIsAuthenticated() && httpCheckToken()) ) {
|
|
|
+ // //Serial.println("web triggered setMode");
|
|
|
+ // sendLog(F("WEB: /setMode"), LOGLEVEL_INFO);
|
|
|
+ // if (httpServer.hasArg("value")) {
|
|
|
+ // char bufVal[20];
|
|
|
+ // httpServer.arg("value").toCharArray(bufVal, 20);
|
|
|
+ // int valueInt = atoi(bufVal);
|
|
|
+ // if (valueInt >= 0 && valueInt <= 1) setHeatingmodeTo(valueInt);
|
|
|
+ // httpSend200OK();
|
|
|
+ // }
|
|
|
+ // } //if
|
|
|
+ // else httpSendUnauthorized();
|
|
|
+ //});
|
|
|
+
|
|
|
+ //httpServer.on("/setPreset", []() {
|
|
|
+ // if ( httpIsAuthenticated() || (!httpIsAuthenticated() && httpCheckToken()) ) {
|
|
|
+ // //Serial.println("web triggered setPreset");
|
|
|
+ // sendLog(F("WEB: /setPreset"), LOGLEVEL_INFO);
|
|
|
+ // if (httpServer.hasArg("value")) {
|
|
|
+ // char bufVal[20];
|
|
|
+ // httpServer.arg("value").toCharArray(bufVal, 20);
|
|
|
+ // int valueInt = atoi(bufVal);
|
|
|
+ // if (valueInt >= 0 && valueInt <= 2) setPresetTo(valueInt);
|
|
|
+ // httpSend200OK();
|
|
|
+ // }
|
|
|
+ // } //if
|
|
|
+ // else httpSendUnauthorized();
|
|
|
+ //});
|
|
|
|
|
|
httpServer.on("/confDataWeb", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) httpSendUnauthorized();
|
|
|
else {
|
|
|
- Serial.println("httpServer.on /confdata");
|
|
|
+ //Serial.println("httpServer.on /confdata");
|
|
|
+ //sendLog("WEB: /confDataWeb", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /confDataWeb (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
StaticJsonDocument<1000> json;
|
|
|
|
|
|
json["apiToken"] = confWeb.http_token;
|
|
@@ -428,6 +522,10 @@ void httpServerInit() {
|
|
|
//json["httpP2"] = confWeb.http_pass2;
|
|
|
if(strlen(confWeb.http_pass2) > 0) json["httpP2"] = "****";
|
|
|
else json["httpP2"] = "";
|
|
|
+
|
|
|
+ if (confWeb.enableConsole) json["enableConsole"] = 1;
|
|
|
+ else json["enableConsole"] = 0;
|
|
|
+
|
|
|
yield();
|
|
|
|
|
|
char jsonchar[1000];
|
|
@@ -441,7 +539,12 @@ void httpServerInit() {
|
|
|
httpServer.on("/confDataMqtt", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) httpSendUnauthorized();
|
|
|
else {
|
|
|
- Serial.println("httpServer.on /confdata");
|
|
|
+ //sendLog("WEB: /confDataMqtt", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /confDataMqtt (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
StaticJsonDocument<1000> json;
|
|
|
|
|
|
if (confMqtt.mqtt_enable) json["mqttEnable"] = 1;
|
|
@@ -492,7 +595,12 @@ void httpServerInit() {
|
|
|
httpServer.on("/setConfWeb", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) httpSendUnauthorized();
|
|
|
else {
|
|
|
- Serial.println("httpServer.on /setConfWeb");
|
|
|
+ //sendLog("WEB: /setConfWeb", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /setConfWeb (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
bool httpPASet, httpP1Set, httpP2Set;
|
|
|
httpPASet = false;
|
|
|
httpP1Set = false;
|
|
@@ -541,7 +649,13 @@ void httpServerInit() {
|
|
|
httpServer.on("/setConfMqtt", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) httpSendUnauthorized();
|
|
|
else {
|
|
|
- Serial.println("httpServer.on /setConfMqtt");
|
|
|
+ //Serial.println("httpServer.on /setConfMqtt");
|
|
|
+ //sendLog("WEB: /setConfMqtt", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /setConfMqtt (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
bool mqttPassSet;
|
|
|
mqttPassSet = false;
|
|
|
if (httpServer.hasArg("mqttPassSet")) mqttPassSet = true;
|
|
@@ -578,6 +692,12 @@ void httpServerInit() {
|
|
|
httpServer.on("/confDataDevWiFi", []() {
|
|
|
if (!httpIsAuthenticated()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
+ //sendLog("WEB: /confDataDevWiFi", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /confDataDevWiFi (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
for (int i = 0; i < httpServer.args(); i++) {
|
|
|
char bufName[20];
|
|
|
char bufValue[101];
|
|
@@ -627,7 +747,11 @@ void httpServerInit() {
|
|
|
httpServer.on("/setConfDevWiFi", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) httpSendUnauthorized();
|
|
|
else {
|
|
|
- Serial.println("httpServer.on /setConfDevWiFi");
|
|
|
+ //sendLog("WEB: /setConfDevWiFi", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /setConfDevWiFi (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
|
|
|
bool WPW1Set, WPW2Set, WPWAPSet;
|
|
|
WPW1Set = false;
|
|
@@ -674,7 +798,11 @@ void httpServerInit() {
|
|
|
httpServer.on("/setConfBas", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) httpSendUnauthorized();
|
|
|
else {
|
|
|
- Serial.println("httpServer.on /setConfBas");
|
|
|
+ //sendLog("WEB: /setConfBas", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /setConfBas (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
|
|
|
for (int i = 0; i < httpServer.args(); i++) {
|
|
|
char bufName[20];
|
|
@@ -704,7 +832,11 @@ void httpServerInit() {
|
|
|
httpServer.on("/setConfAdv", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) httpSendUnauthorized();
|
|
|
else {
|
|
|
- Serial.println("httpServer.on /setConfAdv");
|
|
|
+ //sendLog("WEB: /setConfAdv", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /setConfAdv (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
|
|
|
for (int i = 0; i < httpServer.args(); i++) {
|
|
|
char bufName[20];
|
|
@@ -734,7 +866,11 @@ void httpServerInit() {
|
|
|
httpServer.on("/setConfAdd", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) httpSendUnauthorized();
|
|
|
else {
|
|
|
- Serial.println("httpServer.on /setConfAdd");
|
|
|
+ //sendLog("WEB: /setConfAdd", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /setConfAdd (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
|
|
|
for (int i = 0; i < httpServer.args(); i++) {
|
|
|
char bufName[20];
|
|
@@ -761,10 +897,83 @@ void httpServerInit() {
|
|
|
}
|
|
|
}); //httpServer.on /setConfAdd
|
|
|
|
|
|
+ httpServer.on("/setConfTime", []() {
|
|
|
+ if (!httpIsAuthenticatedAdmin()) httpSendUnauthorized();
|
|
|
+ else {
|
|
|
+ //sendLog("WEB: /setConfTime", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /setConfTime (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
+ for (int i = 0; i < httpServer.args(); i++) {
|
|
|
+ char bufName[20];
|
|
|
+ char bufValue[101];
|
|
|
+ httpServer.argName(i).toCharArray(bufName, 20);
|
|
|
+ httpServer.arg(i).toCharArray(bufValue, 101);
|
|
|
+
|
|
|
+ if (strlen(bufName) > 0) {
|
|
|
+ Serial.print("web update ");
|
|
|
+ Serial.print(bufName);
|
|
|
+ Serial.print(" = ");
|
|
|
+ Serial.println(bufValue);
|
|
|
+ setConfig(bufName, bufValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ yield();
|
|
|
+ saveConfigTime();
|
|
|
+
|
|
|
+ httpServerHandleConfSavedPage();
|
|
|
+ config_was_changed = true;
|
|
|
+ // delay(10);
|
|
|
+ // yield();
|
|
|
+ // ESP.restart();
|
|
|
+ }
|
|
|
+ }); //httpServer.on /setConfTime
|
|
|
+
|
|
|
+ httpServer.on("/setConfLog", []() {
|
|
|
+ if (!httpIsAuthenticatedAdmin()) httpSendUnauthorized();
|
|
|
+ else {
|
|
|
+ //sendLog("WEB: /setConfLog", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /setConfLog (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
+ for (int i = 0; i < httpServer.args(); i++) {
|
|
|
+ char bufName[20];
|
|
|
+ char bufValue[101];
|
|
|
+ httpServer.argName(i).toCharArray(bufName, 20);
|
|
|
+ httpServer.arg(i).toCharArray(bufValue, 101);
|
|
|
+
|
|
|
+ if (strlen(bufName) > 0) {
|
|
|
+ Serial.print("web update ");
|
|
|
+ Serial.print(bufName);
|
|
|
+ Serial.print(" = ");
|
|
|
+ Serial.println(bufValue);
|
|
|
+ setConfig(bufName, bufValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ yield();
|
|
|
+ saveConfigLog();
|
|
|
+
|
|
|
+ httpServerHandleConfSavedPage();
|
|
|
+ config_was_changed = true;
|
|
|
+ // delay(10);
|
|
|
+ // yield();
|
|
|
+ // ESP.restart();
|
|
|
+ }
|
|
|
+ }); //httpServer.on /setConfLog
|
|
|
+
|
|
|
httpServer.on("/confDataBas", []() {
|
|
|
if (!httpIsAuthenticated()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
+ //sendLog("WEB: /confDataBas", LOGLEVEL_INFO);
|
|
|
//Serial.println("httpServer.on /confdata2");
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /confDataBas (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
|
|
|
for (int i = 0; i < httpServer.args(); i++) {
|
|
|
char bufName[20];
|
|
@@ -823,7 +1032,12 @@ void httpServerInit() {
|
|
|
httpServer.on("/confDataAdv", []() {
|
|
|
if (!httpIsAuthenticated()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
+ //sendLog("WEB: /confDataAdv", LOGLEVEL_INFO);
|
|
|
//Serial.println("httpServer.on /confdata2");
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /confDataAdv (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
|
|
|
for (int i = 0; i < httpServer.args(); i++) {
|
|
|
char bufName[20];
|
|
@@ -870,7 +1084,12 @@ void httpServerInit() {
|
|
|
httpServer.on("/confDataAdd", []() {
|
|
|
if (!httpIsAuthenticated()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
+ //sendLog("WEB: /confDataAdd", LOGLEVEL_INFO);
|
|
|
//Serial.println("httpServer.on /confdata2");
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /confDataAdd (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
|
|
|
for (int i = 0; i < httpServer.args(); i++) {
|
|
|
char bufName[20];
|
|
@@ -907,18 +1126,138 @@ void httpServerInit() {
|
|
|
}
|
|
|
}); //httpServer.on /confdadd
|
|
|
|
|
|
+ httpServer.on("/confDataTime", []() {
|
|
|
+ if (!httpIsAuthenticated()) return httpServer.requestAuthentication();
|
|
|
+ else {
|
|
|
+ //sendLog("WEB: /confDataTime", LOGLEVEL_INFO);
|
|
|
+ //Serial.println("httpServer.on /confdata2");
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /confDataTime (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
+ for (int i = 0; i < httpServer.args(); i++) {
|
|
|
+ char bufName[20];
|
|
|
+ char bufValue[101];
|
|
|
+ httpServer.argName(i).toCharArray(bufName, 20);
|
|
|
+ httpServer.arg(i).toCharArray(bufValue, 101);
|
|
|
+
|
|
|
+ if (strlen(bufName) > 0) {
|
|
|
+ //Serial.print("web update ");
|
|
|
+ //Serial.print(bufName);
|
|
|
+ //Serial.print(" = ");
|
|
|
+ //Serial.println(bufValue);
|
|
|
+ setConfig(bufName, bufValue);
|
|
|
+ }
|
|
|
+ saveConfig2ToFlash = true;
|
|
|
+ //Serial.println("web triggered saveConfig2ToFlash");
|
|
|
+ }
|
|
|
+ yield();
|
|
|
+
|
|
|
+ //build json object of program data
|
|
|
+ StaticJsonDocument<1000> json;
|
|
|
+
|
|
|
+ if(confTime.ntpEnable) json["NTPEnable"] = 1;
|
|
|
+ else json["NTPEnable"] = 0;
|
|
|
+
|
|
|
+ json["NTPServer1"] = confTime.ntpServer1;
|
|
|
+ json["NTPServer2"] = confTime.ntpServer2;
|
|
|
+ json["TZStr"] = confTime.timeZoneStr;
|
|
|
+ json["NTPSyncInt"] = confTime.ntpSyncInterval;
|
|
|
+
|
|
|
+ yield();
|
|
|
+
|
|
|
+ char jsonchar[1000];
|
|
|
+ serializeJson(json, jsonchar);
|
|
|
+ httpServer.send(200, "application/json", jsonchar);
|
|
|
+ }
|
|
|
+ }); //httpServer.on /confDataTime
|
|
|
+
|
|
|
+ httpServer.on("/confDataLog", []() {
|
|
|
+ if (!httpIsAuthenticated()) return httpServer.requestAuthentication();
|
|
|
+ else {
|
|
|
+ //sendLog("WEB: /confDataLog", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /confDataLog (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
+ for (int i = 0; i < httpServer.args(); i++) {
|
|
|
+ char bufName[20];
|
|
|
+ char bufValue[101];
|
|
|
+ httpServer.argName(i).toCharArray(bufName, 20);
|
|
|
+ httpServer.arg(i).toCharArray(bufValue, 101);
|
|
|
+
|
|
|
+ if (strlen(bufName) > 0) {
|
|
|
+ //Serial.print("web update ");
|
|
|
+ //Serial.print(bufName);
|
|
|
+ //Serial.print(" = ");
|
|
|
+ //Serial.println(bufValue);
|
|
|
+ setConfig(bufName, bufValue);
|
|
|
+ }
|
|
|
+ saveConfig2ToFlash = true;
|
|
|
+ //Serial.println("web triggered saveConfig2ToFlash");
|
|
|
+ }
|
|
|
+ yield();
|
|
|
+
|
|
|
+ //build json object of program data
|
|
|
+ StaticJsonDocument<1000> json;
|
|
|
+
|
|
|
+ //if(confTime.ntpEnable) json["NTPEnable"] = 1;
|
|
|
+ //else json["NTPEnable"] = 0;
|
|
|
+
|
|
|
+ json["logLevSer"] = confLog.logLevelSerial;
|
|
|
+ json["logLevWeb"] = confLog.logLevelWeb;
|
|
|
+ json["logLevMqtt"] = confLog.logLevelMqtt;
|
|
|
+
|
|
|
+ yield();
|
|
|
+
|
|
|
+ char jsonchar[1000];
|
|
|
+ serializeJson(json, jsonchar);
|
|
|
+ httpServer.send(200, "application/json", jsonchar);
|
|
|
+ }
|
|
|
+ }); //httpServer.on /confDataLog
|
|
|
+
|
|
|
//get heap status, analog input value and all GPIO statuses in one json call
|
|
|
- httpServer.on("/info", HTTP_GET, []() {
|
|
|
+ httpServer.on("/sysinfo", HTTP_GET, []() {
|
|
|
if (!httpIsAuthenticated()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
- String json = " {";
|
|
|
- json += "\"wifissid\":\"" + WiFi.SSID() + "\"";
|
|
|
- json += "\"heap\":" + String(ESP.getFreeHeap());
|
|
|
- json += "}";
|
|
|
- httpServer.send(200, "text/json", json);
|
|
|
- json = String();
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /sysinfo (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
+ StaticJsonDocument<600> json;
|
|
|
+ json["Devname"] = confDevWiFi.deviceName;
|
|
|
+ json["Ssid"] = WiFi.SSID();
|
|
|
+ json["WiFiNum"] = persWM.getActiveWiFiNum();
|
|
|
+ json["Uptime"] = uptimeStr;
|
|
|
+ json["HeapFree"] = ESP.getFreeHeap();
|
|
|
+ json["HeapFragment"] = ESP.getHeapFragmentation();
|
|
|
+ json["HeapMaxBlock"] = ESP.getMaxFreeBlockSize();
|
|
|
+ json["ResetReason"] = ESP.getResetReason();
|
|
|
+ json["CoreVersion"] = ESP.getCoreVersion();
|
|
|
+ json["SDKVersion"] = ESP.getSdkVersion();
|
|
|
+ json["CPUfreq"] = ESP.getCpuFreqMHz();
|
|
|
+ json["SketchSize"] = ESP.getSketchSize();
|
|
|
+ json["FlashSize"] = ESP.getFlashChipRealSize();
|
|
|
+
|
|
|
+ if(confTime.ntpEnable) {
|
|
|
+ char buf[13];
|
|
|
+ updateTime();
|
|
|
+ strftime(buf, sizeof(buf), "%H:%M", <);
|
|
|
+ json["time"] = buf;
|
|
|
+ strftime(buf, sizeof(buf), "%d.%m.%Y", <);
|
|
|
+ json["date"] = buf;
|
|
|
+ }
|
|
|
+
|
|
|
+ yield();
|
|
|
+
|
|
|
+ char jsonchar[1000];
|
|
|
+ serializeJson(json, jsonchar);
|
|
|
+ httpServer.send(200, "application/json", jsonchar);
|
|
|
}
|
|
|
- }); //httpServer.on /info
|
|
|
+ }); //httpServer.on /sysinfo
|
|
|
|
|
|
/*httpServer.on("/", []() {
|
|
|
if ( WifiInApMode ) {
|
|
@@ -932,8 +1271,14 @@ void httpServerInit() {
|
|
|
});*/
|
|
|
|
|
|
httpServer.on("/", []() {
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: / (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
if (httpServer.hasArg("restart")) {
|
|
|
if (httpIsAuthenticated() || (!httpIsAuthenticated() && httpCheckToken()) ) {
|
|
|
+ sendLog("WEB: /?restart", LOGLEVEL_INFO);
|
|
|
httpServerHandleRestartPage();
|
|
|
restart();
|
|
|
}
|
|
@@ -942,6 +1287,7 @@ void httpServerInit() {
|
|
|
else if (httpServer.hasArg("mqttreconnect")) {
|
|
|
if ( httpIsAuthenticated() || (!httpIsAuthenticated() && httpCheckToken()) ) {
|
|
|
//Serial.println("web triggered mqttreconnect");
|
|
|
+ sendLog("WEB: /?mqttreconnect", LOGLEVEL_INFO);
|
|
|
mqttReconnect();
|
|
|
httpServer.sendHeader("Location", "/", true);
|
|
|
httpServer.send(303);
|
|
@@ -950,6 +1296,7 @@ void httpServerInit() {
|
|
|
}
|
|
|
else if (httpServer.hasArg("clearconf")) {
|
|
|
if (httpIsAuthenticatedAdmin() || (!httpIsAuthenticatedAdmin() && httpCheckToken()) ) {
|
|
|
+ sendLog("WEB: /?clearconf", LOGLEVEL_INFO);
|
|
|
httpServerHandleClearconfPage();
|
|
|
|
|
|
yield();
|
|
@@ -960,6 +1307,7 @@ void httpServerInit() {
|
|
|
}
|
|
|
else if (!httpIsAuthenticated()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
+ sendLog("WEB: /", LOGLEVEL_INFO);
|
|
|
httpServerHandleMainPage();
|
|
|
}
|
|
|
});
|
|
@@ -967,6 +1315,12 @@ void httpServerInit() {
|
|
|
httpServer.on("/conf", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
+ //sendLog("WEB: /conf", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /conf (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
httpServerHandleConfPage();
|
|
|
}
|
|
|
});
|
|
@@ -974,6 +1328,12 @@ void httpServerInit() {
|
|
|
httpServer.on("/confweb", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
+ //sendLog("WEB: /confweb", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /confweb (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
httpServerHandleConfWebPage();
|
|
|
}
|
|
|
});
|
|
@@ -981,6 +1341,12 @@ void httpServerInit() {
|
|
|
httpServer.on("/confmqtt", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
+ //sendLog("WEB: /confmqtt", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /confmqtt (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
httpServerHandleConfMqttPage();
|
|
|
}
|
|
|
});
|
|
@@ -988,6 +1354,12 @@ void httpServerInit() {
|
|
|
httpServer.on("/confdevwifi", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
+ //sendLog("WEB: /confdevwifi", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /confdevwifi (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
httpServerHandleConfDevWiFiPage();
|
|
|
}
|
|
|
});
|
|
@@ -995,6 +1367,12 @@ void httpServerInit() {
|
|
|
httpServer.on("/confbas", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
+ //sendLog("WEB: /confbas", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /confbas (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
httpServerHandleConfBasPage();
|
|
|
}
|
|
|
});
|
|
@@ -1002,6 +1380,12 @@ void httpServerInit() {
|
|
|
httpServer.on("/confadv", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
+ //sendLog("WEB: /confadv", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /confadv (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
httpServerHandleConfAdvPage();
|
|
|
}
|
|
|
});
|
|
@@ -1009,18 +1393,79 @@ void httpServerInit() {
|
|
|
httpServer.on("/confadd", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
+ //sendLog("WEB: /confadd", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /confadd (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
httpServerHandleConfAddPage();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ httpServer.on("/conftime", []() {
|
|
|
+ if (!httpIsAuthenticatedAdmin()) return httpServer.requestAuthentication();
|
|
|
+ else {
|
|
|
+ //sendLog("WEB: /conftime", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /conftime (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
+ httpServerHandleConfTimePage();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ httpServer.on("/conflog", []() {
|
|
|
+ if (!httpIsAuthenticatedAdmin()) return httpServer.requestAuthentication();
|
|
|
+ else {
|
|
|
+ //sendLog("WEB: /conflog", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /conflog (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
+ httpServerHandleConfLogPage();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
httpServer.on("/redTemps", []() {
|
|
|
if (!httpIsAuthenticatedAdmin()) return httpServer.requestAuthentication();
|
|
|
else {
|
|
|
+ //sendLog("WEB: /redTemps", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /redTemps (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
httpServerHandleRedTempsPage();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ if(confWeb.enableConsole) {
|
|
|
+ httpServer.on("/console", []() {
|
|
|
+ if (!httpIsAuthenticatedAdmin()) return httpServer.requestAuthentication();
|
|
|
+ else {
|
|
|
+ //sendLog("WEB: /console", LOGLEVEL_INFO);
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: /console (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
+
|
|
|
+ wsValidSessionId = millis();
|
|
|
+ char sidbuf[20];
|
|
|
+ sprintf(sidbuf, "sessionId=%lu|", wsValidSessionId);
|
|
|
+ httpServer.sendHeader("Set-Cookie",sidbuf);
|
|
|
+ httpServerHandleConsolePage();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
httpServer.onNotFound([]() {
|
|
|
+ String addr = httpServer.client().remoteIP().toString();
|
|
|
+ char buf[40];
|
|
|
+ sprintf(buf, "WEB: 404 (from %s)", addr.c_str());
|
|
|
+ sendLog(buf, LOGLEVEL_INFO);
|
|
|
httpServerHandleNotFound();
|
|
|
}); //httpServer.onNotFound
|
|
|
|