From decd29d40f6b813aad88643e0f45015a4b6dad55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=B3r=C3=A1nt=20Pint=C3=A9r?= Date: Fri, 13 Dec 2024 10:20:19 +0100 Subject: [PATCH] Do not log an error when NVS namespace is missing on read --- main/kernel/NvsStore.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/main/kernel/NvsStore.hpp b/main/kernel/NvsStore.hpp index 9607dd3..ef1d590 100644 --- a/main/kernel/NvsStore.hpp +++ b/main/kernel/NvsStore.hpp @@ -133,9 +133,18 @@ class NvsStore { nvs_handle_t handle; esp_err_t err = nvs_open(name.c_str(), readOnly ? NVS_READONLY : NVS_READWRITE, &handle); - if (err != ESP_OK) { - LOGTE("nvs", "failed to %s '%s'", readOnly ? "read" : "write", name.c_str()); - return false; + switch (err) { + case ESP_OK: + break; + case ESP_ERR_NVS_NOT_FOUND: + LOGTV("nvs", "namespace '%s' does not exist yet, nothing to read", + name.c_str()); + return ESP_ERR_NOT_FOUND; + break; + default: + LOGTW("nvs", "failed to open NVS to %s '%s': %s", + readOnly ? "read" : "write", name.c_str(), esp_err_to_name(err)); + break; } esp_err_t result = action(handle);