This library is designed to simplify a a common task: Storing a struct of persistent data in the Gen 3 POSIX file system, retained memory, or EEPROM. It also works with SdFat (SD cards), SPIFFS (SPI flash), and FRAM.
It supports all C/C++ primitive types and C strings (null-terminated) up to a maximum length defined in the structure. It includes change detection, deferred saves (to reduce flash wear), and is extensible to store data on other types of file systems or storage methods. Validity checking includes magic bytes, version numbers, and a saved hash to determine if the data has been corrupted.
You can add values to the structure later and still maintain compatibility; new fields will be zeroed out if the new firmware has a bigger structure than the one that was saved.
It also includes a simple file system abstraction for reading and writing files on POSIX, SdFat, or SPIFFS.
There seems to be no end in sight for the phrase āthis keeps getting better and betterā.
Iām happy.
All the little and big things the Particle team and you keep adding make our work so much easier and enjoyable with the platform.
Thank you, Mr RK!
This is a great resource and complement to sleepHelper - thank you for your amazing work.
Two questions:
Since this code is refactored out of sleepHelper, could you please push the new v0.0.4 to the Particle Library system. I see it on GitHub but when I install sleepHelper, it is still v0.0.3
I am struggling a bit with implementing FRAM storage which I seems that storageHelper supports. Here is what I have done:
Started with your example code- 04-persistent.cpp and verified it compiles
Installed and included MBRC85RC256V-FRAM-RK
instantiated the FRAM using "MB85RC64 fram(Wire, 0); "
changed one line of code as outlined in the instructions:
class MyPersistentData : public StorageHelperRK::PersistentDataFRAM {
I expected some errors but, it seems the FRAM class is not recognized. Here is the compile error:
Creating /Users/chipmc/Documents/Maker/Particle/Utilities/StorageHelper-Demo-FRAM/target/2.3.0/boron/platform_user_ram.ld ...
/Users/chipmc/Documents/Maker/Particle/Utilities/StorageHelper-Demo-FRAM//src/StorageHelper-Demo-FRAM.cpp:22:70: error: expected class-name before '{' token
22 | class MyPersistentData : public StorageHelperRK::PersistentDataFRAM {
I fixed the Particle library upload of SleepHelper. I forgot to make that public. I just fixed it.
Make sure you put the includes in the right order. The FRAM include must be before StorageHelperRK or anything that includes it like SleepHelper 0.0.4.
Thank you for the update to the sleepHelper library and the clue on the order of includes - it was clearly called out in your header file - sorry I missed it.
I am trying to get this working and am running into a compile warning (it does compile) on this line:
Creating /Users/chipmc/Documents/Maker/Particle/Utilities/StorageHelper-Demo-FRAM/target/2.3.0/boron/platform_user_ram.ld ...
D.116051.fram'/Users/chipmc/Documents/Maker/Particle/Utilities/StorageHelper-Demo-FRAM//src/StorageHelper-Demo-FRAM.cpp: In member function 'MyPersistentData::MyPersistentData()':
/Users/chipmc/Documents/Maker/Particle/Utilities/StorageHelper-Demo-FRAM//src/StorageHelper-Demo-FRAM.cpp:40:117: warning: is used uninitialized in this function [-Wuninitialized]
40 | MyPersistentData() : PersistentDataFRAM(fram, FRAM_OFFSET, &myData.header, sizeof(MyData), DATA_MAGIC, DATA_VERSION) {};
Not sure why it is saying that the version is uninitialized when I thought that was taken care of in the line above the call. As you can see from the tool tip, the value of the version number is being seen: