mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	web_server_ support for ota backend idf
This commit is contained in:
		| @@ -67,7 +67,10 @@ 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); } | ||||
| 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) { | ||||
|   esp_err_t err = esp_ota_write(this->update_handle_, data, len); | ||||
| @@ -84,10 +87,12 @@ OTAResponseTypes IDFOTABackend::write(uint8_t *data, size_t len) { | ||||
| } | ||||
|  | ||||
| OTAResponseTypes IDFOTABackend::end() { | ||||
|   this->md5_.calculate(); | ||||
|   if (!this->md5_.equals_hex(this->expected_bin_md5_)) { | ||||
|     this->abort(); | ||||
|     return OTA_RESPONSE_ERROR_MD5_MISMATCH; | ||||
|   if (this->md5_set_) { | ||||
|     this->md5_.calculate(); | ||||
|     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; | ||||
|   | ||||
| @@ -24,6 +24,7 @@ class IDFOTABackend : public OTABackend { | ||||
|   const esp_partition_t *partition_; | ||||
|   md5::MD5Digest md5_{}; | ||||
|   char expected_bin_md5_[32]; | ||||
|   bool md5_set_{false}; | ||||
| }; | ||||
|  | ||||
| }  // namespace ota_base | ||||
|   | ||||
		Reference in New Issue
	
	Block a user