diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp index 6070cad7..9019cf37 100644 --- a/src/sys/svc/hasp_http.cpp +++ b/src/sys/svc/hasp_http.cpp @@ -82,9 +82,6 @@ extern const uint8_t SCRIPT_JS_GZ_END[] asm("_binary_data_script_js_gz_end"); HTTPUpload* upload; -// const char HTTP_MENU_BUTTON[] PROGMEM = -// "

"; - const char MAIN_MENU_BUTTON[] PROGMEM = "" D_HTTP_MAIN_MENU ""; const char HTTP_DOCTYPE[] PROGMEM = " // String lcdFirmwareUrl = "http://haswitchplate.com/update/HASwitchPlate.tft"; //////////////////////////////////////////////////////////////////////////////////////////////////// -String getOption(int value, String label, int current_value) +String getOption(int value, String label, int current_value = INT_MIN) { char buffer[128]; snprintf_P(buffer, sizeof(buffer), PSTR(""), value, @@ -250,15 +247,9 @@ static void webSendHeader(const char* nodename, uint32_t httpdatalength, uint8_t } #if defined(STM32F4xx) - // webServer.sendContent(HTTP_SCRIPT); // 131 - // webServer.sendContent(HTTP_STYLE); // 487 - // webServer.sendContent(HASP_STYLE); // 145 webServer.sendContent(HTTP_HEADER_END); // 80 #else - // webServer.sendContent_P(HTTP_SCRIPT); // 131 - // webServer.sendContent_P(HTTP_STYLE); // 487 - // webServer.sendContent_P(HASP_STYLE); // 145 - webServer.sendContent_P(HTTP_HEADER_END); // 80 + webServer.sendContent_P(HTTP_HEADER_END); // 80 #endif } @@ -488,7 +479,7 @@ static void webHandleApiConfig() return; } - DynamicJsonDocument doc(800); + DynamicJsonDocument doc(1024); JsonObject settings; String contentType = getContentType(F(".json")); String endpoint((char*)0); @@ -786,7 +777,6 @@ static void webHandleFirmwareUpload() #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 static int handleFileRead(String path) { - // if(!httpIsAuthenticated(F("fileread"))) return false; if(!httpIsAuthenticated()) return false; path = webServer.urlDecode(path).substring(0, 31); @@ -896,7 +886,6 @@ static void handleFileUpload() LOG_ERROR(TAG_HTTP, F("Filename %s is too long"), filename.c_str()); } } else if(upload->status == UPLOAD_FILE_WRITE) { - // DBG_OUTPUT_PORT.print("handleFileUpload Data: "); debugPrintln(upload.currentSize); if(fsUploadFile) { if(fsUploadFile.write(upload->buf, upload->currentSize) != upload->currentSize) { LOG_ERROR(TAG_HTTP, F("Failed to write received data to file")); @@ -916,8 +905,6 @@ static void handleFileUpload() webServer.send_P(400, PSTR("text/plain"), "Bad Request"); } haspProgressVal(255); - - // httpReconnect(); } } @@ -941,7 +928,6 @@ static void handleFileDelete() } HASP_FS.remove(path); webServer.send_P(200, mimetype, PSTR("")); - // path.clear(); } static void handleFileCreate() @@ -1156,7 +1142,6 @@ static void webHandleMqttConfig() httpMessage += F("
"); // Submit & End Form @@ -1179,9 +1164,6 @@ static void webHandleGuiConfig() if(!httpIsAuthenticated(F("config/gui"))) return; { // Send Content - StaticJsonDocument<256> settings; - guiGetConfig(settings.to()); - String httpMessage((char*)0); httpMessage.reserve(HTTP_PAGE_SIZE); httpMessage += F("

"); @@ -1196,61 +1178,55 @@ static void webHandleGuiConfig() httpMessage += F("
"); httpMessage += F("
"); // Long Idle httpMessage += F("
"); httpMessage += F("
"); // Rotation - int8_t rotation = -1; // settings[FPSTR(FP_GUI_ROTATION)].as(); httpMessage += F("
"); httpMessage += F("
"); // Invert httpMessage += F("
"); httpMessage += F("
()) httpMessage += F(" checked"); httpMessage += F(">Invert Colors
"); // Cursor httpMessage += F("
"); httpMessage += F("
()) httpMessage += F(" checked"); httpMessage += F(">Show Pointer
"); // Backlight Pin - int8_t bcklpin = settings[FPSTR(FP_GUI_BACKLIGHTPIN)].as(); httpMessage += F("
"); httpMessage += F("
"); @@ -1289,9 +1265,6 @@ static void webHandleWifiConfig() if(!httpIsAuthenticated(F("config/wifi"))) return; { // Send Content - StaticJsonDocument<256> settings; - wifiGetConfig(settings.to()); - String httpMessage((char*)0); httpMessage.reserve(HTTP_PAGE_SIZE); httpMessage += F("

"); @@ -1307,7 +1280,6 @@ static void webHandleWifiConfig() httpMessage += F("
"); // Wifi Password @@ -1315,9 +1287,6 @@ static void webHandleWifiConfig() httpMessage += F("
"); // Submit & End Form @@ -1350,9 +1319,6 @@ static void webHandleHttpConfig() if(!httpIsAuthenticated(F("config/http"))) return; { // Send Content - StaticJsonDocument<256> settings; - httpGetConfig(settings.to()); - String httpMessage((char*)0); httpMessage.reserve(HTTP_PAGE_SIZE); httpMessage += F("

"); @@ -1367,16 +1333,12 @@ static void webHandleHttpConfig() httpMessage += F("
"); httpMessage += F("
"); // Password httpMessage += F("
"); httpMessage += F("
"); // Submit & End Form @@ -1585,9 +1547,6 @@ static void webHandleGpioOutput() if(!httpIsAuthenticated(F("config/gpio/options"))) return; { // Send Content - StaticJsonDocument<256> settings; - guiGetConfig(settings.to()); - uint8_t config_id = webServer.arg(F("id")).toInt(); String httpMessage((char*)0); @@ -1668,9 +1627,6 @@ static void webHandleGpioInput() if(!httpIsAuthenticated(F("config/gpio/input"))) return; { // Send Content - StaticJsonDocument<256> settings; - guiGetConfig(settings.to()); - uint8_t config_id = webServer.arg(F("id")).toInt(); String httpMessage((char*)0); @@ -1760,9 +1716,6 @@ static void webHandleDebugConfig() if(!httpIsAuthenticated(F("config/debug"))) return; { // Send Content - StaticJsonDocument<256> settings; - debugGetConfig(settings.to()); - String httpMessage((char*)0); httpMessage.reserve(HTTP_PAGE_SIZE); httpMessage += F("

"); @@ -1774,33 +1727,30 @@ static void webHandleDebugConfig() httpMessage += F("
"); // Baudrate - uint16_t baudrate = settings[FPSTR(FP_CONFIG_BAUD)].as(); httpMessage += F("
"); httpMessage += F("
"); // Telemetry Period httpMessage += F("
"); httpMessage += F("
"); // Invert httpMessage += F("
"); httpMessage += F("
()) httpMessage += F(" checked"); httpMessage += F(">Use ANSI Colors
"); #if HASP_USE_SYSLOG > 0 @@ -1809,32 +1759,26 @@ static void webHandleDebugConfig() httpMessage += F("
"); // Syslog Port httpMessage += F("
"); httpMessage += F("
"); // Syslog Facility - uint8_t logid = settings[FPSTR(FP_CONFIG_LOG)].as(); httpMessage += F("
"); httpMessage += F("
"); // Syslog Protocol - uint8_t proto = settings[FPSTR(FP_CONFIG_PROTOCOL)].as(); httpMessage += F("
"); httpMessage += F("
IETF (RFC 5424)   BSD (RFC 3164)"); httpMessage += F("
"); #endif @@ -1860,9 +1804,6 @@ static void webHandleHaspConfig() if(!httpIsAuthenticated(F("config/hasp"))) return; { // Send Content - StaticJsonDocument<256> settings; - haspGetConfig(settings.to()); - String httpMessage((char*)0); httpMessage.reserve(HTTP_PAGE_SIZE); httpMessage += F("

"); @@ -1897,33 +1838,25 @@ static void webHandleHaspConfig() // Theme httpMessage += F("
"); httpMessage += F("
"); - // Hue - // httpMessage += F("
"); - // httpMessage += F("
"); - // Primary Color httpMessage += F("
"); httpMessage += F("
"); @@ -1936,23 +1869,19 @@ static void webHandleHaspConfig() httpMessage += F("
"); httpMessage += F("
"); - httpMessage += getOption(0, F("Disabled"), -1); - httpMessage += getOption(1, F("Strict"), -1); - httpMessage += getOption(2, F("Always"), -1); + httpMessage += getOption(0, F("Disabled")); + httpMessage += getOption(1, F("Strict")); + httpMessage += getOption(2, F("Always")); httpMessage += F("
"); // Submit & End Form @@ -2119,14 +2048,6 @@ static void webHandleFirmware() //////////////////////////////////////////////////////////////////////////////////////////////////// #if HASP_USE_CONFIG > 0 -// static void webHandleSaveConfig() -// { -// if(!httpIsAuthenticated(F("saveConfig"))) return; - -// configWrite(); -// } - -//////////////////////////////////////////////////////////////////////////////////////////////////// static void httpHandleResetConfig() { // http://plate01/config/reset if(!httpIsAuthenticated(F("reset"))) return; @@ -2268,8 +2189,6 @@ static inline void webStartConfigPortal() void httpSetup() { - // httpSetConfig(settings); - // ask server to track these headers const char* headerkeys[] = {"Content-Length"}; // "Authentication" size_t headerkeyssize = sizeof(headerkeys) / sizeof(char*); @@ -2341,7 +2260,6 @@ void httpSetup() webServer.on(F("/"), webHandleRoot); webServer.on(F("/info"), webHandleInfoJson); - // webServer.on(F("/info"), webHandleInfo); webServer.on(F("/screenshot"), webHandleScreenshot); webServer.on(F("/reboot"), httpHandleReboot); @@ -2361,7 +2279,6 @@ void httpSetup() webServer.on(F("/config/gpio/options"), webHandleGpioOutput); webServer.on(F("/config/gpio/input"), webHandleGpioInput); #endif - // webServer.on(F("/saveConfig"), webHandleSaveConfig); webServer.on(F("/config/reset"), httpHandleResetConfig); #endif // HASP_USE_CONFIG webServer.onNotFound(httpHandleFileFromFlash); @@ -2370,24 +2287,6 @@ void httpSetup() // webStart(); Wait for network connection } -//////////////////////////////////////////////////////////////////////////////////////////////////// -/* -static void httpReconnect() -{ - if(!http_config.enable) return; - - if(webServerStarted) { - httpStop(); - } else -#if HASP_USE_WIFI > 0 && !defined(STM32F4xx) - if(WiFi.status() == WL_CONNECTED || WiFi.getMode() != WIFI_STA) -#endif - { - httpStart(); - } -} -*/ - //////////////////////////////////////////////////////////////////////////////////////////////////// IRAM_ATTR void httpLoop(void) {