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

Having problems after initiate disconnect from slave side

Hello

I'm using S110 with nRF51822.

I'm trying to implement some logic which is quite simple, but for some reason things are not working properly.

I'm advertising using the BLE slave device. I initiate a connection from master device to the slave device. On the slave device code - when getting a BLE_GAP_EVT_CONNECTED event, I would like to disconnected right away (I'm using the connection for some kind of "stupid" ack). So sd_ble_gap_disconnect function is called when the event is received. The disconnection works - the problem is I want the slave to start advertising right away after this. For some reason this gives me some problems. The slave will not work properly after this.

Is this logic is somehow problematic? If I want to disconnect from the slave device side - I should use sd_ble_gap_disconnect?

Thanks.

Parents
  • You are correct, you should be able to disconnect from the slave.

    You need to handle the BLE_GAP_EVT_DISCONNECTED event in order for the slave to be able to function after performing the disconnect procedure. The reason is that the softdevice needs to know that it is in a valid state before advertising.

    Try adding this to your BLE event handler:

    static void on_ble_evt(ble_evt_t * p_ble_evt)
    {
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_DISCONNECTED:
            {
                m_conn_handle = BLE_CONN_HANDLE_INVALID;
            }
        }
    }
    
Reply
  • You are correct, you should be able to disconnect from the slave.

    You need to handle the BLE_GAP_EVT_DISCONNECTED event in order for the slave to be able to function after performing the disconnect procedure. The reason is that the softdevice needs to know that it is in a valid state before advertising.

    Try adding this to your BLE event handler:

    static void on_ble_evt(ble_evt_t * p_ble_evt)
    {
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_DISCONNECTED:
            {
                m_conn_handle = BLE_CONN_HANDLE_INVALID;
            }
        }
    }
    
Children
Related