From 5aaaa56cc3627afc7a0877a50896b32d9a1ee820 Mon Sep 17 00:00:00 2001 From: MG-5 Date: Tue, 4 Jun 2024 00:55:22 +0200 Subject: [PATCH] Fixed issue with loading string values from NVS --- main/nvm/NonVolatileMemory.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main/nvm/NonVolatileMemory.hpp b/main/nvm/NonVolatileMemory.hpp index 398a722..8b47986 100644 --- a/main/nvm/NonVolatileMemory.hpp +++ b/main/nvm/NonVolatileMemory.hpp @@ -45,11 +45,16 @@ class NonVolatileMemory } else if constexpr (std::is_same_v) { - err = handle->get_string(key.data(), value.data(), value.max_size()); + size_t bufferSize = 128; + char *buffer = new char[bufferSize]; + + err = handle->get_string(key.data(), buffer, bufferSize); if (err == ESP_OK) + { ESP_LOGI(PrintTag, "Load \"%s\" from NVS: %s", key.data(), value.data()); - + value = buffer; + } else if (err == ESP_ERR_NVS_NOT_FOUND) { ESP_LOGE(