2024-07-25 12:47 AM
Hello @STTwo-32 @Remi QUINTIN ,
I have a question regarding the BLE pairing process. After following the tutorial from ST on BLE security regarding pairing and bonding, the passkey authentication is happening only when the user requests to read a characteristic value.
But in our case, we would like to have the pairing with passkey whenever the user wants to connect to the device. I have seen the example of the BLE _HID in the STM32CubeWB SDK, but i could not find the any relevant APIs that are calling the pairing request function during the connection. There is also no .ioc file for this project. Could you please provide information regarding this example?
From the pm0271 document, we can initiate a pairing procedure using the "aci_gap_peripheral_security_req()" on the peripheral device. What is the correct procedure to call this function for the pairing to happen with passkey when the user tries to connect to the device? is this the correct function to call?
Because from HeartRate example, the peripheral is sending a command "aci_gap_slave_security_req()" for the pairing process to happen?
What is the proper call to this happen? i mean can we call this api in the HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE after the connection complete is done as shown below
case HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE:
{
p_connection_complete_event = (hci_le_connection_complete_event_rp0 *) p_meta_evt->data;
/**
* The connection is done, there is no need anymore to schedule the LP ADV
*/
APP_DBG_MSG(">>== HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE - Connection handle: 0x%x\n", p_connection_complete_event->Connection_Handle);
APP_DBG_MSG(" - Connection established with Central: @:%02x:%02x:%02x:%02x:%02x:%02x\n",
p_connection_complete_event->Peer_Address[5],
p_connection_complete_event->Peer_Address[4],
p_connection_complete_event->Peer_Address[3],
p_connection_complete_event->Peer_Address[2],
p_connection_complete_event->Peer_Address[1],
p_connection_complete_event->Peer_Address[0]);
APP_DBG_MSG(" - Connection Interval: %.2f ms\n - Connection latency: %d\n - Supervision Timeout: %d ms\n\r",
p_connection_complete_event->Conn_Interval*1.25,
p_connection_complete_event->Conn_Latency,
p_connection_complete_event->Supervision_Timeout*10
);
if (BleApplicationContext.Device_Connection_Status == APP_BLE_LP_CONNECTING)
{
/* Connection as client */
BleApplicationContext.Device_Connection_Status = APP_BLE_CONNECTED_CLIENT;
}
else
{
/* Connection as server */
BleApplicationContext.Device_Connection_Status = APP_BLE_CONNECTED_SERVER;
}
BleApplicationContext.BleApplicationContext_legacy.connectionHandle = p_connection_complete_event->Connection_Handle;
/**
* SPECIFIC to Custom Template APP
*/
HandleNotification.Custom_Evt_Opcode = CUSTOM_CONN_HANDLE_EVT;
HandleNotification.ConnectionHandle = BleApplicationContext.BleApplicationContext_legacy.connectionHandle;
Custom_APP_Notification(&HandleNotification);
/* USER CODE BEGIN HCI_EVT_LE_CONN_COMPLETE */
tBleStatus ret = BLE_STATUS_INVALID_PARAMS;
ret = aci_gap_slave_security_req(BleApplicationContext.BleApplicationContext_legacy.connectionHandle);
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG("==>> aci_gap_slave_security_req() Fail , result: %d \n", ret);
}
else
{
APP_DBG_MSG("===>> aci_gap_slave_security_req - Success\n");
}
/* USER CODE END HCI_EVT_LE_CONN_COMPLETE */
break; /* HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE */
Looking forward to your answer
Thanks
Poorna
Solved! Go to Solution.
2024-09-13 09:58 AM
Hello @teja_111
If you want to Use a Pin for connection, you can use the CFG_USED_FIXED_PIN to Enable/Disable pin option and select the CFG_FIXED_PIN you want on CubeMX config:
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-09-13 09:58 AM
Hello @teja_111
If you want to Use a Pin for connection, you can use the CFG_USED_FIXED_PIN to Enable/Disable pin option and select the CFG_FIXED_PIN you want on CubeMX config:
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.