diff --git a/project_components/wt_storage/wt_nvs.c b/project_components/wt_storage/wt_nvs.c index 26fdc4b..4ec9974 100644 --- a/project_components/wt_storage/wt_nvs.c +++ b/project_components/wt_storage/wt_nvs.c @@ -95,3 +95,21 @@ int wt_nvs_get_once(const char* namespace, const uint32_t key, void *data, uint3 wt_nvs_close(handle); return 0; } + +int wt_nvs_set_once(const char* namespace, const uint32_t key, void *data, uint32_t data_size) +{ + nvs_handle_t handle; + int err; + err = wt_nvs_open(namespace, &handle); + if (err) { + return err; + } + + err = wt_nvs_set(handle, key, data, data_size); + if (err) { + return err; + } + + wt_nvs_close(handle); + return 0; +} diff --git a/project_components/wt_storage/wt_nvs.h b/project_components/wt_storage/wt_nvs.h index d8556a4..dff93f7 100644 --- a/project_components/wt_storage/wt_nvs.h +++ b/project_components/wt_storage/wt_nvs.h @@ -20,6 +20,9 @@ int wt_nvs_get(nvs_handle_t handle, uint32_t key, void *data, uint32_t data_size int wt_nvs_set(nvs_handle_t handle, uint32_t key, void *data, uint32_t data_size); +int wt_nvs_get_once(const char* namespace, const uint32_t key, void *data, uint32_t data_size); +int wt_nvs_set_once(const char* namespace, const uint32_t key, void *data, uint32_t data_size); + int wt_nvs_flush(nvs_handle_t handle); void wt_nvs_init();