mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-22 10:42:10 +10:00
Fixup ota
This commit is contained in:
+9
-5
@@ -3488,22 +3488,22 @@ void WiFiManager::handleUpdating(){
|
|||||||
// UPLOAD START
|
// UPLOAD START
|
||||||
if (upload.status == UPLOAD_FILE_START) {
|
if (upload.status == UPLOAD_FILE_START) {
|
||||||
if(_debug) Serial.setDebugOutput(true);
|
if(_debug) Serial.setDebugOutput(true);
|
||||||
|
uint32_t maxSketchSpace;
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
WiFiUDP::stopAll();
|
WiFiUDP::stopAll();
|
||||||
uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
|
maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
// Think we do not need to stop WiFIUDP because we haven't started a listener
|
// Think we do not need to stop WiFIUDP because we haven't started a listener
|
||||||
// uint32_t maxSketchSpace = (ESP.getFlashChipSize() - 0x1000) & 0xFFFFF000;
|
// maxSketchSpace = (ESP.getFlashChipSize() - 0x1000) & 0xFFFFF000;
|
||||||
#define UPDATE_SIZE_UNKNOWN 0xFFFFFFFF // include update.h
|
// #define UPDATE_SIZE_UNKNOWN 0xFFFFFFFF // include update.h
|
||||||
maxSketchSpace = UPDATE_SIZE_UNKNOWN;
|
maxSketchSpace = UPDATE_SIZE_UNKNOWN;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Serial.printf("Update: %s\r\n", upload.filename.c_str());
|
Serial.printf("Update: %s\r\n", upload.filename.c_str());
|
||||||
|
|
||||||
if (!Update.begin(maxSketchSpace)) { // start with max available size
|
if (!Update.begin(maxSketchSpace)) { // start with max available size
|
||||||
Update.printError(Serial); // size error
|
DEBUG_WM(F("[OTA] Update ERROR"), Update.getError());
|
||||||
DEBUG_WM(F("[OTA] Update ERROR"), "Not enough space");
|
|
||||||
error = true;
|
error = true;
|
||||||
Update.end(); // Not sure the best way to abort, I think client will keep sending..
|
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()) {
|
if (Update.hasError()) {
|
||||||
page += FPSTR(HTTP_UPDATE_FAIL);
|
page += FPSTR(HTTP_UPDATE_FAIL);
|
||||||
|
#ifdef ESP32
|
||||||
|
page += "OTA Error: " + (String)Update.errorString();
|
||||||
|
#else
|
||||||
page += "OTA Error: " + (String)Update.getError();
|
page += "OTA Error: " + (String)Update.getError();
|
||||||
|
#endif
|
||||||
DEBUG_WM(F("[OTA] update failed"));
|
DEBUG_WM(F("[OTA] update failed"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
+2
-2
@@ -593,14 +593,14 @@ class WiFiManager
|
|||||||
|
|
||||||
boolean _debug = true;
|
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
|
// build debuglevel support
|
||||||
// @todo use DEBUG_ESP_x?
|
// @todo use DEBUG_ESP_x?
|
||||||
|
|
||||||
// Set default debug level
|
// Set default debug level
|
||||||
#ifndef WM_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
|
#endif
|
||||||
|
|
||||||
// override debug level OFF
|
// override debug level OFF
|
||||||
|
|||||||
+1
-1
@@ -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[] 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_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
|
#ifdef WM_JSTEST
|
||||||
const char HTTP_JS[] PROGMEM =
|
const char HTTP_JS[] PROGMEM =
|
||||||
|
|||||||
Reference in New Issue
Block a user