diff --git a/cores/esp8266/Updater.h b/cores/esp8266/Updater.h index df3e8fa38..f8c02859f 100644 --- a/cores/esp8266/Updater.h +++ b/cores/esp8266/Updater.h @@ -44,6 +44,7 @@ class UpdaterClass { or there is an error this will clear everything and return false the last error is available through getError() + evenIfRemaining is helpfull when you update without knowing the final size first */ bool end(bool evenIfRemaining = false); @@ -53,14 +54,14 @@ class UpdaterClass { void printError(Stream &out); //Helpers - uint8_t getError(){ return _error; } - void clearError(){ _error = UPDATE_ERROR_OK; } - bool hasError(){ return _error != UPDATE_ERROR_OK; } - bool isRunning(){ return _size > 0; } - bool isFinished(){ return _currentAddress == (_startAddress + _size); } - size_t size(){ return _size; } - size_t progress(){ return _currentAddress - _startAddress; } - size_t remaining(){ return _size - (_currentAddress - _startAddress); } + inline uint8_t getError(){ return _error; } + inline void clearError(){ _error = UPDATE_ERROR_OK; } + inline bool hasError(){ return _error != UPDATE_ERROR_OK; } + inline bool isRunning(){ return _size > 0; } + inline bool isFinished(){ return _currentAddress == (_startAddress + _size); } + inline size_t size(){ return _size; } + inline size_t progress(){ return _currentAddress - _startAddress; } + inline size_t remaining(){ return _size - (_currentAddress - _startAddress); } /* Template to write from objects that expose diff --git a/libraries/ESP8266WebServer/examples/WebUpdate/WebUpdate.ino b/libraries/ESP8266WebServer/examples/WebUpdate/WebUpdate.ino index d72ab1345..b411d234e 100644 --- a/libraries/ESP8266WebServer/examples/WebUpdate/WebUpdate.ino +++ b/libraries/ESP8266WebServer/examples/WebUpdate/WebUpdate.ino @@ -28,6 +28,7 @@ void setup(void){ HTTPUpload& upload = server.upload(); if(upload.status == UPLOAD_FILE_START){ Serial.setDebugOutput(true); + WiFiUDP::stopAll(); Serial.printf("Update: %s\n", upload.filename.c_str()); uint32_t maxSketchSpace = ((ESP.getFreeSketchSpace() + ESP.getSketchSize()) / 2) & 0xFFFFF000; if(!Update.begin(maxSketchSpace)){//start with max available size diff --git a/libraries/ESP8266mDNS/examples/DNS_SD_Arduino_OTA/DNS_SD_Arduino_OTA.ino b/libraries/ESP8266mDNS/examples/DNS_SD_Arduino_OTA/DNS_SD_Arduino_OTA.ino index 4320bbbba..e7dc97795 100644 --- a/libraries/ESP8266mDNS/examples/DNS_SD_Arduino_OTA/DNS_SD_Arduino_OTA.ino +++ b/libraries/ESP8266mDNS/examples/DNS_SD_Arduino_OTA/DNS_SD_Arduino_OTA.ino @@ -43,7 +43,9 @@ void loop() { Serial.print(remote); Serial.printf(", port:%d, size:%d\n", port, size); uint32_t startTime = millis(); - + + WiFiUDP::stopAll(); + if(!Update.begin(size)){ Serial.println("Update Begin Error"); return;