NVS base.
More...
#include <base.hpp>
|
auto | begin () const |
|
auto | cbegin () const |
|
auto | end () const |
|
auto | cend () const |
|
esp_err_t | erase (std::string const &key) |
| Erase key-value pair with given key name.
|
|
esp_err_t | eraseAll () |
| Erase all key-value pairs in a namespace.
|
|
|
| Base (char const *namespace_name, nvs_open_mode_t open_mode) |
| Ctor.
|
|
| ~Base () |
| Dtor.
|
|
std::string | getBlob (std::string const &key) const |
| Get blob value for given key.
|
|
esp_err_t | setBlob (std::string const &key, std::string_view str) |
| Set blob value for given key.
|
|
uint8_t | getU8 (std::string const &key) const |
| Get uint8_t value for given key.
|
|
esp_err_t | setU8 (std::string const &key, uint8_t value) |
| Set uint8_t value for given key.
|
|
uint8_t | getU16 (std::string const &key) const |
| Get uint16_t value for given key.
|
|
esp_err_t | setU16 (std::string const &key, uint16_t value) |
| Set uint16_t value for given key.
|
|
|
char const * | _namespace_name {} |
| Store namespace name (mainly for iterator)
|
|
nvs_handle_t | _handle {} |
| Opaque pointer type representing non-volatile storage handle.
|
|
bool | _commit_pending {} |
| Flag to indicate commit pending.
|
|
nvs::Base is a convenience wrapper over the NVS C-API and forms the basis of all NVS classes. The RAII idiom ensures that the desired namespace is opened in the constructor and that any write operations are committed in the destructor and the namespace is closed again.
A nested iterator type (nvs::Base::Iterator) ensures that the keys of the namespace can be iterated over.
◆ Base()
mem::nvs::Base::Base |
( |
char const * | namespace_name, |
|
|
nvs_open_mode_t | open_mode ) |
|
protected |
Open non-volatile storage with a given namespace from the default NVS partition.
- Parameters
-
namespace_name | Namespace to open |
open_mode | Mode of opening the non-volatile storage |
◆ ~Base()
mem::nvs::Base::~Base |
( |
| ) |
|
|
protected |
Write any pending changes to non-volatile storage, then close the storage handle and free any allocated resources.
◆ begin()
auto mem::nvs::Base::begin |
( |
| ) |
const |
|
inline |
◆ cbegin()
auto mem::nvs::Base::cbegin |
( |
| ) |
const |
|
inline |
◆ cend()
auto mem::nvs::Base::cend |
( |
| ) |
const |
|
inline |
◆ end()
auto mem::nvs::Base::end |
( |
| ) |
const |
|
inline |
◆ erase()
esp_err_t mem::nvs::Base::erase |
( |
std::string const & | key | ) |
|
- Parameters
-
- Return values
-
ESP_OK | Erase operation was successful |
ESP_FAIL | Internal error |
ESP_ERR_NVS_NOT_FOUND | Requested key doesn't exist |
◆ eraseAll()
esp_err_t mem::nvs::Base::eraseAll |
( |
| ) |
|
- Return values
-
ESP_OK | Erase operation was successful |
ESP_FAIL | Internal error |
◆ getBlob()
std::string mem::nvs::Base::getBlob |
( |
std::string const & | key | ) |
const |
|
protected |
- Parameters
-
- Returns
- Blob value as
std::string
◆ getU16()
uint8_t mem::nvs::Base::getU16 |
( |
std::string const & | key | ) |
const |
|
protected |
- Parameters
-
- Returns
- uint16_t value
◆ getU8()
uint8_t mem::nvs::Base::getU8 |
( |
std::string const & | key | ) |
const |
|
protected |
- Parameters
-
- Returns
- uint8_t value
◆ setBlob()
esp_err_t mem::nvs::Base::setBlob |
( |
std::string const & | key, |
|
|
std::string_view | str ) |
|
protected |
- Parameters
-
key | Key name |
str | Blob value |
- Return values
-
ESP_OK | Value was set successfully |
ESP_FAIL | Internal error |
ESP_ERR_NVS_INVALID_NAME | Key name doesn't satisfy constraints |
ESP_ERR_NVS_NOT_ENOUGH_SPACE | Not enough space |
ESP_ERR_NVS_REMOVE_FAILED | Value wasn't updated because flash write operation has failed |
ESP_ERR_NVS_VALUE_TOO_LONG | String value is too long |
◆ setU16()
esp_err_t mem::nvs::Base::setU16 |
( |
std::string const & | key, |
|
|
uint16_t | value ) |
|
protected |
- Parameters
-
key | Key name |
value | uint16_t value |
- Return values
-
ESP_OK | Value was set successfully |
ESP_FAIL | Internal error |
ESP_ERR_NVS_INVALID_NAME | Key name doesn't satisfy constraints |
ESP_ERR_NVS_NOT_ENOUGH_SPACE | Not enough space |
ESP_ERR_NVS_REMOVE_FAILED | Value wasn't updated because flash write operation has failed |
◆ setU8()
esp_err_t mem::nvs::Base::setU8 |
( |
std::string const & | key, |
|
|
uint8_t | value ) |
|
protected |
- Parameters
-
key | Key name |
value | uint8_t value |
- Return values
-
ESP_OK | Value was set successfully |
ESP_FAIL | Internal error |
ESP_ERR_NVS_INVALID_NAME | Key name doesn't satisfy constraints |
ESP_ERR_NVS_NOT_ENOUGH_SPACE | Not enough space |
ESP_ERR_NVS_REMOVE_FAILED | Value wasn't updated because flash write operation has failed |
◆ _commit_pending
bool mem::nvs::Base::_commit_pending {} |
|
private |
◆ _handle
nvs_handle_t mem::nvs::Base::_handle {} |
|
private |
◆ _namespace_name
char const* mem::nvs::Base::_namespace_name {} |
|
private |
The documentation for this class was generated from the following files:
- /home/runner/work/Firmware/Firmware/src/mem/nvs/base.hpp
- /home/runner/work/Firmware/Firmware/src/mem/nvs/base.cpp