Paul,
So it looks like one object in the flash got corrupted, and the ReplayMessenger keeps tripping over that. This causes a device restart, the application re-runs, tries again, etc. (note that repeated restarts due to application crashes is something the application can handle intelligently in order not to burn through a lot of battery or data volume unnecessarily - happy to explain more).
Why did the flash object get corrupted? It could be an actual fault in the flash (possible, but unlikely), or - more likely - the application was interrupted while it was writing the object to flash, e.g. due to a power loss or reset. The SPIFlashLogger object storage is not atomic and happens in two steps, first the metadata, then the object itself. If the 2nd step is interrupted then it will leave a corrupt object behind.
To resolve the situation, you can add code into your application that combs through the stored objects and clears out any corrupted objects before starting ReplayMessenger. The code would be something like this:
function validateMessages(onDone) {
local onData = function(payload, address, next) {
try {
local id = payload[RM_COMPRESSED_MSG_PAYLOAD]["id"];
} catch (err) {
logger.error("Corrupted message detected: " + err);
spiFL.erase(address);
}
next();
}.bindenv(this);
spiFL.read(onData, onDone, -1);
}
Note this is not ideal if the number of stored objects is large it will take significant time to iterate over all of them. There are smarter ways to clean the store that can be considered, but as a quick resolution this should work.
I will file an enhancement request for ReplayMessenger, i.e. to more gracefully handle corrupt objects in flash.
Let me know if that helps!
Best,
– Terrence