Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
|
kv_store API More...
Data Structures | |
struct | kv_store_cb |
KV store callback structure. More... | |
Macros | |
#define | KV_STORE_WRITE(key, data) |
Write a key to the KV store. | |
#define | KV_STORE_READ(key, data) |
Read a key from the KV store. | |
#define | KV_STORE_READ_FALLBACK(key, data, fallback) |
Read a key from the KV store, with a fallback if it doesn't exist. | |
Functions | |
void * | kv_store_fs (void) |
Get filesystem used by KV store. | |
int | kv_store_reset (void) |
Reset key-value storage. | |
void | kv_store_register_callback (struct kv_store_cb *cb) |
Register to be notified of KV store events. | |
uint32_t | kv_store_reflect_crc (void) |
Get the current KV store reflect CRC. | |
bool | kv_store_key_enabled (uint16_t key) |
Check whether a given key is valid for reading/writing. | |
bool | kv_store_key_exists (uint16_t key) |
Check whether a given key exists in the store. | |
int | kv_store_external_write_only (uint16_t key) |
Check whether a given keys data is valid to return externally. | |
int | kv_store_external_read_only (uint16_t key) |
Check whether a given keys data is valid to update externally. | |
ssize_t | kv_store_delete (uint16_t key) |
Delete a value from the KV store. | |
ssize_t | kv_store_write (uint16_t key, const void *data, size_t data_len) |
Write a value to the KV store. | |
ssize_t | kv_store_read (uint16_t key, void *data, size_t max_data_len) |
Read a value from the KV store. | |
ssize_t | kv_store_read_fallback (uint16_t key, void *data, size_t max_data_len, const void *fallback, size_t fallback_len) |
Read a key from the KV store, with a fallback if it doesn't exist. | |
kv_store API
#define KV_STORE_READ | ( | key, | |
data ) |
#include <infuse/fs/kv_store.h>
Read a key from the KV store.
key | Key to read from |
data | Pointer to value |
#define KV_STORE_READ_FALLBACK | ( | key, | |
data, | |||
fallback ) |
#include <infuse/fs/kv_store.h>
Read a key from the KV store, with a fallback if it doesn't exist.
key | Key to read from |
data | Pointer to value |
fallback | Pointer to fallback value |
#define KV_STORE_WRITE | ( | key, | |
data ) |
#include <infuse/fs/kv_store.h>
Write a key to the KV store.
key | Key to write to |
data | Pointer to value |
ssize_t kv_store_delete | ( | uint16_t | key | ) |
#include <infuse/fs/kv_store.h>
Delete a value from the KV store.
key | Key to delete |
0 | if key was deleted |
-EACCES | if key is not enabled |
-ENOENT | if key does not exist |
int kv_store_external_read_only | ( | uint16_t | key | ) |
#include <infuse/fs/kv_store.h>
Check whether a given keys data is valid to update externally.
key | Key to check |
0 | key data is valid to update |
-EACCESS | key is not enabled |
-EPERM | key data should not be updated |
int kv_store_external_write_only | ( | uint16_t | key | ) |
#include <infuse/fs/kv_store.h>
Check whether a given keys data is valid to return externally.
key | Key to check |
0 | key data is valid to return |
-EACCESS | key is not enabled |
-EPERM | key data should not be returned |
void * kv_store_fs | ( | void | ) |
bool kv_store_key_enabled | ( | uint16_t | key | ) |
#include <infuse/fs/kv_store.h>
Check whether a given key is valid for reading/writing.
key | Key to check |
bool kv_store_key_exists | ( | uint16_t | key | ) |
#include <infuse/fs/kv_store.h>
Check whether a given key exists in the store.
key | Key to check |
ssize_t kv_store_read | ( | uint16_t | key, |
void * | data, | ||
size_t | max_data_len ) |
#include <infuse/fs/kv_store.h>
Read a value from the KV store.
key | Key to read from |
data | Pointer to buffer for data |
max_data_len | Maximum size of data buffer |
>0 | length of data read |
-EACCES | if key is not enabled |
-errno | value from nvs_read otherwise |
ssize_t kv_store_read_fallback | ( | uint16_t | key, |
void * | data, | ||
size_t | max_data_len, | ||
const void * | fallback, | ||
size_t | fallback_len ) |
#include <infuse/fs/kv_store.h>
Read a key from the KV store, with a fallback if it doesn't exist.
key | Key to read from |
data | Pointer to buffer for data |
max_data_len | Maximum size of data buffer |
fallback | Pointer to the fallback value |
fallback_len | Size of the fallback value |
uint32_t kv_store_reflect_crc | ( | void | ) |
#include <infuse/fs/kv_store.h>
Get the current KV store reflect CRC.
While this value does not change value, there have been no changes to any KV data that need to be actioned by the cloud.
void kv_store_register_callback | ( | struct kv_store_cb * | cb | ) |
#include <infuse/fs/kv_store.h>
Register to be notified of KV store events.
cb | Callback struct to register |
int kv_store_reset | ( | void | ) |
ssize_t kv_store_write | ( | uint16_t | key, |
const void * | data, | ||
size_t | data_len ) |
#include <infuse/fs/kv_store.h>
Write a value to the KV store.
key | Key to write to |
data | Pointer to value |
data_len | Length of value in bytes |
0 | if data already matched |
>0 | length of data written |
-EACCES | if key is not enabled |
-errno | value from nvs_write otherwise |