avrcp_target.c (9192020a6656c4bc46feb4a63ee628096661bb3b) | avrcp_target.c (182c9f077ee1071cbc50a5a96d212e07f6d2fdc7) |
---|---|
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 --- 1066 unchanged lines hidden (view full) --- 1075 switch (hci_event_packet_get_type(packet)){ 1076 case L2CAP_EVENT_CAN_SEND_NOW:{ 1077 connection = avrcp_get_connection_for_l2cap_signaling_cid_for_role(AVRCP_TARGET, channel); 1078 1079 if (connection->accept_response){ 1080 connection->accept_response = 0; 1081 avrcp_target_send_response(connection->l2cap_signaling_cid, connection); 1082 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); | 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 --- 1066 unchanged lines hidden (view full) --- 1075 switch (hci_event_packet_get_type(packet)){ 1076 case L2CAP_EVENT_CAN_SEND_NOW:{ 1077 connection = avrcp_get_connection_for_l2cap_signaling_cid_for_role(AVRCP_TARGET, channel); 1078 1079 if (connection->accept_response){ 1080 connection->accept_response = 0; 1081 avrcp_target_send_response(connection->l2cap_signaling_cid, connection); 1082 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); |
1083 break; | 1083 return; |
1084 } 1085 | 1084 } 1085 |
1086 else if (connection->abort_continue_response){ | 1086 if (connection->abort_continue_response){ |
1087 connection->abort_continue_response = 0; 1088 connection->now_playing_info_response = 0; 1089 avrcp_target_abort_continue_response(connection->l2cap_signaling_cid, connection); | 1087 connection->abort_continue_response = 0; 1088 connection->now_playing_info_response = 0; 1089 avrcp_target_abort_continue_response(connection->l2cap_signaling_cid, connection); |
1090 break; | 1090 return; |
1091 } 1092 | 1091 } 1092 |
1093 else if (connection->now_playing_info_response){ | 1093 if (connection->now_playing_info_response){ |
1094 connection->now_playing_info_response = 0; 1095 avrcp_target_send_now_playing_info(connection->l2cap_signaling_cid, connection); | 1094 connection->now_playing_info_response = 0; 1095 avrcp_target_send_now_playing_info(connection->l2cap_signaling_cid, connection); |
1096 break; | 1096 return; |
1097 } 1098 | 1097 } 1098 |
1099 else if (connection->track_changed){ | 1099 if (connection->track_changed){ |
1100 connection->track_changed = 0; 1101 avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_TRACK_CHANGED, connection->track_id, 8); 1102 avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_TRACK_CHANGED); 1103 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); | 1100 connection->track_changed = 0; 1101 avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_TRACK_CHANGED, connection->track_id, 8); 1102 avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_TRACK_CHANGED); 1103 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); |
1104 break; | 1104 return; |
1105 } 1106 | 1105 } 1106 |
1107 else if (connection->playback_status_changed){ | 1107 if (connection->playback_status_changed){ |
1108 connection->playback_status_changed = 0; 1109 uint8_t playback_status = (uint8_t) connection->playback_status; 1110 avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED, &playback_status, 1); 1111 avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED); 1112 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); | 1108 connection->playback_status_changed = 0; 1109 uint8_t playback_status = (uint8_t) connection->playback_status; 1110 avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED, &playback_status, 1); 1111 avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED); 1112 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); |
1113 break; | 1113 return; |
1114 } 1115 | 1114 } 1115 |
1116 else if (connection->playing_content_changed){ | 1116 if (connection->playing_content_changed){ |
1117 connection->playing_content_changed = 0; 1118 avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED, NULL, 0); 1119 avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED); 1120 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); | 1117 connection->playing_content_changed = 0; 1118 avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED, NULL, 0); 1119 avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED); 1120 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); |
1121 break; | 1121 return; |
1122 } 1123 | 1122 } 1123 |
1124 else if (connection->battery_status_changed){ | 1124 if (connection->battery_status_changed){ |
1125 connection->battery_status_changed = 0; 1126 avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_BATT_STATUS_CHANGED, (uint8_t *)&connection->battery_status, 1); 1127 avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_BATT_STATUS_CHANGED); 1128 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); | 1125 connection->battery_status_changed = 0; 1126 avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_BATT_STATUS_CHANGED, (uint8_t *)&connection->battery_status, 1); 1127 avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_BATT_STATUS_CHANGED); 1128 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); |
1129 break; | 1129 return; |
1130 } 1131 | 1130 } 1131 |
1132 else if (connection->notify_volume_percentage_changed){ | 1132 if (connection->notify_volume_percentage_changed){ |
1133 connection->notify_volume_percentage_changed = 0; 1134 avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_VOLUME_CHANGED, &connection->volume_percentage, 1); 1135 avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_VOLUME_CHANGED); 1136 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); | 1133 connection->notify_volume_percentage_changed = 0; 1134 avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_VOLUME_CHANGED, &connection->volume_percentage, 1); 1135 avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_VOLUME_CHANGED); 1136 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); |
1137 break; | 1137 return; |
1138 } 1139 | 1138 } 1139 |
1140 else if (connection->reject_transport_header){ | 1140 if (connection->reject_transport_header){ |
1141 connection->state = AVCTP_CONNECTION_OPENED; 1142 connection->reject_transport_header = 0; 1143 l2cap_reserve_packet_buffer(); 1144 uint8_t * out_buffer = l2cap_get_outgoing_buffer(); 1145 out_buffer[0] = connection->transport_header; 1146 big_endian_store_16(out_buffer, 1, connection->invalid_pid); 1147 l2cap_send_prepared(connection->l2cap_signaling_cid, 3); 1148 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); | 1141 connection->state = AVCTP_CONNECTION_OPENED; 1142 connection->reject_transport_header = 0; 1143 l2cap_reserve_packet_buffer(); 1144 uint8_t * out_buffer = l2cap_get_outgoing_buffer(); 1145 out_buffer[0] = connection->transport_header; 1146 big_endian_store_16(out_buffer, 1, connection->invalid_pid); 1147 l2cap_send_prepared(connection->l2cap_signaling_cid, 3); 1148 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); |
1149 break; | 1149 return; |
1150 } 1151 1152 switch (connection->state){ 1153 case AVCTP_W2_SEND_RESPONSE: 1154 connection->state = AVCTP_CONNECTION_OPENED; 1155 avrcp_target_send_response(connection->l2cap_signaling_cid, connection); 1156 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); 1157 return; --- 31 unchanged lines hidden --- | 1150 } 1151 1152 switch (connection->state){ 1153 case AVCTP_W2_SEND_RESPONSE: 1154 connection->state = AVCTP_CONNECTION_OPENED; 1155 avrcp_target_send_response(connection->l2cap_signaling_cid, connection); 1156 avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); 1157 return; --- 31 unchanged lines hidden --- |