BSB Developer Docs
Loading...
Searching...
No Matches
nvm.h
Go to the documentation of this file.
1
5#pragma once
6
7#include <stddef.h>
8#include <stdint.h>
9#include <stdbool.h>
10#include <furi.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
21#define RECORD_NVM "nvm"
22
29typedef enum {
31 NvmKeyRangeUser1Min = 0x10000UL,
32 NvmKeyBlePairingData = 0x10001UL,
33 NvmKeyCryptoAccessMode = 0x10002UL,
34 /* Add more key ranges here */
35 NvmKeyRangeUser1Max = 0x87000UL,
36 NvmKeyRangeUser2Min = 0x88000UL,
37 /* Add more key ranges here */
38 NvmKeyRangeMax = 0x1000000UL,
40
41typedef struct Nvm Nvm;
42
52bool nvm_exists(Nvm* instance, uint32_t key, size_t* len);
53
67FURI_CHECK_RETURN
68bool nvm_read(Nvm* instance, uint32_t key, void* data, size_t len);
69
84FURI_CHECK_RETURN
85bool nvm_read_partial(Nvm* instance, uint32_t key, void* data, size_t offset, size_t len);
86
100FURI_CHECK_RETURN
101bool nvm_write(Nvm* instance, uint32_t key, const void* data, size_t len);
102
112FURI_CHECK_RETURN
113bool nvm_read_counter(Nvm* instance, uint32_t key, uint32_t* value);
114
124FURI_CHECK_RETURN
125bool nvm_write_counter(Nvm* instance, uint32_t key, uint32_t value);
126
136FURI_CHECK_RETURN
137bool nvm_increment_counter(Nvm* instance, uint32_t key, uint32_t* value);
138
147FURI_CHECK_RETURN
148bool nvm_delete(Nvm* instance, uint32_t key);
149
160FURI_CHECK_RETURN
161bool nvm_repack(Nvm* instance);
162
172FURI_CHECK_RETURN
173bool nvm_erase_all(Nvm* instance);
174
187FURI_CHECK_RETURN
188bool nvm_purge_all(Nvm* instance);
189
190#ifdef __cplusplus
191}
192#endif
FURI_CHECK_RETURN bool nvm_delete(Nvm *instance, uint32_t key)
Delete the record under a given key.
Definition nvm.c:80
FURI_CHECK_RETURN bool nvm_write_counter(Nvm *instance, uint32_t key, uint32_t value)
Write the counter value under a given key.
Definition nvm.c:70
FURI_CHECK_RETURN bool nvm_read(Nvm *instance, uint32_t key, void *data, size_t len)
Read the record data under a given key.
Definition nvm.c:42
FURI_CHECK_RETURN bool nvm_increment_counter(Nvm *instance, uint32_t key, uint32_t *value)
Increment the counter under a given key by 1 and optionally get its value.
Definition nvm.c:75
FURI_CHECK_RETURN bool nvm_purge_all(Nvm *instance)
Erase all data AND metadata from the storage.
Definition nvm.c:95
bool nvm_exists(Nvm *instance, uint32_t key, size_t *len)
Check if a record exists under a given key and optionally get its length.
Definition nvm.c:32
FURI_CHECK_RETURN bool nvm_repack(Nvm *instance)
Repack the storage to optimise space.
Definition nvm.c:85
FURI_CHECK_RETURN bool nvm_read_partial(Nvm *instance, uint32_t key, void *data, size_t offset, size_t len)
Read the record data under a given key partially.
Definition nvm.c:49
NvmKeyRange
Enumeration of available Nvm key ranges.
Definition nvm.h:29
@ NvmKeyRangeMax
Maximum key value (non-inclusive)
Definition nvm.h:38
@ NvmKeyRangeUser2Min
Free to use key range 2 start (inclusive)
Definition nvm.h:36
@ NvmKeyRangeUser1Max
Free to use key range 1 end (non-inclusive)
Definition nvm.h:35
@ NvmKeyRangeUser1Min
Free to use key range 1 start (inclusive)
Definition nvm.h:31
@ NvmKeyRangeMin
Minimum key value (inclusive)
Definition nvm.h:30
FURI_CHECK_RETURN bool nvm_write(Nvm *instance, uint32_t key, const void *data, size_t len)
Write data to a record under a given key.
Definition nvm.c:56
FURI_CHECK_RETURN bool nvm_erase_all(Nvm *instance)
Erase all data from the storage.
Definition nvm.c:90
FURI_CHECK_RETURN bool nvm_read_counter(Nvm *instance, uint32_t key, uint32_t *value)
Read the counter value under a given key.
Definition nvm.c:63
Definition nvm.c:12