ESPHome
2023.3.2
esphome
esphome
components
ota
ota_backend_arduino_esp32.cpp
Go to the documentation of this file.
1
#include "
esphome/core/defines.h
"
2
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
3
4
#include "
ota_backend_arduino_esp32.h
"
5
#include "
ota_component.h
"
6
#include "
ota_backend.h
"
7
8
#include <Update.h>
9
10
namespace
esphome
{
11
namespace
ota {
12
13
OTAResponseTypes
ArduinoESP32OTABackend::begin
(
size_t
image_size) {
14
bool
ret = Update.begin(image_size, U_FLASH);
15
if
(ret) {
16
return
OTA_RESPONSE_OK
;
17
}
18
19
uint8_t error = Update.getError();
20
if
(error == UPDATE_ERROR_SIZE)
21
return
OTA_RESPONSE_ERROR_ESP32_NOT_ENOUGH_SPACE
;
22
return
OTA_RESPONSE_ERROR_UNKNOWN
;
23
}
24
25
void
ArduinoESP32OTABackend::set_update_md5
(
const
char
*md5) { Update.setMD5(md5); }
26
27
OTAResponseTypes
ArduinoESP32OTABackend::write
(uint8_t *data,
size_t
len
) {
28
size_t
written = Update.write(data, len);
29
if
(written != len) {
30
return
OTA_RESPONSE_ERROR_WRITING_FLASH
;
31
}
32
return
OTA_RESPONSE_OK
;
33
}
34
35
OTAResponseTypes
ArduinoESP32OTABackend::end
() {
36
if
(!Update.end())
37
return
OTA_RESPONSE_ERROR_UPDATE_END
;
38
return
OTA_RESPONSE_OK
;
39
}
40
41
void
ArduinoESP32OTABackend::abort
() { Update.abort(); }
42
43
}
// namespace ota
44
}
// namespace esphome
45
46
#endif // USE_ESP32_FRAMEWORK_ARDUINO
esphome::ota::OTA_RESPONSE_ERROR_WRITING_FLASH
Definition:
ota_component.h:27
esphome::ota::OTAResponseTypes
OTAResponseTypes
Definition:
ota_component.h:12
esphome::ota::ArduinoESP32OTABackend::begin
OTAResponseTypes begin(size_t image_size) override
Definition:
ota_backend_arduino_esp32.cpp:13
ota_component.h
esphome::ota::ArduinoESP32OTABackend::set_update_md5
void set_update_md5(const char *md5) override
Definition:
ota_backend_arduino_esp32.cpp:25
esphome::ota::ArduinoESP32OTABackend::write
OTAResponseTypes write(uint8_t *data, size_t len) override
Definition:
ota_backend_arduino_esp32.cpp:27
esphome::ota::ArduinoESP32OTABackend::end
OTAResponseTypes end() override
Definition:
ota_backend_arduino_esp32.cpp:35
ota_backend.h
esphome::ota::OTA_RESPONSE_ERROR_ESP32_NOT_ENOUGH_SPACE
Definition:
ota_component.h:33
defines.h
esphome::ota::OTA_RESPONSE_ERROR_UNKNOWN
Definition:
ota_component.h:37
esphome::len
std::string size_t len
Definition:
helpers.h:286
esphome::ota::ArduinoESP32OTABackend::abort
void abort() override
Definition:
ota_backend_arduino_esp32.cpp:41
esphome
Definition:
a4988.cpp:4
esphome::ota::OTA_RESPONSE_ERROR_UPDATE_END
Definition:
ota_component.h:28
ota_backend_arduino_esp32.h
esphome::ota::OTA_RESPONSE_OK
Definition:
ota_component.h:13
Generated by
1.8.13