Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/ThingSetPersistence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,26 @@ bool ThingSetPersistence::load()
return decoder.decodeMap<uint16_t>([&](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<ThingSetBinaryDecodable *>(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();
}

Expand Down
6 changes: 6 additions & 0 deletions zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down