MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / readNvsDeviceValue

Function readNvsDeviceValue

lib/hal/HalGPIO.cpp:124–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122enum class NvsDeviceValue : uint8_t { Unknown = 0, X4 = 1, X3 = 2 };
123
124NvsDeviceValue readNvsDeviceValue(const char* key, NvsDeviceValue defaultValue) {
125 Preferences prefs;
126 if (!prefs.begin(HW_NAMESPACE, true)) {
127 return defaultValue;
128 }
129 const uint8_t raw = prefs.getUChar(key, static_cast<uint8_t>(defaultValue));
130 prefs.end();
131 if (raw > static_cast<uint8_t>(NvsDeviceValue::X3)) {
132 return defaultValue;
133 }
134 return static_cast<NvsDeviceValue>(raw);
135}
136
137void writeNvsDeviceValue(const char* key, NvsDeviceValue value) {
138 Preferences prefs;

Callers 1

Calls 2

endMethod · 0.80
beginMethod · 0.45

Tested by

no test coverage detected