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

In Multi-Link Central Example, Where can I check the disconnect code?

Hello, all.

I'm using nRF52833, pca10100.

What I'm trying to do is just manually disconnect.

So, I referred to the Multi-link Central example. Multi-link Central is that pressing BUTTON1 on the central, all connected peripherals are disconnected. And I would like to refer this part.

In which part of the example, in which file can this be found?

BR,

lyrics

Parents
  • Hi,

    You disconnect by calling sd_ble_gap_disconnect(). This takes two parameters, the connection handle and the disconnect reason. The method here is example the same regardless of if the role is central or peripheral.

    You can see an example of this in for instance the ble_app_gatts example, which has this code snippet to trigger disconnect by a button press on the DK:

            case BSP_EVENT_DISCONNECT:
                err_code = sd_ble_gap_disconnect(m_conn_handle,
                                                 BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
                if (err_code != NRF_ERROR_INVALID_STATE)
                {
                    APP_ERROR_CHECK(err_code);
                }
                break;

  • Hi,

    which has this code snippet to trigger disconnect by a button press on the DK:

    As you explain, in the example of ble_app_gatts, I understood that pressing the button trigger 'BSP_EVENT_DISCONNECT' case.

    However, the multi-link central example also sets the BSP_EVENT_DISCONNECT setting in bsp_btn_ble.c, but I can't find where that BSP_EVENT_DISCONNECT case is.

    (this is BSP_EVENT_DISCONNECT setting code that I found.)

    static uint32_t connection_buttons_configure()
    {
        uint32_t err_code;
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_SLEEP,
                                                     BTN_ACTION_SLEEP,
                                                     BSP_EVENT_DEFAULT);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_WHITELIST_OFF,
                                                     BTN_ACTION_WHITELIST_OFF,
                                                     BSP_EVENT_WHITELIST_OFF);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_DISCONNECT,
                                                     BTN_ACTION_DISCONNECT,
                                                     BSP_EVENT_DISCONNECT);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
        return NRF_SUCCESS;
    }

    In other words, I don't understand about is how DISCONNECT interrupt is called in multi-link central sample and I cannot find where code can be checked.

    BR,

    lyrics

  • Hi Lyrics,

    The Multilink central does not use BSP for buttons (only LEDs), so you there is no way to use the BSP_EVENT_DISCONNECT event to trigger disconnect without more changes to the example. I kept that to provide context. The only thing you need to disconnect is to call sd_ble_gap_disconnect() for each connection handle you want to disconnect from.

    If you want to do this with a button press and with minimal changes to the multilink central example you could for instance configure an additional button in buttons_init, adding a second line in the buttons array. That could still use the same button_event_handler, and then you add a case for the new button in that handler. In that handling, call sd_ble_gap_disconnect() for each active connection.

Reply
  • Hi Lyrics,

    The Multilink central does not use BSP for buttons (only LEDs), so you there is no way to use the BSP_EVENT_DISCONNECT event to trigger disconnect without more changes to the example. I kept that to provide context. The only thing you need to disconnect is to call sd_ble_gap_disconnect() for each connection handle you want to disconnect from.

    If you want to do this with a button press and with minimal changes to the multilink central example you could for instance configure an additional button in buttons_init, adding a second line in the buttons array. That could still use the same button_event_handler, and then you add a case for the new button in that handler. In that handling, call sd_ble_gap_disconnect() for each active connection.

Children
Related