16#define MESHX_NVS_INIT_MAGIC 0x5489
18#ifdef CONFIG_BLE_MESH_SPECIFIC_PARTITION
19#define MESHX_NVS_PARTITION CONFIG_BLE_MESH_PARTITION_NAME
22#define MESHX_NVS_NAMESPACE_PID "MESHX_PID"
23#define MESHX_NVS_NAMESPACE_CID "MESHX_CID"
24#define MESHX_NVS_TIMER_NAME "MESHX_COMMIT_TIMER"
25#define MESHX_NVS_ELEMENT_CTX "MESHX_API_%04x"
26#define MESHX_NVS_RELOAD_ONE_SHOT 0
27#define MESHX_KEY_NAME_MAX_SIZE 16
28#define MESHX_KEY_VALUE_MAX_SIZE 256
48#if CONFIG_ENABLE_UNIT_TEST
49#define MESHX_NVS_UNIT_TEST_KEY "MESHX_UT"
59#if MESHX_NVS_TIMER_PERIOD
138#if CONFIG_ENABLE_UNIT_TEST
181#if MESHX_NVS_TIMER_PERIOD
182 if(commit_timeout_ms == 0)
190 &meshx_nvs_os_timer_cb,
309#if MESHX_NVS_TIMER_PERIOD
380 memcpy(cur->
data, blob, blob_size);
381 cur->
len = blob_size;
392 memcpy(node->
data, blob, blob_size);
393 node->
len = blob_size;
400#if MESHX_NVS_TIMER_PERIOD
469#if CONFIG_ENABLE_UNIT_TEST
503 uint32_t ut_blob = 0xDEAD;
504 uint32_t ut_blob_get = 0x00;
#define CONFIG_CID_ID
Application Main.
meshx_err_t
MeshX Error Codes.
#define MESHX_LOGW(module_id, format,...)
#define MESHX_LOGI(module_id, format,...)
#define MESHX_LOGE(module_id, format,...)
#define MESHX_LOGD(module_id, format,...)
meshx_err_t meshx_nvs_element_ctx_set(uint16_t element_id, const void *blob, size_t blob_size)
Store the context of a specific element to NVS.
meshx_err_t meshx_nvs_init(void)
MeshX NVS Initialisation.
meshx_err_t meshx_nvs_close(void)
Close the NVS handle.
enum meshx_nvs_cli_cmd meshx_nvs_cli_cmd_t
MeshX NVS unit test command IDs.
meshx_err_t meshx_nvs_element_ctx_get(uint16_t element_id, void *blob, size_t blob_size)
Retrieve the context of a specific element from NVS.
#define MESHX_KEY_NAME_MAX_SIZE
#define MESHX_NVS_INIT_MAGIC
#define MESHX_NVS_UNIT_TEST_KEY
#define MESHX_NVS_RELOAD_ONE_SHOT
meshx_err_t meshx_nvs_element_ctx_remove(uint16_t element_id)
Remove the context of a specific element from NVS.
#define MESHX_NVS_NAMESPACE_PID
#define MESHX_NVS_TIMER_NAME
#define MESHX_NVS_NAMESPACE_CID
#define MESHX_NVS_ELEMENT_CTX
meshx_err_t meshx_nvs_remove(char const *key)
Remove a key-value pair from the NVS.
#define MESHX_KEY_VALUE_MAX_SIZE
static meshx_nvs_t meshx_nvs_inst
: MeshX NVS Instance
struct meshx_nvs_write_list meshx_nvs_write_list_t
meshx_err_t meshx_nvs_open(uint16_t cid, uint16_t pid, uint32_t commit_timeout_ms)
Open the NVS with a timeout.
meshx_err_t meshx_nvs_set(char const *key, void const *blob, uint16_t blob_size, bool arm_timer)
Set a value in the NVS.
meshx_nvs_write_list_t * meshx_nvs_write_list_head
Head of the linked list used to store key-value pairs that need to be written to NVS.
meshx_err_t meshx_nvs_commit(void)
Commit changes to the NVS.
meshx_err_t meshx_nvs_erase(void)
Erase all key-value pairs stored in the NVS.
static meshx_err_t meshx_nvs_erase_prod_init(uint16_t cid, uint16_t pid)
Erase the NVS and set the product ID.
meshx_err_t meshx_nvs_get(char const *key, void *blob, uint16_t blob_size)
Get a value from the NVS.
meshx_nvs_cli_cmd
MeshX NVS unit test command IDs.
@ MESHX_NVS_CLI_CMD_REMOVE
@ MESHX_NVS_CLI_CMD_COMMIT
@ MESHX_NVS_CLI_CMD_CLOSE
@ MESHX_NVS_CLI_CMD_ERASE
static meshx_err_t meshx_nvs_unit_test_cb_handler(int cmd_id, int argc, char **argv)
Callback handler for MeshX NVS unit test command.
Header file for MeshX Non-Volatile Storage (NVS) operations.
struct meshx_nvs meshx_nvs_t
#define MESHX_NVS_NO_AUTO_COMMIT
#define MESHX_NVS_TIMER_PERIOD
#define MESHX_NVS_AUTO_COMMIT
meshx_err_t meshx_nvs_plat_read(uintptr_t p_nvs_handle, char const *key, uint8_t *p_data, uint16_t len)
Read blob value for given key from non-volatile storage.
meshx_err_t meshx_nvs_plat_open(uintptr_t *p_nvs_handle)
Open non-volatile storage with a given namespace from the default partition.
meshx_err_t meshx_nvs_plat_write(uintptr_t p_nvs_handle, char const *key, uint8_t const *p_data, uint16_t len)
Write a blob value to the non-volatile storage with a given key and namespace.
meshx_err_t meshx_nvs_plat_commit(uintptr_t p_nvs_handle)
Commit changes to the non-volatile storage.
meshx_err_t meshx_nvs_plat_erase(uintptr_t p_nvs_handle)
Erase all key-value pairs in the given namespace.
meshx_err_t meshx_nvs_plat_remove(uintptr_t p_nvs_handle, char const *key)
Remove a key-value pair from the non-volatile storage with a given key and namespace.
meshx_err_t meshx_nvs_plat_close(uintptr_t p_nvs_handle)
Close the non-volatile storage handle.
struct meshx_os_timer meshx_os_timer_t
Alias for the meshx_os_timer structure.
meshx_err_t meshx_os_timer_create(const char *name, uint32_t period, bool reload, meshx_os_timer_cb_t cb, meshx_os_timer_t **timer_handle)
Create a timer.
meshx_err_t meshx_os_timer_restart(const meshx_os_timer_t *timer_handle)
Restart a timer.
meshx_err_t meshx_os_timer_delete(meshx_os_timer_t **timer_handle)
Delete a timer.
#define OS_TMER_GET_TIMER_NAME(timer)
return timer registered name pointer
@ MODULE_ID_COMPONENT_MESHX_NVS
Linked list structure used to store key-value pairs that need to be written to NVS.
struct meshx_nvs_write_list * next
uint8_t data[MESHX_KEY_VALUE_MAX_SIZE]
char key[MESHX_KEY_NAME_MAX_SIZE]
meshx_err_t register_unit_test(module_id_t module_id, module_callback_t callback)
Register a unit test for a specific module.
#define UT_GET_ARG(_x, _type, _argv)
Macro to extract an argument from the argument list.