How the Pairing is happening using the bt_conn_auth_cb callback and what we need to set in prj.conf?

Hi,

1. we are referring the example code for the BLE how the pairing is happening and where this (passkey_display ,cancel ,pairing_complete ,pairing_failed ) callbacks are called?

static struct bt_conn_auth_cb conn_auth_callbacks = {
.passkey_display = auth_passkey_display,
.cancel = auth_cancel,
.pairing_complete = pairing_complete,
.pairing_failed = pairing_failed

}
2. When we are trying the example code we are directly able to connect to the device it is not asking for the passkey even for the first time . If we are going for the pairing then it showing the passkey on the display and it is getting paired . but my question is after authenticate the passkey then only the connection should happen , is my logic is correct? 
  • Hi,

    1. we are referring the example code for the BLE how the pairing is happening and where this (passkey_display ,cancel ,pairing_complete ,pairing_failed ) callbacks are called?

    The callbacks are called by the BLE stack when appropriate. For instance, if pairing with MITM and the Bluetooth stack is configured so that the device has output capabilities, passkey_display is called when the passkey should be displayed. cancel is called if the pairing was cancelled, pairing_complete when paring has been successfully completed, and so on. This is similar to other Bluetooth events, like connected, disconnected, etc.

    2. When we are trying the example code we are directly able to connect to the device it is not asking for the passkey even for the first time . If we are going for the pairing then it showing the passkey on the display and it is getting paired . but my question is after authenticate the passkey then only the connection should happen , is my logic is correct? 

    There is not requirement to pair immediately even if pairing is supported. Every characteristic has a security level associated with it, and if you only try to access open characteristics, then that works without pairing. Pairing is only needed to access characteristics that require it. (For instance, iOS will normally not pair before it is needed, because it is denied access to a characteristic).

Related