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:
committed by
radek.tandler
parent
e44d4260ad
commit
f2af1c5305
@@ -1,16 +1,8 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <cstdlib>
|
||||
#include "nvs_handle.hpp"
|
||||
#include "nvs_partition_manager.hpp"
|
||||
@@ -126,6 +118,10 @@ bool NVSHandleSimple::findEntry(nvs_opaque_iterator_t* it, const char* name) {
|
||||
return mStoragePtr->findEntry(it, name);
|
||||
}
|
||||
|
||||
bool NVSHandleSimple::findEntryNs(nvs_opaque_iterator_t* it) {
|
||||
return mStoragePtr->findEntryNs(it, mNsIndex);
|
||||
}
|
||||
|
||||
bool NVSHandleSimple::nextEntry(nvs_opaque_iterator_t* it) {
|
||||
return mStoragePtr->nextEntry(it);
|
||||
}
|
||||
@@ -134,4 +130,8 @@ const char *NVSHandleSimple::get_partition_name() const {
|
||||
return mStoragePtr->getPartName();
|
||||
}
|
||||
|
||||
Storage *NVSHandleSimple::get_storage() const {
|
||||
return mStoragePtr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user