22#include <idfxx/partition>
26#include <esp_app_desc.h>
150#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
330#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
363#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
373 void write(
const void* data,
size_t size);
383 void write(std::span<const uint8_t> data);
467#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
514#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
604#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
632#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
701#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
729#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
// end of idfxx_ota
Application description from a firmware image.
std::string_view version() const
Returns the application version string.
uint32_t secure_version() const
Returns the secure version counter.
std::string_view date() const
Returns the compile date string.
std::span< const uint8_t, 32 > app_elf_sha256() const
Returns the SHA-256 hash of the application ELF file.
std::string_view time() const
Returns the compile time string.
const esp_app_desc_t & idf_handle() const
Returns a reference to the underlying ESP-IDF app description structure.
std::string_view project_name() const
Returns the project name.
std::string_view idf_ver() const
Returns the ESP-IDF version string used to build the image.
friend result< app_description > try_partition_description(const partition &)
Returns the application description from a partition.
Error category for OTA errors.
const char * name() const noexcept override final
Returns the name of the error category.
std::string message(int ec) const override final
Returns a human-readable message for the given error code.
void end()
Finalizes the OTA update and validates the written image.
static result< update > make(const partition &part, sequential_erase_tag)
Begins an OTA update with sequential (incremental) flash erase.
update(const partition &part)
Begins an OTA update, erasing the entire partition.
static update resume(const partition &part, size_t offset)
Resumes an interrupted OTA update, erasing all remaining flash.
void write_with_offset(uint32_t offset, const void *data, size_t size)
Writes data at a specific offset in the OTA partition.
result< void > try_abort()
Aborts the OTA update and frees associated resources.
void abort()
Aborts the OTA update and frees associated resources.
static result< update > try_resume(const partition &part, size_t offset, sequential_erase_tag)
Resumes an interrupted OTA update with sequential (incremental) flash erase.
result< void > try_write_with_offset(uint32_t offset, std::span< const uint8_t > data)
Writes data at a specific offset in the OTA partition.
void set_final_partition(const partition &final_part, bool copy=true)
Redirects the validated image to a different final partition.
void write(std::span< const uint8_t > data)
Writes data sequentially to the OTA partition.
update(const partition &part, size_t image_size)
Begins an OTA update, erasing space for the specified image size.
static update resume(const partition &part, size_t offset, sequential_erase_tag)
Resumes an interrupted OTA update with sequential (incremental) flash erase.
static result< update > try_resume(const partition &part, size_t offset)
Resumes an interrupted OTA update, erasing all remaining flash.
void write(const void *data, size_t size)
Writes data sequentially to the OTA partition.
update(const update &)=delete
void write_with_offset(uint32_t offset, std::span< const uint8_t > data)
Writes data at a specific offset in the OTA partition.
result< void > try_set_final_partition(const partition &final_part, bool copy=true)
Redirects the validated image to a different final partition.
update(update &&other) noexcept
Move constructor.
update & operator=(const update &)=delete
result< void > try_write_with_offset(uint32_t offset, const void *data, size_t size)
Writes data at a specific offset in the OTA partition.
result< void > try_write(const void *data, size_t size)
Writes data sequentially to the OTA partition.
static update resume(const partition &part, size_t offset, size_t erase_size)
Resumes an interrupted OTA update, erasing the specified amount of flash.
result< void > try_write(std::span< const uint8_t > data)
Writes data sequentially to the OTA partition.
update & operator=(update &&other) noexcept
Move assignment.
result< void > try_end()
Finalizes the OTA update and validates the written image.
update(const partition &part, sequential_erase_tag)
Begins an OTA update with sequential (incremental) flash erase.
static result< update > make(const partition &part, size_t image_size)
Begins an OTA update, erasing space for the specified image size.
static result< update > make(const partition &part)
Begins an OTA update, erasing the entire partition.
static result< update > try_resume(const partition &part, size_t offset, size_t erase_size)
Resumes an interrupted OTA update, erasing the specified amount of flash.
uint32_t esp_ota_handle_t
void invalidate_inactive_ota_data_slot()
Invalidates the OTA data slot for the last boot application partition.
void mark_valid()
Marks the running app as valid, cancelling any pending rollback.
partition boot_partition()
Returns the currently configured boot partition.
partition running_partition()
Returns the partition of the currently running application.
constexpr sequential_erase_tag sequential_erase
Tag value for sequential (incremental) flash erase mode.
result< partition > try_running_partition()
Returns the partition of the currently running application.
result< image_state > try_partition_state(const partition &part)
Returns the OTA image state for a partition.
result< void > try_mark_invalid_and_rollback()
Marks the running app as invalid and triggers a rollback with reboot.
app_description partition_description(const partition &part)
Returns the application description from a partition.
result< partition > try_last_invalid_partition()
Returns the last partition with invalid state.
image_state
OTA image state.
result< partition > try_next_update_partition(const partition *start_from=nullptr)
Returns the next OTA app partition to write an update to.
std::unexpected< std::error_code > ota_error(esp_err_t e)
Creates an unexpected error from an ESP-IDF error code, mapping to OTA error codes where possible.
size_t app_partition_count()
Returns the number of OTA app partitions in the partition table.
result< void > try_erase_last_boot_app_partition()
Erases the previous boot application partition and its OTA data.
void set_boot_partition(const partition &part)
Sets the boot partition for the next reboot.
void mark_invalid_and_rollback()
Marks the running app as invalid and triggers a rollback with reboot.
partition last_invalid_partition()
Returns the last partition with invalid state.
std::error_code make_error_code(errc e) noexcept
Creates an error code from an idfxx::ota::errc value.
errc
Error codes for OTA operations.
result< void > try_set_boot_partition(const partition &part)
Sets the boot partition for the next reboot.
bool rollback_possible()
Checks whether a rollback to a previous firmware is possible.
result< void > try_invalidate_inactive_ota_data_slot()
Invalidates the OTA data slot for the last boot application partition.
void erase_last_boot_app_partition()
Erases the previous boot application partition and its OTA data.
result< void > try_mark_valid()
Marks the running app as valid, cancelling any pending rollback.
result< partition > try_boot_partition()
Returns the currently configured boot partition.
result< app_description > try_partition_description(const partition &part)
Returns the application description from a partition.
const error_category & ota_category() noexcept
Returns a reference to the OTA error category singleton.
image_state partition_state(const partition &part)
Returns the OTA image state for a partition.
partition next_update_partition(const partition *start_from=nullptr)
Returns the next OTA app partition to write an update to.
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Tag type for sequential (incremental) flash erase mode.