MeshX 0.4
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.
Loading...
Searching...
No Matches
meshx_kv_engine.h
Go to the documentation of this file.
1/**
2 * Copyright © 2024 - 2025 MeshX
3 *
4 * @file meshx_kv_engine.h
5 * @brief Portable Key-Value Engine for MeshX.
6 *
7 * This engine provides a lightweight KV store with built-in wear-leveling
8 * and power-fail safety, designed to run on top of the FAL interface.
9 *
10 * @author Pranjal Chanda
11 */
12
13#ifndef __MESHX_KV_ENGINE_H__
14#define __MESHX_KV_ENGINE_H__
15
16#include "meshx_err.h"
18#include <stdint.h>
19#include <stdbool.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/**
26 * @brief Initialize the KV engine.
27 *
28 * @param[in] part Pointer to the flash partition to use.
29 *
30 * @return meshx_err_t MESHX_SUCCESS on success, or error code.
31 */
33
34/**
35 * @brief Read a value from the KV engine.
36 *
37 * @param[in] key Key name.
38 * @param[out] buf Buffer to store read data.
39 * @param[in] len Length of the data to read.
40 *
41 * @return meshx_err_t MESHX_SUCCESS on success, or error code.
42 */
43meshx_err_t meshx_kv_engine_read(const char *key, void *buf, uint16_t len);
44
45/**
46 * @brief Buffer a write operation in RAM.
47 *
48 * @param[in] key Key name.
49 * @param[in] buf Buffer containing data to write.
50 * @param[in] len Length of the data.
51 *
52 * @return meshx_err_t MESHX_SUCCESS on success, or error code.
53 */
54meshx_err_t meshx_kv_engine_set(const char *key, const void *buf, uint16_t len);
55
56/**
57 * @brief Commit all buffered changes to flash.
58 *
59 * @return meshx_err_t MESHX_SUCCESS on success, or error code.
60 */
62
63/**
64 * @brief Remove a key from the KV engine.
65 *
66 * @param[in] key Key name.
67 *
68 * @return meshx_err_t MESHX_SUCCESS on success, or error code.
69 */
70meshx_err_t meshx_kv_engine_remove(const char *key);
71
72/**
73 * @brief Erase the entire KV partition.
74 *
75 * @return meshx_err_t MESHX_SUCCESS on success, or error code.
76 */
78
79#ifdef __cplusplus
80}
81#endif
82
83#endif /* __MESHX_KV_ENGINE_H__ */
MeshX Error Codes.
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:43
Flash Abstraction Layer (FAL) Interface for MeshX.
meshx_err_t meshx_kv_engine_commit(void)
Commit all buffered changes to flash.
Definition meshx_kv_engine.c:181
meshx_err_t meshx_kv_engine_remove(const char *key)
Remove a key from the KV engine.
Definition meshx_kv_engine.c:223
meshx_err_t meshx_kv_engine_read(const char *key, void *buf, uint16_t len)
Read a value from the KV engine.
Definition meshx_kv_engine.c:105
meshx_err_t meshx_kv_engine_set(const char *key, const void *buf, uint16_t len)
Buffer a write operation in RAM.
Definition meshx_kv_engine.c:157
meshx_err_t meshx_kv_engine_erase_all(void)
Erase the entire KV partition.
Definition meshx_kv_engine.c:232
meshx_err_t meshx_kv_engine_init(const meshx_fal_partition_t *part)
Initialize the KV engine.
Definition meshx_kv_engine.c:66
Definition meshx_fal_interface.h:27