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?

Reply
  • 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?

Children
Related