A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol
C arduinobluetoothcan-busdebuggingeepromesp32flipperzerogpiohardware-hackingi2cjtagopenocdprotocolspwmradiorfidspisubghzuartwifi
check if nvs key exists before fetching it
Geo64b45fe0546f
diff --git a/src/Services/NvsService.cpp b/src/Services/NvsService.cppindex 23903ebe..e10019db 100644--- a/src/Services/NvsService.cpp+++ b/src/Services/NvsService.cpp@@ -13,12 +13,19 @@ void NvsService::close() {preferences.end(); // Close namespace}+bool NvsService::hasKey(const std::string& key) {+ return preferences.isKey(key.c_str());+}+void NvsService::saveString(const std::string& key, const std::string& value) {preferences.putString(key.c_str(), value.c_str());}std::string NvsService::getString(const std::string& key, const std::string& defaultValue) {- return preferences.getString(key.c_str(), defaultValue.c_str()).c_str();+ if (hasKey(key)) {+ return preferences.getString(key.c_str(), defaultValue.c_str()).c_str();+ }+ return defaultValue;}void NvsService::saveInt(const std::string& key, int value) {diff --git a/src/Services/NvsService.h b/src/Services/NvsService.hindex 78e88d97..9bfb7506 100644--- a/src/Services/NvsService.h+++ b/src/Services/NvsService.h@@ -12,6 +12,7 @@ public:// Open/Close namespacevoid open();void close();+ bool hasKey(const std::string& key);// Read/write stringvoid saveString(const std::string& key, const std::string& value);