diff --git a/src/Afterburner/src/Utility/BTC_JSON.cpp b/src/Afterburner/src/Utility/BTC_JSON.cpp index 30f88e3..823b048 100644 --- a/src/Afterburner/src/Utility/BTC_JSON.cpp +++ b/src/Afterburner/src/Utility/BTC_JSON.cpp @@ -41,6 +41,7 @@ CModerator MQTTmoderator; CModerator IPmoderator; CModerator GPIOmoderator; CModerator SysModerator; +bool bTriggerSysParams = false; void validateTimer(int ID); void Expand(std::string& str); @@ -195,6 +196,7 @@ void interpretJsonCommand(char* pLine) // system info else if(strcmp("SQuery", it->key) == 0) { SysModerator.reset(); // force MQTT params to be sent + bTriggerSysParams = true; } // MQTT parameters else if(strcmp("MQuery", it->key) == 0) { @@ -557,7 +559,8 @@ void updateJSONclients(bool report) // report System info { - if(makeJSONStringSysInfo(SysModerator, jsonStr, sizeof(jsonStr))) { + if(bTriggerSysParams && makeJSONStringSysInfo(SysModerator, jsonStr, sizeof(jsonStr))) { + bTriggerSysParams = false; if (report) { DebugPort.printf("JSON send: %s\r\n", jsonStr); } diff --git a/src/Afterburner/src/WiFi/BTCWebServer.cpp b/src/Afterburner/src/WiFi/BTCWebServer.cpp index 50df0ad..3a2d26e 100644 --- a/src/Afterburner/src/WiFi/BTCWebServer.cpp +++ b/src/Afterburner/src/WiFi/BTCWebServer.cpp @@ -598,16 +598,22 @@ void listSPIFFS(const char * dirname, uint8_t levels, String& HTMLreport, int wi if(withHTMLanchors) { String fn2; if(fn.endsWith(".html") || fn.endsWith(".htm")) { + // can hyperlink .html files fn2 = fn; } else if(fn.endsWith(".html.gz") || fn.endsWith(".htm.gz")) { - fn2 = fn.substring(0, fn.length()-3); + // can hyperlink .html.gz files but we must strip .gz extension for + // the hyperlink otherwise you get asked if you want to download the .gz, not view web page! +// fn2 = fn.substring(0, fn.length()-3); // strip ".gz" + fn2 = fn; + fn2.remove(fn2.length()-3, 3); // strip trailing ".gz" } if(fn2.length() != 0) { + // create hyperlink if web page file fn = "" + file.name() + ""; } } - String sz; sz += int(file.size()); + String sz( int(file.size())); addTableData(HTMLreport, ""); addTableData(HTMLreport, fn); addTableData(HTMLreport, sz); @@ -755,7 +761,16 @@ void onUploadProgression() DebugPort.print("."); if(fsUploadFile) { - fsUploadFile.write(upload.buf, upload.currentSize); // Write the received bytes to the file + if(fsUploadFile.write(upload.buf, upload.currentSize) != upload.currentSize) { // Write the received bytes to the file + Update.printError(DebugPort); + fsUploadFile.close(); + fsUploadFile.flush(); + DebugPort.println("WEB: SPIFFS WRITE FAIL"); + server.send(500, "text/plain", "500: couldn't create file"); + String filename = upload.filename; + SPIFFS.remove(filename.c_str()); // remove the file + SPIFFSupload = 2; + } } else { if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {