mirror of
https://github.com/esphome/esphome.git
synced 2025-09-17 18:52:19 +01:00
revert ota
This commit is contained in:
@@ -1,21 +1,17 @@
|
||||
#include "esphome/core/defines.h"
|
||||
#ifdef USE_ARDUINO
|
||||
#ifdef USE_RP2040
|
||||
#include "ota_backend_arduino_rp2040.h"
|
||||
#include "ota_backend.h"
|
||||
|
||||
#include "esphome/components/rp2040/preferences.h"
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "ota_backend.h"
|
||||
#include "ota_backend_arduino_rp2040.h"
|
||||
#include "ota_component.h"
|
||||
|
||||
#include <Updater.h>
|
||||
|
||||
namespace esphome {
|
||||
namespace ota {
|
||||
|
||||
static const char *const TAG = "ota.arduino_rp2040";
|
||||
|
||||
std::unique_ptr<ota::OTABackend> make_ota_backend() { return make_unique<ota::ArduinoRP2040OTABackend>(); }
|
||||
|
||||
OTAResponseTypes ArduinoRP2040OTABackend::begin(size_t image_size) {
|
||||
bool ret = Update.begin(image_size, U_FLASH);
|
||||
if (ret) {
|
||||
@@ -32,9 +28,6 @@ OTAResponseTypes ArduinoRP2040OTABackend::begin(size_t image_size) {
|
||||
return OTA_RESPONSE_ERROR_WRONG_CURRENT_FLASH_CONFIG;
|
||||
if (error == UPDATE_ERROR_SPACE)
|
||||
return OTA_RESPONSE_ERROR_RP2040_NOT_ENOUGH_SPACE;
|
||||
|
||||
ESP_LOGE(TAG, "Begin error: %d", error);
|
||||
|
||||
return OTA_RESPONSE_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -42,25 +35,16 @@ void ArduinoRP2040OTABackend::set_update_md5(const char *md5) { Update.setMD5(md
|
||||
|
||||
OTAResponseTypes ArduinoRP2040OTABackend::write(uint8_t *data, size_t len) {
|
||||
size_t written = Update.write(data, len);
|
||||
if (written == len) {
|
||||
return OTA_RESPONSE_OK;
|
||||
if (written != len) {
|
||||
return OTA_RESPONSE_ERROR_WRITING_FLASH;
|
||||
}
|
||||
|
||||
uint8_t error = Update.getError();
|
||||
ESP_LOGE(TAG, "Write error: %d", error);
|
||||
|
||||
return OTA_RESPONSE_ERROR_WRITING_FLASH;
|
||||
return OTA_RESPONSE_OK;
|
||||
}
|
||||
|
||||
OTAResponseTypes ArduinoRP2040OTABackend::end() {
|
||||
if (Update.end()) {
|
||||
return OTA_RESPONSE_OK;
|
||||
}
|
||||
|
||||
uint8_t error = Update.getError();
|
||||
ESP_LOGE(TAG, "End error: %d", error);
|
||||
|
||||
return OTA_RESPONSE_ERROR_UPDATE_END;
|
||||
if (!Update.end())
|
||||
return OTA_RESPONSE_ERROR_UPDATE_END;
|
||||
return OTA_RESPONSE_OK;
|
||||
}
|
||||
|
||||
void ArduinoRP2040OTABackend::abort() {
|
||||
|
Reference in New Issue
Block a user