SD GATT procedure failed on Central device.

Hi All,

         I am using NRF52840 in my project and working on SDK 17.0.2. I have one central device and 2 Peripherals. The peripherals are connected to the central properly after power ON. Now let's say I Power OFF the central device for sometime. The peripherals are still kept ON and they keep advertising continuously. Let's say after after sometime I powered ON the central device, it should be able to connect to both the peripherals. What I am observing is sometimes it goes for connection but it gets "SD GATT procedure failed on Central device." and disconnects from that peripheral. The log I observed on central device is as follows:-

00> <error> nrf_ble_gq: SD GATT procedure (2) failed on connection handle 1 with error: 0x0000000D.
00>
00> <info> app: BLE_GATTC_EVT_TIMEOUT
00>
00> <info> app: CENTRAL: Disconnected, handle: 1, reason: 0x16

Also when a peripheral is disconnected it gets hanged and I have to reboot it to connect again.

Is this central device firmware issue or the peripheral device firmware issue? How to solve this issue?

Thanks & Regards,

Snehal Bundele.

  • Hi Susheel,

                Unfortunately I won't be able to capture sniffer logs for some reason. I also feel that there is some issue with function "nrf_ble_scan_connect_with_target".

    static void nrf_ble_scan_connect_with_target(nrf_ble_scan_t           const * const p_scan_ctx,
                                                 ble_gap_evt_adv_report_t const * const p_adv_report)
    {
        ret_code_t err_code;
        scan_evt_t scan_evt;
    
        // For readability.
        ble_gap_addr_t const        * p_addr        = &p_adv_report->peer_addr;
        ble_gap_scan_params_t const * p_scan_params = &p_scan_ctx->scan_params;
        ble_gap_conn_params_t const * p_conn_params = &p_scan_ctx->conn_params;
        uint8_t                       con_cfg_tag   = p_scan_ctx->conn_cfg_tag;
    
        // Return if the automatic connection is disabled.
        if (!p_scan_ctx->connect_if_match)
        {
            return;
        }
    
        // Stop scanning.
        nrf_ble_scan_stop(); 
    
        memset(&scan_evt, 0, sizeof(scan_evt));
    
        // Establish connection.
        err_code = sd_ble_gap_connect(p_addr,
                                      p_scan_params,
                                      p_conn_params,
                                      con_cfg_tag);
    
        NRF_LOG_INFO("Connecting");
    
        scan_evt.scan_evt_id                    = NRF_BLE_SCAN_EVT_CONNECTING_ERROR;
        scan_evt.params.connecting_err.err_code = err_code;
    
        NRF_LOG_INFO("Connection status: %d", err_code);
    
        // If an error occurred, send an event to the event handler.
        if ((err_code != NRF_SUCCESS) && (p_scan_ctx->evt_handler != NULL))
        {
            p_scan_ctx->evt_handler(&scan_evt);
        }
    
    }
    

    Here in this function nrf_ble_scan_stop() is called. My doubt is when peripheral-1 is detected, the central goes into this function and nrf_ble_scan_stop() is called and it connects to peripheral-1. Now as nrf_ble_scan_stop is called the central device does not look for the peripheral-2 and does not connect to it. Am I right?

    Thanks & Regards,

    Snehal

  • Hi , Can you please reply? Is there any way to implement reconnect mechanism?

  • It would help with sniffer logs but the error you see the same thing as mentioned here. Check the solution mentioned there if that helps.

Related