From 7379ca3deb9401fc5de5bd03acbe874d7841a78e Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Tue, 9 Feb 2021 15:00:54 +0100 Subject: [PATCH] hid_host: in finalize_connection call l2cap_disconnect when needed --- src/classic/hid_host.c | 12 ++++++++++++ src/classic/hid_host.h | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/classic/hid_host.c b/src/classic/hid_host.c index a4c75b8f9..e53bd10fb 100644 --- a/src/classic/hid_host.c +++ b/src/classic/hid_host.c @@ -335,6 +335,18 @@ static hid_host_connection_t * hid_host_get_connection_for_bd_addr(bd_addr_t add static void hid_host_finalize_connection(hid_host_connection_t * connection){ + uint16_t interrupt_cid = connection->interrupt_cid; + uint16_t control_cid = connection->control_cid; + + connection->interrupt_cid = 0; + connection->control_cid = 0; + + if (interrupt_cid != 0){ + l2cap_disconnect(interrupt_cid, 0); + } + if (control_cid != 0){ + l2cap_disconnect(control_cid, 0); + } btstack_linked_list_remove(&connections, (btstack_linked_item_t*) connection); btstack_memory_hid_host_connection_free(connection); } diff --git a/src/classic/hid_host.h b/src/classic/hid_host.h index 688356c40..57d9454fa 100644 --- a/src/classic/hid_host.h +++ b/src/classic/hid_host.h @@ -141,7 +141,7 @@ void hid_host_register_packet_handler(btstack_packet_handler_t callback); * followed by HID_SUBEVENT_DESCRIPTOR_AVAILABLE that informs if the HID Descriptor was found. In the case of incoming * connection, i.e. HID Device initiating the connection, the HID_SUBEVENT_DESCRIPTOR_AVAILABLE is delayed, and the reports * may already come via HID_SUBEVENT_REPORT event. It is up to the application code if - * these events should be buffered or ignored until the descriptor is available. + * these reports should be buffered or ignored until the descriptor is available. * @note HID_PROTOCOL_MODE_REPORT_WITH_FALLBACK_TO_BOOT will try ti set up REPORT mode, but fallback to BOOT mode if necessary. * @note HID_SUBEVENT_DESCRIPTOR_AVAILABLE possible status values are: * - ERROR_CODE_SUCCESS if descriptor available,