Skip to content

Commit

Permalink
Fixed issue with loading string values from NVS
Browse files Browse the repository at this point in the history
  • Loading branch information
MG-5 committed Jun 3, 2024
1 parent d876b66 commit 5aaaa56
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main/nvm/NonVolatileMemory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ class NonVolatileMemory
}
else if constexpr (std::is_same_v<std::string, T>)
{
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(
Expand Down

0 comments on commit 5aaaa56

Please sign in to comment.