0
0
Fork 0

feat(wt_nvs) add set/get once, simpler to use when only call one time

This commit is contained in:
kerms 2024-07-06 15:29:25 +08:00
parent 67b97b3396
commit 3208261f97
2 changed files with 21 additions and 0 deletions

View File

@ -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;
}

View File

@ -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();