From 929a4a5041cd195dfd74b8906952ef6310d705a1 Mon Sep 17 00:00:00 2001
From: fvanroie
Date: Sat, 19 Dec 2020 03:05:55 +0100
Subject: [PATCH] Add delete GPIO config
---
src/hasp_http.cpp | 321 +++++++++++++++++++++++-----------------------
1 file changed, 164 insertions(+), 157 deletions(-)
diff --git a/src/hasp_http.cpp b/src/hasp_http.cpp
index f6816db2..8dabd652 100644
--- a/src/hasp_http.cpp
+++ b/src/hasp_http.cpp
@@ -8,7 +8,7 @@
#include "StringStream.h"
#if defined(ARDUINO_ARCH_ESP32)
-#include "Update.h"
+ #include "Update.h"
#endif
#include "hasp_conf.h"
@@ -26,34 +26,34 @@ bool httpEnable = true;
bool webServerStarted = false;
uint16_t httpPort = 80;
-#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
+ #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
File fsUploadFile;
-#endif
+ #endif
char httpUser[32] = "";
char httpPassword[32] = "";
-#define HTTP_PAGE_SIZE (6 * 256)
+ #define HTTP_PAGE_SIZE (6 * 256)
-#if defined(STM32F4xx) && HASP_USE_ETHERNET > 0
-#include
+ #if defined(STM32F4xx) && HASP_USE_ETHERNET > 0
+ #include
EthernetWebServer webServer(80);
-#endif
+ #endif
-#if defined(STM32F4xx) && HASP_USE_WIFI > 0
-#include
+ #if defined(STM32F4xx) && HASP_USE_WIFI > 0
+ #include
// #include
EthernetWebServer webServer(80);
-#endif
+ #endif
-#if defined(ARDUINO_ARCH_ESP8266)
-#include
+ #if defined(ARDUINO_ARCH_ESP8266)
+ #include
ESP8266WebServer webServer(80);
-#endif
+ #endif
-#if defined(ARDUINO_ARCH_ESP32)
-#include
+ #if defined(ARDUINO_ARCH_ESP32)
+ #include
WebServer webServer(80);
-#endif // ESP32
+ #endif // ESP32
HTTPUpload * upload;
@@ -103,11 +103,11 @@ String espFirmwareUrl = "http://haswitchplate.com/update/HASwitchPlate.ino.d1_mi
// Default link to compiled Nextion firmware images
String lcdFirmwareUrl = "http://haswitchplate.com/update/HASwitchPlate.tft";
-#if HASP_USE_MQTT > 0
+ #if HASP_USE_MQTT > 0
extern char mqttNodeName[16];
-#else
+ #else
char mqttNodeName[3] = "na";
-#endif
+ #endif
////////////////////////////////////////////////////////////////////////////////////////////////////
void webHandleHaspConfig();
@@ -127,13 +127,13 @@ bool httpIsAuthenticated(const __FlashStringHelper * fstr_page)
}
}
-#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
+ #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
Log.notice(TAG_HTTP, F("Sending %S page to client connected from: %s"), fstr_page,
webServer.client().remoteIP().toString().c_str());
-#else
- // Log.trace(TAG_HTTP,F("Sending %s page to client connected from: %s"), page,
- // String(webServer.client().remoteIP()).c_str());
-#endif
+ #else
+ // Log.trace(TAG_HTTP,F("Sending %s page to client connected from: %s"), page,
+ // String(webServer.client().remoteIP()).c_str());
+ #endif
return true;
}
@@ -159,15 +159,15 @@ void webSendFooter()
char buffer[16];
snprintf_P(buffer, sizeof(buffer), PSTR("%u.%u.%u"), HASP_VERSION_MAJOR, HASP_VERSION_MINOR, HASP_VERSION_REVISION);
-#if defined(STM32F4xx)
+ #if defined(STM32F4xx)
webServer.sendContent(HTTP_END);
webServer.sendContent(buffer);
webServer.sendContent(HTTP_FOOTER);
-#else
+ #else
webServer.sendContent_P(HTTP_END);
webServer.sendContent(buffer);
webServer.sendContent_P(HTTP_FOOTER);
-#endif
+ #endif
}
void webSendPage(char * nodename, uint32_t httpdatalength, bool gohome = false)
@@ -194,29 +194,29 @@ void webSendPage(char * nodename, uint32_t httpdatalength, bool gohome = false)
}
webServer.setContentLength(contentLength + httpdatalength);
-#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
+ #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
webServer.send_P(200, PSTR("text/html"), HTTP_DOCTYPE); // 122
-#else
+ #else
webServer.send(200, ("text/html"), HTTP_DOCTYPE); // 122
-#endif
+ #endif
snprintf_P(buffer, sizeof(buffer), HTTP_HEADER, nodename);
webServer.sendContent(buffer); // 17-2+len
}
-#if defined(STM32F4xx)
+ #if defined(STM32F4xx)
webServer.sendContent(HTTP_SCRIPT); // 131
webServer.sendContent(HTTP_STYLE); // 487
webServer.sendContent(HASP_STYLE); // 145
if(gohome) webServer.sendContent(HTTP_META_GO_BACK); // 47
webServer.sendContent(HTTP_HEADER_END); // 80
-#else
+ #else
webServer.sendContent_P(HTTP_SCRIPT); // 131
webServer.sendContent_P(HTTP_STYLE); // 487
webServer.sendContent_P(HASP_STYLE); // 145
if(gohome) webServer.sendContent_P(HTTP_META_GO_BACK); // 47
webServer.sendContent_P(HTTP_HEADER_END); // 80
-#endif
+ #endif
}
void webHandleRoot()
@@ -239,12 +239,12 @@ void webHandleRoot()
httpMessage +=
F("
");
-#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
+ #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
if(HASP_FS.exists(F("/edit.htm.gz"))) {
httpMessage += F("");
}
-#endif
+ #endif
httpMessage +=
F("");
@@ -366,15 +366,15 @@ void webHandleAbout()
F("ArduinoLog
Copyright© 2017,2018 Thijs Elenbaas, MrRobot62, rahuldeo2047, NOX73, "
"dhylands, Josha blemasle, mfalkvidd");
httpMessage += FPSTR(MIT_LICENSE);
-#if HASP_USE_SYSLOG > 0
- // Replaced with WiFiUDP client
- // httpMessage += F("Syslog
Copyright© 2016 Martin Sloup");
- // httpMessage += FPSTR(MIT_LICENSE);
-#endif
-#if HASP_USE_QRCODE > 0
+ #if HASP_USE_SYSLOG > 0
+ // Replaced with WiFiUDP client
+ // httpMessage += F("Syslog
Copyright© 2016 Martin Sloup");
+ // httpMessage += FPSTR(MIT_LICENSE);
+ #endif
+ #if HASP_USE_QRCODE > 0
httpMessage += F("QR Code generator
Copyright© Project Nayuki");
httpMessage += FPSTR(MIT_LICENSE);
-#endif
+ #endif
httpMessage += F("AceButton
Copyright© 2018 Brian T. Park");
httpMessage += FPSTR(MIT_LICENSE);
@@ -441,14 +441,14 @@ void webHandleInfo()
httpMessage += F("
Memory Fragmentation: ");
httpMessage += String(halGetHeapFragmentation());
-#if ARDUINO_ARCH_ESP32
+ #if ARDUINO_ARCH_ESP32
if(psramFound()) {
httpMessage += F("
Free PSRam: ");
httpMessage += halFormatBytes(ESP.getFreePsram());
httpMessage += F("
PSRam Size: ");
httpMessage += halFormatBytes(ESP.getPsramSize());
}
-#endif
+ #endif
/* LVGL Stats */
lv_mem_monitor_t mem_mon;
@@ -467,7 +467,7 @@ void webHandleInfo()
httpMessage += String(haspGetPage());
/* Wifi Stats */
-#if HASP_USE_WIFI > 0
+ #if HASP_USE_WIFI > 0
httpMessage += F("SSID: ");
httpMessage += String(WiFi.SSID());
httpMessage += F("Signal Strength: ");
@@ -487,7 +487,7 @@ void webHandleInfo()
} else {
httpMessage += F("Very Bad)");
}
-#if defined(STM32F4xx)
+ #if defined(STM32F4xx)
byte mac[6];
WiFi.macAddress(mac);
char macAddress[16];
@@ -499,7 +499,7 @@ void webHandleInfo()
httpMessage += String(WiFi.gatewayIP());
httpMessage += F("MAC Address: ");
httpMessage += String(macAddress);
-#else
+ #else
httpMessage += F("IP Address: ");
httpMessage += String(WiFi.localIP().toString());
httpMessage += F("Gateway: ");
@@ -508,10 +508,10 @@ void webHandleInfo()
httpMessage += String(WiFi.dnsIP().toString());
httpMessage += F("MAC Address: ");
httpMessage += String(WiFi.macAddress());
-#endif
-#endif
-#if HASP_USE_ETHERNET > 0
-#if defined(ARDUINO_ARCH_ESP32)
+ #endif
+ #endif
+ #if HASP_USE_ETHERNET > 0
+ #if defined(ARDUINO_ARCH_ESP32)
httpMessage += F("
Ethernet: ");
httpMessage += String(ETH.linkSpeed());
httpMessage += F(" Mbps");
@@ -526,10 +526,10 @@ void webHandleInfo()
httpMessage += String(ETH.dnsIP().toString());
httpMessage += F("MAC Address: ");
httpMessage += String(ETH.macAddress());
-#endif
-#endif
-/* Mqtt Stats */
-#if HASP_USE_MQTT > 0
+ #endif
+ #endif
+ /* Mqtt Stats */
+ #if HASP_USE_MQTT > 0
httpMessage += F("
MQTT Status: ");
if(mqttIsConnected()) { // Check MQTT connection
httpMessage += F("Connected");
@@ -547,7 +547,7 @@ void webHandleInfo()
httpMessage += mqttClientId;
}
-#endif // MQTT
+ #endif // MQTT
/* ESP Stats */
httpMessage += F("
MCU Model: ");
@@ -555,14 +555,14 @@ void webHandleInfo()
httpMessage += F("
CPU Frequency: ");
httpMessage += String(halGetCpuFreqMHz());
-#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
+ #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
httpMessage += F("MHz
Flash Chip Size: ");
httpMessage += halFormatBytes(ESP.getFlashChipSize());
httpMessage += F("Program Size: ");
httpMessage += halFormatBytes(ESP.getSketchSize());
httpMessage += F("
Free Program Space: ");
httpMessage += halFormatBytes(ESP.getFreeSketchSpace());
-#endif
+ #endif
//#if defined(ARDUINO_ARCH_ESP32)
// httpMessage += F("
ESP SDK version: ");
@@ -651,7 +651,7 @@ void webUploadProgress()
haspProgressVal(t);
}
-#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
+ #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
void webUpdatePrintError()
{
String output((char *)0);
@@ -714,9 +714,9 @@ void webHandleFirmwareUpdate()
}
}
}
-#endif
+ #endif
-#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
+ #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
bool handleFileRead(String path)
{
if(!httpIsAuthenticated(F("fileread"))) return false;
@@ -848,7 +848,7 @@ void handleFileList()
Log.notice(TAG_HTTP, F("handleFileList: %s"), path.c_str());
path.clear();
-#if defined(ARDUINO_ARCH_ESP32)
+ #if defined(ARDUINO_ARCH_ESP32)
File root = HASP_FS.open("/", FILE_READ);
File file = root.openNextFile();
String output = "[";
@@ -873,7 +873,7 @@ void handleFileList()
}
output += "]";
webServer.send(200, PSTR("text/json"), output);
-#elif defined(ARDUINO_ARCH_ESP8266)
+ #elif defined(ARDUINO_ARCH_ESP8266)
Dir dir = HASP_FS.openDir(path);
String output = "[";
while(dir.next()) {
@@ -895,9 +895,9 @@ void handleFileList()
}
output += "]";
webServer.send(200, PSTR("text/json"), output);
-#endif
+ #endif
}
-#endif
+ #endif
////////////////////////////////////////////////////////////////////////////////////////////////////
void webHandleConfig()
@@ -914,10 +914,10 @@ void webHandleConfig()
if(save == String(PSTR("hasp"))) {
haspSetConfig(settings.as());
-#if HASP_USE_MQTT > 0
+ #if HASP_USE_MQTT > 0
} else if(save == String(PSTR("mqtt"))) {
mqttSetConfig(settings.as());
-#endif
+ #endif
} else if(save == String(PSTR("gui"))) {
settings[FPSTR(F_GUI_POINTER)] = webServer.hasArg(PSTR("pointer"));
@@ -932,20 +932,20 @@ void webHandleConfig()
// Password might have changed
if(!httpIsAuthenticated(F("config"))) return;
-#if HASP_USE_WIFI > 0
+ #if HASP_USE_WIFI > 0
} else if(save == String(PSTR("wifi"))) {
wifiSetConfig(settings.as());
-#endif
+ #endif
}
}
}
-// Reboot after saving wifi config in AP mode
-#if HASP_USE_WIFI > 0 && !defined(STM32F4xx)
+ // Reboot after saving wifi config in AP mode
+ #if HASP_USE_WIFI > 0 && !defined(STM32F4xx)
if(WiFi.getMode() != WIFI_STA) {
httpHandleReboot();
}
-#endif
+ #endif
{
String httpMessage((char *)0);
@@ -954,15 +954,15 @@ void webHandleConfig()
httpMessage += httpGetNodename();
httpMessage += F("
");
-#if HASP_USE_WIFI > 0
+ #if HASP_USE_WIFI > 0
httpMessage +=
F("
");
-#endif
+ #endif
-#if HASP_USE_MQTT > 0
+ #if HASP_USE_MQTT > 0
httpMessage +=
F("");
-#endif
+ #endif
httpMessage +=
F("");
@@ -973,10 +973,10 @@ void webHandleConfig()
httpMessage +=
F("");
-#if HASP_USE_GPIO > 0
+ #if HASP_USE_GPIO > 0
httpMessage +=
F("");
-#endif
+ #endif
httpMessage +=
F("");
@@ -994,8 +994,8 @@ void webHandleConfig()
webSendFooter();
}
-////////////////////////////////////////////////////////////////////////////////////////////////////
-#if HASP_USE_MQTT > 0
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ #if HASP_USE_MQTT > 0
void webHandleMqttConfig()
{ // http://plate01/config/mqtt
if(!httpIsAuthenticated(F("config/mqtt"))) return;
@@ -1042,7 +1042,7 @@ void webHandleMqttConfig()
// httpMessage.clear();
webSendFooter();
}
-#endif
+ #endif
////////////////////////////////////////////////////////////////////////////////////////////////////
void webHandleGuiConfig()
@@ -1090,7 +1090,7 @@ void webHandleGuiConfig()
int8_t bcklpin = settings[FPSTR(F_GUI_BACKLIGHTPIN)].as();
httpMessage += F("Backlight Control
");
httpMessage += F("");
@@ -1124,8 +1124,8 @@ void webHandleGuiConfig()
if(webServer.hasArg(F("action"))) dispatch_text_line(webServer.arg(F("action")).c_str());
}
-////////////////////////////////////////////////////////////////////////////////////////////////////
-#if HASP_USE_WIFI > 0
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ #if HASP_USE_WIFI > 0
void webHandleWifiConfig()
{ // http://plate01/config/wifi
if(!httpIsAuthenticated(F("config/wifi"))) return;
@@ -1150,26 +1150,26 @@ void webHandleWifiConfig()
}
httpMessage += F("'>");
-#if HASP_USE_WIFI > 0 && !defined(STM32F4xx)
+ #if HASP_USE_WIFI > 0 && !defined(STM32F4xx)
if(WiFi.getMode() == WIFI_STA) {
httpMessage +=
PSTR("");
}
-#endif
+ #endif
webSendPage(httpGetNodename(), httpMessage.length(), false);
webServer.sendContent(httpMessage);
-#if defined(STM32F4xx)
+ #if defined(STM32F4xx)
httpMessage = "";
-#else
+ #else
httpMessage.clear();
-#endif
+ #endif
webSendFooter();
}
-#endif
+ #endif
-////////////////////////////////////////////////////////////////////////////////////////////////////
-#if HASP_USE_HTTP > 0
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ #if HASP_USE_HTTP > 0
void webHandleHttpConfig()
{ // http://plate01/config/http
if(!httpIsAuthenticated(F("config/http"))) return;
@@ -1204,10 +1204,10 @@ void webHandleHttpConfig()
// httpMessage.clear();
webSendFooter();
}
-#endif
+ #endif
-////////////////////////////////////////////////////////////////////////////////////////////////////
-#if defined(HASP_USE_GPIO) && (HASP_USE_GPIO > 0)
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ #if defined(HASP_USE_GPIO) && (HASP_USE_GPIO > 0)
void webHandleGpioConfig()
{ // http://plate01/config/gpio
if(!httpIsAuthenticated(F("config/gpio"))) return;
@@ -1224,6 +1224,11 @@ void webHandleGpioConfig()
uint8_t pinfunc = webServer.arg(F("func")).toInt();
gpioSavePinConfig(id, pin, type, group, pinfunc);
}
+ if(webServer.hasArg(PSTR("del"))) {
+ uint8_t id = webServer.arg(F("id")).toInt();
+ uint8_t pin = webServer.arg(F("pin")).toInt();
+ gpioSavePinConfig(id, pin, HASP_GPIO_FREE, 0, 0);
+ }
{
String httpMessage((char *)0);
@@ -1284,8 +1289,10 @@ void webHandleGpioConfig()
httpMessage += F("Edit Edit Delete | ");
configCount++;
}
@@ -1400,7 +1407,7 @@ void webHandleGpioOptions()
if(webServer.hasArg(F("action"))) dispatch_text_line(webServer.arg(F("action")).c_str()); // Security check
}
-#endif // HASP_USE_GPIO
+ #endif // HASP_USE_GPIO
////////////////////////////////////////////////////////////////////////////////////////////////////
void webHandleDebugConfig()
@@ -1433,7 +1440,7 @@ void webHandleDebugConfig()
httpMessage += settings[FPSTR(F_DEBUG_TELEPERIOD)].as();
httpMessage += F("'>");
-#if HASP_USE_SYSLOG > 0
+ #if HASP_USE_SYSLOG > 0
httpMessage += F("Syslog Hostame (optional)() == 1) httpMessage += F(" checked");
httpMessage += F(">BSD (RFC 3164)");
-#endif
+ #endif
httpMessage += F("");
@@ -1490,35 +1497,35 @@ void webHandleHaspConfig()
uint8_t themeid = settings[FPSTR(F_CONFIG_THEME)].as();
// httpMessage += getOption(0, F("Built-in"), themeid == 0);
-#if LV_USE_THEME_HASP == 1
+ #if LV_USE_THEME_HASP == 1
httpMessage += getOption(2, F("Hasp Dark"), themeid == 2);
httpMessage += getOption(1, F("Hasp Light"), themeid == 1);
-#endif
-#if LV_USE_THEME_EMPTY == 1
+ #endif
+ #if LV_USE_THEME_EMPTY == 1
httpMessage += getOption(0, F("Empty"), themeid == 0);
-#endif
-#if LV_USE_THEME_ALIEN == 1
+ #endif
+ #if LV_USE_THEME_ALIEN == 1
httpMessage += getOption(1, F("Alien"), themeid == 1);
-#endif
-#if LV_USE_THEME_NIGHT == 1
+ #endif
+ #if LV_USE_THEME_NIGHT == 1
httpMessage += getOption(2, F("Night"), themeid == 2);
-#endif
-#if LV_USE_THEME_MONO == 1
+ #endif
+ #if LV_USE_THEME_MONO == 1
httpMessage += getOption(3, F("Mono"), themeid == 3);
-#endif
-#if LV_USE_THEME_MATERIAL == 1
+ #endif
+ #if LV_USE_THEME_MATERIAL == 1
httpMessage += getOption(5, F("Material Dark"), themeid == 5);
httpMessage += getOption(4, F("Material Light"), themeid == 4);
-#endif
-#if LV_USE_THEME_ZEN == 1
- // httpMessage += getOption(5, F("Zen"), themeid == 5);
-#endif
-#if LV_USE_THEME_NEMO == 1
+ #endif
+ #if LV_USE_THEME_ZEN == 1
+ // httpMessage += getOption(5, F("Zen"), themeid == 5);
+ #endif
+ #if LV_USE_THEME_NEMO == 1
httpMessage += getOption(6, F("Nemo"), themeid == 6);
-#endif
-#if LV_USE_THEME_TEMPLATE == 1
+ #endif
+ #if LV_USE_THEME_TEMPLATE == 1
httpMessage += getOption(7, F("Template"), themeid == 7);
-#endif
+ #endif
httpMessage += F("");
httpMessage +=
F("Hue");
httpMessage += F("Default Font
");
httpMessage += F("Startup Layout (optional) 0 || HASP_USE_LITTLEFS > 0
+ #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
if(handleFileRead(webServer.uri())) return;
-#endif
+ #endif
-#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
+ #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
Log.notice(TAG_HTTP, F("Sending 404 to client connected from: %s"),
webServer.client().remoteIP().toString().c_str());
-#else
+ #else
// Log.notice(TAG_HTTP,F("Sending 404 to client connected from: %s"), String(webServer.client().remoteIP()).c_str());
-#endif
+ #endif
String httpMessage((char *)0);
httpMessage.reserve(HTTP_PAGE_SIZE);
@@ -1723,24 +1730,24 @@ void httpStart()
{
webServer.begin();
webServerStarted = true;
-#if HASP_USE_WIFI > 0
-#if defined(STM32F4xx)
+ #if HASP_USE_WIFI > 0
+ #if defined(STM32F4xx)
IPAddress ip;
ip = WiFi.localIP();
Log.trace(TAG_HTTP, F("Server started @ http://%d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
-#else
+ #else
Log.trace(TAG_HTTP, F("Server started @ http://%s"),
(WiFi.getMode() != WIFI_STA ? WiFi.softAPIP().toString().c_str() : WiFi.localIP().toString().c_str()));
-#endif
-#else
+ #endif
+ #else
IPAddress ip;
-#if defined(ARDUINO_ARCH_ESP32)
+ #if defined(ARDUINO_ARCH_ESP32)
ip = ETH.localIP();
-#else
+ #else
ip = Ethernet.localIP();
-#endif
+ #endif
Log.trace(TAG_HTTP, F("Server started @ http://%d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
-#endif
+ #endif
}
void httpStop()
@@ -1755,14 +1762,14 @@ void httpSetup()
{
// httpSetConfig(settings);
-#if HASP_USE_WIFI > 0
-#if !defined(STM32F4xx)
+ #if HASP_USE_WIFI > 0
+ #if !defined(STM32F4xx)
if(WiFi.getMode() != WIFI_STA) {
Log.notice(TAG_HTTP, F("Wifi access point"));
webServer.on(F("/"), webHandleWifiConfig);
} else {
-#endif
-#endif
+ #endif
+ #endif
webServer.on(F("/page/"), []() {
String pageid = webServer.arg(F("page"));
@@ -1770,7 +1777,7 @@ void httpSetup()
haspSetPage(pageid.toInt());
});
-#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
+ #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
webServer.on(F("/list"), HTTP_GET, handleFileList);
// load editor
webServer.on(F("/edit"), HTTP_GET, []() {
@@ -1791,7 +1798,7 @@ void httpSetup()
Log.verbose(TAG_HTTP, F("Headers: %d"), webServer.headers());
},
handleFileUpload);
-#endif
+ #endif
// get heap status, analog input value and all GPIO statuses in one json call
/*webServer.on(F("/all"), HTTP_GET, []() {
@@ -1816,21 +1823,21 @@ void httpSetup()
webServer.on(F("/config/http"), webHandleHttpConfig);
webServer.on(F("/config/gui"), webHandleGuiConfig);
webServer.on(F("/config/debug"), webHandleDebugConfig);
-#if HASP_USE_MQTT > 0
+ #if HASP_USE_MQTT > 0
webServer.on(F("/config/mqtt"), webHandleMqttConfig);
-#endif
-#if HASP_USE_WIFI > 0
+ #endif
+ #if HASP_USE_WIFI > 0
webServer.on(F("/config/wifi"), webHandleWifiConfig);
-#endif
-#if HASP_USE_GPIO > 0
+ #endif
+ #if HASP_USE_GPIO > 0
webServer.on(F("/config/gpio"), webHandleGpioConfig);
webServer.on(F("/config/gpio/options"), webHandleGpioOptions);
-#endif
+ #endif
webServer.on(F("/screenshot"), webHandleScreenshot);
webServer.on(F("/saveConfig"), webHandleSaveConfig);
webServer.on(F("/resetConfig"), httpHandleResetConfig);
webServer.on(F("/firmware"), webHandleFirmware);
-#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
+ #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
webServer.on(
F("/update"), HTTP_POST,
[]() {
@@ -1839,14 +1846,14 @@ void httpSetup()
},
webHandleFirmwareUpdate);
webServer.on(F("/espfirmware"), httpHandleEspFirmware);
-#endif
+ #endif
webServer.on(F("/reboot"), httpHandleReboot);
webServer.onNotFound(httpHandleNotFound);
-#if HASP_USE_WIFI > 0
-#if !defined(STM32F4xx)
+ #if HASP_USE_WIFI > 0
+ #if !defined(STM32F4xx)
}
-#endif
-#endif
+ #endif
+ #endif
// Shared pages
webServer.on(F("/about"), webHandleAbout);
@@ -1870,9 +1877,9 @@ void httpReconnect()
if(webServerStarted) {
httpStop();
} else
-#if HASP_USE_WIFI > 0 && !defined(STM32F4xx)
+ #if HASP_USE_WIFI > 0 && !defined(STM32F4xx)
if(WiFi.status() == WL_CONNECTED || WiFi.getMode() != WIFI_STA)
-#endif
+ #endif
{
httpStart();
}