nvs: support iteration over namespace by index

Users of the nvs API are likely to have `nvs_handle_t` in all cases, but
not all of them carry around the partition name and namespace name (as
they aren't needed after creating an `nvs_handle_t`).

Allow this common case to use nvs iteration without them tracking
additional data by using the `nvs_handle_t` to locate the namespace
index and the partition name by introducing an alterate to
`nvs_entry_find` called `nvs_entry_find_in_handle`, which operates
similarly except that it is given a `nvs_handle_t` instead of partition
and namespace strings.

This is somewhat more limited than the `nvs_entry_find` API as one
cannot examine all keys in a given partition.
This commit is contained in:
Cody P Schafer
2023-04-03 16:48:02 -04:00
committed by radek.tandler
parent e44d4260ad
commit f2af1c5305
8 changed files with 138 additions and 19 deletions
+9
View File
@@ -782,6 +782,15 @@ bool Storage::findEntry(nvs_opaque_iterator_t* it, const char* namespace_name)
return nextEntry(it);
}
bool Storage::findEntryNs(nvs_opaque_iterator_t* it, uint8_t nsIndex)
{
it->entryIndex = 0;
it->nsIndex = nsIndex;
it->page = mPageManager.begin();
return nextEntry(it);
}
inline bool isIterableItem(Item& item)
{
return (item.nsIndex != 0 &&