BLE_GAP_EVT_DISCONNECTED not triggered

Hi, 

I had a working application for both central and peripheral devices. I did a code refactor of rf application layer on central side (I didn't touch any connection parameters or any other SDK-related settings, just application) and after the refactor, BLE_GAP_EVT_DISCONNECTED is not triggered on central side, even though peripheral disconnects successfully. What are possible reasons for it to stop working? My connection parameters are as follows:

#define GAP_MIN_CONN_INTERVAL                           MSEC_TO_UNITS(30, UNIT_1_25_MS)
#define GAP_MAX_CONN_INTERVAL                           MSEC_TO_UNITS(200, UNIT_1_25_MS)
#define GAP_SLAVE_LATENCY                               3
#define GAP_CONN_SUP_TIMEOUT                            MSEC_TO_UNITS(2000, UNIT_10_MS)

  • Hi Jakub, 

    Could you give more information on how you tested  ? Which peripheral device you tested with ? 
    Have you modified anything in ble_evt_handler() and how you declared it with NRF_SDH_BLE_OBSERVER() ? 
    I assume you still receive BLE_GAP_EVT_CONNECTED and other BLE events ? 

    From which side did you initialize the disconnection ? 

    I would suggest to capture a sniffer trace to see what actually happens during the connect termination. 


  • I've used custom board as a peripheral. The peripheral side wasn't change and I'm sure it works as expected and disconnects because I see this log:

    00> <info> app: RADIO: Disconnected, reason 0x16.

    I did modify ble_evt_handler, my disconnection case looks like this:

        case BLE_GAP_EVT_DISCONNECTED: {
            LOG_INFO("RADIO: (role: central) Disconnected, reason 0x%x.", p_ble_evt->evt.gap_evt.params.disconnected.reason);
            m_radio.conn.central_conn_handle = BLE_CONN_HANDLE_INVALID;
            m_radio.conn.bonded_device = false;
        }
        break;

    Other events such as BLE_GAP_EVT_CONNECTED or BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE work as expected. 

    I initialize the disconnection from peripheral side.

    This is how I declare observer:

    NRF_SDH_BLE_OBSERVER(m_ble_observer, BLE_OBSERVER_PRIO, ble_evt_handler, NULL);

  • Hi Jakub, 

    Have you checked if the central still working normally after the peripheral disconnect ? Is there any chance that it crashed ? 
    Could  you try to capture a sniffer trace ? 

    Can you reproduce the issue on a Devkit so that we can test here ? If you can provide a minimum code that can generate the issue it would be great. 

  • Thanks for the tips, It turned out that the device just crashed and that's why the event wasn't registered, the problem was somewhere else

Related