Skip to content

Commit

Permalink
splitting update into verify function
Browse files Browse the repository at this point in the history
  • Loading branch information
andreagilardoni committed May 27, 2024
1 parent 080e75e commit 13c6009
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/Arduino_ESP32_OTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,10 @@ void Arduino_ESP32_OTA::clean()
}
}

Arduino_ESP32_OTA::Error Arduino_ESP32_OTA::update()
Arduino_ESP32_OTA::Error Arduino_ESP32_OTA::verify()
{
assert(_context != nullptr);

/* ... then finalize ... */
_context->calculatedCrc32 ^= 0xFFFFFFFF;

Expand All @@ -323,14 +325,24 @@ Arduino_ESP32_OTA::Error Arduino_ESP32_OTA::update()
return Error::OtaHeaderCrc;
}

clean();

return Error::None;
}

Arduino_ESP32_OTA::Error Arduino_ESP32_OTA::update()
{
Arduino_ESP32_OTA::Error res = Error::None;
if(_context != nullptr && (res = verify()) != Error::None) {
return res;
}

if (!Update.end(true)) {
DEBUG_ERROR("%s: Failure to apply OTA update", __FUNCTION__);
return Error::OtaStorageEnd;
}

clean();

return Error::None;
return res;
}

void Arduino_ESP32_OTA::reset()
Expand Down
1 change: 1 addition & 0 deletions src/Arduino_ESP32_OTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class Arduino_ESP32_OTA
size_t downloadSize();

virtual void write_byte_to_flash(uint8_t data);
Arduino_ESP32_OTA::Error verify();
Arduino_ESP32_OTA::Error update();
void reset();
static bool isCapable();
Expand Down

0 comments on commit 13c6009

Please sign in to comment.