Rishka
RISC-V virtual runtime in C/C++ made for ESP32-WROVER
nvs.h
Go to the documentation of this file.
1/*
2 * This file is part of the Rishka distribution (https://github.com/nthnn/rishka).
3 * Copyright (c) 2024 Nathanne Isip.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
31#ifndef LIBRISHKA_DRIVERS_NVS_H
32#define LIBRISHKA_DRIVERS_NVS_H
33
34#include <librishka/types.h>
35
48class NVS final {
49public:
54 static bool commit();
55
61 static bool erase_all(bool force = true);
62
69 static bool erase(string key, bool force = true);
70
78 static bool set_i8(string key, i8 value, bool force = true);
79
87 static bool set_i16(string key, i16 value, bool force = true);
88
96 static bool set_i32(string key, i32 value, bool force = true);
97
105 static bool set_i64(string key, i64 value, bool force = true);
106
114 static bool set_u8(string key, u8 value, bool force = true);
115
123 static bool set_u16(string key, u16 value, bool force = true);
124
132 static bool set_u32(string key, u32 value, bool force = true);
133
141 static bool set_u64(string key, u64 value, bool force = true);
142
149 static i8 get_i8(string key, i8 defvalue);
150
157 static i16 get_i16(string key, i16 defvalue);
158
165 static i32 get_i32(string key, i32 defvalue);
166
173 static i64 get_i64(string key, i64 defvalue);
174
181 static u8 get_u8(string key, u8 defvalue);
182
189 static u16 get_u16(string key, u16 defvalue);
190
197 static u32 get_u32(string key, u32 defvalue);
198
205 static u64 get_u64(string key, u64 defvalue);
206
214 static bool set_string(string key, string value, bool force = true);
215
221 static string get_string(string key);
222
227 static bool has_wifi_config();
228
234 static bool set_wifi_ssid(string ssid);
235
241 static bool set_wifi_pword(string pword);
242};
243
244#endif
Provides an interface to the non-volatile storage (NVS) in the Rishka system.
Definition: nvs.h:48
static bool erase(string key, bool force=true)
Erases a specific key-value pair from the NVS.
Definition: librishka_drivers_nvs.cpp:29
static u64 get_u64(string key, u64 defvalue)
Retrieves a 64-bit unsigned integer value from the NVS.
Definition: librishka_drivers_nvs.cpp:93
static bool set_u32(string key, u32 value, bool force=true)
Sets a 32-bit unsigned integer value in the NVS.
Definition: librishka_drivers_nvs.cpp:57
static bool set_i64(string key, i64 value, bool force=true)
Sets a 64-bit signed integer value in the NVS.
Definition: librishka_drivers_nvs.cpp:45
static u32 get_u32(string key, u32 defvalue)
Retrieves a 32-bit unsigned integer value from the NVS.
Definition: librishka_drivers_nvs.cpp:89
static bool set_i16(string key, i16 value, bool force=true)
Sets a 16-bit signed integer value in the NVS.
Definition: librishka_drivers_nvs.cpp:37
static bool set_u16(string key, u16 value, bool force=true)
Sets a 16-bit unsigned integer value in the NVS.
Definition: librishka_drivers_nvs.cpp:53
static bool erase_all(bool force=true)
Erases all key-value pairs in the NVS.
Definition: librishka_drivers_nvs.cpp:25
static i64 get_i64(string key, i64 defvalue)
Retrieves a 64-bit signed integer value from the NVS.
Definition: librishka_drivers_nvs.cpp:77
static string get_string(string key)
Retrieves a string value from the NVS.
Definition: librishka_drivers_nvs.cpp:101
static bool set_wifi_ssid(string ssid)
Sets the Wi-Fi SSID in the NVS.
Definition: librishka_drivers_nvs.cpp:109
static i32 get_i32(string key, i32 defvalue)
Retrieves a 32-bit signed integer value from the NVS.
Definition: librishka_drivers_nvs.cpp:73
static bool set_string(string key, string value, bool force=true)
Sets a string value in the NVS.
Definition: librishka_drivers_nvs.cpp:97
static u8 get_u8(string key, u8 defvalue)
Retrieves an 8-bit unsigned integer value from the NVS.
Definition: librishka_drivers_nvs.cpp:81
static bool set_wifi_pword(string pword)
Sets the Wi-Fi password in the NVS.
Definition: librishka_drivers_nvs.cpp:113
static u16 get_u16(string key, u16 defvalue)
Retrieves a 16-bit unsigned integer value from the NVS.
Definition: librishka_drivers_nvs.cpp:85
static bool commit()
Commits the changes to the NVS.
Definition: librishka_drivers_nvs.cpp:21
static bool set_u8(string key, u8 value, bool force=true)
Sets an 8-bit unsigned integer value in the NVS.
Definition: librishka_drivers_nvs.cpp:49
static bool set_i8(string key, i8 value, bool force=true)
Sets an 8-bit signed integer value in the NVS.
Definition: librishka_drivers_nvs.cpp:33
static bool set_u64(string key, u64 value, bool force=true)
Sets a 64-bit unsigned integer value in the NVS.
Definition: librishka_drivers_nvs.cpp:61
static bool has_wifi_config()
Checks if a Wi-Fi configuration is available in the NVS.
Definition: librishka_drivers_nvs.cpp:105
static bool set_i32(string key, i32 value, bool force=true)
Sets a 32-bit signed integer value in the NVS.
Definition: librishka_drivers_nvs.cpp:41
static i8 get_i8(string key, i8 defvalue)
Retrieves an 8-bit signed integer value from the NVS.
Definition: librishka_drivers_nvs.cpp:65
static i16 get_i16(string key, i16 defvalue)
Retrieves a 16-bit signed integer value from the NVS.
Definition: librishka_drivers_nvs.cpp:69
Header file for common data types used in Rishka applications.
signed char i8
Alias for the signed 8-bit integer type.
Definition: types.h:46
signed int i32
Alias for the signed 32-bit integer type.
Definition: types.h:58
unsigned int u32
Alias for the unsigned 32-bit integer type.
Definition: types.h:82
signed short int i16
Alias for the signed 16-bit integer type.
Definition: types.h:52
signed long int i64
Alias for the signed 64-bit integer type.
Definition: types.h:64
unsigned short int u16
Alias for the unsigned 16-bit integer type.
Definition: types.h:76
unsigned char u8
Alias for the unsigned 8-bit integer type.
Definition: types.h:70
unsigned long int u64
Alias for the unsigned 64-bit integer type.
Definition: types.h:88