avrcp.c (4b1ac81384ed9d633f7fb7fe85445e864cc542f6) | avrcp.c (34b22aac0913b061ca6c0da686fd034f9e188df1) |
---|---|
1/* 2 * Copyright (C) 2016 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 --- 692 unchanged lines hidden (view full) --- 701 if (!sdp_query_context.role_supported || !sdp_query_context.avrcp_l2cap_psm){ 702 sdp_query_context.connection->state = AVCTP_CONNECTION_IDLE; 703 avrcp_emit_connection_established(sdp_query_context.avrcp_context->avrcp_callback, sdp_query_context.connection->avrcp_cid, sdp_query_context.connection->remote_addr, SDP_SERVICE_NOT_FOUND); 704 break; 705 } 706 log_info("AVRCP Control PSM 0x%02x, Browsing PSM 0x%02x", sdp_query_context.avrcp_l2cap_psm, sdp_query_context.avrcp_browsing_l2cap_psm); 707 708 sdp_query_context.connection->state = AVCTP_CONNECTION_W4_L2CAP_CONNECTED; | 1/* 2 * Copyright (C) 2016 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 --- 692 unchanged lines hidden (view full) --- 701 if (!sdp_query_context.role_supported || !sdp_query_context.avrcp_l2cap_psm){ 702 sdp_query_context.connection->state = AVCTP_CONNECTION_IDLE; 703 avrcp_emit_connection_established(sdp_query_context.avrcp_context->avrcp_callback, sdp_query_context.connection->avrcp_cid, sdp_query_context.connection->remote_addr, SDP_SERVICE_NOT_FOUND); 704 break; 705 } 706 log_info("AVRCP Control PSM 0x%02x, Browsing PSM 0x%02x", sdp_query_context.avrcp_l2cap_psm, sdp_query_context.avrcp_browsing_l2cap_psm); 707 708 sdp_query_context.connection->state = AVCTP_CONNECTION_W4_L2CAP_CONNECTED; |
709 printf("sdp_query_context.packet_handler %p\n",sdp_query_context.avrcp_context->packet_handler); 710 |
|
709 l2cap_create_channel(sdp_query_context.avrcp_context->packet_handler, sdp_query_context.connection->remote_addr, sdp_query_context.avrcp_l2cap_psm, l2cap_max_mtu(), NULL); 710 break; 711 } 712} 713 714static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connection_t * connection, uint8_t *packet, uint16_t size){ 715 uint8_t operands[20]; 716 uint8_t opcode; --- 483 unchanged lines hidden (view full) --- 1200 case L2CAP_DATA_PACKET: 1201 connection = get_avrcp_connection_for_l2cap_signaling_cid(channel, context); 1202 if (!connection) break; 1203 avrcp_handle_l2cap_data_packet_for_signaling_connection(connection, packet, size); 1204 break; 1205 1206 case HCI_EVENT_PACKET: 1207 switch (hci_event_packet_get_type(packet)) { | 711 l2cap_create_channel(sdp_query_context.avrcp_context->packet_handler, sdp_query_context.connection->remote_addr, sdp_query_context.avrcp_l2cap_psm, l2cap_max_mtu(), NULL); 712 break; 713 } 714} 715 716static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connection_t * connection, uint8_t *packet, uint16_t size){ 717 uint8_t operands[20]; 718 uint8_t opcode; --- 483 unchanged lines hidden (view full) --- 1202 case L2CAP_DATA_PACKET: 1203 connection = get_avrcp_connection_for_l2cap_signaling_cid(channel, context); 1204 if (!connection) break; 1205 avrcp_handle_l2cap_data_packet_for_signaling_connection(connection, packet, size); 1206 break; 1207 1208 case HCI_EVENT_PACKET: 1209 switch (hci_event_packet_get_type(packet)) { |
1210 case HCI_EVENT_DISCONNECTION_COMPLETE: 1211 // connection closed -> quit test app 1212 // status = hci_event_disconnection_complete_get_status(packet); 1213 avrcp_emit_connection_closed(avrcp_callback, 0); 1214 break; |
|
1208 case L2CAP_EVENT_INCOMING_CONNECTION: 1209 l2cap_event_incoming_connection_get_address(packet, event_addr); 1210 local_cid = l2cap_event_incoming_connection_get_local_cid(packet); 1211 connection = avrcp_create_connection(event_addr, context); 1212 if (!connection) { 1213 log_error("Failed to alloc connection structure"); 1214 l2cap_decline_connection(local_cid); 1215 break; --- 47 unchanged lines hidden (view full) --- 1263 avrcp_handle_can_send_now(connection); 1264 break; 1265 1266 case L2CAP_EVENT_CHANNEL_CLOSED: 1267 // data: event (8), len(8), channel (16) 1268 local_cid = l2cap_event_channel_closed_get_local_cid(packet); 1269 connection = get_avrcp_connection_for_l2cap_signaling_cid(local_cid, context); 1270 if (connection){ | 1215 case L2CAP_EVENT_INCOMING_CONNECTION: 1216 l2cap_event_incoming_connection_get_address(packet, event_addr); 1217 local_cid = l2cap_event_incoming_connection_get_local_cid(packet); 1218 connection = avrcp_create_connection(event_addr, context); 1219 if (!connection) { 1220 log_error("Failed to alloc connection structure"); 1221 l2cap_decline_connection(local_cid); 1222 break; --- 47 unchanged lines hidden (view full) --- 1270 avrcp_handle_can_send_now(connection); 1271 break; 1272 1273 case L2CAP_EVENT_CHANNEL_CLOSED: 1274 // data: event (8), len(8), channel (16) 1275 local_cid = l2cap_event_channel_closed_get_local_cid(packet); 1276 connection = get_avrcp_connection_for_l2cap_signaling_cid(local_cid, context); 1277 if (connection){ |
1271 avrcp_emit_connection_closed(avrcp_callback, connection->avrcp_cid); | 1278 avrcp_emit_connection_closed(avrcp_callback, local_cid); |
1272 // free connection 1273 btstack_linked_list_remove(&context->connections, (btstack_linked_item_t*) connection); 1274 btstack_memory_avrcp_connection_free(connection); 1275 break; 1276 } 1277 break; 1278 default: 1279 break; --- 373 unchanged lines hidden --- | 1279 // free connection 1280 btstack_linked_list_remove(&context->connections, (btstack_linked_item_t*) connection); 1281 btstack_memory_avrcp_connection_free(connection); 1282 break; 1283 } 1284 break; 1285 default: 1286 break; --- 373 unchanged lines hidden --- |