MeshX 0.3
This repository provides an implementation for Bluetooth Low Energy (BLE) Mesh network nodes. The project allows you to create BLE mesh nodes that can communicate with each other, enabling the development of smart home solutions or other IoT-based applications.
|
Implementation for MeshX Non-Volatile Storage (NVS) operations. More...
Go to the source code of this file.
Data Structures | |
struct | meshx_nvs_write_list |
Linked list structure used to store key-value pairs that need to be written to NVS. More... | |
Macros | |
#define | MESHX_NVS_INIT_MAGIC 0x5489 |
#define | MESHX_NVS_NAMESPACE_PID "MESHX_PID" |
#define | MESHX_NVS_NAMESPACE_CID "MESHX_CID" |
#define | MESHX_NVS_TIMER_NAME "MESHX_COMMIT_TIMER" |
#define | MESHX_NVS_ELEMENT_CTX "MESHX_API_%04x" |
#define | MESHX_NVS_RELOAD_ONE_SHOT 0 |
#define | MESHX_KEY_NAME_MAX_SIZE 16 |
#define | MESHX_KEY_VALUE_MAX_SIZE 256 |
#define | MESHX_NVS_UNIT_TEST_KEY "MESHX_UT" |
Typedefs | |
typedef struct meshx_nvs_write_list | meshx_nvs_write_list_t |
typedef enum meshx_nvs_cli_cmd | meshx_nvs_cli_cmd_t |
MeshX NVS unit test command IDs. | |
Enumerations | |
enum | meshx_nvs_cli_cmd { MESHX_NVS_CLI_CMD_OPEN , MESHX_NVS_CLI_CMD_SET , MESHX_NVS_CLI_CMD_GET , MESHX_NVS_CLI_CMD_COMMIT , MESHX_NVS_CLI_CMD_REMOVE , MESHX_NVS_CLI_CMD_ERASE , MESHX_NVS_CLI_CMD_CLOSE , MESHX_NVS_CLI_MAX } |
MeshX NVS unit test command IDs. More... | |
Functions | |
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. | |
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_init (void) |
MeshX NVS Initialisation. | |
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_erase (void) |
Erase all key-value pairs stored in the NVS. | |
meshx_err_t | meshx_nvs_commit (void) |
Commit changes to the NVS. | |
meshx_err_t | meshx_nvs_close (void) |
Close the NVS handle. | |
meshx_err_t | meshx_nvs_remove (char const *key) |
Remove a key-value pair from the NVS. | |
meshx_err_t | meshx_nvs_get (char const *key, void *blob, uint16_t blob_size) |
Get a value from the NVS. | |
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_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. | |
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_element_ctx_remove (uint16_t element_id) |
Remove the context of a specific element from NVS. | |
Variables | |
meshx_nvs_write_list_t * | meshx_nvs_write_list_head = NULL |
Head of the linked list used to store key-value pairs that need to be written to NVS. | |
static meshx_nvs_t | meshx_nvs_inst |
: MeshX NVS Instance | |
Implementation for MeshX Non-Volatile Storage (NVS) operations.
Copyright © 2024 - 2025 MeshX
This file provides APIs to manage the Non-Volatile Storage (NVS) used in the MeshX system. It includes functions to read, write, erase, and manage key-value pairs stored persistently.
Definition in file meshx_nvs.c.
#define MESHX_KEY_NAME_MAX_SIZE 16 |
Definition at line 27 of file meshx_nvs.c.
#define MESHX_KEY_VALUE_MAX_SIZE 256 |
Definition at line 28 of file meshx_nvs.c.
#define MESHX_NVS_ELEMENT_CTX "MESHX_API_%04x" |
Definition at line 25 of file meshx_nvs.c.
#define MESHX_NVS_INIT_MAGIC 0x5489 |
Definition at line 16 of file meshx_nvs.c.
#define MESHX_NVS_NAMESPACE_CID "MESHX_CID" |
Definition at line 23 of file meshx_nvs.c.
#define MESHX_NVS_NAMESPACE_PID "MESHX_PID" |
Definition at line 22 of file meshx_nvs.c.
#define MESHX_NVS_RELOAD_ONE_SHOT 0 |
Definition at line 26 of file meshx_nvs.c.
#define MESHX_NVS_TIMER_NAME "MESHX_COMMIT_TIMER" |
Definition at line 24 of file meshx_nvs.c.
#define MESHX_NVS_UNIT_TEST_KEY "MESHX_UT" |
Definition at line 49 of file meshx_nvs.c.
typedef enum meshx_nvs_cli_cmd meshx_nvs_cli_cmd_t |
MeshX NVS unit test command IDs.
typedef struct meshx_nvs_write_list meshx_nvs_write_list_t |
enum meshx_nvs_cli_cmd |
MeshX NVS unit test command IDs.
Enumerator | |
---|---|
MESHX_NVS_CLI_CMD_OPEN | |
MESHX_NVS_CLI_CMD_SET | |
MESHX_NVS_CLI_CMD_GET | |
MESHX_NVS_CLI_CMD_COMMIT | |
MESHX_NVS_CLI_CMD_REMOVE | |
MESHX_NVS_CLI_CMD_ERASE | |
MESHX_NVS_CLI_CMD_CLOSE | |
MESHX_NVS_CLI_MAX |
Definition at line 474 of file meshx_nvs.c.
meshx_err_t meshx_nvs_close | ( | void | ) |
Close the NVS handle.
This function releases any resources associated with the NVS handle.
Definition at line 297 of file meshx_nvs.c.
meshx_err_t meshx_nvs_commit | ( | void | ) |
Commit changes to the NVS.
This function ensures that any pending changes to the NVS are flushed to persistent storage.
Definition at line 259 of file meshx_nvs.c.
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.
This function fetches the stored context of a given element identified by its ID from the Non-Volatile Storage (NVS).
[in] | element_id | The ID of the element whose context is to be retrieved. |
[out] | blob | Pointer to the buffer where the retrieved context will be stored. |
[in] | blob_size | Size of the buffer provided to store the context. |
Definition at line 424 of file meshx_nvs.c.
meshx_err_t meshx_nvs_element_ctx_remove | ( | uint16_t | element_id | ) |
Remove the context of a specific element from NVS.
This function deletes the stored context of a given element identified by its ID from the Non-Volatile Storage (NVS).
[in] | element_id | The ID of the element whose context is to be removed. |
Definition at line 462 of file meshx_nvs.c.
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.
This function saves the context of a given element identified by its ID to the Non-Volatile Storage (NVS).
[in] | element_id | The ID of the element whose context is to be stored. |
[in] | blob | Pointer to the buffer containing the context to be stored. |
[in] | blob_size | Size of the buffer containing the context. |
Definition at line 444 of file meshx_nvs.c.
meshx_err_t meshx_nvs_erase | ( | void | ) |
Erase all key-value pairs stored in the NVS.
This function clears all data stored in the Non-Volatile Storage.
Definition at line 243 of file meshx_nvs.c.
|
static |
Erase the NVS and set the product ID.
This function erases the NVS and sets the product ID.
[in] | cid | Company ID |
[in] | pid | Product ID |
Definition at line 89 of file meshx_nvs.c.
meshx_err_t meshx_nvs_get | ( | char const * | key, |
void * | blob, | ||
uint16_t | blob_size ) |
Get a value from the NVS.
This function retrieves a value associated with the given key from the NVS.
[in] | key | The key identifying the value to be retrieved. |
[out] | blob | Pointer to the buffer where the value will be stored. |
[in] | blob_size | Size of the buffer in bytes. |
Definition at line 346 of file meshx_nvs.c.
meshx_err_t meshx_nvs_init | ( | void | ) |
MeshX NVS Initialisation.
Definition at line 135 of file meshx_nvs.c.
meshx_err_t meshx_nvs_open | ( | uint16_t | cid, |
uint16_t | pid, | ||
uint32_t | commit_timeout_ms ) |
Open the NVS with a timeout.
This function initializes the NVS and sets a timeout for stability operations.
[in] | cid | Company ID |
[in] | pid | Product ID |
[in] | commit_timeout_ms | Timeout for stability operations in milliseconds. |
Definition at line 165 of file meshx_nvs.c.
meshx_err_t meshx_nvs_remove | ( | char const * | key | ) |
Remove a key-value pair from the NVS.
This function deletes a specific key-value pair from the NVS based on the provided key.
[in] | key | The key identifying the value to be removed. |
Definition at line 326 of file meshx_nvs.c.
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.
This function stores a value associated with the given key in the NVS.
[in] | key | The key identifying the value to be stored. |
[in] | blob | Pointer to the buffer containing the value. |
[in] | blob_size | Size of the buffer in bytes. |
[in] | arm_timer | Re-arm stability timer and auto commit |
Definition at line 366 of file meshx_nvs.c.
|
static |
Callback handler for MeshX NVS unit test command.
This function handles MeshX NVS unit test command by processing the provided command ID and arguments.
[in] | cmd_id | The command ID to be processed. |
[in] | argc | The number of arguments provided. |
[in] | argv | The array of arguments. |
Definition at line 500 of file meshx_nvs.c.
|
static |
: MeshX NVS Instance
Definition at line 57 of file meshx_nvs.c.
meshx_nvs_write_list_t* meshx_nvs_write_list_head = NULL |
Head of the linked list used to store key-value pairs that need to be written to NVS.
Definition at line 46 of file meshx_nvs.c.