From 7ae03ad1ef13c2c34faaa2801db1898c83f4c82c Mon Sep 17 00:00:00 2001 From: Ethan Duckett Date: Fri, 11 Sep 2026 11:24:17 +0100 Subject: [PATCH 1/3] Skip and log for unrecognised values --- src/ThingSetPersistence.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ThingSetPersistence.cpp b/src/ThingSetPersistence.cpp index bacdc27..6326804 100644 --- a/src/ThingSetPersistence.cpp +++ b/src/ThingSetPersistence.cpp @@ -38,14 +38,16 @@ bool ThingSetPersistence::load() return decoder.decodeMap([&](uint16_t id) { ThingSetNode *node; if (!ThingSetRegistry::findById(id, &node)) { - return false; + LOG_WARN("Ignoring unknown persisted value 0x%x", id); + return decoder.skip(); } void *target; if (node->tryCastTo(ThingSetNodeType::decodable, &target)) { ThingSetBinaryDecodable *decodable = reinterpret_cast(target); return decodable->decode(decoder); } - return false; + LOG_WARN("Ignoring persisted value 0x%x as it is not decodable", id); + return decoder.skip(); }) && decoder.verify(); } From 529d09b3a68f08722d1d30c6cf9697a8d7597f76 Mon Sep 17 00:00:00 2001 From: Ethan Duckett Date: Fri, 11 Sep 2026 13:47:29 +0100 Subject: [PATCH 2/3] Add Kconfig --- src/ThingSetPersistence.cpp | 10 ++++++++++ zephyr/Kconfig | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/ThingSetPersistence.cpp b/src/ThingSetPersistence.cpp index 6326804..20ea2d0 100644 --- a/src/ThingSetPersistence.cpp +++ b/src/ThingSetPersistence.cpp @@ -38,16 +38,26 @@ bool ThingSetPersistence::load() return decoder.decodeMap([&](uint16_t id) { ThingSetNode *node; if (!ThingSetRegistry::findById(id, &node)) { +#ifdef CONFIG_THINGSET_PLUS_PLUS_EEPROM_SKIP_UNRECOGNISED LOG_WARN("Ignoring unknown persisted value 0x%x", id); return decoder.skip(); +#else + LOG_WARN("Unknown persisted value 0x%x, abandoning load", id); + return false; +#endif } void *target; if (node->tryCastTo(ThingSetNodeType::decodable, &target)) { ThingSetBinaryDecodable *decodable = reinterpret_cast(target); return decodable->decode(decoder); } +#ifdef CONFIG_THINGSET_PLUS_PLUS_EEPROM_SKIP_UNRECOGNISED LOG_WARN("Ignoring persisted value 0x%x as it is not decodable", id); return decoder.skip(); +#else + LOG_WARN("Persisted value 0x%x is not decodable, abandoning load", id); + return false; +#endif }) && decoder.verify(); } diff --git a/zephyr/Kconfig b/zephyr/Kconfig index cf73a50..a34f7ae 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -133,6 +133,16 @@ config THINGSET_PLUS_PLUS_EEPROM_DATA_VERSION help Increment this if you change the IDs of any persisted objects. +config THINGSET_PLUS_PLUS_EEPROM_SKIP_UNRECOGNISED + bool "Skip unrecognised persisted values" + default n + help + If enabled, a persisted value whose ID is not present in the + registry, or whose node is not decodable, is logged and skipped, + and loading continues with the remaining values. If disabled, + such a value causes the whole load to fail, leaving every object + at its default value. + endif module = THINGSET_PLUS_PLUS From 8c19d96860788521e6b4e7b0c29b7017376ba1bc Mon Sep 17 00:00:00 2001 From: Ethan Duckett Date: Fri, 11 Sep 2026 13:48:36 +0100 Subject: [PATCH 3/3] Change comment --- zephyr/Kconfig | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/zephyr/Kconfig b/zephyr/Kconfig index a34f7ae..eb103b1 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -137,11 +137,7 @@ config THINGSET_PLUS_PLUS_EEPROM_SKIP_UNRECOGNISED bool "Skip unrecognised persisted values" default n help - If enabled, a persisted value whose ID is not present in the - registry, or whose node is not decodable, is logged and skipped, - and loading continues with the remaining values. If disabled, - such a value causes the whole load to fail, leaving every object - at its default value. + If enabled, skips IDs that are not recognised in EEPROM rather than aborting endif