forked from xiaozhi/xiaozhi-esp32
add network error callback
This commit is contained in:
@@ -11,7 +11,7 @@ Settings::Settings(const std::string& ns, bool read_write) : ns_(ns), read_write
|
||||
|
||||
Settings::~Settings() {
|
||||
if (nvs_handle_ != 0) {
|
||||
if (read_write_) {
|
||||
if (read_write_ && dirty_) {
|
||||
ESP_ERROR_CHECK(nvs_commit(nvs_handle_));
|
||||
}
|
||||
nvs_close(nvs_handle_);
|
||||
@@ -37,6 +37,7 @@ std::string Settings::GetString(const std::string& key, const std::string& defau
|
||||
void Settings::SetString(const std::string& key, const std::string& value) {
|
||||
if (read_write_) {
|
||||
ESP_ERROR_CHECK(nvs_set_str(nvs_handle_, key.c_str(), value.c_str()));
|
||||
dirty_ = true;
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Namespace %s is not open for writing", ns_.c_str());
|
||||
}
|
||||
@@ -57,6 +58,7 @@ int32_t Settings::GetInt(const std::string& key, int32_t default_value) {
|
||||
void Settings::SetInt(const std::string& key, int32_t value) {
|
||||
if (read_write_) {
|
||||
ESP_ERROR_CHECK(nvs_set_i32(nvs_handle_, key.c_str(), value));
|
||||
dirty_ = true;
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Namespace %s is not open for writing", ns_.c_str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user