Skip to content

Commit

Permalink
nvs_config: Add abstraction for nvs_config_erase
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Oct 7, 2024
1 parent a6f73d3 commit efa5e77
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions main/nvs_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,21 @@ void nvs_config_set_u64(const char * key, const uint64_t value)
}
nvs_close(handle);
}

void nvs_config_erase(const char * key)
{

nvs_handle handle;
esp_err_t err;
err = nvs_open(NVS_CONFIG_NAMESPACE, NVS_READWRITE, &handle);
if (err != ESP_OK) {
ESP_LOGW(TAG, "Could not open nvs");
return;
}

err = nvs_erase_key(handle, key);
if (err != ESP_OK) {
ESP_LOGW(TAG, "Could not erase nvs key: %s, value: %llu", key, value);
}
nvs_close(handle);
}
1 change: 1 addition & 0 deletions main/nvs_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ uint16_t nvs_config_get_u16(const char * key, const uint16_t default_value);
void nvs_config_set_u16(const char * key, const uint16_t value);
uint64_t nvs_config_get_u64(const char * key, const uint64_t default_value);
void nvs_config_set_u64(const char * key, const uint64_t value);
void nvs_config_erase(const char * key);

#endif // MAIN_NVS_CONFIG_H

0 comments on commit efa5e77

Please sign in to comment.