From 1ddd8bc669a7b56a2b45ae4609614c55e78c6791 Mon Sep 17 00:00:00 2001 From: Magnus Persson Date: Wed, 12 Oct 2022 19:51:38 +0200 Subject: [PATCH] Removed upload functions (not used) --- html/upload.htm | 179 -------------------- html/upload.min.htm | 1 - script/copy_html.py | 34 ---- src/resources.cpp | 10 +- src/webserver.cpp | 305 +++++----------------------------- src/webserver.hpp | 68 +++++--- src_docs/source/compiling.rst | 2 - 7 files changed, 82 insertions(+), 517 deletions(-) delete mode 100644 html/upload.htm delete mode 100644 html/upload.min.htm delete mode 100644 script/copy_html.py diff --git a/html/upload.htm b/html/upload.htm deleted file mode 100644 index db63b5a..0000000 --- a/html/upload.htm +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - Beer Gravity Monitor - - - - - - - - - - - - - - - -
- - - - - -
-
-

- -

-
-
- -
-
The listed files below needs to be uploaded to the FileSystem in order for the GUI to work. - You can also flash the LittleFS filesystem but in that case you will loose your device settings. An OTA upgrade will automatically download - the files if they are found in the same location as the firmware.bin. This page is a fallback option. -
-

Once all the files are confirmed, please reboot the device for normal operation.
-
- -
-
index.min.htm
-
Checking...
-
-
-
config.min.htm
-
Checking...
-
-
-
calibration.min.htm
-
Checking...
-
-
-
format.min.htm
-
Checking...
-
-
-
test.min.htm
-
Checking...
-
-
-
about.min.htm
-
Checking...
-
- -
-
-
- -
-
-
-
- -
-
-
- -
-
-
-
-
- - - - - -
(C) Copyright 2021-22 Magnus Persson
- - \ No newline at end of file diff --git a/html/upload.min.htm b/html/upload.min.htm deleted file mode 100644 index d197c8a..0000000 --- a/html/upload.min.htm +++ /dev/null @@ -1 +0,0 @@ -Beer Gravity Monitor

The listed files below needs to be uploaded to the FileSystem in order for the GUI to work. You can also flash the LittleFS filesystem but in that case you will loose your device settings. An OTA upgrade will automatically download the files if they are found in the same location as the firmware.bin. This page is a fallback option.

Once all the files are confirmed, please reboot the device for normal operation.
index.min.htm
Checking...
config.min.htm
Checking...
calibration.min.htm
Checking...
format.min.htm
Checking...
test.min.htm
Checking...
about.min.htm
Checking...
(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/script/copy_html.py b/script/copy_html.py deleted file mode 100644 index b925881..0000000 --- a/script/copy_html.py +++ /dev/null @@ -1,34 +0,0 @@ -Import("env") -import shutil, os - -print( "Executing custom step " ) -dir = env.GetLaunchDir() -source = dir + "/html/" -target = dir + "/data/" -print( "Copy html-files from " + source + " -> " + target ) - -os.makedirs(os.path.dirname( target ), exist_ok=True) -file = "about.min.htm" -#print( "Copy file: " + source + file + "->" + target + file) -shutil.copyfile( source + file, target + file ) -file = "calibration.min.htm" -#print( "Copy file: " + source + file + "->" + target + file) -shutil.copyfile( source + file, target + file ) -file = "config.min.htm" -#print( "Copy file: " + source + file + "->" + target + file) -shutil.copyfile( source + file, target + file ) -file = "index.min.htm" -#print( "Copy file: " + source + file + "->" + target + file) -shutil.copyfile( source + file, target + file ) -file = "upload.min.htm" -#print( "Copy file: " + source + file + "->" + target + file) -shutil.copyfile( source + file, target + file ) -file = "format.min.htm" -#print( "Copy file: " + source + file + "->" + target + file) -shutil.copyfile( source + file, target + file ) -file = "test.min.htm" -#print( "Copy file: " + source + file + "->" + target + file) -shutil.copyfile( source + file, target + file ) -file = "firmware.min.htm" -#print( "Copy file: " + source + file + "->" + target + file) -shutil.copyfile( source + file, target + file ) diff --git a/src/resources.cpp b/src/resources.cpp index f57792c..277f0af 100644 --- a/src/resources.cpp +++ b/src/resources.cpp @@ -23,23 +23,15 @@ SOFTWARE. */ #if defined(ESP8266) #define INCBIN_OUTPUT_SECTION ".irom.text" -#endif #include - #include - -#if defined(EMBED_HTML) -// Using minify to reduce memory usage. Reducing RAM memory usage with about 7% INCBIN(IndexHtm, "data/index.min.htm"); INCBIN(ConfigHtm, "data/config.min.htm"); INCBIN(CalibrationHtm, "data/calibration.min.htm"); INCBIN(FormatHtm, "data/format.min.htm"); INCBIN(TestHtm, "data/test.min.htm"); INCBIN(AboutHtm, "data/about.min.htm"); -#else -// Minium web interface for uploading htm files -INCBIN(UploadHtm, "data/upload.min.htm"); -#endif INCBIN(FirmwareHtm, "data/firmware.min.htm"); +#endif // EOF diff --git a/src/webserver.cpp b/src/webserver.cpp index 4bcaf24..3ec2b1e 100644 --- a/src/webserver.cpp +++ b/src/webserver.cpp @@ -37,9 +37,6 @@ WebServerHandler myWebServerHandler; // My wrapper class fr webserver functions extern bool sleepModeActive; extern bool sleepModeAlwaysSkip; -// -// Callback from webServer when / has been accessed. -// void WebServerHandler::webHandleConfig() { LOG_PERF_START("webserver-api-config"); Log.notice(F("WEB : webServer callback for /api/config(get)." CR)); @@ -107,173 +104,65 @@ void WebServerHandler::webHandleConfig() { LOG_PERF_STOP("webserver-api-config"); } -// -// Callback from webServer when / has been accessed. -// -void WebServerHandler::webHandleUpload() { - LOG_PERF_START("webserver-api-upload"); - Log.notice(F("WEB : webServer callback for /api/upload(get)." CR)); - DynamicJsonDocument doc(300); - - doc["index"] = checkHtmlFile(WebServerHandler::HTML_INDEX); - doc["config"] = checkHtmlFile(WebServerHandler::HTML_CONFIG); - doc["calibration"] = checkHtmlFile(WebServerHandler::HTML_CALIBRATION); - doc["format"] = checkHtmlFile(WebServerHandler::HTML_FORMAT); - doc["about"] = checkHtmlFile(WebServerHandler::HTML_ABOUT); - doc["test"] = checkHtmlFile(WebServerHandler::HTML_TEST); - -#if defined(ESP8266) - JsonArray files = doc.createNestedArray(PARAM_FILES); - - // Show files in the filessytem at startup - FSInfo fs; - LittleFS.info(fs); - Dir dir = LittleFS.openDir("/"); - while (dir.next()) { - JsonObject obj = files.createNestedObject(); - obj[PARAM_FILE_NAME] = dir.fileName(); - obj[PARAM_FILE_SIZE] = dir.fileSize(); - } -#else // defined(ESP32) - JsonArray files = doc.createNestedArray(PARAM_FILES); - - File dir = LittleFS.open("/"); - - while (true) { - File entry = dir.openNextFile(); - if (!entry) { - // no more files - break; - } - - if (!entry.isDirectory()) { - JsonObject obj = files.createNestedObject(); - obj[PARAM_FILE_NAME] = entry.name(); - obj[PARAM_FILE_SIZE] = entry.size(); - } - entry.close(); - } - dir.close(); -#endif - -#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING) - serializeJson(doc, Serial); - Serial.print(CR); -#endif - - String out; - out.reserve(300); - serializeJson(doc, out); - doc.clear(); - _server->send(200, "application/json", out.c_str()); - LOG_PERF_STOP("webserver-api-upload"); -} void WebServerHandler::webHandleUploadFile() { LOG_PERF_START("webserver-api-upload-file"); Log.verbose(F("WEB : webServer callback for /api/upload(post)." CR)); HTTPUpload& upload = _server->upload(); String f = upload.filename; - bool validFilename = false; - bool firmware = false; - - if (f.equalsIgnoreCase("index.min.htm") || - f.equalsIgnoreCase("calibration.min.htm") || - f.equalsIgnoreCase("config.min.htm") || - f.equalsIgnoreCase("format.min.htm") || - f.equalsIgnoreCase("test.min.htm") || - f.equalsIgnoreCase("about.min.htm")) { - validFilename = true; - } - - if (f.endsWith(".bin")) { - validFilename = true; - firmware = true; - } #if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING) Log.verbose( - F("WEB : webServer callback for /api/upload, receiving file %s, %d(%d) " - "valid=%s, firmware=%s." CR), - f.c_str(), upload.currentSize, upload.totalSize, - validFilename ? "yes" : "no", firmware ? "yes" : "no"); + F("WEB : webServer callback for /api/upload, receiving file %s, %d(%d)." CR), + f.c_str(), upload.currentSize, upload.totalSize); #endif - if (firmware) { - // Handle firmware update, hardcode since function return wrong value. - // (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000; - uint32_t maxSketchSpace = MAX_SKETCH_SPACE; + // Handle firmware update, hardcode since function return wrong value. + // (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000; + uint32_t maxSketchSpace = MAX_SKETCH_SPACE; - if (upload.status == UPLOAD_FILE_START) { - _uploadReturn = 200; - Log.notice(F("WEB : Start firmware upload, max sketch size %d kb." CR), - maxSketchSpace / 1024); + if (upload.status == UPLOAD_FILE_START) { + _uploadReturn = 200; + Log.notice(F("WEB : Start firmware upload, max sketch size %d kb." CR), + maxSketchSpace / 1024); - if (!Update.begin(maxSketchSpace, U_FLASH, PIN_LED)) { - writeErrorLog("WEB : Not enough space to store for this firmware."); - _uploadReturn = 500; - } - } else if (upload.status == UPLOAD_FILE_WRITE) { - Log.notice(F("WEB : Writing firmware upload %d (%d)." CR), - upload.totalSize, maxSketchSpace); - - if (upload.totalSize > maxSketchSpace) { - Log.error(F("WEB : Firmware file is to large." CR)); - _uploadReturn = 500; - } else if (Update.write(upload.buf, upload.currentSize) != - upload.currentSize) { - Log.warning(F("WEB : Firmware write was unsuccessful." CR)); - _uploadReturn = 500; - } - } else if (upload.status == UPLOAD_FILE_END) { - Log.notice(F("WEB : Finish firmware upload." CR)); - if (Update.end(true)) { - _server->send(200); - delay(500); - ESP_RESET(); - } else { - writeErrorLog("WEB : Failed to finish firmware flashing error=%d", - Update.getError()); - _uploadReturn = 500; - } - } else { - Update.end(); - Log.notice(F("WEB : Firmware flashing aborted." CR)); + if (!Update.begin(maxSketchSpace, U_FLASH, PIN_LED)) { + writeErrorLog("WEB : Not enough space to store for this firmware."); _uploadReturn = 500; } + } else if (upload.status == UPLOAD_FILE_WRITE) { + Log.notice(F("WEB : Writing firmware upload %d (%d)." CR), + upload.totalSize, maxSketchSpace); - delay(0); - - } else { - // Handle HTML file upload - if (upload.status == UPLOAD_FILE_START) { - _uploadReturn = 200; - Log.notice(F("WEB : Start html upload." CR)); - - if (validFilename) _uploadFile = LittleFS.open(f, "w"); - } else if (upload.status == UPLOAD_FILE_WRITE) { - Log.notice(F("WEB : Writing html upload." CR)); - if (_uploadFile) _uploadFile.write(upload.buf, upload.currentSize); - } else if (upload.status == UPLOAD_FILE_END) { - Log.notice(F("WEB : Finish html upload." CR)); - if (_uploadFile) { - _uploadFile.close(); - Log.notice(F("WEB : Html file uploaded %d bytes." CR), - upload.totalSize); - } - _server->sendHeader("Location", "/"); - _server->send(303); - } else { - _server->send(500, "text/plain", "Couldn't upload html file."); + if (upload.totalSize > maxSketchSpace) { + Log.error(F("WEB : Firmware file is to large." CR)); + _uploadReturn = 500; + } else if (Update.write(upload.buf, upload.currentSize) != + upload.currentSize) { + Log.warning(F("WEB : Firmware write was unsuccessful." CR)); + _uploadReturn = 500; } + } else if (upload.status == UPLOAD_FILE_END) { + Log.notice(F("WEB : Finish firmware upload." CR)); + if (Update.end(true)) { + _server->send(200); + delay(500); + ESP_RESET(); + } else { + writeErrorLog("WEB : Failed to finish firmware flashing error=%d", + Update.getError()); + _uploadReturn = 500; + } + } else { + Update.end(); + Log.notice(F("WEB : Firmware flashing aborted." CR)); + _uploadReturn = 500; } + delay(0); LOG_PERF_STOP("webserver-api-upload-file"); } -// -// Callback from webServer when / has been accessed. -// void WebServerHandler::webHandleCalibrate() { LOG_PERF_START("webserver-api-calibrate"); String id = _server->arg(PARAM_ID); @@ -439,9 +328,6 @@ void WebServerHandler::webHandleStatusSleepmode() { LOG_PERF_STOP("webserver-api-sleepmode"); } -// -// Update device settings. -// void WebServerHandler::webHandleConfigDevice() { LOG_PERF_START("webserver-api-config-device"); String id = _server->arg(PARAM_ID); @@ -471,9 +357,6 @@ void WebServerHandler::webHandleConfigDevice() { LOG_PERF_STOP("webserver-api-config-device"); } -// -// Update push settings. -// void WebServerHandler::webHandleConfigPush() { LOG_PERF_START("webserver-api-config-push"); String id = _server->arg(PARAM_ID); @@ -535,9 +418,6 @@ void WebServerHandler::webHandleConfigPush() { LOG_PERF_STOP("webserver-api-config-push"); } -// -// Get string with all received arguments. Used for debugging only. -// String WebServerHandler::getRequestArguments() { String debug; @@ -554,9 +434,6 @@ String WebServerHandler::getRequestArguments() { return debug; } -// -// Update gravity settings. -// void WebServerHandler::webHandleConfigGravity() { LOG_PERF_START("webserver-api-config-gravity"); String id = _server->arg(PARAM_ID); @@ -591,9 +468,6 @@ void WebServerHandler::webHandleConfigGravity() { LOG_PERF_STOP("webserver-api-config-gravity"); } -// -// Update hardware settings. -// void WebServerHandler::webHandleConfigHardware() { LOG_PERF_START("webserver-api-config-hardware"); String id = _server->arg(PARAM_ID); @@ -645,9 +519,6 @@ void WebServerHandler::webHandleConfigHardware() { LOG_PERF_STOP("webserver-api-config-hardware"); } -// -// Update advanced settings. -// void WebServerHandler::webHandleConfigAdvancedWrite() { LOG_PERF_START("webserver-api-config-advanced"); String id = _server->arg(PARAM_ID); @@ -723,9 +594,6 @@ void WebServerHandler::webHandleConfigAdvancedWrite() { LOG_PERF_STOP("webserver-api-config-advanced"); } -// -// Read advanced settings -// void WebServerHandler::webHandleConfigAdvancedRead() { LOG_PERF_START("webserver-api-config-advanced"); Log.notice(F("WEB : webServer callback for /api/config/advanced(get)." CR)); @@ -766,9 +634,6 @@ void WebServerHandler::webHandleConfigAdvancedRead() { LOG_PERF_STOP("webserver-api-config-advanced"); } -// -// Callback from webServer when / has been accessed. -// void WebServerHandler::webHandleFormulaRead() { LOG_PERF_START("webserver-api-formula-read"); Log.notice(F("WEB : webServer callback for /api/formula(get)." CR)); @@ -852,9 +717,6 @@ void WebServerHandler::webHandleFormulaRead() { LOG_PERF_STOP("webserver-api-formula-read"); } -// -// Update format template -// void WebServerHandler::webHandleConfigFormatWrite() { LOG_PERF_START("webserver-api-config-format-write"); String id = _server->arg(PARAM_ID); @@ -898,9 +760,6 @@ void WebServerHandler::webHandleConfigFormatWrite() { LOG_PERF_STOP("webserver-api-config-format-write"); } -// -// Get format with real data -// void WebServerHandler::webHandleTestPush() { LOG_PERF_START("webserver-api-test-push"); String id = _server->arg(PARAM_ID); @@ -969,10 +828,6 @@ void WebServerHandler::webHandleTestPush() { LOG_PERF_STOP("webserver-api-test-push"); } -// -// Write file to disk, if there is no data then delete the current file (if it -// exists) = reset to default. -// bool WebServerHandler::writeFile(String fname, String data) { if (data.length()) { data = urldecode(data); @@ -998,9 +853,6 @@ bool WebServerHandler::writeFile(String fname, String data) { return false; } -// -// Read file from disk -// String WebServerHandler::readFile(String fname) { File file = LittleFS.open(fname, "r"); if (file) { @@ -1014,9 +866,6 @@ String WebServerHandler::readFile(String fname) { return ""; } -// -// Get format templates -// void WebServerHandler::webHandleConfigFormatRead() { LOG_PERF_START("webserver-api-config-format-read"); Log.notice(F("WEB : webServer callback for /api/config/formula(get)." CR)); @@ -1071,9 +920,6 @@ void WebServerHandler::webHandleConfigFormatRead() { LOG_PERF_STOP("webserver-api-config-format-read"); } -// -// Update hardware settings. -// void WebServerHandler::webHandleFormulaWrite() { LOG_PERF_START("webserver-api-formula-write"); String id = _server->arg(PARAM_ID); @@ -1166,57 +1012,11 @@ void WebServerHandler::webHandleFormulaWrite() { LOG_PERF_STOP("webserver-api-formula-write"); } -// -// Helper function to check if files exist on file system. -// -const char* WebServerHandler::getHtmlFileName(HtmlFile item) { - Log.notice(F("WEB : Looking up filename for %d." CR), item); - - switch (item) { - case HtmlFile::HTML_INDEX: - return "index.min.htm"; - case HtmlFile::HTML_CONFIG: - return "config.min.htm"; - case HtmlFile::HTML_CALIBRATION: - return "calibration.min.htm"; - case HtmlFile::HTML_FORMAT: - return "format.min.htm"; - case HtmlFile::HTML_ABOUT: - return "about.min.htm"; - case HtmlFile::HTML_TEST: - return "test.min.htm"; - } - - return ""; -} - -// -// Helper function to check if files exist on file system. -// -bool WebServerHandler::checkHtmlFile(HtmlFile item) { - const char* fn = getHtmlFileName(item); - -#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING) - Log.verbose(F("WEB : Checking for file %s." CR), fn); -#endif - - // TODO: We might need to add more checks here like zero file size etc. But - // for now we only check if the file exist. - - return LittleFS.exists(fn); -} - -// -// Handler for page not found -// void WebServerHandler::webHandlePageNotFound() { Log.error(F("WEB : URL not found %s received." CR), _server->uri().c_str()); _server->send(404, "text/plain", F("URL not found")); } -// -// Setup the Web Server callbacks and start it -// bool WebServerHandler::setupWebServer() { Log.notice(F("WEB : Configuring web server." CR)); @@ -1240,7 +1040,7 @@ bool WebServerHandler::setupWebServer() { LittleFS.remove(dir.fileName().c_str()); } } -#else // defined( ESP32 ) +#else File root = LittleFS.open("/"); File f = root.openNextFile(); while (f) { @@ -1258,7 +1058,6 @@ bool WebServerHandler::setupWebServer() { // Static content Log.notice(F("WEB : Setting up handlers for web server." CR)); -#if defined(EMBED_HTML) _server->on("/", std::bind(&WebServerHandler::webReturnIndexHtm, this)); _server->on("/index.htm", std::bind(&WebServerHandler::webReturnIndexHtm, this)); @@ -1272,31 +1071,6 @@ bool WebServerHandler::setupWebServer() { std::bind(&WebServerHandler::webReturnAboutHtm, this)); _server->on("/test.htm", std::bind(&WebServerHandler::webReturnTestHtm, this)); -#else - // Check if the html files exist, if so serve them, else show the static - // upload page. - if (checkHtmlFile(HTML_INDEX) && checkHtmlFile(HTML_CONFIG) && - checkHtmlFile(HTML_CALIBRATION) && checkHtmlFile(HTML_FORMAT) && - checkHtmlFile(HTML_ABOUT) && checkHtmlFile(HTML_TEST)) { - Log.notice(F("WEB : All html files exist, starting in normal mode." CR)); - - _server->serveStatic("/", LittleFS, "/index.min.htm"); - _server->serveStatic("/index.htm", LittleFS, "/index.min.htm"); - _server->serveStatic("/config.htm", LittleFS, "/config.min.htm"); - _server->serveStatic("/about.htm", LittleFS, "/about.min.htm"); - _server->serveStatic("/test.htm", LittleFS, "/test.min.htm"); - _server->serveStatic("/calibration.htm", LittleFS, "/calibration.min.htm"); - _server->serveStatic("/format.htm", LittleFS, "/format.min.htm"); - - // Also add the static upload view in case we we have issues that needs to - // be fixed. - _server->on("/upload.htm", - std::bind(&WebServerHandler::webReturnUploadHtm, this)); - } else { - Log.error(F("WEB : Missing html files, starting with upload UI." CR)); - _server->on("/", std::bind(&WebServerHandler::webReturnUploadHtm, this)); - } -#endif _server->on("/firmware.htm", std::bind(&WebServerHandler::webReturnFirmwareHtm, this)); _server->serveStatic("/log", LittleFS, ERR_FILENAME); @@ -1320,9 +1094,6 @@ bool WebServerHandler::setupWebServer() { std::bind(&WebServerHandler::webHandleStatus, this)); _server->on("/api/clearwifi", HTTP_GET, std::bind(&WebServerHandler::webHandleClearWIFI, this)); - _server->on( - "/api/upload", HTTP_GET, - std::bind(&WebServerHandler::webHandleUpload, this)); // Get upload.json _server->on("/api/upload", HTTP_POST, std::bind(&WebServerHandler::webReturnOK, this), diff --git a/src/webserver.hpp b/src/webserver.hpp index e820098..38e9bb7 100644 --- a/src/webserver.hpp +++ b/src/webserver.hpp @@ -29,26 +29,39 @@ SOFTWARE. #include #include #define MAX_SKETCH_SPACE 1044464 -#else // defined (ESP32) +#else #include #include #include #include #define MAX_SKETCH_SPACE 1835008 #endif -#include -#if defined(EMBED_HTML) +#if defined(ESP8266) +#include INCBIN_EXTERN(IndexHtm); INCBIN_EXTERN(ConfigHtm); INCBIN_EXTERN(CalibrationHtm); INCBIN_EXTERN(FormatHtm); INCBIN_EXTERN(TestHtm); INCBIN_EXTERN(AboutHtm); -#else -INCBIN_EXTERN(UploadHtm); -#endif INCBIN_EXTERN(FirmwareHtm); +#else +extern const uint8_t indexHtmStart[] asm("_binary_html_index_min_htm_start"); +extern const uint8_t indexHtmEnd[] asm("_binary_html_index_min_htm_end"); +extern const uint8_t configHtmStart[] asm("_binary_html_config_min_htm_start"); +extern const uint8_t configHtmEnd[] asm("_binary_html_config_min_htm_end"); +extern const uint8_t calibrationHtmStart[] asm("_binary_html_calibration_min_htm_start"); +extern const uint8_t calibrationHtmEnd[] asm("_binary_html_calibration_min_htm_end"); +extern const uint8_t formatHtmStart[] asm("_binary_html_format_min_htm_start"); +extern const uint8_t formatHtmEnd[] asm("_binary_html_format_min_htm_end"); +extern const uint8_t testHtmStart[] asm("_binary_html_test_min_htm_start"); +extern const uint8_t testHtmEnd[] asm("_binary_html_test_min_htm_end"); +extern const uint8_t aboutHtmStart[] asm("_binary_html_about_min_htm_start"); +extern const uint8_t aboutHtmEnd[] asm("_binary_html_about_min_htm_end"); +extern const uint8_t firmwareHtmStart[] asm("_binary_html_firmware_min_htm_start"); +extern const uint8_t firmwareHtmEnd[] asm("_binary_html_firmware_min_htm_end"); +#endif class WebServerHandler { private: @@ -75,7 +88,6 @@ class WebServerHandler { void webHandleFactoryDefaults(); void webHandleCalibrate(); void webHandleUploadFile(); - void webHandleUpload(); void webHandleLogClear(); void webHandlePageNotFound(); @@ -86,7 +98,7 @@ class WebServerHandler { // Inline functions. void webReturnOK() { _server->send(_uploadReturn); } -#if defined(EMBED_HTML) +#if defined(ESP8266) void webReturnIndexHtm() { _server->send_P(200, "text/html", (const char*)gIndexHtmData, gIndexHtmSize); @@ -110,31 +122,37 @@ class WebServerHandler { void webReturnTestHtm() { _server->send_P(200, "text/html", (const char*)gTestHtmData, gTestHtmSize); } -#else - void webReturnUploadHtm() { - _server->send_P(200, "text/html", (const char*)gUploadHtmData, - gUploadHtmSize); - } -#endif void webReturnFirmwareHtm() { _server->send_P(200, "text/html", (const char*)gFirmwareHtmData, gFirmwareHtmSize); } +#else + void webReturnIndexHtm() { + _server->send_P(200, "text/html", (const char*)indexHtmStart, indexHtmEnd-indexHtmStart); + } + void webReturnConfigHtm() { + _server->send_P(200, "text/html", (const char*)configHtmStart, configHtmEnd-configHtmStart); + } + void webReturnCalibrationHtm() { + _server->send_P(200, "text/html", (const char*)calibrationHtmStart, calibrationHtmEnd-calibrationHtmStart); + } + void webReturnFormatHtm() { + _server->send_P(200, "text/html", (const char*)formatHtmStart, formatHtmEnd-formatHtmStart); + } + void webReturnAboutHtm() { + _server->send_P(200, "text/html", (const char*)aboutHtmStart, aboutHtmEnd-aboutHtmStart); + } + void webReturnTestHtm() { + _server->send_P(200, "text/html", (const char*)testHtmStart, testHtmEnd-testHtmStart); + } + void webReturnFirmwareHtm() { + _server->send_P(200, "text/html", (const char*)firmwareHtmStart, firmwareHtmEnd-firmwareHtmStart); + } +#endif public: - enum HtmlFile { - HTML_INDEX = 0, - HTML_CONFIG = 1, - HTML_ABOUT = 2, - HTML_CALIBRATION = 3, - HTML_FORMAT = 4, - HTML_TEST = 5 - }; - bool setupWebServer(); void loop(); - bool checkHtmlFile(HtmlFile item); - const char* getHtmlFileName(HtmlFile item); }; // Global instance created diff --git a/src_docs/source/compiling.rst b/src_docs/source/compiling.rst index fe824a9..25e92ad 100644 --- a/src_docs/source/compiling.rst +++ b/src_docs/source/compiling.rst @@ -91,8 +91,6 @@ This is a list of C++ defines that is used to enable/disable functions in the co - Done include verbose logging in the corresponding class. Excessive logging may crash device. * - USE_LITTLEFS - Use the new filesystem in Ardurino - * - EMBED_HTML - - Html files are included in code, if not defined they are served from the file system. * - USER_SSID - If defined the device will always use this SSID * - USER_SSID_PWD