feat(wt_nvs) add set/get once, simpler to use when only call one time
This commit is contained in:
parent
67b97b3396
commit
3208261f97
|
@ -95,3 +95,21 @@ int wt_nvs_get_once(const char* namespace, const uint32_t key, void *data, uint3
|
||||||
wt_nvs_close(handle);
|
wt_nvs_close(handle);
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -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_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);
|
int wt_nvs_flush(nvs_handle_t handle);
|
||||||
|
|
||||||
void wt_nvs_init();
|
void wt_nvs_init();
|
||||||
|
|
Loading…
Reference in New Issue