| 122 | enum class NvsDeviceValue : uint8_t { Unknown = 0, X4 = 1, X3 = 2 }; |
| 123 | |
| 124 | NvsDeviceValue 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 | |
| 137 | void writeNvsDeviceValue(const char* key, NvsDeviceValue value) { |
| 138 | Preferences prefs; |
no test coverage detected