This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Minimising latency when relaying on nrf52832

Hi,

I'm trying to reduce latency when relaying BLE packets. The goal is to have a couple of wireless peripherals connected to a hub talking BLE with a central, with minimal latency.

First of all, I use nrf52832 with softdevice s132 (7.2.0) and sdk 17.0.2. The setup consist of three pca10040s, configured as follows: one Transmitter being peripheral, one Relay being multirole, and one Receiver being central.

The Transmitter sends a packet at regular intervals to the Relay, which upon reception is passed on to the Receiver. When the Transmitter sends, a gpio is pulsed. When the Receiver receives, a gpio is pulsed. Both gpios are fed to an oscilloscope and we can thus easily see the time it takes from start of transmission to end of reception. I draw a lot inspiration from the sdk - examples/ble_central_and_peripheral/experimental/ble_app_hrs_rscs_relay.

I use my own service with a characteristic having notify and write w/o resp capabilities. The connection interval for all three devices is set to 7.5ms, and is agreed upon and verified on connection. The packet that is sent and relayed is always 17 bytes - 16 byte id plus a sequence number. PHY is 1Mbps.

Once everything is connected, all scanning and advertising is turned off.

Now - if I connect Transmitter and Receiver directly without relaying, I get a transfer time ranging from 0ms to 8ms as expected. However, when relaying, we can go from 14ms up to 40ms transfer time. This is somewhat expected, as the Relay cannot TX and RX at the same time: I gather the softdevice chops things up for us when TXing a lot.

In order to remedy this, I rebuilt the Relay part. It now consists of two pca10040s, connected via SPI. Thus we have the original Transmitter and Receiver, but the Relay now has one dedicated receiver and one dedicated transmitter. The SPI part is one-directional from receiver to transmitter, running 8MHz, triggered by PPI. It's verified giving max up to 1 millisecond delays. Connection intervals for all four boards is still 7.5ms.
The packets thus now travel from Transmitter to RelayRX via BLE. From there they go to RelayTX via SPI. And finally from RelayTX to Receiver via BLE.

Unfortunately, despite all my pains, the transfer time ranges from 15ms to 35ms.

This leads me to following questions:
* Have I missed anything obvoius?
* Why the big difference in delays? I guess each retransmission adds 7.5ms to a packet.
* Would I be better off not using BLE between devices and the hub but something proprietary?

Regards

Parents Reply Children
Related