mirror of
https://github.com/esphome/esphome.git
synced 2025-08-07 19:07:45 +00:00
web_server_ support for ota backend idf
This commit is contained in:
parent
93dc5765bb
commit
649ad47e62
@ -67,7 +67,10 @@ OTAResponseTypes IDFOTABackend::begin(size_t image_size) {
|
|||||||
return OTA_RESPONSE_OK;
|
return OTA_RESPONSE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDFOTABackend::set_update_md5(const char *expected_md5) { memcpy(this->expected_bin_md5_, expected_md5, 32); }
|
void IDFOTABackend::set_update_md5(const char *expected_md5) {
|
||||||
|
memcpy(this->expected_bin_md5_, expected_md5, 32);
|
||||||
|
this->md5_set_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
OTAResponseTypes IDFOTABackend::write(uint8_t *data, size_t len) {
|
OTAResponseTypes IDFOTABackend::write(uint8_t *data, size_t len) {
|
||||||
esp_err_t err = esp_ota_write(this->update_handle_, data, len);
|
esp_err_t err = esp_ota_write(this->update_handle_, data, len);
|
||||||
@ -84,11 +87,13 @@ OTAResponseTypes IDFOTABackend::write(uint8_t *data, size_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OTAResponseTypes IDFOTABackend::end() {
|
OTAResponseTypes IDFOTABackend::end() {
|
||||||
|
if (this->md5_set_) {
|
||||||
this->md5_.calculate();
|
this->md5_.calculate();
|
||||||
if (!this->md5_.equals_hex(this->expected_bin_md5_)) {
|
if (!this->md5_.equals_hex(this->expected_bin_md5_)) {
|
||||||
this->abort();
|
this->abort();
|
||||||
return OTA_RESPONSE_ERROR_MD5_MISMATCH;
|
return OTA_RESPONSE_ERROR_MD5_MISMATCH;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
esp_err_t err = esp_ota_end(this->update_handle_);
|
esp_err_t err = esp_ota_end(this->update_handle_);
|
||||||
this->update_handle_ = 0;
|
this->update_handle_ = 0;
|
||||||
if (err == ESP_OK) {
|
if (err == ESP_OK) {
|
||||||
|
@ -24,6 +24,7 @@ class IDFOTABackend : public OTABackend {
|
|||||||
const esp_partition_t *partition_;
|
const esp_partition_t *partition_;
|
||||||
md5::MD5Digest md5_{};
|
md5::MD5Digest md5_{};
|
||||||
char expected_bin_md5_[32];
|
char expected_bin_md5_[32];
|
||||||
|
bool md5_set_{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ota_base
|
} // namespace ota_base
|
||||||
|
Loading…
x
Reference in New Issue
Block a user