diff --git a/main/qrimport.cpp b/main/qrimport.cpp index 81b46d2..6e84f7d 100644 --- a/main/qrimport.cpp +++ b/main/qrimport.cpp @@ -1,8 +1,8 @@ #include "qrimport.h" -// system includes // 3rd party includes +#include #include #include #include @@ -17,16 +17,28 @@ cpputils::DelayedConstruction http_request; } // namespace // nvs -tl::expected get_qr_code(std::string_view key) +tl::expected get_qr_code(std::string_view key) { return ""; } -tl::expected set_qr_code(std::string_view qrcode, std::string_view key) +tl::expected set_qr_code(std::string_view qrcode, std::string_view key) { return{}; } +bool has_qr_code(std::string_view key) +{ + if (const auto result = get_qr_code(key); !result) + { + return (result.error() == ESP_ERR_NVS_NOT_FOUND); + } + else + { + return true; + } +} + // web request void setup_request() { diff --git a/main/qrimport.h b/main/qrimport.h index 57da4a1..3bd0911 100644 --- a/main/qrimport.h +++ b/main/qrimport.h @@ -9,14 +9,16 @@ #include // 3rd party includes +#include #include // local includes namespace qrimport { // nvs - tl::expected get_qr_code(std::string_view key); - tl::expected set_qr_code(std::string_view qrcode, std::string_view key); + tl::expected get_qr_code(std::string_view key); + tl::expected set_qr_code(std::string_view qrcode, std::string_view key); + bool has_qr_code(std::string_view key); // web request void setup_request();