Locos stored in NVS.
More...
#include <locos.hpp>
|
| Locos () |
|
dcc::NvLocoBase | get (dcc::Address::value_type addr) const |
| Get loco by address.
|
|
dcc::NvLocoBase | get (std::string const &key) const |
| Get loco by key.
|
|
esp_err_t | set (dcc::Address::value_type addr, dcc::NvLocoBase const &loco) |
| Set loco from address.
|
|
esp_err_t | set (std::string const &key, dcc::NvLocoBase const &loco) |
| Set loco from key.
|
|
esp_err_t | erase (dcc::Address::value_type addr) |
| Erase loco from address.
|
|
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.
|
|
|
static std::string | address2key (dcc::Address::value_type addr) |
| Convert address to key.
|
|
static dcc::Address::value_type | key2address (std::string_view key) |
| Convert key to address.
|
|
|
| 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.
|
|
nvs::Locos allows to store locomotives (i.e. mobile decoders) in a JSON format in the NVS namespace "locos". The decoder address is used as key, the JSON string represents the value. The conversion to and from JSON is handled internally by the ArduinoJson library. Getters and setters are overloaded and available in dcc::Address::value_type
or std::string
variants.
The two utility functions nvs::Locos::address2key() and nvs::Locos::key2address() are also part of this class. They can be used to convert a dcc::Address::value_type
into a std::string
(or vice versa).
◆ Locos()
mem::nvs::Locos::Locos |
( |
| ) |
|
|
inlineexplicit |
◆ address2key()
std::string mem::nvs::Locos::address2key |
( |
dcc::Address::value_type | addr | ) |
|
|
static |
◆ erase()
esp_err_t mem::nvs::Locos::erase |
( |
dcc::Address::value_type | addr | ) |
|
- Parameters
-
- Return values
-
ESP_OK | Erase operation was successful |
ESP_FAIL | Internal error |
ESP_ERR_NVS_NOT_FOUND | Requested key doesn't exist |
◆ get() [1/2]
dcc::NvLocoBase mem::nvs::Locos::get |
( |
dcc::Address::value_type | addr | ) |
const |
◆ get() [2/2]
◆ key2address()
dcc::Address::value_type mem::nvs::Locos::key2address |
( |
std::string_view | key | ) |
|
|
static |
- Parameters
-
- Returns
- Address
◆ set() [1/2]
esp_err_t mem::nvs::Locos::set |
( |
dcc::Address::value_type | addr, |
|
|
dcc::NvLocoBase const & | loco ) |
- Parameters
-
- 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 |
◆ set() [2/2]
esp_err_t mem::nvs::Locos::set |
( |
std::string const & | key, |
|
|
dcc::NvLocoBase const & | loco ) |
- Parameters
-
- 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 |
The documentation for this class was generated from the following files:
- /home/runner/work/Firmware/Firmware/src/mem/nvs/locos.hpp
- /home/runner/work/Firmware/Firmware/src/mem/nvs/locos.cpp