My Project
 All Classes Functions Variables Pages
CPPNVS.h
1 /*
2  * NVS.h
3  *
4  * Created on: Mar 27, 2017
5  * Author: kolban
6  */
7 
8 #ifndef COMPONENTS_CPP_UTILS_CPPNVS_H_
9 #define COMPONENTS_CPP_UTILS_CPPNVS_H_
10 #include <nvs.h>
11 #include <string>
12 
16 class NVS {
17 public:
18  NVS(std::string name, nvs_open_mode openMode = NVS_READWRITE);
19  virtual ~NVS();
20  void commit();
21 
22  void erase();
23  void erase(std::string key);
24  int get(std::string key, std::string* result, bool isBlob = false);
25  int get(std::string key, uint8_t* result, size_t& length);
26  int get(std::string key, uint32_t& value);
27  void set(std::string key, std::string data, bool isBlob = false);
28  void set(std::string key, uint32_t value);
29  void set(std::string key, uint8_t* data, size_t length);
30 
31 private:
32  std::string m_name;
33  nvs_handle m_handle;
34 
35 };
36 
37 #endif /* COMPONENTS_CPP_UTILS_CPPNVS_H_ */
void erase()
Erase ALL the keys in the namespace.
Definition: CPPNVS.cpp:52
void commit()
Commit any work performed in the namespace.
Definition: CPPNVS.cpp:44
NVS(std::string name, nvs_open_mode openMode=NVS_READWRITE)
Constructor.
Definition: CPPNVS.cpp:23
virtual ~NVS()
Desctructor.
Definition: CPPNVS.cpp:36
void set(std::string key, std::string data, bool isBlob=false)
Set the string/blob value by key.
Definition: CPPNVS.cpp:123
Provide Non Volatile Storage access.
Definition: CPPNVS.h:16