mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-17 20:42:47 +00:00
emit disconnect events on hci power off
This commit is contained in:
parent
19f8f3d6f8
commit
8837e9ef66
16
src/hci.c
16
src/hci.c
@ -2327,15 +2327,19 @@ void hci_run(void){
|
|||||||
// close all open connections
|
// close all open connections
|
||||||
connection = (hci_connection_t *) hci_stack->connections;
|
connection = (hci_connection_t *) hci_stack->connections;
|
||||||
if (connection){
|
if (connection){
|
||||||
|
uint16_t con_handle = (uint16_t) connection->con_handle;
|
||||||
// send disconnect
|
|
||||||
if (!hci_can_send_command_packet_now()) return;
|
if (!hci_can_send_command_packet_now()) return;
|
||||||
|
|
||||||
log_info("HCI_STATE_HALTING, connection %p, handle %u", connection, (uint16_t)connection->con_handle);
|
|
||||||
hci_send_cmd(&hci_disconnect, connection->con_handle, 0x13); // remote closed connection
|
|
||||||
|
|
||||||
// send disconnected event right away - causes higher layer connections to get closed, too.
|
log_info("HCI_STATE_HALTING, connection %p, handle %u", connection, con_handle);
|
||||||
|
|
||||||
|
// cancel all l2cap connections right away instead of waiting for disconnection complete event ...
|
||||||
|
hci_emit_disconnection_complete(con_handle, 0x16); // terminated by local host
|
||||||
|
|
||||||
|
// ... which would be ignored anyway as we shutdown (free) the connection now
|
||||||
hci_shutdown_connection(connection);
|
hci_shutdown_connection(connection);
|
||||||
|
|
||||||
|
// finally, send the disconnect command
|
||||||
|
hci_send_cmd(&hci_disconnect, con_handle, 0x13); // remote closed connection
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log_info("HCI_STATE_HALTING, calling off");
|
log_info("HCI_STATE_HALTING, calling off");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user