TB2026-YDS Firmware
Loading...
Searching...
No Matches
Settings service

Persistent key/value store for user preferences (NVS-backed). More...

Collaboration diagram for Settings service:

Functions

esp_err_t settings_init (void)
 Initialise NVS so the settings accessors can be used.
esp_err_t settings_get_u8 (const char *key, uint8_t *out)
 Read a stored uint8 preference.
esp_err_t settings_set_u8 (const char *key, uint8_t val)
 Store a uint8 preference and commit it.
esp_err_t settings_get_u32 (const char *key, uint32_t *out)
 Read a stored uint32 preference.
esp_err_t settings_set_u32 (const char *key, uint32_t val)
 Store a uint32 preference and commit it.
esp_err_t settings_get_str (const char *key, char *out, size_t out_size)
 Read a stored NUL-terminated string preference.
esp_err_t settings_set_str (const char *key, const char *val)
 Store a NUL-terminated string preference and commit it.

Detailed Description

Persistent key/value store for user preferences (NVS-backed).

Function Documentation

◆ settings_get_str()

esp_err_t settings_get_str ( const char * key,
char * out,
size_t out_size )

Read a stored NUL-terminated string preference.

Parameters
[in]keyNVS key (<= 15 chars).
[out]outBuffer to receive the string (always NUL-terminated on ESP_OK).
[in]out_sizeSize of out in bytes.
Returns
ESP_OK, ESP_ERR_NVS_NOT_FOUND if absent, ESP_ERR_NVS_INVALID_LENGTH if out is too small, or another esp_err_t.

◆ settings_get_u32()

esp_err_t settings_get_u32 ( const char * key,
uint32_t * out )

Read a stored uint32 preference.

Parameters
[in]keyNVS key (<= 15 chars).
[out]outReceives the stored value; untouched on error.
Returns
ESP_OK, ESP_ERR_NVS_NOT_FOUND if absent, or another esp_err_t.

◆ settings_get_u8()

esp_err_t settings_get_u8 ( const char * key,
uint8_t * out )

Read a stored uint8 preference.

Parameters
[in]keyNVS key (<= 15 chars).
[out]outReceives the stored value; untouched on error.
Returns
ESP_OK, ESP_ERR_NVS_NOT_FOUND if the key was never set (use your default), or another esp_err_t.

◆ settings_init()

esp_err_t settings_init ( void )

Initialise NVS so the settings accessors can be used.

Safe to call more than once and from any service's init: the underlying nvs_flash_init() is idempotent. Recovers a corrupt/outdated NVS partition by erasing and re-initialising it.

Returns
ESP_OK on success, or an esp_err_t from nvs_flash_init().

◆ settings_set_str()

esp_err_t settings_set_str ( const char * key,
const char * val )

Store a NUL-terminated string preference and commit it.

See also
settings_get_str

◆ settings_set_u32()

esp_err_t settings_set_u32 ( const char * key,
uint32_t val )

Store a uint32 preference and commit it.

See also
settings_get_u32

◆ settings_set_u8()

esp_err_t settings_set_u8 ( const char * key,
uint8_t val )

Store a uint8 preference and commit it.

See also
settings_get_u8