oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
Functions
Non-Volatile Storage

Key-value store backed by non-volatile memory. More...

Functions

int ove_nvs_init (void)
 Initialise the non-volatile storage subsystem.
 
void ove_nvs_deinit (void)
 Deinitialise the non-volatile storage subsystem.
 
int ove_nvs_read (const char *key, void *buf, size_t buf_len, size_t *out_len)
 Read a value from non-volatile storage by key.
 
int ove_nvs_write (const char *key, const void *data, size_t len)
 Write or update a value in non-volatile storage.
 
int ove_nvs_erase (const char *key)
 Delete a key-value pair from non-volatile storage.
 

Detailed Description

Key-value store backed by non-volatile memory.

Provides a simple string-keyed binary value store persisted in non-volatile storage (e.g. flash, EEPROM). Keys are null-terminated strings; values are arbitrary byte blobs of any size supported by the backend.

The subsystem must be initialised once with ove_nvs_init before any read, write, or erase operations are performed.

Note
Requires CONFIG_OVE_NVS.

Function Documentation

◆ ove_nvs_init()

int ove_nvs_init ( void  )

Initialise the non-volatile storage subsystem.

Must be called once before any other ove_nvs_* function. Performs backend-specific mount and integrity checks.

Returns
OVE_OK on success, negative error code on failure.
Note
Requires CONFIG_OVE_NVS.

◆ ove_nvs_deinit()

void ove_nvs_deinit ( void  )

Deinitialise the non-volatile storage subsystem.

Flushes any pending writes and unmounts the NVS backend. After this call all other ove_nvs_* functions will fail until ove_nvs_init is called again.

Note
Requires CONFIG_OVE_NVS.

◆ ove_nvs_read()

int ove_nvs_read ( const char *  key,
void *  buf,
size_t  buf_len,
size_t *  out_len 
)

Read a value from non-volatile storage by key.

Copies the value associated with key into buf. At most buf_len bytes are written. The actual size of the stored value is written to out_len when not NULL, which allows the caller to detect truncation or to perform a size query (pass NULL for buf and 0 for buf_len).

Parameters
[in]keyNull-terminated key string.
[out]bufBuffer to receive the value, or NULL for size query.
[in]buf_lenSize of buf in bytes.
[out]out_lenReceives the actual stored value length in bytes, or NULL if not needed.
Returns
OVE_OK on success, OVE_ERR_NOT_FOUND if the key does not exist, or another negative error code on failure.
Note
Requires CONFIG_OVE_NVS.

◆ ove_nvs_write()

int ove_nvs_write ( const char *  key,
const void *  data,
size_t  len 
)

Write or update a value in non-volatile storage.

Associates key with the len bytes pointed to by data. If the key already exists its value is replaced. The write is committed to non-volatile storage before the function returns.

Parameters
[in]keyNull-terminated key string.
[in]dataPointer to the value data to store.
[in]lenNumber of bytes to store.
Returns
OVE_OK on success, negative error code on failure.
Note
Requires CONFIG_OVE_NVS.

◆ ove_nvs_erase()

int ove_nvs_erase ( const char *  key)

Delete a key-value pair from non-volatile storage.

Permanently removes the entry identified by key. Has no effect if the key does not exist.

Parameters
[in]keyNull-terminated key string to erase.
Returns
OVE_OK on success, negative error code on failure.
Note
Requires CONFIG_OVE_NVS.