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

Sending data continuously via NUS with the ble_app_uart example

Hi all,

in my project I have a nRF52DK and a nRF52840DK. I will use the nRF52DK as peripheral and the nRF52840DK as central. For this I flashed ble_app_uart on to the peripheral and ble_app_uart_c on the central. This works like a charm :) . I am very happy with these examples.

For my project I want to send some data continuously from the peripheral to the central. So I need a continuous data transfer from the peripheral to the central. I need to achieve a data rate of ~50 kBit/s (~6,25 kByte/s). To achieve this data rate, I want to send for example 200 Bytes every 32 ms. The ble_app_uart example seems like a great starting point for this. In the ble_app_uart example the send function (ble_nus_data_send()) gets called by "enter" as input. So maybe I need to call this function in a loop or with a timer. But I am not quite sure how to implement this correct.

I am familiar with the basics of BLE (Connection Interval, MTU, DLE,..) and have a few experience with the programming of microcontrollers, but I am pretty new to the nRF environment.

So I want to ask you kindly, if you can give me some proper guidance on how to modify the ble_app_uart example to get this continuous data transfer via NUS?

I am looking forward to hearing from you. Thank you so much in advance.

Kind regards,

Maria

Parents Reply Children
  • Hello,

    thank you for your quick response.

    in order to achieve my required data rate of 50 kBit/s, I call the ble_nus_data_send() function every 32ms with 200 Bytes of data. I set NRF_SDH_BLE_GAP_EVENT_LENGTH to 10 and hvn_tx_queue_size to 30.

    I set the connection interval on central and peripheral to 31,25 ms (for min. and max). 

    But I am receiving ERROR 19  [NRF_ERROR_RESOURCES] after I called the ble_nus_data_send() function for about 10 to 30 times. 

    Here are my questions:

    1. Do I miss something here?

    2. Can you please help me to achieve this 50 kBit/s data-rate?

    3. What are the ideal connection parameters to achieve this?

    Thank you very much in advance. I hope you can help me again.

    Kind regards,

    Maria

  • Hello Maria,

    Could you try with the example I sent and see what throughput you get then? Also, how many packets are you attempting to send per timer event? 

    Kind regards,

    Vidar

  • Hello Vidar Berg,

    I had to add the following to the ble_stack_init:

        err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATTS, &ble_cfg, ram_start);
        if (err_code != NRF_SUCCESS)
        {
            NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_CONN_CFG_GATTS.",
                          nrf_strerror_get(err_code));
        }

    It looks like the queue size was not applied before. I have to do further testing, but I it looks promising at the moment. It seems that it works now.

    Thank you very much.

    Kind regards,

    Maria

Related