SDK Version: 9.0.0 Softdevice: S110 v8.0.0
I'm currently trying to send streams of data from an Android app to a nrf51. However, at some point, Android side writes to the characteristic which the nrf51 does not acknolwedge.
How it works:
- Android reads file
- Android sends first data record (16 bytes) to nrf51
- nrf51 changes a characteristic value to trigger notification
- Android receives notification and sends next data record
This repeats until all the data has been received by nrf51.
Problem:
At some point, the Android device will send a data record which the nrf51 will not receive. This halts the procedure. I confirmed this by having a counter where my App writes to the characteristic to show it sent X data records then one on the nrf51 (OnWrite function) to show it received only X-1 data records. I do get an acknowledgment on the Android side that the characteristic has been written (from the BluetoothGattCallback onCharacteristicWrite callback). I can get this to work if I put a delay >= 50ms (in Android app) between receiving notification from nrf51 and sending next data record.
I understand a workaround would be to have a timeout on the Android side and retransmit but I believe there must be a way to make this first pass more reliable.
Investigation:
After some research, I discovered a low connection interval could cause issues here. I have started to implement the connection parameters module to negotiate an appropriate connection interval upon connect. However, before I go any further, I would like to confirm that this is the cause and not something completely different.
I looked at the time between nrf51 receiving each data record and discovered it was always in slots - mainly 145ms and sometimes 197ms. Reducing the Android delay from 50ms to 30ms led to 96ms, mostly 145ms and sometimes 197ms. This further suggests that the transmission is missing some sort of window.
Has anyone else come across this behaviour before? Am I right in thinking that modifying the connection interval would solve issues with sending large data sequentially? Or is this a known issue with my version of the softdevice?