Hi there,
I'm currently working on getting a streaming application running which is supposed to sample some audio at 16kHz and send it (uncompressed) to a central device via BLE.
Current Status, what works:
The SAADC is configured with a double buffer, each containing 122 samples of uint16 samples. The samples are stored intermediately in an Atomic FIFO until they are then broken up into two uint8 values and sent using the function sd_ble_gatts_hvx(). The transmission works with data-length extension and connection-length extension enabled. The code as of now, works at lower sampling rates of about 1.5kHz, however going beyond this sampling-rate makes the BLE connection fail. Consequently the peripheral device looses the connection to the central device and needs to reconnect.
Connecting the peripheral with the nRF Connect App on an Android phone, the central (App) side reports: Disconnected Error 0x8 [= GATT CONN TIMEOUT].
What doesn't work:
At this point I am confident to say, it is most likely a timing constraint which is violated, since the BLE connection breaks earlier the higher the sampling-rate. Likewise increasing the distance, i.e. latency of the BLE connection leads to a earlier loss of connection. The connection breaks with the BLE_GAP_EVT_DISCONNECTED case. The code never reconnects after this event and just remains / "freezes" in this state. No error is reported, the program keeps running.
The problem:
- I have isolated the SAADC part of my code printing the values via UART to my terminal instead of transmitting via BLE. This works just fine, even at sampling-rates as high as 32kHz the code never freezes and the Atomic FIFO never fills up.
- I have isolated the BLE transmission part, sending simply dummy data in intervals triggered by a timer. This too works at frequencies of up to 20kHz with out loosing connection or "freezing up".
The set-up I use is:
2x NRF52 DevKit (nrf52832) with S132
nrf SDK 15.3.0
Segger Embedded Studio 4.16
The code I am using is based on the ble_app_uart example from the SDK.
Question:
- Am I correct in my calculations/ assumptions that this amount of data should be transmittable via BLE?
- How can I increase the throughput of my code, such that the data stream may run continuously?
- Is there any working example around of streaming large quantities of data while using the SAADC?
- How can I resolve the loosing of connection on my device and how to fix the freezing up/ not reconnecting of the devices?
Thanks a lot for your time and help
Oliver