MTU exchange issue – ble_app_uart_c / ble_app_uart with MTU 247

I am using the nRF5 SDK, nRF52833, and nRF52832.

I flashed the following two demos:

  • nRF5_SDK_17.1.0_ddde560\examples\ble_central\ble_app_uart_c\pca10100\s122 (nRF52833)

  • nRF5_SDK_17.1.0_ddde560\examples\ble_peripheral\ble_app_uart\pca10040\s132 (nRF52832)

I changed BLE_GATT_ATT_MTU_DEFAULT to 247 in both projects.

However, the MTU exchange does not happen. In the following function:

void gatt_evt_handler(nrf_ble_gatt_t * p_gatt, nrf_ble_gatt_evt_t const * p_evt)
{
    if (p_evt->evt_id == NRF_BLE_GATT_EVT_ATT_MTU_UPDATED)
    {
        NRF_LOG_INFO("ATT MTU exchange completed.");
        m_ble_nus_max_data_len = p_evt->params.att_mtu_effective - OPCODE_LENGTH - HANDLE_LENGTH;
        NRF_LOG_INFO("Ble NUS max data length set to 0x%X(%d)", m_ble_nus_max_data_len, m_ble_nus_max_data_len);
    }
}

These two log messages do not appear.

In actual data transmission, I can only send 20 bytes. Sending 23 bytes causes an error.

Could you please help me understand why the MTU exchange is not taking place?

Thank you.

Parents
  • Hello,

    I have not tried to reproduce this yet, but as a test, please try set NRF_BLE_GATT_MTU_EXCHANGE_INITIATION_ENABLED to "0" in your ble_app_uart build so that the MTU exchange is only initiated by the central. 

    Best regards,

    Vidar

  • Hi Vidar,

    Thank you for your suggestion. Setting NRF_BLE_GATT_MTU_EXCHANGE_INITIATION_ENABLED to 0 on the peripheral side worked – the MTU exchange now happens successfully.

    However, I have a follow-up question. Looking at the logs:

    00> <debug> nrf_ble_gatt: max_rx_octets: 27
    00> 
    00> <debug> nrf_ble_gatt: max_tx_octets: 27

    Why is it showing 27 bytes?

    Here is the full log for reference:

    00> <info> app_timer: RTC: initialized.
    00> 
    00> <info> app: Debug logging for UART over RTT started.
    00> 
    00> <info> app: Advertising_start.
    00> 
    00> <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.
    00> 
    00> <info> app: Connected
    00> 
    00> <debug> nrf_ble_gatt: Peer on connection 0x0 requested an ATT MTU of 247 bytes.
    00> 
    00> <debug> nrf_ble_gatt: Updating ATT MTU to 247 bytes (desired: 247) on connection 0x0.
    00> 
    00> <info> app: Data len is set to 0xF4(244)
    00> 
    00> <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
    00> 
    00> <debug> nrf_ble_gatt: Data length updated to 27 on connection 0x0.
    00> 
    00> <debug> nrf_ble_gatt: max_rx_octets: 27
    00> 
    00> <debug> nrf_ble_gatt: max_tx_octets: 27
    00> 
    00> <debug> nrf_ble_gatt: max_rx_time: 328
    00> 
    00> <debug> nrf_ble_gatt: max_tx_time: 328
    00> 
    00> <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
    00> 

    The ATT MTU exchange shows 247 bytes (0xF7), but the data length update shows only 27 octets. I expected the data length to be updated to a larger value as well.

    Could you please explain why the data length remains at 27 bytes in this case?

    Thank you for your help.

  • Hi,

    Please make sure that NRF_SDH_BLE_GAP_DATA_LENGTH is set to "251" in the sdk_config.h header in both projects. The radio packet length should be updated from 27 bytes to 251 with this setting.

    Best regards,

    Vidar

  • Hi Vidar,

    Thank you for the suggestion.

    I have checked both projects (central and peripheral), and NRF_SDH_BLE_GAP_DATA_LENGTH is already set to 251 in both sdk_config.h files:

    // <i> Requested BLE GAP data length to be negotiated.
    #ifndef NRF_SDH_BLE_GAP_DATA_LENGTH
    #define NRF_SDH_BLE_GAP_DATA_LENGTH 251
    #endif

    However, the log still shows max_rx_octets: 27 and max_tx_octets: 27 after the data length update.

    Could there be another configuration or setting that is limiting the data length to 27 bytes?

    Thank you for your continued support.

Reply
  • Hi Vidar,

    Thank you for the suggestion.

    I have checked both projects (central and peripheral), and NRF_SDH_BLE_GAP_DATA_LENGTH is already set to 251 in both sdk_config.h files:

    // <i> Requested BLE GAP data length to be negotiated.
    #ifndef NRF_SDH_BLE_GAP_DATA_LENGTH
    #define NRF_SDH_BLE_GAP_DATA_LENGTH 251
    #endif

    However, the log still shows max_rx_octets: 27 and max_tx_octets: 27 after the data length update.

    Could there be another configuration or setting that is limiting the data length to 27 bytes?

    Thank you for your continued support.

Children
No Data
Related