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

[CLOSED][nrf52832][S132 4.0.0] connection fails: exchange MTU request is not received on evt.common_evt.conn_handle=2

Configuration:

(1) 52832 PCA10040;(2) softdevice: s132_nrf52_4.0.2; (3) sdk 13.0.0(4) 52832 configure 4 conccurent peripheral connections:

ble_cfg_t ble_cfg;
memset(&ble_cfg, 0, sizeof(ble_cfg));
ble_cfg.gap_cfg.role_count_cfg.periph_role_count  = 4;
ble_cfg.gap_cfg.role_count_cfg.central_role_count = 0;
ble_cfg.gap_cfg.role_count_cfg.central_sec_count  = 0;
err_code = sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &ble_cfg, ram_start);

Attachments of Log: (1)52832 conn handle 2 fail .log: 52832 RTT View log; (2) conn handle 2 fail.pcap: wireshark log by sniffer

Problem description: (1) APP triggers 1st connection and connection parameter update is completed: image description

Such connection is established on evt.common_evt.conn_handle =2 in 52832: image description

(2) wireshark log confirms APP sends exchange MTU request to 52832 , however no request is received in 52832 (RTT log does not contain "AAAA nrf_ble_gatt_on_ble_evt id:18 " where 18 =BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST ). It causes exchange MTU procedure fails and connection procedure is not completed.

image description

(3) APP triggers 2nd connection of 52832, and it is OK now. image description

From 52832 RTT log, conn_handle =1 : image description

Conclusion: Connection fails on evt.common_evt.conn_handle=2 every time. However it is OK on conn_handle=1 for the same APP. If I set periph_role_count=2, it means it is impossible to conn_handle = 2 (range is [0,1] for 2 connections). Such problem does not exist. I suspect some bug for conn_handle=2 for multiple peripheral connections.

Please help check it. Thanks.

  • FormerMember
    0 FormerMember

    The reason that there only will a be MTU request/exchange for the two first links (0x00 and 0x01) is because of the default values used by the nrf_ble_gatt module.

    nrf_ble_gatt_on_ble_evt(..) in nrf_ble_gatt.c looks like the following:

    void nrf_ble_gatt_on_ble_evt(nrf_ble_gatt_t * p_gatt, ble_evt_t const * p_ble_evt)
    {
        uint16_t conn_handle = p_ble_evt->evt.common_evt.conn_handle;
    
        if (conn_handle >= NRF_BLE_GATT_LINK_COUNT)
        {
            return;
        }
    ...
    

    The nrf_ble_gatt module will only do an action if conn_handle < NRF_BLE_GATT_LINK_COUNT. The root cause of the problem is how NRF_BLE_GATT_LINK_COUNT is set in nrf_ble_gatt.h:

    #define NRF_BLE_GATT_LINK_COUNT (NRF_BLE_PERIPHERAL_LINK_COUNT + NRF_BLE_CENTRAL_LINK_COUNT)
    

    Since both NRF_BLE_PERIPHERAL_LINK_COUNT and NRF_BLE_CENTRAL_LINK_COUNT by default only are defined in nrf_ble_gatt.h, their value is not related to the actual project settings, but instead the default value of '1'. Therefore, NRF_BLE_GATT_LINK_COUNT is by default '2', and there the module will only do MTU request/exchange for the two first links. Changing the value of NRF_BLE_PERIPHERAL_LINK_COUNT and NRF_BLE_CENTRAL_LINK_COUNT to the correct values will solve the problem.

    When "re-defining" NRF_BLE_PERIPHERAL_LINK_COUNT and NRF_BLE_CENTRAL_LINK_COUNT, I would recommend to do so in sdk_config.h.

Related