-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvs_memory.h
69 lines (63 loc) · 2.01 KB
/
nvs_memory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef _LIBESP_NVS_H
#define _LIBESP_NVS_H
#include <stdint.h>
#include <esp_system.h>
#include <nvs_flash.h>
#include <nvs.h>
#include "error_type.h"
namespace libesp {
class NVS {
public:
static const uint32_t NVS_ERROR = 0xFFFFFFFF;
static const char *LOGTAG;
public:
NVS(const char *partLabel, const char *ns, bool readOnly);
ErrorType initStorage();
ErrorType init();
ErrorType wipe();
ErrorType eraseKey(const char *name);
ErrorType setValue(const char *name, int8_t value);
ErrorType setValue(const char *name, uint8_t value);
ErrorType setValue(const char *name, int16_t value);
ErrorType setValue(const char *name, uint16_t value);
ErrorType setValue(const char *name, int32_t value);
ErrorType setValue(const char *name, uint32_t value);
ErrorType setValue(const char *name, int64_t value);
ErrorType setValue(const char *name, uint64_t value);
ErrorType setValue(const char *name, const char *value);
ErrorType setBlob(const char *name, const void *data, uint32_t length);
ErrorType getValue(const char *name, int8_t &value);
ErrorType getValue(const char *name, uint8_t &value);
ErrorType getValue(const char *name, int16_t &value);
ErrorType getValue(const char *name, uint16_t &value);
ErrorType getValue(const char *name, int32_t &value);
ErrorType getValue(const char *name, uint32_t &value);
ErrorType getValue(const char *name, int64_t &value);
ErrorType getValue(const char *name, uint64_t &value);
ErrorType getValue(const char *name, char *value, uint32_t &length);
ErrorType getBlob(const char *name, void *data, uint32_t &length);
//bool doesKeyExist(const char *name);
//uint16_t countInNamespace();
ErrorType commit();
void close();
void logInfo();
uint32_t getNumberOfNamespaces();
uint32_t getUsedEntryCount();
uint32_t getNumberFreeEntries();
uint32_t getTotalEnties();
~NVS();
private:
char PartitionLabel[15];
char Namespace[15];
nvs_handle MyHandle;
bool ReadOnly;
};
class NVSStackCommit {
public:
NVSStackCommit(NVS *);
~NVSStackCommit();
private:
NVS *nvs;
};
}
#endif