提交 61f71930 编写于 作者: D ducalex 提交者: Me No Dev

The progress callback is now correctly invoked with Update.write (#3024)

The progress callback was only invoked with Update.writeStream before
上级 ec40c4c9
......@@ -189,6 +189,9 @@ bool UpdateClass::_writeBuffer(){
//this ensures that partially written firmware will not be bootable
_buffer[0] = 0xFF;
}
if (!_progress && _progress_callback) {
_progress_callback(0, _size);
}
if(!ESP.flashEraseSector((_partition->address + _progress)/SPI_FLASH_SEC_SIZE)){
_abort(UPDATE_ERROR_ERASE);
return false;
......@@ -204,6 +207,9 @@ bool UpdateClass::_writeBuffer(){
_md5.add(_buffer, _bufferLen);
_progress += _bufferLen;
_bufferLen = 0;
if (_progress_callback) {
_progress_callback(_progress, _size);
}
return true;
}
......@@ -319,9 +325,6 @@ size_t UpdateClass::writeStream(Stream &data) {
_reset();
return 0;
}
if (_progress_callback) {
_progress_callback(0, _size);
}
if(_ledPin != -1) {
pinMode(_ledPin, OUTPUT);
......@@ -352,12 +355,6 @@ size_t UpdateClass::writeStream(Stream &data) {
if((_bufferLen == remaining() || _bufferLen == SPI_FLASH_SEC_SIZE) && !_writeBuffer())
return written;
written += toRead;
if(_progress_callback) {
_progress_callback(_progress, _size);
}
}
if(_progress_callback) {
_progress_callback(_size, _size);
}
return written;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册