From d5f76b16b9ec7a62ac7d9c72b4a2f57453b75edf Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 30 Dec 2020 14:52:39 -0800 Subject: [PATCH 1/4] write readLength to debug console --- src/meshwifi/meshhttp.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/meshwifi/meshhttp.cpp b/src/meshwifi/meshhttp.cpp index d6d2e22b..678c89de 100644 --- a/src/meshwifi/meshhttp.cpp +++ b/src/meshwifi/meshhttp.cpp @@ -791,10 +791,12 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res) file.write(buf, readLength); fileLength += readLength; + DEBUG_MSG("readLength - %i", readLength); + // Abort the transfer if there is less than 50k space left on the filesystem. if (SPIFFS.totalBytes() - SPIFFS.usedBytes() < 51200) { file.close(); - res->println("

Write aborted! File is won't fit!

"); + res->println("

Write aborted! Reserving 50k on filesystem.

"); delete parser; return; From 7716d6201816d5b62085c7c5d79836091ef557ae Mon Sep 17 00:00:00 2001 From: Jm Date: Wed, 30 Dec 2020 15:16:04 -0800 Subject: [PATCH 2/4] Remove old comment --- src/plugins/TextMessagePlugin.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/plugins/TextMessagePlugin.cpp b/src/plugins/TextMessagePlugin.cpp index 31d98fee..1e742454 100644 --- a/src/plugins/TextMessagePlugin.cpp +++ b/src/plugins/TextMessagePlugin.cpp @@ -18,11 +18,5 @@ bool TextMessagePlugin::handleReceived(const MeshPacket &mp) powerFSM.trigger(EVENT_RECEIVED_TEXT_MSG); notifyObservers(&mp); - // This is going into the wifidev feature branch - // Only update the WebUI if WiFi is enabled - //#if WiFi_MODE != 0 - // notifyWebUI(); - //#endif - return false; // Let others look at this message also if they want } From 2867f8fd5378011b98e5df37d8e734f09de50799 Mon Sep 17 00:00:00 2001 From: Jm Date: Wed, 30 Dec 2020 18:10:35 -0800 Subject: [PATCH 3/4] Fix for #606 and #597 Upload interface randomly crashes #606 watchdog timer exception while building https certificate #597 --- src/esp32/main-esp32.cpp | 3 ++- src/meshwifi/meshhttp.cpp | 43 ++++++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/esp32/main-esp32.cpp b/src/esp32/main-esp32.cpp index 25e7e1a3..0e60fba8 100644 --- a/src/esp32/main-esp32.cpp +++ b/src/esp32/main-esp32.cpp @@ -49,7 +49,8 @@ void esp32Setup() // Since we are turning on watchdogs rather late in the release schedule, we really don't want to catch any // false positives. The wait-to-sleep timeout for shutting down radios is 30 secs, so pick 45 for now. -#define APP_WATCHDOG_SECS 45 +// #define APP_WATCHDOG_SECS 45 +#define APP_WATCHDOG_SECS 90 res = esp_task_wdt_init(APP_WATCHDOG_SECS, true); assert(res == ESP_OK); diff --git a/src/meshwifi/meshhttp.cpp b/src/meshwifi/meshhttp.cpp index 678c89de..319a70d7 100644 --- a/src/meshwifi/meshhttp.cpp +++ b/src/meshwifi/meshhttp.cpp @@ -3,6 +3,7 @@ #include "PowerFSM.h" #include "airtime.h" #include "configuration.h" +#include "esp_task_wdt.h" #include "main.h" #include "meshhttpStatic.h" #include "meshwifi/meshwifi.h" @@ -190,6 +191,7 @@ void createSSLCert() DEBUG_MSG("."); delay(1000); yield(); + esp_task_wdt_reset(); } DEBUG_MSG("SSL Cert Ready!\n"); } @@ -341,7 +343,7 @@ void middlewareSpeedUp160(HTTPRequest *req, HTTPResponse *res, std::functionprintln("File Editedprintln("File Edited

File Edited

"); // The form is submitted with the x-www-form-urlencoded content type, so we need the @@ -499,15 +501,15 @@ void handleStaticBrowse(HTTPRequest *req, HTTPResponse *res) std::string pathDelete = "/" + paramValDelete; if (SPIFFS.remove(pathDelete.c_str())) { Serial.println(pathDelete.c_str()); - res->println("File " + res->println("<html><head><meta http-equiv=\"refresh\" content=\"1;url=/static\" /><title>File " "deleted!

File deleted!

"); - res->println("\n"); + res->println("\n"); res->println(""); return; } else { Serial.println(pathDelete.c_str()); - res->println("Error deleteing " + res->println("<html><head><meta http-equiv=\"refresh\" content=\"1;url=/static\" /><title>Error deleteing " "file!

Error deleteing file!

"); res->println("Error deleteing file!
"); @@ -559,7 +561,7 @@ void handleStaticBrowse(HTTPRequest *req, HTTPResponse *res) res->println("

Upload new file

"); res->println("

*** This interface is experimental ***

"); res->println("

This form allows you to upload files. Keep your filenames very short and files small. Big filenames and big " - "files are a known problem.

"); + "files (>200k) are a known problem.

"); res->println("
"); res->println("file:
"); res->println(""); @@ -700,6 +702,9 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res) void handleFormUpload(HTTPRequest *req, HTTPResponse *res) { + // The upload process is very CPU intensive. Let's speed things up a bit. + setCpuFrequencyMhz(240); + // First, we need to check the encoding of the form that we have received. // The browser will set the Content-Type request header, so we can use it for that purpose. // Then we select the body parser based on the encoding. @@ -726,7 +731,7 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res) return; } - res->println("File " + res->println("<html><head><meta http-equiv=\"refresh\" content=\"1;url=/static\" /><title>File " "Upload

File Upload

"); // We iterate over the fields. Any field with a filename is uploaded. @@ -786,22 +791,31 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res) // With endOfField you can check whether the end of field has been reached or if there's // still data pending. With multipart bodies, you cannot know the field size in advance. while (!parser->endOfField()) { + esp_task_wdt_reset(); + byte buf[512]; size_t readLength = parser->read(buf, 512); - file.write(buf, readLength); - fileLength += readLength; - - DEBUG_MSG("readLength - %i", readLength); + // DEBUG_MSG("\n\nreadLength - %i\n", readLength); // Abort the transfer if there is less than 50k space left on the filesystem. if (SPIFFS.totalBytes() - SPIFFS.usedBytes() < 51200) { file.close(); res->println("

Write aborted! Reserving 50k on filesystem.

"); + // enableLoopWDT(); + delete parser; return; } + + //if (readLength) { + file.write(buf, readLength); + fileLength += readLength; + DEBUG_MSG("File Length %i\n", fileLength); + //} } + // enableLoopWDT(); + file.close(); res->printf("

Saved %d bytes to %s

", (int)fileLength, pathname.c_str()); } @@ -850,10 +864,8 @@ void handleHotspot(HTTPRequest *req, HTTPResponse *res) // We want to deliver a simple HTML page, so we send a corresponding content type: res->setHeader("Content-Type", "text/html"); - // The response implements the Print interface, so you can use it just like - // you would write to Serial etc. - res->println(""); - res->println("\n"); + // res->println(""); + res->println("\n"); } void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res) @@ -976,7 +988,7 @@ void handleRoot(HTTPRequest *req, HTTPResponse *res) res->printf("

\n"); res->printf("

You have gotten this error because the filesystem for the web server has not been loaded.

\n"); res->printf("

Please review the 'Common Problems' section of the web interface documentation.

\n"); + "href=https://github.com/meshtastic/Meshtastic-device/wiki/How-to-use-the-Meshtastic-Web-Interface-over-WiFi>web interface documentation.

\n"); return; } @@ -1129,7 +1141,6 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) res->println("\"ip\": \"" + String(WiFi.localIP().toString().c_str()) + "\""); } - res->println("},"); res->println("\"test\": 123"); From 279c89dca361dc450d654eeedff8afd29ec6a581 Mon Sep 17 00:00:00 2001 From: Wei Fang Date: Wed, 30 Dec 2020 21:46:43 -0800 Subject: [PATCH 4/4] Shall upgrade RTC currentQuality if higher q available --- src/gps/RTC.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gps/RTC.cpp b/src/gps/RTC.cpp index 387f4c0c..56b51e0a 100644 --- a/src/gps/RTC.cpp +++ b/src/gps/RTC.cpp @@ -36,6 +36,7 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv) bool shouldSet; if (q > currentQuality) { + currentQuality = q; shouldSet = true; DEBUG_MSG("Upgrading time to RTC %ld secs (quality %d)\n", tv->tv_sec, q); } else if(q == RTCQualityGPS && (now - lastSetMsec) > (12 * 60 * 60 * 1000L)) {