diff --git a/main/qrimport.cpp b/main/qrimport.cpp index 634558d..70aa525 100644 --- a/main/qrimport.cpp +++ b/main/qrimport.cpp @@ -44,7 +44,8 @@ tl::expected get_qr_code(std::string_view key) size_t length; if (const esp_err_t result = nvs_get_str(handle, key.data(), nullptr, &length); result != ESP_OK) { - ESP_LOGW(TAG, "nvs_get_str() size-only for key %.*s failed with %s", key.size(), key.data(), esp_err_to_name(result)); + if (result != ESP_ERR_NVS_NOT_FOUND) + ESP_LOGW(TAG, "nvs_get_str() size-only for key %.*s failed with %s", key.size(), key.data(), esp_err_to_name(result)); return tl::make_unexpected(result); } @@ -68,7 +69,15 @@ tl::expected get_qr_code(std::string_view key) tl::expected set_qr_code(std::string_view key, std::string_view qrcode) { - return{}; + const auto handle = settingsPersister.getCommonHandle(); + + if (const esp_err_t result = nvs_set_str(handle, key.data(), qrcode.data()); result != ESP_OK) + { + ESP_LOGW(TAG, "nvs_set_str() for key %.*s failed with %s", key.size(), key.data(), esp_err_to_name(result)); + return tl::make_unexpected(result); + } + + return {}; } // web request