mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	revert ota backend changes
This commit is contained in:
		| @@ -6,7 +6,6 @@ | ||||
|  | ||||
| #include <esp_ota_ops.h> | ||||
| #include <esp_task_wdt.h> | ||||
| #include <cstring> | ||||
|  | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
| #include <spi_flash_mmap.h> | ||||
| @@ -18,9 +17,6 @@ namespace ota { | ||||
| std::unique_ptr<ota::OTABackend> make_ota_backend() { return make_unique<ota::IDFOTABackend>(); } | ||||
|  | ||||
| OTAResponseTypes IDFOTABackend::begin(size_t image_size) { | ||||
|   // Reset MD5 validation state | ||||
|   this->md5_set_ = false; | ||||
|  | ||||
|   this->partition_ = esp_ota_get_next_update_partition(nullptr); | ||||
|   if (this->partition_ == nullptr) { | ||||
|     return OTA_RESPONSE_ERROR_NO_UPDATE_PARTITION; | ||||
| @@ -71,10 +67,7 @@ OTAResponseTypes IDFOTABackend::begin(size_t image_size) { | ||||
|   return OTA_RESPONSE_OK; | ||||
| } | ||||
|  | ||||
| void IDFOTABackend::set_update_md5(const char *expected_md5) { | ||||
|   memcpy(this->expected_bin_md5_, expected_md5, 32); | ||||
|   this->md5_set_ = true; | ||||
| } | ||||
| void IDFOTABackend::set_update_md5(const char *expected_md5) { memcpy(this->expected_bin_md5_, expected_md5, 32); } | ||||
|  | ||||
| OTAResponseTypes IDFOTABackend::write(uint8_t *data, size_t len) { | ||||
|   esp_err_t err = esp_ota_write(this->update_handle_, data, len); | ||||
| @@ -92,15 +85,10 @@ OTAResponseTypes IDFOTABackend::write(uint8_t *data, size_t len) { | ||||
|  | ||||
| OTAResponseTypes IDFOTABackend::end() { | ||||
|   this->md5_.calculate(); | ||||
|  | ||||
|   // Only validate MD5 if one was provided | ||||
|   if (this->md5_set_) { | ||||
|   if (!this->md5_.equals_hex(this->expected_bin_md5_)) { | ||||
|     this->abort(); | ||||
|     return OTA_RESPONSE_ERROR_MD5_MISMATCH; | ||||
|   } | ||||
|   } | ||||
|  | ||||
|   esp_err_t err = esp_ota_end(this->update_handle_); | ||||
|   this->update_handle_ = 0; | ||||
|   if (err == ESP_OK) { | ||||
|   | ||||
| @@ -12,7 +12,6 @@ namespace ota { | ||||
|  | ||||
| class IDFOTABackend : public OTABackend { | ||||
|  public: | ||||
|   IDFOTABackend() : expected_bin_md5_{}, md5_set_(false) {} | ||||
|   OTAResponseTypes begin(size_t image_size) override; | ||||
|   void set_update_md5(const char *md5) override; | ||||
|   OTAResponseTypes write(uint8_t *data, size_t len) override; | ||||
| @@ -25,7 +24,6 @@ class IDFOTABackend : public OTABackend { | ||||
|   const esp_partition_t *partition_; | ||||
|   md5::MD5Digest md5_{}; | ||||
|   char expected_bin_md5_[32]; | ||||
|   bool md5_set_; | ||||
| }; | ||||
|  | ||||
| }  // namespace ota | ||||
|   | ||||
		Reference in New Issue
	
	Block a user