|
oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
|
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. | |
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.
CONFIG_OVE_NVS. | 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.
CONFIG_OVE_NVS. | 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.
CONFIG_OVE_NVS. | 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).
| [in] | key | Null-terminated key string. |
| [out] | buf | Buffer to receive the value, or NULL for size query. |
| [in] | buf_len | Size of buf in bytes. |
| [out] | out_len | Receives the actual stored value length in bytes, or NULL if not needed. |
OVE_ERR_NOT_FOUND if the key does not exist, or another negative error code on failure. CONFIG_OVE_NVS. | 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.
| [in] | key | Null-terminated key string. |
| [in] | data | Pointer to the value data to store. |
| [in] | len | Number of bytes to store. |
CONFIG_OVE_NVS. | 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.
| [in] | key | Null-terminated key string to erase. |
CONFIG_OVE_NVS.