RBCX
Library for the RB3204-RBCX board with the ESP32 by RoboticsBrno.
Loading...
Searching...
No Matches
RBCXNvs.h
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
9namespace rb {
10
11class Nvs {
12public:
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
27private:
28 esp_err_t initFlash();
29
30 nvs_handle m_handle;
31 bool m_dirty;
32};
33
34} // namespace rb
Definition: RBCXNvs.h:11
std::string getString(const char *key)
Returns the string value of the key in the NVS.
Definition: RBCXNvs.cpp:54
void commit()
Commits the changes to the NVS (it nessecary to call this to save the changes)
Definition: RBCXNvs.cpp:68
int getInt(const char *key)
Returns the int value of the key in the NVS.
Definition: RBCXNvs.cpp:38
bool existsString(const char *key)
Returns true if the key for the string exists in the NVS.
Definition: RBCXNvs.cpp:49
~Nvs()
Definition: RBCXNvs.cpp:15
bool existsInt(const char *key)
Returns true if the key for the int exists in the NVS.
Definition: RBCXNvs.cpp:33
void writeString(const char *key, const std::string &value)
Writes the string value to the key in the NVS.
Definition: RBCXNvs.cpp:63
Nvs(const Nvs &)=delete
void writeInt(const char *key, int value)
Writes the int value to the key in the NVS.
Definition: RBCXNvs.cpp:44
Definition: RBCXAngle.cpp:3