diff --git a/src/ThingSetPersistence.cpp b/src/ThingSetPersistence.cpp index bacdc27..20ea2d0 100644 --- a/src/ThingSetPersistence.cpp +++ b/src/ThingSetPersistence.cpp @@ -38,14 +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..eb103b1 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -133,6 +133,12 @@ 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, skips IDs that are not recognised in EEPROM rather than aborting + endif module = THINGSET_PLUS_PLUS