This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

About the value of "ble_gap_evt_t::conn_handle

SDK: 15.3.0
SoftDevice: S132
Device: EYSHJNZWZ (nRF52832)

Please tell me about the value of "ble_gap_evt_t::conn_handle".

I use central and peripheral.
I have the following settings in "sdk_config.h".

#define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 1
#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 2
#define NRF_SDH_BLE_TOTAL_LINK_COUNT ( NRF_SDH_BLE_PERIPHERAL_LINK_COUNT + NRF_SDH_BLE_CENTRAL_LINK_COUNT )

[Step 1].
    I connected to my device from my central smartphone.
    At that time, I got "conn_handle == 2".
    I did not connect anything except my smartphone.

[Step 2]
    I connected from my device to another device that is a peripheral.
    At that time, I got "conn_handle == 0".

[Step 3]
    I connected from my device to another device that is a peripheral.
    At that time, I got "conn_handle == 1".


1) I thought that the devices were assigned in the order in which they were connected, starting from "0".
    Is my understanding wrong?

2) In the case of [Step 1], I want the connection to be made with "conn_handle == 0".
    Is that possible?

3) Is it possible to assign different numbers for central and peripheral?
    [Step 1] "conn_handle == 0" (central)
    [Step 2]"conn_handle == 0" (peripheral)
    [Step 3]"conn_handle == 1" (Peripheral)

  • Hi 

    The way the SoftDevice assign these numbers is by reserving the lowest indexes for central connections, and the higher numbers for peripheral connections. 

    In other words, when you have NRF_SDH_BLE_CENTRAL_LINK_COUNT set to 2 the connection handles of 0 and 1 will be reserved for central connections, and 2 and up will be used for peripheral connections. 

    There is no way to change this, it is hard coded in the SoftDevice. If you want to assign some other number to your connections you need to establish a map in memory where you map the conn_handle values to your preferred number. 

    Best regards
    Torbjørn

Related