cancel
Showing results for 
Search instead for 
Did you mean: 

[BLE] How can I know upon getting connection event if device was previously bonded?

DS.4
Senior II

I am a the peripheral, and just got a connection event from the client.

Would like to know if server side provides a feature to know if I already bonded with client , or bonding will be needed.

Is there a command I can give e.g., the ConnectionHandle and will tell me if paired (yes no?)

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Alan PORTE
ST Employee

Dear @DS.4 ,
Let me post here my answer that I already shared with you directly through our Online Support platform.

Yes, for such purpose you can use the command ACI_GAP_IS_DEVICE_BONDED.
Here the description coming from application note AN5270:
"Finds whether the device, whose address is specified in the command, is present in the bonding table. If the device is found the command returns BLE_STATUS_SUCCESS."
https://www.st.com/resource/en/application_note/an5270-stm32wb-bluetooth-low-energy-ble-wireless-interface-stmicroelectronics.pdf#page=80

 

Please, notes that you can also get the list of bonded devices with ACI_GAP_GET_BONDED_DEVICES.

Then, 
you can recover the peer address of the peer device when you got your connection event (HCI_LE_CONNECTION_COMPLETE_EVENT) on the peripheral side.
https://www.st.com/resource/en/application_note/an5270-stm32wb-bluetooth-low-energy-ble-wireless-interface-stmicroelectronics.pdf#page=132

This is this Peer_Address you need to provide in ACI_GAP_IS_DEVICE_BONDED in order to get the status if already bonded or not.

Please, find below an example of implementation that I tried on BLE_HearRate example:

tBleStatus result = BLE_STATUS_SUCCESS;
result = aci_gap_is_device_bonded(p_connection_complete_event->Peer_Address_Type,p_connection_complete_event->Peer_Address);
if (result == BLE_STATUS_SUCCESS)
{
    APP_DBG_MSG("Address bonded\n\r");
}
else
{
    APP_DBG_MSG("Address not bonded\n\r");
}

Pairing is already supported by BLE_HeartRate example on Nucleo-WB55RG (SW1 clears the security database, SW2 requests the slave req pairing).
https://github.com/STMicroelectronics/STM32CubeWB/tree/master/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_HeartRate

Find attached the app_ble.c with the modification. 

Best Regards,
Alan PORTE
ST MCU Support Team

View solution in original post

1 REPLY 1
Alan PORTE
ST Employee

Dear @DS.4 ,
Let me post here my answer that I already shared with you directly through our Online Support platform.

Yes, for such purpose you can use the command ACI_GAP_IS_DEVICE_BONDED.
Here the description coming from application note AN5270:
"Finds whether the device, whose address is specified in the command, is present in the bonding table. If the device is found the command returns BLE_STATUS_SUCCESS."
https://www.st.com/resource/en/application_note/an5270-stm32wb-bluetooth-low-energy-ble-wireless-interface-stmicroelectronics.pdf#page=80

 

Please, notes that you can also get the list of bonded devices with ACI_GAP_GET_BONDED_DEVICES.

Then, 
you can recover the peer address of the peer device when you got your connection event (HCI_LE_CONNECTION_COMPLETE_EVENT) on the peripheral side.
https://www.st.com/resource/en/application_note/an5270-stm32wb-bluetooth-low-energy-ble-wireless-interface-stmicroelectronics.pdf#page=132

This is this Peer_Address you need to provide in ACI_GAP_IS_DEVICE_BONDED in order to get the status if already bonded or not.

Please, find below an example of implementation that I tried on BLE_HearRate example:

tBleStatus result = BLE_STATUS_SUCCESS;
result = aci_gap_is_device_bonded(p_connection_complete_event->Peer_Address_Type,p_connection_complete_event->Peer_Address);
if (result == BLE_STATUS_SUCCESS)
{
    APP_DBG_MSG("Address bonded\n\r");
}
else
{
    APP_DBG_MSG("Address not bonded\n\r");
}

Pairing is already supported by BLE_HeartRate example on Nucleo-WB55RG (SW1 clears the security database, SW2 requests the slave req pairing).
https://github.com/STMicroelectronics/STM32CubeWB/tree/master/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_HeartRate

Find attached the app_ble.c with the modification. 

Best Regards,
Alan PORTE
ST MCU Support Team