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

Sending more than 1 packet per connection with nRF52840

As I'm new to the nRF52840 and Bluetooth, I read documents and DevZone posts related to the bluetooth maximum throughput.

According to the references like Jimmy and Sigurd and so on, it seems that I can get higher throughput if I set MTU to the maximum value and send multiple packets per connection.

The problem is that it was not able for me to find options to enable sending multiple packets.

Currently, I mixed ble_app_uart and saadc examples to get signal and send them via bluetooth. And the data length extension and MTU size are set to the maximum as I know.

And I send data using the following code which is written by another team member

static void nus_data_handler(ble_nus_evt_t * p_evt)
{

    if (p_evt->type == BLE_NUS_EVT_RX_DATA)
    {
        uint32_t err_code;

        NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);

        for (uint32_t i = 0; i < p_evt->params.rx_data.length; i++)
        {
            do
            {
                err_code = app_uart_put(p_evt->params.rx_data.p_data[i]);
                if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY))
                {
                    APP_ERROR_CHECK(err_code);
                }
            } while (err_code == NRF_ERROR_BUSY);
        }
        if (p_evt->params.rx_data.p_data[p_evt->params.rx_data.length - 1] == '\r')
        {
            while (app_uart_put('\n') == NRF_ERROR_BUSY);
        }
    }

}

Are there any examples sending multiple packets per connection so I can try to implement to mine?

Parents
  • Hi,

    Generally, to achieve a high throughput you want to send longer packets, and often send multiple packets per connection event. So you should ensure you set a long NRF_SDH_BLE_GATT_MAX_MTU_SIZE and NRF_SDH_BLE_GAP_DATA_LENGTH, and that you set a high NRF_SDH_BLE_GAP_EVENT_LENGTH (for highest throughput the event length should be equal to the connection interval). The event length is specifically wha tyou need to adjust in order to send multiple packet per connection event, as you need more time to send more packets.

    There is no specific API for sending more packets per connection event, you just queue up notifications (for instance using ble_nus_data_send() in this case, which calls sd_ble_gatts_hvx()). As long as the SoftDevice has queued data, there is enough time left in the connection event and previous packet is acked, the next packet will also be transmitted, and so on.

    There is no specific performance issue with using NUS, as this uses notifications, which is what gives best performance. But that assumes that you do not combine it with physical UART, which is really completely independent.

  • Fisrt of all, thanks for the answer!

    for highest throughput the event length should be equal to the connection interval

    So, in the case of 10 ms(=8 units of 1.25 ms) connection internal, does it mean that I can get the highest throughput by setting the NRF_SDH_BLE_GAP_EVENT_LENGTH to 8 in sdk_config.h?

    you just queue up notifications (for instance using ble_nus_data_send() in this case, which calls sd_ble_gatts_hvx()).

    Is this mean that I don't need to define some variables, but only need to use ble_nus_data_send()? And then the notifications are automatically queued by the SoftDevice?

    the next packet will also be transmitted, and so on

    And then, maybe I get the different number of packets per connection, right?

  • Hi,

    The actual parameters you get will depend on the configuration and capabilities of both peer devices. So you should expect significant differences between phone models and Android versions, and also other factors that could affect the scheduling on the phone (other BLE devices, and even WiFi traffic etc).

  • The actual parameters you get will depend on the configuration and capabilities of both peer devices.

     As the Android device does not use any WiFi or other Bluetooth device, I cannot expect the cause of sending fewer packets. Does the demo also show a decrease in throughput if it transmits with an Android?

  • DL_November said:
    As the Android device does not use any WiFi or other Bluetooth device, I cannot expect the cause of sending fewer packets.

    I see. But regardless of that very few Android devices will allow you to get maximum BLE throughput (what you could achieve by the throughput example and two nRF devices). Which are you using?

    DL_November said:
    Does the demo also show a decrease in throughput if it transmits with an Android?

    The throughput (and most other factors) depends on the capabilities of the devices. It does not really make sense to talk about Android as a general term when it comes to BLE performance as it varies greatly.

    Knowing which Android device you are testing with and seeing a sniffer trace could explain the performance you get, but there is generally little we can do if the Android device is the limiting factor (which is often the case). That may not be the case here though, so you could set up a test with an nRF on both sides to verify.

  • Which are you using?

    I'm using Samsung Galaxy tab s7+, one of the latest models. And I checked the number of packets according to the log of nRF connect application.

    I	19:37:36.259	Notification received from 6e400003-b5a3-f393-e0a9-e50e24dcca9e, value: (0x) 76-00-76-00-74-00-75-00-75-00-76-00-74-00-73-00-74-00-73-00-74-00-71-00-73-00-71-00-71-00-71-00-71-00-70-00-71-00-6F-00-6D-00-6E-00-6D-00-6D-00-6B-00-6E-00-6B-00-6B-00-6A-00-6B-00-68-00-69-00-69-00-68-00-67-00-69-00-67-00-65-00-65-00-63-00-65-00-63-00-62-00-61-00-61-00-61-00-5E-00-5F-00-5E-00-5E-00-5E-00-60-00-5D-00-5E-00-5B-00-5B-00-59-00-5A-00-5B-00-5A-00-5E-00-5C-00-5A-00-5A-00-57-00-57-00-57-00-57-00-57-00-57-00-56-00-56-00-55-00-56-00-56-00-55-00-54-00-53-00-54-00-52-00-53-00-52-00-53-00-54-00-52-00-54-00-51-00-52-00-53-00-51-00-51-00-4F-00-51-00-51-00-51-00-50-00-4F-00-51-00-4E-00-4E-00-4E-00-4E-00-4E-00-4D-00-4C-00-4C-00-4A-00-4C-00-4A-00-4B-00-4A-00-4B-00-49-00-49-00-4B-00-4A-00-4B-00-4B-00-4A-00-4A-00
    A	19:37:36.259	"v v t u u v t s t s t q s q q q q p q o m n m m k n k k j k h i i h g i g e e c e c b a a a ^ _ ^ ^ ^ ` ] ^ [ [ Y Z [ Z ^ \ Z Z W W W W W W V V U V V U T S T R S R S T R T Q R S Q Q O Q Q Q P O Q N N N N N M L L J L J K J K I I K J K K J J " received
    I	19:37:36.261	Notification received from 6e400003-b5a3-f393-e0a9-e50e24dcca9e, value: (0x) 49-00-49-00-48-00-4A-00-49-00-48-00-48-00-49-00-4A-00-4A-00-4A-00-4A-00-4B-00-49-00-4C-00-4D-00-4C-00-4C-00-4D-00-4D-00-4D-00-4F-00-4D-00-4E-00-4E-00-50-00-4F-00-4F-00-4F-00-50-00-51-00-51-00-53-00-52-00-53-00-4E-00-55-00-53-00-55-00-59-00-57-00-58-00-58-00-57-00-59-00-5A-00-59-00-5B-00-5B-00-5A-00-5A-00-5C-00-5C-00-5B-00-5D-00-5E-00-5E-00-5E-00-5E-00-60-00-60-00-62-00-61-00-63-00-63-00-64-00-64-00-66-00-64-00-66-00-66-00-67-00-67-00-68-00-66-00-68-00-6C-00-6A-00-69-00-69-00-6B-00-6A-00-6C-00-6B-00-6D-00-6B-00-6D-00-6E-00-6C-00-6C-00-6D-00-6E-00-6F-00-6E-00-6F-00-6F-00-71-00-70-00-72-00-72-00-71-00-72-00-71-00-71-00-72-00-71-00-72-00-72-00-71-00-72-00-73-00-73-00-72-00-74-00-73-00-73-00-73-00-74-00-74-00-75-00
    A	19:37:36.261	"I I H J I H H I J J J J K I L M L L M M M O M N N P O O O P Q Q S R S N U S U Y W X X W Y Z Y [ [ Z Z \ \ [ ] ^ ^ ^ ^ ` ` b a c c d d f d f f g g h f h l j i i k j l k m k m n l l m n o n o o q p r r q r q q r q r r q r s s r t s s s t t u " received
    I	19:37:36.271	Notification received from 6e400003-b5a3-f393-e0a9-e50e24dcca9e, value: (0x) 75-00-76-00-76-00-78-00-78-00-78-00-79-00-7C-00-7A-00-79-00-79-00-78-00-7A-00-78-00-79-00-7A-00-79-00-79-00-7B-00-7A-00-7A-00-7B-00-7B-00-7C-00-7C-00-7D-00-7B-00-7B-00-7B-00-7A-00-7B-00-79-00-7A-00-78-00-77-00-78-00-77-00-76-00-76-00-76-00-76-00-76-00-75-00-77-00-75-00-74-00-74-00-75-00-73-00-74-00-73-00-72-00-72-00-73-00-71-00-71-00-71-00-70-00-70-00-6F-00-70-00-6D-00-6D-00-6D-00-6D-00-6C-00-6C-00-6C-00-6B-00-6A-00-6B-00-6A-00-6A-00-68-00-67-00-69-00-66-00-66-00-65-00-64-00-63-00-63-00-62-00-62-00-60-00-61-00-5D-00-60-00-5E-00-5D-00-5D-00-5D-00-5C-00-5C-00-5C-00-5C-00-5B-00-5A-00-5A-00-5A-00-5D-00-5C-00-58-00-5A-00-56-00-56-00-58-00-56-00-58-00-58-00-56-00-56-00-56-00-55-00-55-00-54-00-55-00-51-00-53-00-52-00
    A	19:37:36.271	"u v v x x x y | z y y x z x y z y y { z z { { | | } { { { z { y z x w x w v v v v v u w u t t u s t s r r s q q q p p o p m m m m l l l k j k j j h g i f f e d c c b b ` a ] ` ^ ] ] ] \ \ \ \ [ Z Z Z ] \ X Z V V X V X X V V V U U T U Q S R " received

    As the connection interval is fixed to 11.25ms (I don't know why but the app always fixes it) and counted Notification received messages.

  • Hi,

    DL_November said:
    I'm using Samsung Galaxy tab s7

    I see.

    DL_November said:
    As the connection interval is fixed to 11.25ms

    All connection parameters are dictated by the central, though the peripheral can request other parameters. As mentioned a sniffer trace could shed more light on what happens, but it may or may not not be possible to get the exact behaviour you want from the galaxy tab.

Reply Children
Related