ESPHome 2025.5.0
Loading...
Searching...
No Matches
ota_backend_arduino_esp32.cpp
Go to the documentation of this file.
1#ifdef USE_ESP32_FRAMEWORK_ARDUINO
3#include "esphome/core/log.h"
4
5#include "ota_backend.h"
7
8#include <Update.h>
9
10namespace esphome {
11namespace ota {
12
13static const char *const TAG = "ota.arduino_esp32";
14
15std::unique_ptr<ota::OTABackend> make_ota_backend() { return make_unique<ota::ArduinoESP32OTABackend>(); }
16
18 bool ret = Update.begin(image_size, U_FLASH);
19 if (ret) {
20 return OTA_RESPONSE_OK;
21 }
22
23 uint8_t error = Update.getError();
24 if (error == UPDATE_ERROR_SIZE)
26
27 ESP_LOGE(TAG, "Begin error: %d", error);
28
30}
31
32void ArduinoESP32OTABackend::set_update_md5(const char *md5) { Update.setMD5(md5); }
33
35 size_t written = Update.write(data, len);
36 if (written == len) {
37 return OTA_RESPONSE_OK;
38 }
39
40 uint8_t error = Update.getError();
41 ESP_LOGE(TAG, "Write error: %d", error);
42
44}
45
47 if (Update.end()) {
48 return OTA_RESPONSE_OK;
49 }
50
51 uint8_t error = Update.getError();
52 ESP_LOGE(TAG, "End error: %d", error);
53
55}
56
57void ArduinoESP32OTABackend::abort() { Update.abort(); }
58
59} // namespace ota
60} // namespace esphome
61
62#endif // USE_ESP32_FRAMEWORK_ARDUINO
void set_update_md5(const char *md5) override
OTAResponseTypes write(uint8_t *data, size_t len) override
OTAResponseTypes begin(size_t image_size) override
std::unique_ptr< ota::OTABackend > make_ota_backend()
@ OTA_RESPONSE_ERROR_ESP32_NOT_ENOUGH_SPACE
Definition ota_backend.h:36
@ OTA_RESPONSE_ERROR_WRITING_FLASH
Definition ota_backend.h:30
@ OTA_RESPONSE_ERROR_UPDATE_END
Definition ota_backend.h:31
@ OTA_RESPONSE_ERROR_UNKNOWN
Definition ota_backend.h:40
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::string size_t len
Definition helpers.h:301
std::unique_ptr< T > make_unique(Args &&...args)
Definition helpers.h:85