Merge pull request #7099 from esphome/bump-2024.7.0b4

2024.7.0b4
This commit is contained in:
Jesse Hills 2024-07-17 11:51:22 +12:00 committed by GitHub
commit 93e0c71c2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 90 additions and 30 deletions

View file

@ -1,14 +1,17 @@
#ifdef USE_ESP32_FRAMEWORK_ARDUINO #ifdef USE_ESP32_FRAMEWORK_ARDUINO
#include "esphome/core/defines.h" #include "esphome/core/defines.h"
#include "esphome/core/log.h"
#include "ota_backend_arduino_esp32.h"
#include "ota_backend.h" #include "ota_backend.h"
#include "ota_backend_arduino_esp32.h"
#include <Update.h> #include <Update.h>
namespace esphome { namespace esphome {
namespace ota { namespace ota {
static const char *const TAG = "ota.arduino_esp32";
std::unique_ptr<ota::OTABackend> make_ota_backend() { return make_unique<ota::ArduinoESP32OTABackend>(); } std::unique_ptr<ota::OTABackend> make_ota_backend() { return make_unique<ota::ArduinoESP32OTABackend>(); }
OTAResponseTypes ArduinoESP32OTABackend::begin(size_t image_size) { OTAResponseTypes ArduinoESP32OTABackend::begin(size_t image_size) {
@ -20,6 +23,9 @@ OTAResponseTypes ArduinoESP32OTABackend::begin(size_t image_size) {
uint8_t error = Update.getError(); uint8_t error = Update.getError();
if (error == UPDATE_ERROR_SIZE) if (error == UPDATE_ERROR_SIZE)
return OTA_RESPONSE_ERROR_ESP32_NOT_ENOUGH_SPACE; return OTA_RESPONSE_ERROR_ESP32_NOT_ENOUGH_SPACE;
ESP_LOGE(TAG, "Begin error: %d", error);
return OTA_RESPONSE_ERROR_UNKNOWN; return OTA_RESPONSE_ERROR_UNKNOWN;
} }
@ -27,18 +33,27 @@ void ArduinoESP32OTABackend::set_update_md5(const char *md5) { Update.setMD5(md5
OTAResponseTypes ArduinoESP32OTABackend::write(uint8_t *data, size_t len) { OTAResponseTypes ArduinoESP32OTABackend::write(uint8_t *data, size_t len) {
size_t written = Update.write(data, len); size_t written = Update.write(data, len);
if (written != len) { if (written == len) {
return OTA_RESPONSE_ERROR_WRITING_FLASH;
}
return OTA_RESPONSE_OK; return OTA_RESPONSE_OK;
} }
uint8_t error = Update.getError();
ESP_LOGE(TAG, "Write error: %d", error);
return OTA_RESPONSE_ERROR_WRITING_FLASH;
}
OTAResponseTypes ArduinoESP32OTABackend::end() { OTAResponseTypes ArduinoESP32OTABackend::end() {
if (!Update.end()) if (Update.end()) {
return OTA_RESPONSE_ERROR_UPDATE_END;
return OTA_RESPONSE_OK; return OTA_RESPONSE_OK;
} }
uint8_t error = Update.getError();
ESP_LOGE(TAG, "End error: %d", error);
return OTA_RESPONSE_ERROR_UPDATE_END;
}
void ArduinoESP32OTABackend::abort() { Update.abort(); } void ArduinoESP32OTABackend::abort() { Update.abort(); }
} // namespace ota } // namespace ota

View file

@ -1,16 +1,19 @@
#ifdef USE_ARDUINO #ifdef USE_ARDUINO
#ifdef USE_ESP8266 #ifdef USE_ESP8266
#include "ota_backend.h"
#include "ota_backend_arduino_esp8266.h" #include "ota_backend_arduino_esp8266.h"
#include "ota_backend.h"
#include "esphome/core/defines.h"
#include "esphome/components/esp8266/preferences.h" #include "esphome/components/esp8266/preferences.h"
#include "esphome/core/defines.h"
#include "esphome/core/log.h"
#include <Updater.h> #include <Updater.h>
namespace esphome { namespace esphome {
namespace ota { namespace ota {
static const char *const TAG = "ota.arduino_esp8266";
std::unique_ptr<ota::OTABackend> make_ota_backend() { return make_unique<ota::ArduinoESP8266OTABackend>(); } std::unique_ptr<ota::OTABackend> make_ota_backend() { return make_unique<ota::ArduinoESP8266OTABackend>(); }
OTAResponseTypes ArduinoESP8266OTABackend::begin(size_t image_size) { OTAResponseTypes ArduinoESP8266OTABackend::begin(size_t image_size) {
@ -29,6 +32,9 @@ OTAResponseTypes ArduinoESP8266OTABackend::begin(size_t image_size) {
return OTA_RESPONSE_ERROR_WRONG_CURRENT_FLASH_CONFIG; return OTA_RESPONSE_ERROR_WRONG_CURRENT_FLASH_CONFIG;
if (error == UPDATE_ERROR_SPACE) if (error == UPDATE_ERROR_SPACE)
return OTA_RESPONSE_ERROR_ESP8266_NOT_ENOUGH_SPACE; return OTA_RESPONSE_ERROR_ESP8266_NOT_ENOUGH_SPACE;
ESP_LOGE(TAG, "Begin error: %d", error);
return OTA_RESPONSE_ERROR_UNKNOWN; return OTA_RESPONSE_ERROR_UNKNOWN;
} }
@ -36,18 +42,27 @@ void ArduinoESP8266OTABackend::set_update_md5(const char *md5) { Update.setMD5(m
OTAResponseTypes ArduinoESP8266OTABackend::write(uint8_t *data, size_t len) { OTAResponseTypes ArduinoESP8266OTABackend::write(uint8_t *data, size_t len) {
size_t written = Update.write(data, len); size_t written = Update.write(data, len);
if (written != len) { if (written == len) {
return OTA_RESPONSE_ERROR_WRITING_FLASH;
}
return OTA_RESPONSE_OK; return OTA_RESPONSE_OK;
} }
uint8_t error = Update.getError();
ESP_LOGE(TAG, "Write error: %d", error);
return OTA_RESPONSE_ERROR_WRITING_FLASH;
}
OTAResponseTypes ArduinoESP8266OTABackend::end() { OTAResponseTypes ArduinoESP8266OTABackend::end() {
if (!Update.end()) if (Update.end()) {
return OTA_RESPONSE_ERROR_UPDATE_END;
return OTA_RESPONSE_OK; return OTA_RESPONSE_OK;
} }
uint8_t error = Update.getError();
ESP_LOGE(TAG, "End error: %d", error);
return OTA_RESPONSE_ERROR_UPDATE_END;
}
void ArduinoESP8266OTABackend::abort() { void ArduinoESP8266OTABackend::abort() {
Update.end(); Update.end();
esp8266::preferences_prevent_write(false); esp8266::preferences_prevent_write(false);

View file

@ -1,14 +1,17 @@
#ifdef USE_LIBRETINY #ifdef USE_LIBRETINY
#include "ota_backend.h"
#include "ota_backend_arduino_libretiny.h" #include "ota_backend_arduino_libretiny.h"
#include "ota_backend.h"
#include "esphome/core/defines.h" #include "esphome/core/defines.h"
#include "esphome/core/log.h"
#include <Update.h> #include <Update.h>
namespace esphome { namespace esphome {
namespace ota { namespace ota {
static const char *const TAG = "ota.arduino_libretiny";
std::unique_ptr<ota::OTABackend> make_ota_backend() { return make_unique<ota::ArduinoLibreTinyOTABackend>(); } std::unique_ptr<ota::OTABackend> make_ota_backend() { return make_unique<ota::ArduinoLibreTinyOTABackend>(); }
OTAResponseTypes ArduinoLibreTinyOTABackend::begin(size_t image_size) { OTAResponseTypes ArduinoLibreTinyOTABackend::begin(size_t image_size) {
@ -20,6 +23,9 @@ OTAResponseTypes ArduinoLibreTinyOTABackend::begin(size_t image_size) {
uint8_t error = Update.getError(); uint8_t error = Update.getError();
if (error == UPDATE_ERROR_SIZE) if (error == UPDATE_ERROR_SIZE)
return OTA_RESPONSE_ERROR_ESP32_NOT_ENOUGH_SPACE; return OTA_RESPONSE_ERROR_ESP32_NOT_ENOUGH_SPACE;
ESP_LOGE(TAG, "Begin error: %d", error);
return OTA_RESPONSE_ERROR_UNKNOWN; return OTA_RESPONSE_ERROR_UNKNOWN;
} }
@ -27,18 +33,27 @@ void ArduinoLibreTinyOTABackend::set_update_md5(const char *md5) { Update.setMD5
OTAResponseTypes ArduinoLibreTinyOTABackend::write(uint8_t *data, size_t len) { OTAResponseTypes ArduinoLibreTinyOTABackend::write(uint8_t *data, size_t len) {
size_t written = Update.write(data, len); size_t written = Update.write(data, len);
if (written != len) { if (written == len) {
return OTA_RESPONSE_ERROR_WRITING_FLASH;
}
return OTA_RESPONSE_OK; return OTA_RESPONSE_OK;
} }
uint8_t error = Update.getError();
ESP_LOGE(TAG, "Write error: %d", error);
return OTA_RESPONSE_ERROR_WRITING_FLASH;
}
OTAResponseTypes ArduinoLibreTinyOTABackend::end() { OTAResponseTypes ArduinoLibreTinyOTABackend::end() {
if (!Update.end()) if (Update.end()) {
return OTA_RESPONSE_ERROR_UPDATE_END;
return OTA_RESPONSE_OK; return OTA_RESPONSE_OK;
} }
uint8_t error = Update.getError();
ESP_LOGE(TAG, "End error: %d", error);
return OTA_RESPONSE_ERROR_UPDATE_END;
}
void ArduinoLibreTinyOTABackend::abort() { Update.abort(); } void ArduinoLibreTinyOTABackend::abort() { Update.abort(); }
} // namespace ota } // namespace ota

View file

@ -1,16 +1,19 @@
#ifdef USE_ARDUINO #ifdef USE_ARDUINO
#ifdef USE_RP2040 #ifdef USE_RP2040
#include "ota_backend.h"
#include "ota_backend_arduino_rp2040.h" #include "ota_backend_arduino_rp2040.h"
#include "ota_backend.h"
#include "esphome/components/rp2040/preferences.h" #include "esphome/components/rp2040/preferences.h"
#include "esphome/core/defines.h" #include "esphome/core/defines.h"
#include "esphome/core/log.h"
#include <Updater.h> #include <Updater.h>
namespace esphome { namespace esphome {
namespace ota { namespace ota {
static const char *const TAG = "ota.arduino_rp2040";
std::unique_ptr<ota::OTABackend> make_ota_backend() { return make_unique<ota::ArduinoRP2040OTABackend>(); } std::unique_ptr<ota::OTABackend> make_ota_backend() { return make_unique<ota::ArduinoRP2040OTABackend>(); }
OTAResponseTypes ArduinoRP2040OTABackend::begin(size_t image_size) { OTAResponseTypes ArduinoRP2040OTABackend::begin(size_t image_size) {
@ -29,6 +32,9 @@ OTAResponseTypes ArduinoRP2040OTABackend::begin(size_t image_size) {
return OTA_RESPONSE_ERROR_WRONG_CURRENT_FLASH_CONFIG; return OTA_RESPONSE_ERROR_WRONG_CURRENT_FLASH_CONFIG;
if (error == UPDATE_ERROR_SPACE) if (error == UPDATE_ERROR_SPACE)
return OTA_RESPONSE_ERROR_RP2040_NOT_ENOUGH_SPACE; return OTA_RESPONSE_ERROR_RP2040_NOT_ENOUGH_SPACE;
ESP_LOGE(TAG, "Begin error: %d", error);
return OTA_RESPONSE_ERROR_UNKNOWN; return OTA_RESPONSE_ERROR_UNKNOWN;
} }
@ -36,18 +42,27 @@ void ArduinoRP2040OTABackend::set_update_md5(const char *md5) { Update.setMD5(md
OTAResponseTypes ArduinoRP2040OTABackend::write(uint8_t *data, size_t len) { OTAResponseTypes ArduinoRP2040OTABackend::write(uint8_t *data, size_t len) {
size_t written = Update.write(data, len); size_t written = Update.write(data, len);
if (written != len) { if (written == len) {
return OTA_RESPONSE_ERROR_WRITING_FLASH;
}
return OTA_RESPONSE_OK; return OTA_RESPONSE_OK;
} }
uint8_t error = Update.getError();
ESP_LOGE(TAG, "Write error: %d", error);
return OTA_RESPONSE_ERROR_WRITING_FLASH;
}
OTAResponseTypes ArduinoRP2040OTABackend::end() { OTAResponseTypes ArduinoRP2040OTABackend::end() {
if (!Update.end()) if (Update.end()) {
return OTA_RESPONSE_ERROR_UPDATE_END;
return OTA_RESPONSE_OK; return OTA_RESPONSE_OK;
} }
uint8_t error = Update.getError();
ESP_LOGE(TAG, "End error: %d", error);
return OTA_RESPONSE_ERROR_UPDATE_END;
}
void ArduinoRP2040OTABackend::abort() { void ArduinoRP2040OTABackend::abort() {
Update.end(); Update.end();
rp2040::preferences_prevent_write(false); rp2040::preferences_prevent_write(false);

View file

@ -1,6 +1,6 @@
"""Constants used by esphome.""" """Constants used by esphome."""
__version__ = "2024.7.0b3" __version__ = "2024.7.0b4"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
VALID_SUBSTITUTIONS_CHARACTERS = ( VALID_SUBSTITUTIONS_CHARACTERS = (