EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #732 background imageLoading...
Page #732 background image
Chapter 2. API Reference
// Example of nvs_get_used_entry_count() to get amount of all key-value pairs
,in one namespace:
nvs_handle_t handle;
nvs_open("namespace1", NVS_READWRITE, &handle);
...
size_t used_entries;
size_t total_entries_namespace;
if(nvs_get_used_entry_count(handle, &used_entries) == ESP_OK){
// the total number of entries occupied by the namespace
total_entries_namespace = used_entries + 1;
}
Return
ESP_OK if the changes have been written successfully. Return param used_entries will be filled
valid value.
ESP_ERR_NVS_NOT_INITIALIZED if the storage driver is not initialized. Return param
used_entries will be filled 0.
ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL. Return param
used_entries will be filled 0.
ESP_ERR_INVALID_ARG if used_entries equal to NULL.
Other error codes from the underlying storage driver. Return param used_entries will be filled 0.
Parameters
[in] handle: Handle obtained from nvs_open function.
[out] used_entries: Returns amount of used entries from a namespace.
nvs_iterator_t nvs_entry_find(const char *part_name, const char *namespace_name, nvs_type_t
type)
Create an iterator to enumerate NVS entries based on one or more parameters.
// Example of listing all the key-value pairs of any type under specified
,partition and namespace
nvs_iterator_t it = nvs_entry_find(partition, namespace, NVS_TYPE_ANY);
while (it != NULL) {
nvs_entry_info_t info;
nvs_entry_info(it, &info);
it = nvs_entry_next(it);
printf("key '%s', type '%d' \n", info.key, info.type);
};
// Note: no need to release iterator obtained from nvs_entry_find function when
// nvs_entry_find or nvs_entry_next function return NULL, indicating no
,other
// element for specified criteria was found.
}
Return Iterator used to enumerate all the entries found, or NULL if no entry satisfying criteria was found.
Iterator obtained through this function has to be released using nvs_release_iterator when not used any
more.
Parameters
[in] part_name: Partition name
[in] namespace_name: Set this value if looking for entries with a specic namespace. Pass
NULL otherwise.
[in] type: One of nvs_type_t values.
nvs_iterator_t nvs_entry_next(nvs_iterator_t iterator)
Returns next item matching the iterator criteria, NULL if no such item exists.
Note that any copies of the iterator will be invalid after this call.
Return NULL if no entry was found, valid nvs_iterator_t otherwise.
Parameters
[in] iterator: Iterator obtained from nvs_entry_find function. Must be non-NULL.
Espressif Systems 721
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish