Fixup ota

This commit is contained in:
tablatronix
2021-02-04 10:25:30 -06:00
parent 83e9bbc9db
commit f714000fb9
3 changed files with 13 additions and 9 deletions
+10 -6
View File
@@ -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 {
+2 -2
View File
@@ -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
+1 -1
View File
@@ -140,7 +140,7 @@ const char HTTP_HELP[] PROGMEM = "";
const char HTTP_UPDATE[] PROGMEM = "Upload New Firmware<br/><form method='POST' action='u' enctype='multipart/form-data' onchange=\"(function(el){document.getElementById('uploadbin').style.display = el.value=='' ? 'none' : 'initial';})(this)\"><input type='file' name='update' accept='.bin,application/octet-stream'><button id='uploadbin' type='submit' class='h D'>Update</button></form><small><a href='http://192.168.4.1/update' target='_blank'>* May not function inside captive portal, Open in browser http://192.168.4.1</a><small>";
const char HTTP_UPDATE_FAIL[] PROGMEM = "<div class='msg D'><strong>Update Failed!</strong><Br/>Reboot device and try again</div>";
const char HTTP_UPDATE_SUCCESS[] PROGMEM = "<div class='msg P'><strong>Update OK!</strong> Device Rebooting now...</div>";
const char HTTP_UPDATE_SUCCESS[] PROGMEM = "<div class='msg S'><strong>Update Successful. </strong> <br/> Device Rebooting now...</div>";
#ifdef WM_JSTEST
const char HTTP_JS[] PROGMEM =