BLE data transfer latencty between peripherals in a multi-connection-system

Dear all,

I'm developing a 1 VS 4 BLE connection system, using 1 nRF52840 as BLE central and 4 nRF52832 as BLE peripherals.

I'm trying to send the same command to 4 peripherals, how to minimize the delay between each peripherals?

For now I'm using following statement to send BLE command:

for(uint8_t i=0; i<NRF_SDH_BLE_CENTRAL_LINK_COUNT; i++)
					{
						uint8_t retry = 0;

						do{
						err_code = ble_nus_c_string_send(&m_ble_nus_c[i], &USB_cmd, 1);
						retry++;
						}while((err_code != NRF_SUCCESS) && (retry < 10));
					}

And connection parameters are as follow:

  • connection interval: 30ms
  • scanning interval: 30ms
  • scan window: 7.5ms
  • gap_event_length: 7.5ms

To test the delay, I send a test command to each peripheral, and captured the time when receive the response. For time being, 4 responses are received in two transferring, delay is about 30ms. Seems like responses are transfered in two connection intervals.

Then I tried to decrease connection parameter further:

  • connection interval: 20ms
  • scanning interval: 20ms
  • scan window: 5ms
  • gap_event_length: 5ms

The connection become very unstable.

How do I suppose to optimize the latency between peripherals? Hopefully the peripherals could receive the command at the same time, or to say, less than 5ms latency?

Thx, Ava

Parents
  • Sorry I just found somthinig wrong with my experiment setup. 

    After modification, I'm monitoring the ble response timing in central ble_nus_data call back, and the delay between each response is about 7~8ms, match the connection parameters:

    • connection interval: 30ms
    • scanning interval: 30ms
    • scan window: 7.5ms
    • gap_event_length: 7.5ms

    Seems like the minimum delay between slaves is the gap_event_length value. Since connection will turn unstable if I further decrease the gap_event_length. I guess this is the optimize BLE setup? 

    THX, AVA

  • Your observations are correct—the delay between the responses from peripherals is mainly influenced by the GAP event length and the connection scheduling of the BLE controller.

    Try increasing GAP event length to 15ms or more, so that all peripherals can be served in one connection interval. Try setting connection interval to 15ms or 10ms while ensuring enough GAP event length. Also try using 2M phy instead of 1M

  • Just wanna double check my understanding: current setup(7.5ms gap_event_length & 30ms connection interval) allows BLE central to connect 1 peripheral at a time, connection would be hold for 7.5ms then the central would turn to the next peripheral connection. In this way, all peripherals have already been served in one connection interval, no? What will be different if I set gap_event_length to 20ms and connection interval to 20ms?

    so that all peripherals can be served in one connection interval

    Additionally, can I set peripheral PHY or ble parameters by central device?(without modifying peripheral firmware) 

    Also try using 2M phy instead of 1M

    Thanks

Reply
  • Just wanna double check my understanding: current setup(7.5ms gap_event_length & 30ms connection interval) allows BLE central to connect 1 peripheral at a time, connection would be hold for 7.5ms then the central would turn to the next peripheral connection. In this way, all peripherals have already been served in one connection interval, no? What will be different if I set gap_event_length to 20ms and connection interval to 20ms?

    so that all peripherals can be served in one connection interval

    Additionally, can I set peripheral PHY or ble parameters by central device?(without modifying peripheral firmware) 

    Also try using 2M phy instead of 1M

    Thanks

Children
  • Avadacadabara said:
    then the central would turn to the next peripheral connection. In this way, all peripherals have already been served in one connection interval, no? 

    That is very simplistic way of multiplexing, but the underlying scheduler that reserves timeslots for each event with each peripheral tries to get a free timeslot, and there might be times where one of those request might be rejected due to something else already reserved a timeslot at the requested time. Apart from that, yes your understanding is right,  You should also know some other variables like priorities for this scheduler to know that sometimes it is not just a round robin selection between peripherals.

    Avadacadabara said:
     What will be different if I set gap_event_length to 20ms and connection interval to 20ms?

    If you set the connection interval to 20ms in central, then the four peripheral Event Length slows might not fit within the 20ms and Peripheral 1 gets served in the first 20ms interval. Peripheral 2 gets served in the next 20ms interval. Peripheral 3 in the next, and so on. With 30ms connection interval and 7.5ms even  length, all four peripherals get a turn within one connection interval (30ms). 

    With 20ms connection interval and 20ms event length, only one peripheral gets served per interval, so each peripheral gets a chance to communicate only once every 80ms, increasing latency.

Related