Skip to content

Commit 840c355

Browse files
John Doeigrr
authored andcommitted
minor enchancement
1 parent aaff638 commit 840c355

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

hardware/esp8266com/esp8266/cores/esp8266/Updater.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ bool UpdaterClass::_writeBuffer(){
106106
interrupts();
107107
if (rc) {
108108
_error = UPDATE_ERROR_WRITE;
109+
_currentAddress = (_startAddress + _size);
109110
#ifdef DEBUG_UPDATER
110111
printError(DEBUG_UPDATER);
111112
#endif
@@ -157,6 +158,7 @@ size_t UpdaterClass::writeStream(Stream &data){
157158
toRead = data.readBytes(_buffer + _bufferLen, toRead);
158159
if(toRead == 0){ //Timeout
159160
_error = UPDATE_ERROR_STREAM;
161+
_currentAddress = (_startAddress + _size);
160162
#ifdef DEBUG_UPDATER
161163
printError(DEBUG_UPDATER);
162164
#endif

hardware/esp8266com/esp8266/cores/esp8266/Updater.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ class UpdaterClass {
5757
void clearError(){ _error = UPDATE_ERROR_OK; }
5858
bool hasError(){ return _error != UPDATE_ERROR_OK; }
5959
bool isRunning(){ return _size > 0; }
60-
bool isFinished(){ return hasError()?true:(_currentAddress == (_startAddress + _size)); }
60+
bool isFinished(){ return _currentAddress == (_startAddress + _size); }
6161
size_t size(){ return _size; }
6262
size_t progress(){ return _currentAddress - _startAddress; }
63-
size_t remaining(){ return hasError()?0:(size() - progress()); }
63+
size_t remaining(){ return _size - (_currentAddress - _startAddress); }
6464

6565
/*
6666
Template to write from objects that expose
@@ -116,4 +116,4 @@ class UpdaterClass {
116116

117117
extern UpdaterClass Update;
118118

119-
#endif
119+
#endif

0 commit comments

Comments
 (0)