@@ -189,6 +189,9 @@ bool UpdateClass::_writeBuffer(){
189
189
// this ensures that partially written firmware will not be bootable
190
190
_buffer[0 ] = 0xFF ;
191
191
}
192
+ if (!_progress && _progress_callback) {
193
+ _progress_callback (0 , _size);
194
+ }
192
195
if (!ESP.flashEraseSector ((_partition->address + _progress)/SPI_FLASH_SEC_SIZE)){
193
196
_abort (UPDATE_ERROR_ERASE);
194
197
return false ;
@@ -204,6 +207,9 @@ bool UpdateClass::_writeBuffer(){
204
207
_md5.add (_buffer, _bufferLen);
205
208
_progress += _bufferLen;
206
209
_bufferLen = 0 ;
210
+ if (_progress_callback) {
211
+ _progress_callback (_progress, _size);
212
+ }
207
213
return true ;
208
214
}
209
215
@@ -319,9 +325,6 @@ size_t UpdateClass::writeStream(Stream &data) {
319
325
_reset ();
320
326
return 0 ;
321
327
}
322
- if (_progress_callback) {
323
- _progress_callback (0 , _size);
324
- }
325
328
326
329
if (_ledPin != -1 ) {
327
330
pinMode (_ledPin, OUTPUT);
@@ -352,12 +355,6 @@ size_t UpdateClass::writeStream(Stream &data) {
352
355
if ((_bufferLen == remaining () || _bufferLen == SPI_FLASH_SEC_SIZE) && !_writeBuffer ())
353
356
return written;
354
357
written += toRead;
355
- if (_progress_callback) {
356
- _progress_callback (_progress, _size);
357
- }
358
- }
359
- if (_progress_callback) {
360
- _progress_callback (_size, _size);
361
358
}
362
359
return written;
363
360
}
0 commit comments