CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
NVS (plugin-namespaced)

Persistent key/value storage scoped to the calling plugin. More...

Functions

int host_nvs_get_blob (const char *key, uint8_t *buf, size_t *len)
 Read a binary blob from NVS.
int host_nvs_set_blob (const char *key, const uint8_t *buf, size_t len)
 Write a binary blob to NVS.
int host_nvs_get_u32 (const char *key, uint32_t *out)
 Read a uint32 value.
int host_nvs_set_u32 (const char *key, uint32_t value)
 Write a uint32 value.
int host_nvs_get_str (const char *key, char *buf, size_t buf_size)
 Read a NUL-terminated string.
int host_nvs_set_str (const char *key, const char *value)
 Write a NUL-terminated string.
int host_nvs_erase (const char *key)
 Delete a single key.
int host_nvs_erase_all (void)
 Erase every key in the plugin's namespace.
int host_nvs_list_keys (char *out, size_t *out_len)
 Enumerate the keys in the plugin's namespace.

Detailed Description

Persistent key/value storage scoped to the calling plugin.

Keys live in an NVS namespace derived from the plugin id, so different plugins cannot collide. Erasing the plugin wipes its namespace.

Function Documentation

◆ host_nvs_erase()

int host_nvs_erase ( const char * key)

Delete a single key.

Definition at line 132 of file host_api_nvs.cpp.

References HOST_ERR_INVALID_ARG, and HOST_OK.

Referenced by cdc::plugin_manager::w_host_nvs_erase().

◆ host_nvs_erase_all()

int host_nvs_erase_all ( void )

Erase every key in the plugin's namespace.

Definition at line 141 of file host_api_nvs.cpp.

References HOST_OK.

Referenced by cdc::plugin_manager::w_host_nvs_erase_all().

◆ host_nvs_get_blob()

int host_nvs_get_blob ( const char * key,
uint8_t * buf,
size_t * len )

Read a binary blob from NVS.

Parameters
lenIn: capacity of buf; out: bytes actually read.

Definition at line 77 of file host_api_nvs.cpp.

References HOST_ERR_INVALID_ARG, and HOST_OK.

Referenced by cdc::plugin_manager::w_host_nvs_get_blob().

◆ host_nvs_get_str()

int host_nvs_get_str ( const char * key,
char * buf,
size_t buf_size )

Read a NUL-terminated string.

Definition at line 113 of file host_api_nvs.cpp.

References HOST_ERR_INVALID_ARG, and HOST_OK.

Referenced by cdc::plugin_manager::w_host_nvs_get_str().

◆ host_nvs_get_u32()

int host_nvs_get_u32 ( const char * key,
uint32_t * out )

Read a uint32 value.

Definition at line 95 of file host_api_nvs.cpp.

References HOST_ERR_INVALID_ARG, and HOST_OK.

Referenced by cdc::plugin_manager::w_host_nvs_get_u32().

◆ host_nvs_list_keys()

int host_nvs_list_keys ( char * out,
size_t * out_len )

Enumerate the keys in the plugin's namespace.

Parameters
out_lenIn: capacity of out; out: bytes written (NUL-separated list).

Definition at line 149 of file host_api_nvs.cpp.

References HOST_ERR_INVALID_ARG, HOST_ERR_NO_CAPABILITY, and HOST_OK.

Referenced by cdc::plugin_manager::w_host_nvs_list_keys().

◆ host_nvs_set_blob()

int host_nvs_set_blob ( const char * key,
const uint8_t * buf,
size_t len )

Write a binary blob to NVS.

Definition at line 86 of file host_api_nvs.cpp.

References HOST_ERR_INVALID_ARG, and HOST_OK.

Referenced by cdc::plugin_manager::w_host_nvs_set_blob().

◆ host_nvs_set_str()

int host_nvs_set_str ( const char * key,
const char * value )

Write a NUL-terminated string.

Definition at line 123 of file host_api_nvs.cpp.

References HOST_ERR_INVALID_ARG, and HOST_OK.

Referenced by cdc::plugin_manager::w_host_nvs_set_str().

◆ host_nvs_set_u32()

int host_nvs_set_u32 ( const char * key,
uint32_t value )

Write a uint32 value.

Definition at line 104 of file host_api_nvs.cpp.

References HOST_ERR_INVALID_ARG, and HOST_OK.

Referenced by cdc::plugin_manager::w_host_nvs_set_u32().