|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
Non-Volatile Storage handle. More...
Classes | |
| class | error_category |
| Error category for NVS errors. More... | |
| class | flash |
Public Types | |
| enum class | errc : esp_err_t { not_found = 0x1102 , type_mismatch = 0x1103 , read_only = 0x1104 , not_enough_space = 0x1105 , invalid_name = 0x1106 , invalid_handle = 0x1107 , remove_failed = 0x1108 , key_too_long = 0x1109 , invalid_state = 0x110b , invalid_length = 0x110c , no_free_pages = 0x110d , value_too_long = 0x110e , part_not_found = 0x110f , new_version_found = 0x1110 , xts_encr_failed = 0x1111 , xts_decr_failed = 0x1112 , xts_cfg_failed = 0x1113 , xts_cfg_not_found = 0x1114 , encr_not_supported = 0x1115 , keys_not_initialized = 0x1116 , corrupt_key_part = 0x1117 , wrong_encryption = 0x1119 } |
| Error codes for NVS operations. More... | |
Public Member Functions | |
| nvs (std::string_view namespace_name, bool read_only=false) | |
| Opens a NVS namespace. | |
| ~nvs () | |
| nvs (const nvs &)=delete | |
| nvs & | operator= (const nvs &)=delete |
| nvs (nvs &&)=delete | |
| nvs & | operator= (nvs &&)=delete |
| bool | is_writeable () const |
| Returns true if the handle allows writes. | |
| void | commit () |
| Commits pending changes to flash. | |
| void | erase (std::string_view key) |
| Erases a key. | |
| void | erase_all () |
| Erases all keys in the namespace. | |
| void | set_string (std::string_view key, std::string_view value) |
| Stores a string. | |
| std::string | get_string (std::string_view key) |
| Retrieves a string. | |
| void | set_blob (std::string_view key, const void *data, size_t length) |
| Stores binary data. | |
| void | set_blob (std::string_view key, const std::vector< uint8_t > &data) |
| Stores binary data. | |
| std::vector< uint8_t > | get_blob (std::string_view key) |
| Retrieves binary data. | |
| template<typename T > requires sized_integral<T> | |
| void | set_value (std::string_view key, T value) |
| Stores an integer value. | |
| template<typename T > requires sized_integral<T> | |
| T | get_value (std::string_view key) |
| Retrieves an integer value. | |
| result< void > | try_commit () |
| Commits pending changes to flash. | |
| result< void > | try_erase (std::string_view key) |
| Erases a key. | |
| result< void > | try_erase_all () |
| Erases all keys in the namespace. | |
| result< void > | try_set_string (std::string_view key, std::string_view value) |
| Stores a string. | |
| result< std::string > | try_get_string (std::string_view key) |
| Retrieves a string. | |
| result< void > | try_set_blob (std::string_view key, const void *data, size_t length) |
| Stores binary data. | |
| result< void > | try_set_blob (std::string_view key, const std::vector< uint8_t > &data) |
| Stores binary data. | |
| result< std::vector< uint8_t > > | try_get_blob (std::string_view key) |
| Retrieves binary data. | |
| template<typename T > requires sized_integral<T> | |
| result< void > | try_set_value (std::string_view key, T value) |
| Stores an integer value. | |
| template<typename T > requires sized_integral<T> | |
| result< T > | try_get_value (std::string_view key) |
| Retrieves an integer value. | |
Static Public Member Functions | |
| static result< std::unique_ptr< nvs > > | make (std::string_view namespace_name, bool read_only=false) |
| Opens a NVS namespace. | |
Non-Volatile Storage handle.
Provides persistent key-value storage in flash memory. Supports strings, binary blobs, and integer types from 8 to 64 bits.
Changes are not persisted until commit() is called.
|
strong |
Error codes for NVS operations.
|
explicit |
Opens a NVS namespace.
| namespace_name | Namespace name (max 15 characters). |
| read_only | If true, opens in read-only mode. |
| std::system_error | on failure. |
| idfxx::nvs::~nvs | ( | ) |
|
delete |
|
delete |
|
inline |
Commits pending changes to flash.
| std::system_error | on error. |
Definition at line 142 of file nvs.hpp.
References try_commit(), and idfxx::unwrap().
|
inline |
Erases a key.
| key | The key to erase. |
| std::system_error | on error. |
Definition at line 150 of file nvs.hpp.
References try_erase(), and idfxx::unwrap().
|
inline |
Erases all keys in the namespace.
| std::system_error | on error. |
Definition at line 157 of file nvs.hpp.
References try_erase_all(), and idfxx::unwrap().
|
inline |
Retrieves binary data.
| key | Key name. |
| std::system_error | on error. |
Definition at line 203 of file nvs.hpp.
References try_get_blob(), and idfxx::unwrap().
|
inline |
Retrieves a string.
| key | Key name. |
| std::system_error | on error. |
Definition at line 175 of file nvs.hpp.
References try_get_string(), and idfxx::unwrap().
|
inline |
Retrieves an integer value.
| T | Integer type (8 to 64 bits, signed or unsigned). |
| key | Key name. |
| std::system_error | on error. |
Definition at line 229 of file nvs.hpp.
References idfxx::unwrap().
|
inline |
|
static |
Opens a NVS namespace.
| namespace_name | Namespace name (max 15 characters). |
| read_only | If true, opens in read-only mode. |
|
inline |
Stores binary data.
| key | Key name. |
| data | Data vector. |
| std::system_error | on error. |
Definition at line 194 of file nvs.hpp.
References try_set_blob(), and idfxx::unwrap().
|
inline |
Stores binary data.
| key | Key name. |
| data | Data pointer. |
| length | Data size in bytes. |
| std::system_error | on error. |
Definition at line 185 of file nvs.hpp.
References try_set_blob(), and idfxx::unwrap().
|
inline |
Stores a string.
| key | Key name. |
| value | String value. |
| std::system_error | on error. |
Definition at line 166 of file nvs.hpp.
References try_set_string(), and idfxx::unwrap().
|
inline |
Stores an integer value.
| T | Integer type (8 to 64 bits, signed or unsigned). |
| key | Key name. |
| value | Value to store. |
| std::system_error | on error. |
Definition at line 215 of file nvs.hpp.
References try_set_value(), and idfxx::unwrap().
| result< void > idfxx::nvs::try_commit | ( | ) |
| result< void > idfxx::nvs::try_erase | ( | std::string_view | key | ) |
| result< void > idfxx::nvs::try_erase_all | ( | ) |
| result< std::vector< uint8_t > > idfxx::nvs::try_get_blob | ( | std::string_view | key | ) |
Retrieves binary data.
| key | Key name. |
Referenced by get_blob().
| result< std::string > idfxx::nvs::try_get_string | ( | std::string_view | key | ) |
Retrieves a string.
| key | Key name. |
Referenced by get_string().
| result< T > idfxx::nvs::try_get_value | ( | std::string_view | key | ) |
Retrieves an integer value.
| T | Integer type (8 to 64 bits, signed or unsigned). |
| key | Key name. |
| result< void > idfxx::nvs::try_set_blob | ( | std::string_view | key, |
| const std::vector< uint8_t > & | data | ||
| ) |
Stores binary data.
| key | Key name. |
| data | Data pointer. |
| length | Data size in bytes. |
| result< void > idfxx::nvs::try_set_blob | ( | std::string_view | key, |
| const void * | data, | ||
| size_t | length | ||
| ) |
Stores binary data.
| key | Key name. |
| data | Data pointer. |
| length | Data size in bytes. |
Referenced by set_blob(), and set_blob().
| result< void > idfxx::nvs::try_set_string | ( | std::string_view | key, |
| std::string_view | value | ||
| ) |
Stores a string.
| key | Key name. |
| value | String value. |
Referenced by set_string().
| result< void > idfxx::nvs::try_set_value | ( | std::string_view | key, |
| T | value | ||
| ) |
Stores an integer value.
| T | Integer type (8 to 64 bits, signed or unsigned). |
| key | Key name. |
| value | Value to store. |
Referenced by set_value().