hid_host: in finalize_connection call l2cap_disconnect when needed

This commit is contained in:
Milanka Ringwald 2021-02-09 15:00:54 +01:00 committed by Matthias Ringwald
parent 2ba92e70de
commit 7379ca3deb
2 changed files with 13 additions and 1 deletions

View File

@ -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);
}

View File

@ -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,