This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

BLE sending mmultiple packets in my conn interval / throughput issue

Hello,

I would like to prepare BLE app with service responsible for sendind data from sensor. Needed throughput is ~250kbit/s. Based on ble_app_uart I made service which is sending notifications (each notification = 240B of sensor data).

Setup:
- nRF SDK v17.1.0
- nRF SoftDevice S140 7.2.0
- Sample program used: ble_app_hrs_freertos + "ble_app_uart"
(FreeRTOS model from (ble_app_hrs_freertos) and ble service base from ble_app_uart)
- PHY 1M

#define MIN_CONN_INTERVAL 6 /* 7,5ms */
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(30, UNIT_1_25_MS)
#define NRF_SDH_BLE_GAP_DATA_LENGTH 251
#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247
#define NRF_SDH_BLE_GAP_EVENT_LENGTH 24
#define BLE_GATTS_HVN_TX_QUEUE_SIZE 30

Inside ble_stack_init() I added this to increase amount of buffers:

/* Configure number of TX notifications buffers */
ble_cfg_t bleCfg;
memset(&bleCfg, 0, sizeof(bleCfg));
bleCfg.conn_cfg.conn_cfg_tag = APP_BLE_CONN_CFG_TAG;
bleCfg.conn_cfg.params.gatts_conn_cfg.hvn_tx_queue_size = BLE_GATTS_HVN_TX_QUEUE_SIZE;
errCode = sd_ble_cfg_set(BLE_CONN_CFG_GATTS, &bleCfg, ramStart);
APP_ERROR_CHECK(errCode);
bleNotificationsAvailable = (int8_t)BLE_GATTS_HVN_TX_QUEUE_SIZE;


I added conn_evt_len_ext_set() and call it after ble_stack_init()

void conn_evt_len_ext_set()
{
    ret_code_t err_code;
    ble_opt_t opt;
    
    memset(&opt, 0x00, sizeof(opt));
    opt.common_opt.conn_evt_ext.enable = 1;
    
    err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &opt);
    APP_ERROR_CHECK(err_code);
}


To verify my code I am working with nRF Connect 3.7.0 and Bluetooth Low Energy tool.
On nrfDongle (Client) connection interval is set to 30ms.

I am testing some cases and my observations are:
1. When I try to send notification (call sd_ble_gatts_hvx) slower than connestion inverval (e.g. 35ms) app works.
2. When I try to send notification (call sd_ble_gatts_hvx) little bit faster than connection interval (e.g. 25ms) it still works. I observe how number of free Tx buffers is changing between 27-30. Observing this changes is possible by adding counter wich is decremented after sd_ble_gatts_hvx() and incremented when event BLE_GATTS_EVT_HVN_TX_COMPLETE occurs. So in this case app it works as expected.
3. When I try to send notification (call sd_ble_gatts_hvx) faster than connection interval (e.g. 20ms) after few seconds of operation there is no free TX buffers and sd_ble_gatts_hvx returns NRF_ERROR_RESOURCES.

It looks like Soft Device is too slow. I have made some time measurements and time between calling sd_ble_gatts_hvx() and the occurrence of BLE_GATTS_EVT_HVN_TX_COMPLETE is between few to more than 20ms.

I suppose there is problem with my settings.
What should I do send multiple packets at every connection interval?
Do you see any issues with my code?

Parents
  • Hi,

    If you are using Windows, I recommend you update to the latest version of nRF connect for desktop.  Version 3.7.0 that you are using now had an issue withe the USB Windows stack configuration that prevented it from receiving multiple packets per connection event. Alternatively, you my try to use nRF connect on Android or iOS instead.

    My results with 1M PHY @ 30 ms:

    Test project based on ble_app_uart:

    nRF5_SDK17.1.0_ble_app_throughput.zip

    Best regards,

    Vidar

Reply
  • Hi,

    If you are using Windows, I recommend you update to the latest version of nRF connect for desktop.  Version 3.7.0 that you are using now had an issue withe the USB Windows stack configuration that prevented it from receiving multiple packets per connection event. Alternatively, you my try to use nRF connect on Android or iOS instead.

    My results with 1M PHY @ 30 ms:

    Test project based on ble_app_uart:

    nRF5_SDK17.1.0_ble_app_throughput.zip

    Best regards,

    Vidar

Children
No Data
Related