hid_host.c (2fca4dad957cd7b88f4657ed51e89c12615dda72) hid_host.c (b93f89661ecd1d19be40311be96b92932960a800)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 354 unchanged lines hidden (view full) ---

363static void hid_host_finalize_connection(hid_host_connection_t * connection){
364 uint16_t interrupt_cid = connection->interrupt_cid;
365 uint16_t control_cid = connection->control_cid;
366
367 connection->interrupt_cid = 0;
368 connection->control_cid = 0;
369
370 if (interrupt_cid != 0){
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 354 unchanged lines hidden (view full) ---

363static void hid_host_finalize_connection(hid_host_connection_t * connection){
364 uint16_t interrupt_cid = connection->interrupt_cid;
365 uint16_t control_cid = connection->control_cid;
366
367 connection->interrupt_cid = 0;
368 connection->control_cid = 0;
369
370 if (interrupt_cid != 0){
371 l2cap_disconnect(interrupt_cid, 0);
371 l2cap_disconnect(interrupt_cid);
372 }
373 if (control_cid != 0){
372 }
373 if (control_cid != 0){
374 l2cap_disconnect(control_cid, 0);
374 l2cap_disconnect(control_cid);
375 }
376 btstack_linked_list_remove(&hid_host_connections, (btstack_linked_item_t*) connection);
377 btstack_memory_hid_host_connection_free(connection);
378}
379
380static void hid_host_handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) {
381 UNUSED(packet_type);
382 UNUSED(channel);

--- 516 unchanged lines hidden (view full) ---

899 l2cap_cid = l2cap_event_channel_closed_get_local_cid(packet);
900 connection = hid_host_get_connection_for_l2cap_cid(l2cap_cid);
901 if (!connection) return;
902
903 if (l2cap_cid == connection->interrupt_cid){
904 connection->interrupt_cid = 0;
905 if (connection->state == HID_HOST_W4_INTERRUPT_CONNECTION_DISCONNECTED){
906 connection->state = HID_HOST_W4_CONTROL_CONNECTION_DISCONNECTED;
375 }
376 btstack_linked_list_remove(&hid_host_connections, (btstack_linked_item_t*) connection);
377 btstack_memory_hid_host_connection_free(connection);
378}
379
380static void hid_host_handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) {
381 UNUSED(packet_type);
382 UNUSED(channel);

--- 516 unchanged lines hidden (view full) ---

899 l2cap_cid = l2cap_event_channel_closed_get_local_cid(packet);
900 connection = hid_host_get_connection_for_l2cap_cid(l2cap_cid);
901 if (!connection) return;
902
903 if (l2cap_cid == connection->interrupt_cid){
904 connection->interrupt_cid = 0;
905 if (connection->state == HID_HOST_W4_INTERRUPT_CONNECTION_DISCONNECTED){
906 connection->state = HID_HOST_W4_CONTROL_CONNECTION_DISCONNECTED;
907 l2cap_disconnect(connection->control_cid, 0);
907 l2cap_disconnect(connection->control_cid);
908 }
909 break;
910 }
911
912 if (l2cap_cid == connection->control_cid){
913 connection->control_cid = 0;
914 hid_emit_event(connection, HID_SUBEVENT_CONNECTION_CLOSED);
915 hid_descriptor_storage_delete(connection);

--- 237 unchanged lines hidden (view full) ---

1153 case HID_HOST_W4_INTERRUPT_CONNECTION_DISCONNECTED:
1154 return;
1155 default:
1156 break;
1157 }
1158
1159 if (connection->interrupt_cid){
1160 connection->state = HID_HOST_W4_INTERRUPT_CONNECTION_DISCONNECTED;
908 }
909 break;
910 }
911
912 if (l2cap_cid == connection->control_cid){
913 connection->control_cid = 0;
914 hid_emit_event(connection, HID_SUBEVENT_CONNECTION_CLOSED);
915 hid_descriptor_storage_delete(connection);

--- 237 unchanged lines hidden (view full) ---

1153 case HID_HOST_W4_INTERRUPT_CONNECTION_DISCONNECTED:
1154 return;
1155 default:
1156 break;
1157 }
1158
1159 if (connection->interrupt_cid){
1160 connection->state = HID_HOST_W4_INTERRUPT_CONNECTION_DISCONNECTED;
1161 l2cap_disconnect(connection->interrupt_cid, 0); // reason isn't used
1161 l2cap_disconnect(connection->interrupt_cid);
1162 return;
1163 }
1164
1165 if (connection->control_cid){
1166 connection->state = HID_HOST_W4_CONTROL_CONNECTION_DISCONNECTED;
1162 return;
1163 }
1164
1165 if (connection->control_cid){
1166 connection->state = HID_HOST_W4_CONTROL_CONNECTION_DISCONNECTED;
1167 l2cap_disconnect(connection->control_cid, 0); // reason isn't used
1167 l2cap_disconnect(connection->control_cid);
1168 return;
1169 }
1170}
1171
1172
1173static inline uint8_t hid_host_send_control_message(uint16_t hid_cid, uint8_t control_message_bitmask){
1174 hid_host_connection_t * connection = hid_host_get_connection_for_hid_cid(hid_cid);
1175 if (!connection || !connection->control_cid) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;

--- 125 unchanged lines hidden ---
1168 return;
1169 }
1170}
1171
1172
1173static inline uint8_t hid_host_send_control_message(uint16_t hid_cid, uint8_t control_message_bitmask){
1174 hid_host_connection_t * connection = hid_host_get_connection_for_hid_cid(hid_cid);
1175 if (!connection || !connection->control_cid) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;

--- 125 unchanged lines hidden ---