15static const char *
const TAG =
"ota.arduino_esp8266";
17std::unique_ptr<ota::OTABackend>
make_ota_backend() {
return make_unique<ota::ArduinoESP8266OTABackend>(); }
21 if (image_size == 0) {
23 image_size = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
25 bool ret = Update.begin(image_size, U_FLASH);
31 uint8_t error = Update.getError();
32 if (error == UPDATE_ERROR_BOOTSTRAP)
34 if (error == UPDATE_ERROR_NEW_FLASH_CONFIG)
36 if (error == UPDATE_ERROR_FLASH_CONFIG)
38 if (error == UPDATE_ERROR_SPACE)
41 ESP_LOGE(TAG,
"Begin error: %d", error);
48 this->md5_set_ =
true;
52 size_t written = Update.write(data,
len);
57 uint8_t error = Update.getError();
58 ESP_LOGE(TAG,
"Write error: %d", error);
66 bool success = Update.end(!this->md5_set_);
70 uint8_t error = Update.getError();
72 if (success || error == UPDATE_ERROR_OK) {
76 ESP_LOGE(TAG,
"End error: %d", error);
OTAResponseTypes end() override
void set_update_md5(const char *md5) override
OTAResponseTypes begin(size_t image_size) override
OTAResponseTypes write(uint8_t *data, size_t len) override
void preferences_prevent_write(bool prevent)
std::unique_ptr< ota::OTABackend > make_ota_backend()
@ OTA_RESPONSE_ERROR_WRONG_NEW_FLASH_CONFIG
@ OTA_RESPONSE_ERROR_WRONG_CURRENT_FLASH_CONFIG
@ OTA_RESPONSE_ERROR_WRITING_FLASH
@ OTA_RESPONSE_ERROR_ESP8266_NOT_ENOUGH_SPACE
@ OTA_RESPONSE_ERROR_UPDATE_END
@ OTA_RESPONSE_ERROR_UNKNOWN
@ OTA_RESPONSE_ERROR_INVALID_BOOTSTRAPPING
Providing packet encoding functions for exchanging data with a remote host.