File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ extern "C" {
1414extern " C" uint32_t _SPIFFS_start;
1515
1616UpdaterClass::UpdaterClass ()
17- : _error(0 )
17+ : _async(false )
18+ , _error(0 )
1819, _buffer(0 )
1920, _bufferLen(0 )
2021, _size(0 )
@@ -202,13 +203,13 @@ bool UpdaterClass::end(bool evenIfRemaining){
202203
203204bool UpdaterClass::_writeBuffer (){
204205
205- yield ();
206+ if (!_async) yield ();
206207 bool result = ESP.flashEraseSector (_currentAddress/FLASH_SECTOR_SIZE);
207- yield ();
208+ if (!_async) yield ();
208209 if (result) {
209210 result = ESP.flashWrite (_currentAddress, (uint32_t *) _buffer, _bufferLen);
210211 }
211- yield ();
212+ if (!_async) yield ();
212213
213214 if (!result) {
214215 _error = UPDATE_ERROR_WRITE;
@@ -240,7 +241,7 @@ size_t UpdaterClass::write(uint8_t *data, size_t len) {
240241 return len - left;
241242 }
242243 left -= toBuff;
243- yield ();
244+ if (!_async) yield ();
244245 }
245246 // lets see whats left
246247 memcpy (_buffer + _bufferLen, data + (len - left), left);
Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ class UpdaterClass {
3737 */
3838 bool begin (size_t size, int command = U_FLASH);
3939
40+ /*
41+ Run Updater from asynchronous callbacs
42+ */
43+ void runAsync (bool async){ _async = async; }
44+
4045 /*
4146 Writes a buffer to the flash and increments the address
4247 Returns the amount written
@@ -143,6 +148,7 @@ class UpdaterClass {
143148 bool _verifyHeader (uint8_t data);
144149 bool _verifyEnd ();
145150
151+ bool _async;
146152 uint8_t _error;
147153 uint8_t *_buffer;
148154 size_t _bufferLen;
You can’t perform that action at this time.
0 commit comments