diff --git a/data/style.css b/data/style.css
index c694b57d..d679ee4f 100644
--- a/data/style.css
+++ b/data/style.css
@@ -1 +1 @@
-:root{--star:url('data:image/svg+xml,')}.c,body{text-align:center}.clear{clear:both}.foot{background-color:transparent!important;all:revert;float:right;margin:0;font-size:.6em}a.foot:link,a.foot:visited{color:var(--footfg)}input:not([type=file]){background-color:var(--fldbg);color:var(--fldfg)}input[type=checkbox],input[type=radio]{width:1em}select{background-color:var(--fldbg);color:var(--fldfg)}input:invalid{border:1px solid var(--redbg)}body{font-family:verdana;width:60%;margin:auto;background:var(--bg);color:var(--txt)}.red{background-color:var(--btnred)}.red:focus,.red:hover{background-color:var(--btnredhi)}#doc{text-align:left;display:inline-block;color:var(--txt);width:100%;min-width:320px;max-width:700px;display:table}td{font-size:.87rem;padding-bottom:0;padding-top:0}th{padding-top:.5em}*{box-sizing:border-box}a,input,select,textarea{width:100%;padding:12px;border:1px solid #ccc;border-radius:.6rem;resize:vertical}label{padding:12px 18px 12px 0;display:inline-block}.required{background-image:var(--star);background-size:1.5em 1.5em;background-position:right;background-repeat:no-repeat}a,button,input[type=submit]{padding:12px;border:1px solid var(--btnbrd);border-radius:.6rem;background-color:var(--btnbg);color:var(--btnfg);font-size:1rem;width:100%;margin:12px 0;display:flex;align-items:center;justify-content:center;text-align:center;text-decoration:none}a:hover,button:hover,input[type=submit]:hover{background-color:var(--btnbghi)}.container{background-color:var(--grpbg);color:var(--grpfg);border-radius:.6rem;padding:10px;margin:20px 0}.dist{display:flex;justify-content:space-between;width:100%}.dist>a{flex-grow:1;margin:0 6px}.dist>a:first-child{margin-left:0}.dist>a:last-child{margin-right:0}.col-25{float:left;width:25%;text-align:right;margin:0}.col-75{margin:0;float:left;width:75%}.row:after{content:"";display:table;clear:both}.row{font-size:.833rem;margin:5px}.gap,.row:last-of-type{margin:5px 5px 20px}.error,.info,.success,.validation,.warning{border:1px solid;margin:10px auto;padding:15px 10px 15px 50px;background-repeat:no-repeat;background-position:10px center;max-width:460px}.info{color:#00529b;background-color:#bde5f8}.success{color:#4f8a10;background-color:#dff2bf}.warning{color:#9f6000;background-color:#feefb3}.error{color:#d8000c;background-color:#ffd2d2}@media screen and (max-width:800px){.col-25,.col-75,input[type=submit]{width:100%;margin-top:0}.col-25{text-align:left}label{padding:5px 18px 5px 0}}
\ No newline at end of file
+:root{--star:url('data:image/svg+xml,')}a.foot:link,a.foot:visited{color:var(--footfg)}input:not([type=file]){background-color:var(--fldbg);color:var(--fldfg)}input[type=checkbox],input[type=radio]{width:1em}select{background-color:var(--fldbg);color:var(--fldfg)}input:invalid{border:1px solid var(--fldred)}body{font-family:verdana;margin:auto;background:var(--bg);color:var(--txt)}.c,body{text-align:center}.clear{clear:both}.foot{background-color:transparent!important;all:revert;float:right;margin:0;font-size:.6em}.red{background-color:var(--btnred)}.red:focus,.red:hover{background-color:var(--btnredhi)}#doc{text-align:left;margin:0 auto;display:inline-block;color:var(--txt);width:80%;min-width:300px;max-width:600px;display:table}td{font-size:.87rem;padding-bottom:0;padding-top:0}th{padding-top:.5em}*{box-sizing:border-box}a,input,select,textarea{width:100%;padding:12px;border:1px solid #ccc;border-radius:.6rem;resize:vertical}label{padding:12px 18px 12px 0;display:inline-block}.required{background-image:var(--star);background-size:1.5em 1.5em;background-position:right;background-repeat:no-repeat}a,button,input[type=submit]{padding:12px;border:1px solid var(--btnbrd);border-radius:.6rem;background-color:var(--btnbg);color:var(--btnfg);font-size:1rem;width:100%;margin:12px 0;display:flex;align-items:center;justify-content:center;text-align:center;text-decoration:none}a:hover,button:hover,input[type=submit]:hover{background-color:var(--btnbghi)}.container{background-color:var(--grpbg);color:var(--grpfg);border-radius:.6rem;padding:10px;margin:20px 0}.dist{display:flex;justify-content:space-between;width:100%}.dist > a{flex-grow:1;margin:0 6px}.dist>a:first-child{margin-left:0}.dist>a:last-child{margin-right:0}.col-25{float:left;width:25%;text-align:right;margin:0}.col-75{margin:0;float:left;width:75%}.row:after{content:"";display:table;clear:both}.row{font-size:.833rem;margin:5px}.gap,.row:last-of-type{margin:5px 5px 20px}.error,.info,.success,.validation,.warning{border:1px solid;margin:10px auto;padding:15px 10px 15px 50px;background-repeat:no-repeat;background-position:10px center;max-width:500px}.info{color:#00529B;background-color:#BDE5F8}.success{color:#4F8A10;background-color:#DFF2BF}.warning{color:#9F6000;background-color:#FEEFB3}.error{color:#D8000C;background-color:#FFD2D2}@media screen and (max-width:800px){.col-25,.col-75,input[type=submit]{width:100%;margin-top:0}.col-25{text-align:left}label{padding:5px 18px 5px 0}}
\ No newline at end of file
diff --git a/data/style.css.gz b/data/style.css.gz
index e481c60a..9a9fe282 100644
Binary files a/data/style.css.gz and b/data/style.css.gz differ
diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp
index 90ea27ee..d255652b 100644
--- a/src/sys/svc/hasp_http.cpp
+++ b/src/sys/svc/hasp_http.cpp
@@ -197,7 +197,7 @@ static String getContentType(const String& path)
////////////////////////////////////////////////////////////////////////////////////////////////////
-void webHandleHaspConfig();
+static void webHandleHaspConfig();
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -227,7 +227,7 @@ bool httpIsAuthenticated(const __FlashStringHelper* notused)
return true;
}
-void webSendFooter()
+static void webSendFooter()
{
#if defined(STM32F4xx)
webServer.sendContent(HTTP_FOOTER);
@@ -240,7 +240,7 @@ void webSendFooter()
#endif
}
-void webSendCacheHeader(int size, int age)
+static void webSendCacheHeader(int size, int age)
{
webServer.sendHeader(F("Content-Length"), (String)(size));
webServer.sendHeader(F("Cache-Control"), F("max-age=3600, public"));
@@ -257,7 +257,7 @@ static int webSendCached(int statuscode, const char* contenttype, const char* da
return statuscode;
}
-void webSendPage(const char* nodename, uint32_t httpdatalength, bool gohome = false)
+static void webSendHeader(const char* nodename, uint32_t httpdatalength, bool gohome = false)
{
{
char buffer[64];
@@ -342,7 +342,7 @@ void saveConfig()
}
}
-void webHandleRoot()
+static void webHandleRoot()
{
if(!httpIsAuthenticated(F("root"))) return;
@@ -373,18 +373,18 @@ void webHandleRoot()
httpMessage += F("" D_HTTP_REBOOT "");
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), false);
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
webServer.sendContent(httpMessage);
}
webSendFooter();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void httpHandleReboot()
+static void httpHandleReboot()
{ // http://plate01/reboot
if(!httpIsAuthenticated(F("reboot"))) return;
- {
+ { // Send Content
String httpMessage((char*)0);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += F("
");
@@ -392,41 +392,44 @@ void httpHandleReboot()
httpMessage += F("
");
httpMessage = F(D_DISPATCH_REBOOT);
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), true);
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), true);
webServer.sendContent(httpMessage);
}
- // httpMessage.clear();
webSendFooter();
- delay(200);
- dispatch_reboot(true);
+ { // Execute Actions
+ // delay(200);
+ dispatch_reboot(true);
+ }
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void webHandleScreenshot()
+static void webHandleScreenshot()
{ // http://plate01/screenshot
if(!httpIsAuthenticated(F("screenshot"))) return;
- if(webServer.hasArg(F("a"))) {
- if(webServer.arg(F("a")) == F("next")) {
- dispatch_page_next(LV_SCR_LOAD_ANIM_NONE);
- } else if(webServer.arg(F("a")) == F("prev")) {
- dispatch_page_prev(LV_SCR_LOAD_ANIM_NONE);
- } else if(webServer.arg(F("a")) == F("back")) {
- dispatch_page_back(LV_SCR_LOAD_ANIM_NONE);
+ { // Execute actions
+ if(webServer.hasArg(F("a"))) {
+ if(webServer.arg(F("a")) == F("next")) {
+ dispatch_page_next(LV_SCR_LOAD_ANIM_NONE);
+ } else if(webServer.arg(F("a")) == F("prev")) {
+ dispatch_page_prev(LV_SCR_LOAD_ANIM_NONE);
+ } else if(webServer.arg(F("a")) == F("back")) {
+ dispatch_page_back(LV_SCR_LOAD_ANIM_NONE);
+ }
+ }
+
+ if(webServer.hasArg(F("q"))) {
+ lv_disp_t* disp = lv_disp_get_default();
+ webServer.setContentLength(122 + disp->driver.hor_res * disp->driver.ver_res * sizeof(lv_color_t));
+ webServer.send_P(200, PSTR("image/bmp"), "");
+ guiTakeScreenshot();
+ webServer.client().stop();
+ return;
}
}
- if(webServer.hasArg(F("q"))) {
- lv_disp_t* disp = lv_disp_get_default();
- webServer.setContentLength(122 + disp->driver.hor_res * disp->driver.ver_res * sizeof(lv_color_t));
- webServer.send_P(200, PSTR("image/bmp"), "");
- guiTakeScreenshot();
- webServer.client().stop();
- return;
- }
-
- {
+ { // Send Content
String httpMessage((char*)0);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += F("");
@@ -441,19 +444,18 @@ void webHandleScreenshot()
httpMessage += F("" D_HTTP_NEXT_PAGE "");
httpMessage += FPSTR(MAIN_MENU_BUTTON);
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), false);
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
webServer.sendContent(httpMessage);
}
webSendFooter();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-
-void webHandleAbout()
+static void webHandleAbout()
{ // http://plate01/about
if(!httpIsAuthenticated(F("about"))) return;
- {
+ { // Send Content
String mitLicense((char*)0);
mitLicense = FPSTR(MIT_LICENSE);
@@ -496,16 +498,14 @@ void webHandleAbout()
httpMessage += FPSTR(MAIN_MENU_BUTTON);
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), false);
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
webServer.sendContent(httpMessage);
}
- // httpMessage.clear();
webSendFooter();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-
-void add_json(String& data, JsonDocument& doc)
+static void add_json(String& data, JsonDocument& doc)
{
char buffer[512];
size_t len = serializeJson(doc, buffer, sizeof(buffer));
@@ -517,62 +517,59 @@ void add_json(String& data, JsonDocument& doc)
doc.clear();
}
-void webHandleInfoJson()
+static void webHandleInfoJson()
{ // http://plate01/
if(!httpIsAuthenticated(F("infojson"))) return;
- String htmldata((char*)0);
- htmldata.reserve(HTTP_PAGE_SIZE);
- DynamicJsonDocument doc(512);
+ { // Send Content
+ String htmldata((char*)0);
+ htmldata.reserve(HTTP_PAGE_SIZE);
+ DynamicJsonDocument doc(512);
- htmldata += F("");
- htmldata += haspDevice.get_hostname();
- htmldata += F("
");
+ htmldata += F("");
+ htmldata += haspDevice.get_hostname();
+ htmldata += F("
");
- htmldata += "
";
+ htmldata += "'; data = JSON.parse(data); var table = \"\"; for(let header in data) { "
+ "table += ` | tr>
${header} th> tr>`;"
+ "for(let key in data[header]) { "
+ "table += ` |
---|
${key}: td> | ${data[header][key]} td> tr>`;"
+ "}} table += \" |
\"; "
+ "document.getElementById(\"info\").innerHTML = table;});";
- // String path = F(".html");
- // webServer.send(200, getContentType(path), htmldata);
+ htmldata += FPSTR(MAIN_MENU_BUTTON);
- htmldata += FPSTR(MAIN_MENU_BUTTON);
-
- webSendPage(haspDevice.get_hostname(), htmldata.length(), false);
- webServer.sendContent(htmldata);
-
- // htmldata.clear();
+ webSendHeader(haspDevice.get_hostname(), htmldata.length(), false);
+ webServer.sendContent(htmldata);
+ }
webSendFooter();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void webHandleInfo()
+static void webHandleInfo()
{ // http://plate01/
if(!httpIsAuthenticated(F("info"))) return;
- {
+ { // Send Content
char size_buf[32];
String httpMessage((char*)0);
httpMessage.reserve(HTTP_PAGE_SIZE);
@@ -764,10 +761,9 @@ void webHandleInfo()
httpMessage += FPSTR(MAIN_MENU_BUTTON);
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), false);
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
webServer.sendContent(httpMessage);
}
- // httpMessage.clear();
webSendFooter();
}
@@ -798,7 +794,7 @@ void webHandleInfo()
} */
static unsigned long htppLastLoopTime = 0;
-void webUploadProgress()
+static void webUploadProgress()
{
long t = webServer.header("Content-Length").toInt();
if(millis() - htppLastLoopTime >= 1250) {
@@ -825,11 +821,11 @@ static inline void webUpdatePrintError()
#endif
}
-void webUpdateReboot()
+static void webUpdateReboot()
{
LOG_INFO(TAG_HTTP, F("Update Success: %u bytes received. Rebooting..."), upload->totalSize);
- {
+ { // Send Content
String httpMessage((char*)0);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += F("");
@@ -837,17 +833,19 @@ void webUpdateReboot()
httpMessage += F("
");
httpMessage += F("Upload complete. Rebooting device, please wait...");
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), true);
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), true);
webServer.sendContent(httpMessage);
}
- // httpMessage.clear();
webSendFooter();
- delay(250);
- dispatch_reboot(true); // Save the current config
+ // Exectute Actions
+ {
+ // delay(250);
+ dispatch_reboot(true); // Save the current config
+ }
}
-void webHandleFirmwareUpload()
+static void webHandleFirmwareUpload()
{
upload = &webServer.upload();
@@ -903,7 +901,7 @@ void webHandleFirmwareUpload()
#endif
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
-int handleFileRead(String path)
+static int handleFileRead(String path)
{
// if(!httpIsAuthenticated(F("fileread"))) return false;
if(!httpIsAuthenticated()) return false;
@@ -974,7 +972,7 @@ int handleFileRead(String path)
return 404; // Not found
}
-void handleFileUpload()
+static void handleFileUpload()
{
if(webServer.uri() != "/edit") {
return;
@@ -1020,7 +1018,7 @@ void handleFileUpload()
}
}
-void handleFileDelete()
+static void handleFileDelete()
{
if(!httpIsAuthenticated(F("filedelete"))) return;
@@ -1043,7 +1041,7 @@ void handleFileDelete()
// path.clear();
}
-void handleFileCreate()
+static void handleFileCreate()
{
if(!httpIsAuthenticated(F("filecreate"))) return;
@@ -1083,7 +1081,7 @@ void handleFileCreate()
webServer.send(200, PSTR("text/plain"), "");
}
-void handleFileList()
+static void handleFileList()
{
if(!httpIsAuthenticated(F("filelist"))) return;
@@ -1154,7 +1152,7 @@ void handleFileList()
////////////////////////////////////////////////////////////////////////////////////////////////////
#if HASP_USE_CONFIG > 0
-void webHandleConfig()
+static void webHandleConfig()
{ // http://plate01/config
if(!httpIsAuthenticated(F("config"))) return;
@@ -1191,23 +1189,22 @@ void webHandleConfig()
httpMessage += F("" D_HTTP_FACTORY_RESET "");
httpMessage += FPSTR(MAIN_MENU_BUTTON);
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), false);
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
webServer.sendContent(httpMessage);
}
- // httpMessage.clear();
webSendFooter();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
#if HASP_USE_MQTT > 0
-void webHandleMqttConfig()
+static void webHandleMqttConfig()
{ // http://plate01/config/mqtt
if(!httpIsAuthenticated(F("config/mqtt"))) return;
- StaticJsonDocument<256> settings;
- mqttGetConfig(settings.to());
+ { // Send Content
+ StaticJsonDocument<256> settings;
+ mqttGetConfig(settings.to());
- {
String httpMessage((char*)0);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += F("");
@@ -1268,20 +1265,19 @@ void webHandleMqttConfig()
httpMessage += F("");
add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"));
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), false);
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
webServer.sendContent(httpMessage);
}
- // httpMessage.clear();
webSendFooter();
}
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////
-void webHandleGuiConfig()
+static void webHandleGuiConfig()
{ // http://plate01/config/wifi
if(!httpIsAuthenticated(F("config/gui"))) return;
- {
+ { // Send Content
StaticJsonDocument<256> settings;
guiGetConfig(settings.to());
@@ -1365,111 +1361,106 @@ void webHandleGuiConfig()
add_form_button(httpMessage, F(D_HTTP_ANTIBURN), F("/config/gui?brn=1"));
add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"));
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), false);
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
webServer.sendContent(httpMessage);
}
webSendFooter();
- if(webServer.hasArg(F("cal"))) dispatch_calibrate(NULL, NULL, TAG_HTTP);
- if(webServer.hasArg(F("brn"))) dispatch_antiburn(NULL, "on", TAG_HTTP);
+ { // Execute Actions
+ if(webServer.hasArg(F("cal"))) dispatch_calibrate(NULL, NULL, TAG_HTTP);
+ if(webServer.hasArg(F("brn"))) dispatch_antiburn(NULL, "on", TAG_HTTP);
+ }
}
////////////////////////////////////////////////////////////////////////////////////////////////////
#if HASP_USE_WIFI > 0
-void webHandleWifiConfig()
+static void webHandleWifiConfig()
{ // http://plate01/config/wifi
if(!httpIsAuthenticated(F("config/wifi"))) return;
- StaticJsonDocument<256> settings;
- wifiGetConfig(settings.to());
+ { // Send Content
+ StaticJsonDocument<256> settings;
+ wifiGetConfig(settings.to());
- String httpMessage((char*)0);
- httpMessage.reserve(HTTP_PAGE_SIZE);
- httpMessage += F("");
- httpMessage += haspDevice.get_hostname();
- httpMessage += F("
");
- httpMessage += F("" D_HTTP_WIFI_SETTINGS "
");
+ String httpMessage((char*)0);
+ httpMessage.reserve(HTTP_PAGE_SIZE);
+ httpMessage += F("");
+ httpMessage += haspDevice.get_hostname();
+ httpMessage += F("
");
+ httpMessage += F("" D_HTTP_WIFI_SETTINGS "
");
- // Form
- httpMessage += F("");
#if HASP_USE_WIFI > 0 && !defined(STM32F4xx)
- if(WiFi.getMode() == WIFI_STA) {
- add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"));
- }
+ if(WiFi.getMode() == WIFI_STA) {
+ add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"));
+ }
#endif
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), false);
- webServer.sendContent(httpMessage);
-#if defined(STM32F4xx)
- httpMessage = "";
-#else
- httpMessage.clear();
-#endif
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
+ webServer.sendContent(httpMessage);
+ }
webSendFooter();
}
#if HASP_USE_CAPTIVE_PORTAL > 0
// I'm not an experienced programmer, this was the only way I managed to get it to work..
-void webHandleCaptivePortalWifiConfig()
+static void webHandleCaptivePortalWifiConfig()
{ // http://plate01/config/wifi
if(!httpIsAuthenticated(F("config/wifi"))) return;
- StaticJsonDocument<256> settings;
- wifiGetConfig(settings.to());
+ { // Send Content
+ StaticJsonDocument<256> settings;
+ wifiGetConfig(settings.to());
- String httpMessage((char*)0);
- httpMessage.reserve(HTTP_PAGE_SIZE);
- httpMessage += F("");
- httpMessage += haspDevice.get_hostname();
- httpMessage += F("
");
+ String httpMessage((char*)0);
+ httpMessage.reserve(HTTP_PAGE_SIZE);
+ httpMessage += F("");
+ httpMessage += haspDevice.get_hostname();
+ httpMessage += F("
");
- httpMessage += F("");
+ httpMessage += F("");
#if HASP_USE_WIFI > 0 && !defined(STM32F4xx)
- if(WiFi.getMode() == WIFI_STA) {
- add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"));
- }
+ if(WiFi.getMode() == WIFI_STA) {
+ add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"));
+ }
#endif
- // webServer.send(200, "text/html", httpMessage);
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), false);
- webServer.sendContent(httpMessage);
-#if defined(STM32F4xx)
- httpMessage = "";
-#else
- httpMessage.clear();
-#endif
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
+ webServer.sendContent(httpMessage);
+ }
webSendFooter();
}
#endif // HASP_USE_CAPTIVE_PORTAL
@@ -1477,35 +1468,47 @@ void webHandleCaptivePortalWifiConfig()
#endif // HASP_USE_WIFI
////////////////////////////////////////////////////////////////////////////////////////////////////
-void webHandleHttpConfig()
+static void webHandleHttpConfig()
{ // http://plate01/config/http
if(!httpIsAuthenticated(F("config/http"))) return;
- {
+ { // Send Content
StaticJsonDocument<256> settings;
httpGetConfig(settings.to());
- char httpMessage[HTTP_PAGE_SIZE];
+ String httpMessage((char*)0);
+ httpMessage.reserve(HTTP_PAGE_SIZE);
+ httpMessage += F("");
+ httpMessage += haspDevice.get_hostname();
+ httpMessage += F("
");
+ httpMessage += F("" D_HTTP_HTTP_SETTINGS "
");
- size_t len = snprintf_P(
- httpMessage, sizeof(httpMessage),
- PSTR("%s
"
- ""
- ""),
- haspDevice.get_hostname(), settings[FPSTR(FP_CONFIG_USER)].as().c_str(),
- settings[FPSTR(FP_CONFIG_PASS)].as().c_str());
+ // Form
+ httpMessage += F("");
+
+ httpMessage += F("" D_HTTP_CONFIGURATION "");
+
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
webServer.sendContent(httpMessage);
}
webSendFooter();
@@ -1513,30 +1516,29 @@ void webHandleHttpConfig()
////////////////////////////////////////////////////////////////////////////////////////////////////
#if HASP_USE_GPIO > 0
-void webHandleGpioConfig()
+static void webHandleGpioConfig()
{ // http://plate01/config/gpio
if(!httpIsAuthenticated(F("config/gpio"))) return;
uint8_t configCount = 0;
- // StaticJsonDocument<256> settings;
- // gpioGetConfig(settings.to());
-
- if(webServer.hasArg(PSTR("save"))) {
- uint8_t id = webServer.arg(F("id")).toInt();
- uint8_t pin = webServer.arg(F("pin")).toInt();
- uint8_t type = webServer.arg(F("type")).toInt();
- uint8_t group = webServer.arg(F("group")).toInt();
- uint8_t pinfunc = webServer.arg(F("func")).toInt();
- bool inverted = webServer.arg(F("state")).toInt();
- gpioSavePinConfig(id, pin, type, group, pinfunc, inverted);
- }
- if(webServer.hasArg(PSTR("del"))) {
+ { // Execute Actions
uint8_t id = webServer.arg(F("id")).toInt();
uint8_t pin = webServer.arg(F("pin")).toInt();
- gpioSavePinConfig(id, pin, hasp_gpio_type_t::FREE, 0, 0, false);
+
+ if(webServer.hasArg(PSTR("save"))) {
+ uint8_t type = webServer.arg(F("type")).toInt();
+ uint8_t group = webServer.arg(F("group")).toInt();
+ uint8_t pinfunc = webServer.arg(F("func")).toInt();
+ bool inverted = webServer.arg(F("state")).toInt();
+ gpioSavePinConfig(id, pin, type, group, pinfunc, inverted);
+ }
+
+ if(webServer.hasArg(PSTR("del"))) {
+ gpioSavePinConfig(id, pin, hasp_gpio_type_t::FREE, 0, 0, false);
+ }
}
- {
+ { // Send Content
String httpMessage((char*)0);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += F("");
@@ -1693,19 +1695,18 @@ void webHandleGpioConfig()
add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"));
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), false);
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
webServer.sendContent(httpMessage);
}
- // httpMessage.clear();
webSendFooter();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void webHandleGpioOutput()
+static void webHandleGpioOutput()
{ // http://plate01/config/gpio/options
if(!httpIsAuthenticated(F("config/gpio/options"))) return;
- {
+ { // Send Content
StaticJsonDocument<256> settings;
guiGetConfig(settings.to());
@@ -1775,7 +1776,7 @@ void webHandleGpioOutput()
httpMessage += PSTR("");
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), false);
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
webServer.sendContent(httpMessage);
}
webSendFooter();
@@ -1784,10 +1785,11 @@ void webHandleGpioOutput()
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void webHandleGpioInput()
+static void webHandleGpioInput()
{ // http://plate01/config/gpio/options
if(!httpIsAuthenticated(F("config/gpio/input"))) return;
- {
+
+ { // Send Content
StaticJsonDocument<256> settings;
guiGetConfig(settings.to());
@@ -1865,7 +1867,7 @@ void webHandleGpioInput()
httpMessage += PSTR("");
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), false);
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
webServer.sendContent(httpMessage);
}
webSendFooter();
@@ -1875,14 +1877,14 @@ void webHandleGpioInput()
#endif // HASP_USE_GPIO
////////////////////////////////////////////////////////////////////////////////////////////////////
-void webHandleDebugConfig()
+static void webHandleDebugConfig()
{ // http://plate01/config/debug
if(!httpIsAuthenticated(F("config/debug"))) return;
- StaticJsonDocument<256> settings;
- debugGetConfig(settings.to());
+ { // Send Content
+ StaticJsonDocument<256> settings;
+ debugGetConfig(settings.to());
- {
String httpMessage((char*)0);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += F("");
@@ -1956,22 +1958,21 @@ void webHandleDebugConfig()
add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"));
- webSendPage(haspDevice.get_hostname(), httpMessage.length(), false);
+ webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
webServer.sendContent(httpMessage);
}
- // httpMessage.clear();
webSendFooter();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void webHandleHaspConfig()
+static void webHandleHaspConfig()
{ // http://plate01/config/http
if(!httpIsAuthenticated(F("config/hasp"))) return;
- StaticJsonDocument<256> settings;
- haspGetConfig(settings.to());
+ { // Send Content
+ StaticJsonDocument<256> settings;
+ haspGetConfig(settings.to());
- {
String httpMessage((char*)0);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += F("");
@@ -1979,16 +1980,35 @@ void webHandleHaspConfig()
httpMessage += F("
");
httpMessage += F("" D_HTTP_HASP_DESIGN "
");
- httpMessage += F("
");
+#if defined(ARDUINO_ARCH_ESP8266)
+ // Form
+ httpMessage += F("");
+#endif
+
+ // Form
+ // httpMessage += F("