I'm using s120 v2.1, with SDK 9, on an nRF51 with 256K ROM and 16K RAM. With s120 I only have 6K of usable RAM for my application. I am running critically low on RAM, and while I am looking at ways to better utilize RAM, and reduce the amount of RAM my application uses. I could free up almost 1K of RAM, if I could do a FLASH write while maintaining a connection.
My application is a BLE Remote control. The remote can control a group of up to 8 devices at a time. The user can configure up to 5 groups. When the user needs to configure a group I switch the remote from a central device to a peripheral device. The user can then connect to the remote with their Android or iOS device, and configure the groups. I have to have enough memory to store all 5 groups, then on disconnect I use pstorage_update() to save the data. If I could save the data to Flash, while maintaining a connection, I could cut my RAM usage from 1K to 200 bytes.
I was looking at the post here.
In the post Aryan first states:
you cannot write to flash directly while softdevice is enabled and connections/advertising/scanning is active
But then says:
You can use either pstorage API or SOC API (sd_flash_write) to access flash safely while in connections
I followed the link labelled documentation and thought I had done everything outlined, but my connection is dropped when I try to do the update. Note - during the write to FLASH, I only need to maintain the connection, all other BLE operations can wait until the write is complete.
I know waiting until there is no connection, advertising, or scanning (basically any radio operations) is the preferred method, but in this case I need the RAM.
Is writing to FLASH possible, while maintaining a connection (several threads imply that it is)? Is there an example that actually writes to the FLASH while maintaining a connection?