Commit e3fe0a4
committed
fix(nvs): resolve contains() method returning false for existing string values
Fixes issue #585 where EspNvs::contains() incorrectly returned false for string
values that actually existed in NVS partitions. The root cause was that contains()
only checked for u64 and blob data types, never checking for string values stored
with nvs_set_str().
Changes:
- Replace broken len()-based contains() with nvs_get_type() implementation
- Add contains_key_of_type() method for type-specific key checking
- Add find_key_type() method to retrieve key data types
- Add NvsDataType enum with From<nvs_type_t> conversion
- Introduce EspKeyValueStorage wrapper for consistent serialized storage behavior
The new contains() implementation uses nvs_get_type() to detect any key type,
ensuring consistent behavior across all NVS data types (u8, u16, u32, u64,
i8, i16, i32, i64, str, blob).
Fixes #5851 parent dd04bd9 commit e3fe0a4
1 file changed
Lines changed: 280 additions & 121 deletions
0 commit comments