diff --git a/cores/esp8266/Updater.cpp b/cores/esp8266/Updater.cpp index 728700c2f..c957428ff 100644 --- a/cores/esp8266/Updater.cpp +++ b/cores/esp8266/Updater.cpp @@ -106,6 +106,7 @@ bool UpdaterClass::_writeBuffer(){ interrupts(); if (rc) { _error = UPDATE_ERROR_WRITE; + _currentAddress = (_startAddress + _size); #ifdef DEBUG_UPDATER printError(DEBUG_UPDATER); #endif @@ -157,6 +158,7 @@ size_t UpdaterClass::writeStream(Stream &data){ toRead = data.readBytes(_buffer + _bufferLen, toRead); if(toRead == 0){ //Timeout _error = UPDATE_ERROR_STREAM; + _currentAddress = (_startAddress + _size); #ifdef DEBUG_UPDATER printError(DEBUG_UPDATER); #endif diff --git a/cores/esp8266/Updater.h b/cores/esp8266/Updater.h index 107706060..ec5b0c4d9 100644 --- a/cores/esp8266/Updater.h +++ b/cores/esp8266/Updater.h @@ -57,10 +57,10 @@ class UpdaterClass { void clearError(){ _error = UPDATE_ERROR_OK; } bool hasError(){ return _error != UPDATE_ERROR_OK; } bool isRunning(){ return _size > 0; } - bool isFinished(){ return hasError()?true:(_currentAddress == (_startAddress + _size)); } + bool isFinished(){ return _currentAddress == (_startAddress + _size); } size_t size(){ return _size; } size_t progress(){ return _currentAddress - _startAddress; } - size_t remaining(){ return hasError()?0:(size() - progress()); } + size_t remaining(){ return _size - (_currentAddress - _startAddress); } /* Template to write from objects that expose @@ -116,4 +116,4 @@ class UpdaterClass { extern UpdaterClass Update; -#endif \ No newline at end of file +#endif