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

Transmitting multiple Notifications in one Connection Interval

Hi, we are developing an Application with one nrf52840 acting as central, that is connected to up to three nrf52840 acting as peripheral. For our Project, latency for transmissions from peripheral to central is essential. Thus, we have set the connection interval for all 3 Peripherals to the minimum of 7,5 ms. For data transfer we use the Nordic UART Service (NUS).

We are currently facing a problem: If we call ble_nus_data_send (which then calls sd_ble_gatts_hvx) on peripheral side, while there is already one notification queued to be sent, it will take 2 connection intervals to transmit both notifications. I would expect both notifications to be sent in one connection interval, as long as the total amount of bytes to be transferred, fit according to NRF_SDH_BLE_GAP_EVENT_LENGTH and  NRF_SDH_BLE_GAP_DATA_LENGTH. Is there a way to achieve that both notifications are sent in one connection interval?

Our Connection Parameters:

NRF_SDH_BLE_GAP_EVENT_LENGTH = 2 (this is needed so that 3 connections fit in one connection interval)

NRF_SDH_BLE_GAP_DATA_LENGTH = 78

NRF_SDH_BLE_GATT_MAX_MTU_SIZE = 140

NRF_BLE_SCAN_MIN_CONNECTION_INTERVAL = 6

We transmit 14 bytes per notification. So I would expect at least two notifications to fit in one connection interval. In addition, when we pass more than 19 bytes to ble_nus_data_send, it takes 2 connection intervals to transmit the notification. I would expect it to be transmitted in one connection interval, as long as the payload size does not exceed NRF_SDH_BLE_GAP_DATA_LENGTH.

Thank you and best regards.

Björn

  • Ok but i only transmit data via notifications from the peripheral to the central. Thus the central should generate the event imidiately when the packet is received, correct? Or do you expect the peripheral to wait, until one packet was answered, until it sends the next one?

    However, this still does not explain why notifications with more than 19 bytes are seperated into two connection intervals.

  • BjoernSchmitz said:
    Ok but i only transmit data via notifications from the peripheral to the central. Thus the central should generate the event imidiately when the packet is received, correct?

    I expect it will be raised during post processing of the connection event.  

    BjoernSchmitz said:

    Or do you expect the peripheral to wait, until one packet was answered, until it sends the next one?

    However, this still does not explain why notifications with more than 19 bytes are seperated into two connection intervals.

    A sniffer log will show what is happening here.

  • Ok, I have found the Issue(s). There were two things that prevented me from sending the notifications as expected:

    1. The tx notification queue size on the peripheral was set to the default value of 1. To send multiple notifications in one connection interval, i had to increase the queue size.

        // Configure the BLE stack using the default settings.
        // Fetch the start address of the application RAM.
        uint32_t ram_start = 0;
        err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start);
        APP_ERROR_CHECK(err_code);
    
        //sd_ble_cfg_set( , ,&ram_start)
        ble_cfg_t ble_cfg;
        memset(&ble_cfg, 0, sizeof(ble_cfg));
    
        ble_cfg.conn_cfg.conn_cfg_tag = APP_BLE_CONN_CFG_TAG;
        ble_cfg.conn_cfg.params.gatts_conn_cfg.hvn_tx_queue_size = 2;
        err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATTS, &ble_cfg, ram_start);
        APP_ERROR_CHECK(err_code);
        // Enable BLE stack.
        err_code = nrf_sdh_ble_enable(&ram_start);
        APP_ERROR_CHECK(err_code);

    2. The other Problem was the setting of NRF_SDH_BLE_GAP_DATA_LENGTH. I used 78, the maximum that the stack would allow me to use when NRF_SDH_BLE_GAP_EVENT_LENGTH is set to 2. Instead of using the maximum value, used a smaller value of 30.

    These two settings in combination allowed me to sent multiple notifications in one connection interval.

Related