File tree 2 files changed +12
-5
lines changed
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ extern "C" {
14
14
extern " C" uint32_t _SPIFFS_start;
15
15
16
16
UpdaterClass::UpdaterClass ()
17
- : _error(0 )
17
+ : _async(false )
18
+ , _error(0 )
18
19
, _buffer(0 )
19
20
, _bufferLen(0 )
20
21
, _size(0 )
@@ -202,13 +203,13 @@ bool UpdaterClass::end(bool evenIfRemaining){
202
203
203
204
bool UpdaterClass::_writeBuffer (){
204
205
205
- yield ();
206
+ if (!_async) yield ();
206
207
bool result = ESP.flashEraseSector (_currentAddress/FLASH_SECTOR_SIZE);
207
- yield ();
208
+ if (!_async) yield ();
208
209
if (result) {
209
210
result = ESP.flashWrite (_currentAddress, (uint32_t *) _buffer, _bufferLen);
210
211
}
211
- yield ();
212
+ if (!_async) yield ();
212
213
213
214
if (!result) {
214
215
_error = UPDATE_ERROR_WRITE;
@@ -240,7 +241,7 @@ size_t UpdaterClass::write(uint8_t *data, size_t len) {
240
241
return len - left;
241
242
}
242
243
left -= toBuff;
243
- yield ();
244
+ if (!_async) yield ();
244
245
}
245
246
// lets see whats left
246
247
memcpy (_buffer + _bufferLen, data + (len - left), left);
Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ class UpdaterClass {
37
37
*/
38
38
bool begin (size_t size, int command = U_FLASH);
39
39
40
+ /*
41
+ Run Updater from asynchronous callbacs
42
+ */
43
+ void runAsync (bool async){ _async = async; }
44
+
40
45
/*
41
46
Writes a buffer to the flash and increments the address
42
47
Returns the amount written
@@ -143,6 +148,7 @@ class UpdaterClass {
143
148
bool _verifyHeader (uint8_t data);
144
149
bool _verifyEnd ();
145
150
151
+ bool _async;
146
152
uint8_t _error;
147
153
uint8_t *_buffer;
148
154
size_t _bufferLen;
You can’t perform that action at this time.
0 commit comments