idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
ota.hpp File Reference

OTA firmware update management. More...

#include <idfxx/error>
#include <idfxx/partition>
#include <cstddef>
#include <cstdint>
#include <esp_app_desc.h>
#include <span>
#include <string_view>

Go to the source code of this file.

Classes

struct  idfxx::ota::sequential_erase_tag
 Tag type for sequential (incremental) flash erase mode. More...
 
class  idfxx::ota::error_category
 Error category for OTA errors. More...
 
class  idfxx::ota::app_description
 Application description from a firmware image. More...
 
class  idfxx::ota::update
 RAII OTA update session. More...
 

Namespaces

namespace  idfxx
 
namespace  idfxx::ota
 

Typedefs

typedef uint32_t esp_ota_handle_t
 

Enumerations

enum class  idfxx::ota::errc : esp_err_t {
  idfxx::ota::partition_conflict = 0x1501 ,
  idfxx::ota::select_info_invalid = 0x1502 ,
  idfxx::ota::validate_failed = 0x1503 ,
  idfxx::ota::small_sec_ver = 0x1504 ,
  idfxx::ota::rollback_failed = 0x1505 ,
  idfxx::ota::rollback_invalid_state = 0x1506
}
 Error codes for OTA operations. More...
 
enum class  idfxx::ota::image_state : uint32_t {
  idfxx::ota::new_image = 0x0U ,
  idfxx::ota::pending_verify = 0x1U ,
  idfxx::ota::valid = 0x2U ,
  idfxx::ota::invalid = 0x3U ,
  idfxx::ota::aborted = 0x4U ,
  idfxx::ota::undefined = 0xFFFFFFFFU
}
 OTA image state. More...
 

Functions

void idfxx::ota::set_boot_partition (const partition &part)
 Sets the boot partition for the next reboot.
 
partition idfxx::ota::boot_partition ()
 Returns the currently configured boot partition.
 
partition idfxx::ota::running_partition ()
 Returns the partition of the currently running application.
 
partition idfxx::ota::next_update_partition (const partition *start_from=nullptr)
 Returns the next OTA app partition to write an update to.
 
result< voididfxx::ota::try_set_boot_partition (const partition &part)
 Sets the boot partition for the next reboot.
 
result< partitionidfxx::ota::try_boot_partition ()
 Returns the currently configured boot partition.
 
result< partitionidfxx::ota::try_running_partition ()
 Returns the partition of the currently running application.
 
result< partitionidfxx::ota::try_next_update_partition (const partition *start_from=nullptr)
 Returns the next OTA app partition to write an update to.
 
app_description idfxx::ota::partition_description (const partition &part)
 Returns the application description from a partition.
 
result< app_descriptionidfxx::ota::try_partition_description (const partition &part)
 Returns the application description from a partition.
 
void idfxx::ota::mark_valid ()
 Marks the running app as valid, cancelling any pending rollback.
 
void idfxx::ota::mark_invalid_and_rollback ()
 Marks the running app as invalid and triggers a rollback with reboot.
 
image_state idfxx::ota::partition_state (const partition &part)
 Returns the OTA image state for a partition.
 
result< voididfxx::ota::try_mark_valid ()
 Marks the running app as valid, cancelling any pending rollback.
 
result< voididfxx::ota::try_mark_invalid_and_rollback ()
 Marks the running app as invalid and triggers a rollback with reboot.
 
result< image_stateidfxx::ota::try_partition_state (const partition &part)
 Returns the OTA image state for a partition.
 
bool idfxx::ota::rollback_possible ()
 Checks whether a rollback to a previous firmware is possible.
 
partition idfxx::ota::last_invalid_partition ()
 Returns the last partition with invalid state.
 
result< partitionidfxx::ota::try_last_invalid_partition ()
 Returns the last partition with invalid state.
 
void idfxx::ota::erase_last_boot_app_partition ()
 Erases the previous boot application partition and its OTA data.
 
void idfxx::ota::invalidate_inactive_ota_data_slot ()
 Invalidates the OTA data slot for the last boot application partition.
 
result< voididfxx::ota::try_erase_last_boot_app_partition ()
 Erases the previous boot application partition and its OTA data.
 
result< voididfxx::ota::try_invalidate_inactive_ota_data_slot ()
 Invalidates the OTA data slot for the last boot application partition.
 
size_t idfxx::ota::app_partition_count ()
 Returns the number of OTA app partitions in the partition table.
 
const error_categoryidfxx::ota::ota_category () noexcept
 Returns a reference to the OTA error category singleton.
 
std::error_code idfxx::ota::make_error_code (errc e) noexcept
 Creates an error code from an idfxx::ota::errc value.
 
std::unexpected< std::error_code > idfxx::ota::ota_error (esp_err_t e)
 Creates an unexpected error from an ESP-IDF error code, mapping to OTA error codes where possible.
 

Variables

constexpr sequential_erase_tag idfxx::ota::sequential_erase {}
 Tag value for sequential (incremental) flash erase mode.
 

Detailed Description

OTA firmware update management.

Definition in file ota.hpp.