I'm investigating the flash usage by the peer manager to store bond related data. While I haven't had a chance to fully investigate how the FDS and fstorage modules work, I did notice two things that surprised me with regards to this:
1. Every time a CCCD is written from a bonded peer device, 44 bytes of flash are being used to store the updated CCCD value. This seems like a lot of flash usage, especially considering that the CCCD value itself is only 2-bytes. I understand that there is some overhead beyond just the two bytes written to the CCCD (e.g. indexes, headers, handle value, etc...) but 44-bytes seems like a huge amount of flash to use. Is there any way to reduce this?
2. I also noticed that if a CCCD gets written to more than once with the same value, the peer manager still writes 44-bytes of flash for these additional writes, even though nothing has actually changed. For example, say that I write a value of 0x0001 to a CCCD to enable notification of the characteristic value. Then later I disconnect from the peer device and then reconnect and re-encrypt the link (and restore the CCCD to it's previous value of 0x0001). If the peer device were to once again write a value of 0x0001 to the CCCD (which doesn't actually change anything), the peer manager still writes 44-bytes of data to the flash. This also seems wasteful of flash. Is there any way to check the previously stored value and only perform the flash write when a value actually changes?
I understand that there is a garbage collection system in FDS that will take effect when pages fill and clean up any old/unused data in flash (please correct me if I'm wrong here), but it still seems like the above two issues create additional flash writes / page erases that are unnecessary and also add complication to the system.
Thanks!