How to manually disconnect a certain peripheral from a central on SDK 16?

Hi everyone, i am developing a system where i have 2 types of board, one board is a central&peripheral (lest name it BOARD1), and the other board is only a peripheral(lets name it BOARD2).

I connect to the BOARD1 peripheral with nrF Connect and send commands over NUS Service, then BOARD1 Scan for a BOARD2, and if it matches the filter it connect with the command:

err_code = sd_ble_gap_connect(&p_adv->peer_addr,
                                          p_scan_param,
                                          &m_scan.conn_params,
                                          APP_BLE_CONN_CFG_TAG);

Just like the ble_app_hrs_rscs_relay example. So i have this flux : APP <-> (PHE,BOARD1,CENT) <->(PHE,BOARD2)

But i dont know what command use to disconnect that specific peripheral from the central side on SDK16. I understand the disconnection from the peripheral side, basically when the peripheral connect to a peer the BLE_GAP_EVT_CONNECTED occur and you assign a m_conn_handle to your QWR instance with "nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle);", and then you disconnect using "sd_ble_gap_disconnect(m_conn_handle,BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);".  But i dont get how to do it from the central side, when i connect the BOARD1 to the BOARD2 while i am connected from the nrF connect APP to the BOARD1, how i distinguish a Central connection from a Peripheral connection? Or assign a m_conn_handle to the Central connection?

My idea is have multiple BOARD2, and sometimes i will want to disconnect from a BOARD2 to connect to another one, but i dont get how to do it on SDK16, i need a extra handler?


Parents Reply Children
  • I may be missing something, but why do you refer to the QWR module in relation to how to terminate a connection? The QWR module has its uses, but disconnecting the connection is a GAP operation that is not related to QWR in any way. (Also, the queued write module subscribes to BLE events so when you disconnect as I explained in my previous post, it will also get the BLE_GAP_EVT_DISCONNECTED and change the internal state accordingly).

    Regarding using QWR for multiple connections you need multiple instances, yes. You can for instance see how that is done in examples\ble_central_and_peripheral\experimental\ble_app_hrs_rscs_relay\main.c where an array of instances is declared using NRF_BLE_QWRS_DEF().

  • Oh i was thinking that the function "nrf_ble_qwr_conn_handle_assign(&m_central_qwr, m_conn_handle);" call in the example after a connection was a necessary step for validate or something the connection. Anyways it works creating a new conn_handle for the central and disconnect that one with disconnect call. So i think the extra step of the QWR module instance for the central was not necessary.

Related