diff --git a/CLC-qthing/SiliconTorch/NVSExplorer.cpp b/CLC-qthing/SiliconTorch/NVSExplorer.cpp index c77f2e0d3c26c9b6889dd0e77b247b61e27da2c0..765d91e6097ceaee16121ce0ee1ceb4f282306d0 100644 --- a/CLC-qthing/SiliconTorch/NVSExplorer.cpp +++ b/CLC-qthing/SiliconTorch/NVSExplorer.cpp @@ -39,10 +39,6 @@ namespace SiliconTorch { nvs_flash_init(); - mutex.run([]() { - ESP_LOGE(TAG, "Running inside our ManagedMutex"); - }); - uint16_t deviceTopicLEN = deviceTopic("").length(); auto wrapMessageHandler = [deviceTopicLEN](std::function<void(std::vector<std::string>&, qthing::multipart_message_t)> handler) { @@ -81,20 +77,19 @@ namespace SiliconTorch { void NVSExplorer::BullShit() { - ESP_LOGW(TAG, "Scanning 👀"); - nvs_iterator_t it = nvs_entry_find("nvs", NULL, NVS_TYPE_ANY); - - while (it != NULL) { - nvs_entry_info_t info; - nvs_entry_info(it, &info); - it = nvs_entry_next(it); - - ESP_LOGW(TAG, "namespace[ %s ] key[ %s ] type[ %d ]", info.namespace_name, info.key, info.type); - } + mutex.run([&]() { + nvs_iterator_t it = nvs_entry_find("nvs", NULL, NVS_TYPE_ANY); + while (it != NULL) { + nvs_entry_info_t info; + nvs_entry_info(it, &info); + it = nvs_entry_next(it); + ESP_LOGW(TAG, "namespace[ %s ] key[ %s ] type[ %d ]", info.namespace_name, info.key, info.type); + } + }); } @@ -102,18 +97,19 @@ namespace SiliconTorch { std::set<std::string> keys; + mutex.run([&]() { + nvs_iterator_t it = nvs_entry_find("nvs", nameSpace.c_str(), NVS_TYPE_ANY); - nvs_iterator_t it = nvs_entry_find("nvs", nameSpace.c_str(), NVS_TYPE_ANY); - - while (it != NULL) { - nvs_entry_info_t info; - nvs_entry_info(it, &info); - it = nvs_entry_next(it); + while (it != NULL) { + nvs_entry_info_t info; + nvs_entry_info(it, &info); + it = nvs_entry_next(it); - ESP_LOGW(TAG, "namespace[ %s ] key[ %s ] type[ %d ]", info.namespace_name, info.key, info.type); // TODO: remove after dev! + ESP_LOGW(TAG, "namespace[ %s ] key[ %s ] type[ %d ]", info.namespace_name, info.key, info.type); // TODO: remove after dev! - keys.insert(info.key); - } + keys.insert(info.key); + } + }); return keys; } @@ -123,17 +119,19 @@ namespace SiliconTorch { std::set<std::string> namespaces; - nvs_iterator_t it = nvs_entry_find("nvs", NULL, NVS_TYPE_ANY); + mutex.run([&]() { + nvs_iterator_t it = nvs_entry_find("nvs", NULL, NVS_TYPE_ANY); - while (it != NULL) { - nvs_entry_info_t info; - nvs_entry_info(it, &info); - it = nvs_entry_next(it); + while (it != NULL) { + nvs_entry_info_t info; + nvs_entry_info(it, &info); + it = nvs_entry_next(it); - ESP_LOGW(TAG, "namespace[ %s ] key[ %s ] type[ %d ]", info.namespace_name, info.key, info.type); // TODO: remove after dev! + ESP_LOGW(TAG, "namespace[ %s ] key[ %s ] type[ %d ]", info.namespace_name, info.key, info.type); // TODO: remove after dev! - namespaces.insert(info.namespace_name); - } + namespaces.insert(info.namespace_name); + } + }); return namespaces; }