From f714000fb9c7d13ab7500c8a1887ba4ecc49d0a0 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Thu, 4 Feb 2021 10:25:30 -0600 Subject: [PATCH] Fixup ota --- WiFiManager.cpp | 16 ++++++++++------ WiFiManager.h | 4 ++-- strings_en.h | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index f2b5763..dc088de 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -3488,22 +3488,22 @@ void WiFiManager::handleUpdating(){ // UPLOAD START if (upload.status == UPLOAD_FILE_START) { if(_debug) Serial.setDebugOutput(true); - + uint32_t maxSketchSpace; + #ifdef ESP8266 WiFiUDP::stopAll(); - uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000; + maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000; #elif defined(ESP32) // Think we do not need to stop WiFIUDP because we haven't started a listener - // uint32_t maxSketchSpace = (ESP.getFlashChipSize() - 0x1000) & 0xFFFFF000; - #define UPDATE_SIZE_UNKNOWN 0xFFFFFFFF // include update.h + // maxSketchSpace = (ESP.getFlashChipSize() - 0x1000) & 0xFFFFF000; + // #define UPDATE_SIZE_UNKNOWN 0xFFFFFFFF // include update.h maxSketchSpace = UPDATE_SIZE_UNKNOWN; #endif Serial.printf("Update: %s\r\n", upload.filename.c_str()); if (!Update.begin(maxSketchSpace)) { // start with max available size - Update.printError(Serial); // size error - DEBUG_WM(F("[OTA] Update ERROR"), "Not enough space"); + DEBUG_WM(F("[OTA] Update ERROR"), Update.getError()); error = true; Update.end(); // Not sure the best way to abort, I think client will keep sending.. } @@ -3548,7 +3548,11 @@ void WiFiManager::handleUpdateDone() { if (Update.hasError()) { page += FPSTR(HTTP_UPDATE_FAIL); + #ifdef ESP32 + page += "OTA Error: " + (String)Update.errorString(); + #else page += "OTA Error: " + (String)Update.getError(); + #endif DEBUG_WM(F("[OTA] update failed")); } else { diff --git a/WiFiManager.h b/WiFiManager.h index a2a6b07..9002a72 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -593,14 +593,14 @@ class WiFiManager boolean _debug = true; - wm_debuglevel_t debugLvlShow = DEBUG_DEV; // at which level start showing [n] level tags + wm_debuglevel_t debugLvlShow = DEBUG_VERBOSE; // at which level start showing [n] level tags // build debuglevel support // @todo use DEBUG_ESP_x? // Set default debug level #ifndef WM_DEBUG_LEVEL - #define WM_DEBUG_LEVEL DEBUG_MAX // development default, not release + #define WM_DEBUG_LEVEL DEBUG_VERBOSE // development default, not release #endif // override debug level OFF diff --git a/strings_en.h b/strings_en.h index f2e22e6..2c0c1d1 100644 --- a/strings_en.h +++ b/strings_en.h @@ -140,7 +140,7 @@ const char HTTP_HELP[] PROGMEM = ""; const char HTTP_UPDATE[] PROGMEM = "Upload New Firmware
* May not function inside captive portal, Open in browser http://192.168.4.1"; const char HTTP_UPDATE_FAIL[] PROGMEM = "
Update Failed!
Reboot device and try again
"; -const char HTTP_UPDATE_SUCCESS[] PROGMEM = "
Update OK! Device Rebooting now...
"; +const char HTTP_UPDATE_SUCCESS[] PROGMEM = "
Update Successful.
Device Rebooting now...
"; #ifdef WM_JSTEST const char HTTP_JS[] PROGMEM =