How to Actively Disconnect Bluetooth Connection of Mobile Phone?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-10-14 11:29 PM
When STM32WB is used as slave device, how to actively disconnect Bluetooth connection of mobile phone?
Solved! Go to Solution.
- Labels:
-
BLE
-
STM32WB series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-10-15 1:16 AM
Not sure I understand what you mean by "actively disconnect" : Either you expect the android application to disconnect automatically the connection each time it is not needed anymore=> This is an decision to be made by the android application (apk) for which the STM32WB has no influence.
Or you expect the STM32WB to inform the mobile that it will stop the connection. In this case you can use the HCI_DISCONNECT command or an higher level command ACI_GAP_TERMINATE that requests the controller to terminate the connection. Then the STM32WB application will wait for the EVT_DISCONN_COMPLETE GAP event.
Please have a look at AN5270 that describe both commands.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-10-15 1:16 AM
Not sure I understand what you mean by "actively disconnect" : Either you expect the android application to disconnect automatically the connection each time it is not needed anymore=> This is an decision to be made by the android application (apk) for which the STM32WB has no influence.
Or you expect the STM32WB to inform the mobile that it will stop the connection. In this case you can use the HCI_DISCONNECT command or an higher level command ACI_GAP_TERMINATE that requests the controller to terminate the connection. Then the STM32WB application will wait for the EVT_DISCONN_COMPLETE GAP event.
Please have a look at AN5270 that describe both commands.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-10-16 8:02 PM
Thank you. ACI_GAP_TERMINATE command is what I need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-10-16 8:20 PM
These command codes are all in the file ble_hci_le.c. I just need to call it. so easy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-04-22 8:14 PM
Hi Remi I was wondering what the best way to determine the connection handle for a BLE connection is as the ACI_GAP_TERMINATE function requires a Connection handle as its first parameter. Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-04-23 1:36 PM
Yes the first parameter is a connection handle.
Please have a look at AN5270 that describes all functions and their parameters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-04-25 3:49 PM
Hi Remi, apologies, please let me clarify. I am aware that the first parameter ACI_GAP_TERMINATE is the connection handle however I am not sure how best to access the value of the connection handle once I have made a connection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-04-26 1:28 AM
The ACI_HAL_GET_LINK_STATUS command returns the status of the maximum eight Bluetooth Low Energy links possibly managed by the device, returning a array of the 8 connection handles
But the connection_handle is returned once the connection is established in the connection_complete_event with the structure:
typedef PACKED(struct)
{
uint8_t Status;
uint16_t Connection_Handle;
uint8_t Role;
uint8_t Peer_Address_Type;
uint8_t Peer_Address[6];
uint16_t Conn_Interval;
uint16_t Conn_Latency;
uint16_t Supervision_Timeout;
uint8_t Master_Clock_Accuracy;
} hci_le_connection_complete_event_rp0;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-04-26 7:10 PM
Thank you for your response Remi, I was able to terminate the connection by extracting the Connection Handle via the EVT_LE_CONN_COMPLETE case in the function SVCCTL_App_Notification in appl_ble.c.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-08-20 3:40 AM
Hi @Community member
can you elaborate more on this topic. I also want to implement the same way.
I want to connect and disconnect BLE server controlled by switch on BLE client.
