bolar_1 date 2026-7-1 d:/proc
This commit is contained in:
26
main/settings.h
Normal file
26
main/settings.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "nvs.h"
|
||||
|
||||
// NVS 持久化配置存储(与 xiaozhi Settings 对齐)
|
||||
// 每个实例绑定一个 NVS namespace
|
||||
class Settings {
|
||||
public:
|
||||
Settings(const char* ns, bool read_write = true);
|
||||
~Settings();
|
||||
|
||||
std::string GetString(const char* key, const std::string& default_val = "") const;
|
||||
void SetString(const char* key, const std::string& value);
|
||||
|
||||
int GetInt(const char* key, int default_val = 0) const;
|
||||
void SetInt(const char* key, int value);
|
||||
|
||||
void EraseKey(const char* key);
|
||||
void EraseAll();
|
||||
|
||||
private:
|
||||
nvs_handle_t handle_ = 0;
|
||||
bool dirty_ = false;
|
||||
bool read_write_ = false;
|
||||
};
|
||||
Reference in New Issue
Block a user