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

better BLE data rate between two NRF52840

Hi,

I am developing a project where I have NRF52840 as a device and another NRF52840 as a BLE USB dongle connected to PC.

I have to improve the BLE data rate between the dongle and the device.

Using for the Device usbd_ble_uart example and added to it the NUS service from the ble_app_uart example

Using for the Dongle the ble_app_multilink_central example because one dongle should be allowed to connect to more than one device, added to the example the ub perepheral from the usbd_ble_uart and the central NUS from the ble_app_uart_c example.

The PC an the Device communicate throw the Dongle, and experience a big delay ( in milliseconds) between sending the command from the PC until the reply from the Device received back.

at the BLE_GAP_EVT_CONNECTED event I check the min_conn_interval and the max_conn_interval like this : 

        case BLE_GAP_EVT_CONNECTED:
	  BLE_Connected = true;

            m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
            err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle);
            APP_ERROR_CHECK(err_code);

	    min = p_ble_evt->evt.gap_evt.params.connected.conn_params.min_conn_interval;
	    max = p_ble_evt->evt.gap_evt.params.connected.conn_params.max_conn_interval;

both the minimum connection interval and the maximum connection interval are 24 .

I set the minimum and the maximum connection interval from the Device to 7.5 ms, after the connection the device got a BLE_GAP_EVT_CONN_PARAM_UPDATE event where the minimum and the maximum connection intervals is set to 6 ms.

1. Am I doing it right ? this will improve the BLE data rate yes ? if No what is the optimal connection interval for a better data rate!?

2. Is there anything else can be done to improve the BLE data rate ?

3. Is setting  the connection intervals to 6 ms as I mentioned above is gonna work for both of the connected devices to the dongle? how it will affect the data rate when two device is connected ?

  • Hi Karl,

    thank you a lot for your fine explanation.

    what is the possible replies that the peripheral can reply to a command?

    there is replies that require a peripheral work, as you explained, ad now it make sense.

    But that raises for me another question:

    In one second we have 1/0.0075 = 133.33 connection events, if the connection interval is 7.5 ms.

    and the biggest MTU is 244 bytes, then the biggest data rate can be 133.33 * 244 = 32533 Bps= 31.7 KB ps = 254.16 Kbps.

    So how can BLE 5 reach 800 Kbps with 1Mbps PHY!?

    Best Reagrds

    JK

  • Hello JK,

    jawadk said:
    thank you a lot for your fine explanation.

    No problem at all, I am happy to help!

    jawadk said:
    there is replies that require a peripheral work, as you explained, ad now it make sense.

    I am happy to hear that we are on the same page now, and that I have understood you correctly - thank you for clarifying!

    jawadk said:

    But that raises for me another question:

    In one second we have 1/0.0075 = 133.33 connection events, if the connection interval is 7.5 ms.

    and the biggest MTU is 244 bytes, then the biggest data rate can be 133.33 * 244 = 32533 Bps= 31.7 KB ps = 254.16 Kbps.

    So how can BLE 5 reach 800 Kbps with 1Mbps PHY!?

    You can change the connection event length, to transfer multiple packets per connection event.
    I recommend that you read through this blog post by my colleague for further detail.
    Please also have a look at the example project and the reply by my colleague Edvin in this ticket.

    Please do not hesitate to ask if anything should be unclear!

    Best regards,
    Karl

  • Hi,

    Thank you again and again for the help.

    Lets say the I am using the maximum connection event length (500ms), maximum MTU (247), maximum data length (251) and connection_interval (min and max) 100ms. as your colleague suggested.

    If I am trying to send a message in between two connection events, it will be sent immediately as a part of the current connection event? or it will be sent as a part of the next connection event ? in other words the latency will be affected or not !? 

    Best Regards

    JK

  • Hello JK,

    jawadk said:

    Lets say the I am using the maximum connection event length (500ms), maximum MTU (247), maximum data length (251) and connection_interval (min and max) 100ms. as your colleague suggested.

    If I am trying to send a message in between two connection events, it will be sent immediately as a part of the current connection event? or it will be sent as a part of the next connection event ? in other words the latency will be affected or not !? 

    Not quite. The SoftDevice will control the CPU for the entire duration of the connection event - so your application may not queue new data for transfer while the event is ongoing.
    However, an event may end early if there is no more data queued for sending, in which case your application will be given back the CPU.
    So, I guess the answer to your question regarding latency is: it depends on how much data you have queued in between each connection event.
    Bear in mind that the connection event length will scale to be < connection_interval. By setting 500 ms event length, you are basically asking to set to to the maximum value possible, for your given connection interval.

    The aforementioned is also the reason why you should use easyDMA and PPI for most of your peripherals - so that they may continue working / sampling / receiving / transferring while the SoftDevice controls the CPU.

    Best regards,
    Karl

  • Hi Karl,

    Lets say that the connection interval is 10 ms.

    In case that the application queued a 25 bytes to send (one packet), and the softdevice send them in the first connection event, after the sending is finished, you said that in this case the first event ends, so what the application queue for sending for now on till the second connection event will be sent during the second connection event yes ?

    the first connection event ends and not returns in this case, is that what you meant ? so in this case my  latency will still be <= 10 ms, is that right ?

    Best Regards

    JK

Related