RBControl
Library for the RB3201-RBControl board with the ESP32 by RoboticsBrno.
RBControl_nvs.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include <esp_system.h>
6 #include <nvs.h>
7 #include <nvs_flash.h>
8 
9 namespace rb {
10 
11 class Nvs {
12 public:
13  Nvs(const char* name_space, const char* partition = "nvs");
14  ~Nvs();
15  Nvs(const Nvs&) = delete;
16 
17  bool existsInt(const char* key);
18  int getInt(const char* key);
19  void writeInt(const char* key, int value);
20 
21  bool existsString(const char* key);
22  std::string getString(const char* key);
23  void writeString(const char* key, const std::string& value);
24 
25  void commit();
26 
27 private:
28  esp_err_t initFlash();
29 
30  nvs_handle m_handle;
31  bool m_dirty;
32 };
33 
34 } // namespace rb
Definition: RBControl_nvs.hpp:11
std::string getString(const char *key)
Definition: RBControl_nvs.cpp:52
void commit()
Definition: RBControl_nvs.cpp:66
int getInt(const char *key)
Definition: RBControl_nvs.cpp:36
bool existsString(const char *key)
Definition: RBControl_nvs.cpp:47
Nvs(const char *name_space, const char *partition="nvs")
Definition: RBControl_nvs.cpp:8
~Nvs()
Definition: RBControl_nvs.cpp:14
bool existsInt(const char *key)
Definition: RBControl_nvs.cpp:31
void writeString(const char *key, const std::string &value)
Definition: RBControl_nvs.cpp:61
Nvs(const Nvs &)=delete
void writeInt(const char *key, int value)
Definition: RBControl_nvs.cpp:42
The base namespace. Contains some logging functions, too.
Definition: half_duplex_uart.cpp:53