From b0d75c910f512fae7c6930f975881962ff644e94 Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Thu, 13 Jul 2017 14:35:07 +0200 Subject: [PATCH] avrcp pts test: done --- src/classic/avdtp.c | 16 ++- src/classic/avdtp.h | 1 + src/classic/avrcp.c | 58 ++++---- test/pts/avrcp_test.c | 307 ++++++++++++++++++++++++------------------ 4 files changed, 211 insertions(+), 171 deletions(-) diff --git a/src/classic/avdtp.c b/src/classic/avdtp.c index e799aa9e9..547cc81d7 100644 --- a/src/classic/avdtp.c +++ b/src/classic/avdtp.c @@ -66,6 +66,14 @@ static uint16_t avdtp_cid_counter = 0; static void (*handle_media_data)(avdtp_stream_endpoint_t * stream_endpoint, uint8_t *packet, uint16_t size); static void avdtp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); +static uint16_t avdtp_get_next_initiator_transaction_label(avdtp_context_t * context){ + context->initiator_transaction_id_counter++; + if (context->initiator_transaction_id_counter == 0){ + context->initiator_transaction_id_counter = 1; + } + return context->initiator_transaction_id_counter; +} + static uint16_t avdtp_get_next_avdtp_cid(){ avdtp_cid_counter++; if (avdtp_cid_counter == 0){ @@ -95,8 +103,7 @@ uint8_t avdtp_connect(bd_addr_t remote, avdtp_sep_type_t query_role, avdtp_conte if (!avdtp_cid) return L2CAP_LOCAL_CID_DOES_NOT_EXIST; - *avdtp_cid = avdtp_get_next_avdtp_cid(); - connection->avdtp_cid = *avdtp_cid; + *avdtp_cid = connection->avdtp_cid; connection->state = AVDTP_SIGNALING_W4_SDP_QUERY_COMPLETE; sdp_query_context.connection = connection; sdp_query_context.query_role = query_role; @@ -237,7 +244,8 @@ avdtp_connection_t * avdtp_create_connection(bd_addr_t remote_addr, avdtp_contex avdtp_connection_t * connection = btstack_memory_avdtp_connection_get(); memset(connection, 0, sizeof(avdtp_connection_t)); connection->state = AVDTP_SIGNALING_CONNECTION_IDLE; - connection->initiator_transaction_label++; + connection->initiator_transaction_label = avdtp_get_next_initiator_transaction_label(context); + connection->avdtp_cid = avdtp_get_next_avdtp_cid(); memcpy(connection->remote_addr, remote_addr, 6); btstack_linked_list_add(&context->connections, (btstack_linked_item_t *) connection); return connection; @@ -307,12 +315,12 @@ static void stream_endpoint_state_machine(avdtp_connection_t * connection, avdtp case L2CAP_EVENT_CHANNEL_CLOSED: local_cid = l2cap_event_channel_closed_get_local_cid(packet); if (stream_endpoint->l2cap_media_cid == local_cid){ + avdtp_streaming_emit_connection_released(context->avdtp_callback, stream_endpoint->connection->avdtp_cid, avdtp_local_seid(stream_endpoint)); stream_endpoint->l2cap_media_cid = 0; stream_endpoint->state = AVDTP_STREAM_ENDPOINT_IDLE; stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE; stream_endpoint->initiator_config_state = AVDTP_INITIATOR_STREAM_CONFIG_IDLE; stream_endpoint->remote_sep_index = 0; - avdtp_streaming_emit_connection_released(context->avdtp_callback, connection->avdtp_cid, avdtp_local_seid(stream_endpoint)); break; } if (stream_endpoint->l2cap_recovery_cid == local_cid){ diff --git a/src/classic/avdtp.h b/src/classic/avdtp.h index c0cb69fac..3e9af7527 100644 --- a/src/classic/avdtp.h +++ b/src/classic/avdtp.h @@ -497,6 +497,7 @@ typedef struct { btstack_linked_list_t connections; btstack_linked_list_t stream_endpoints; uint16_t stream_endpoints_id_counter; + uint16_t initiator_transaction_id_counter; btstack_packet_handler_t avdtp_callback; btstack_packet_handler_t a2dp_callback; void (*handle_media_data)(avdtp_stream_endpoint_t * stream_endpoint, uint8_t *packet, uint16_t size); diff --git a/src/classic/avrcp.c b/src/classic/avrcp.c index 4bc25937c..bc976a960 100644 --- a/src/classic/avrcp.c +++ b/src/classic/avrcp.c @@ -79,8 +79,6 @@ Bit 8-15 = RFA The bits for supported categories are set to 1. Others are set to 0. */ -static uint16_t avrcp_cid_counter = 1; - // TODO: merge with avdtp_packet_type_t typedef enum { AVRCP_SINGLE_PACKET= 0, @@ -95,6 +93,7 @@ typedef enum { } avrcp_frame_type_t; static int record_id = -1; +static uint16_t avrcp_cid_counter = 0; static uint8_t attribute_value[1000]; static const unsigned int attribute_value_buffer_size = sizeof(attribute_value); @@ -704,10 +703,7 @@ static void avrcp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t c break; } log_info("AVRCP Control PSM 0x%02x, Browsing PSM 0x%02x", sdp_query_context.avrcp_l2cap_psm, sdp_query_context.avrcp_browsing_l2cap_psm); - sdp_query_context.connection->state = AVCTP_CONNECTION_W4_L2CAP_CONNECTED; - printf("sdp_query_context.packet_handler %p\n",sdp_query_context.avrcp_context->packet_handler); - 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); break; } @@ -1183,11 +1179,20 @@ static void avrcp_handle_can_send_now(avrcp_connection_t * connection){ } } +static uint16_t avdtp_get_next_avrcp_cid(){ + avrcp_cid_counter++; + if (avrcp_cid_counter == 0){ + avrcp_cid_counter = 1; + } + return avrcp_cid_counter; +} + static avrcp_connection_t * avrcp_create_connection(bd_addr_t remote_addr, avrcp_context_t * context){ avrcp_connection_t * connection = btstack_memory_avrcp_connection_get(); memset(connection, 0, sizeof(avrcp_connection_t)); connection->state = AVCTP_CONNECTION_IDLE; connection->transaction_label = 0xFF; + connection->avrcp_cid = avdtp_get_next_avrcp_cid(); memcpy(connection->remote_addr, remote_addr, 6); btstack_linked_list_add(&context->connections, (btstack_linked_item_t *) connection); return connection; @@ -1196,6 +1201,7 @@ static avrcp_connection_t * avrcp_create_connection(bd_addr_t remote_addr, avrcp static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size, avrcp_context_t * context){ bd_addr_t event_addr; uint16_t local_cid; + uint8_t status; avrcp_connection_t * connection = NULL; switch (packet_type) { @@ -1223,45 +1229,33 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe } connection->state = AVCTP_CONNECTION_W4_L2CAP_CONNECTED; connection->l2cap_signaling_cid = local_cid; + log_info("L2CAP_EVENT_INCOMING_CONNECTION avrcp_cid 0x%02x, l2cap_signaling_cid 0x%02x", connection->avrcp_cid, connection->l2cap_signaling_cid); l2cap_accept_connection(local_cid); break; case L2CAP_EVENT_CHANNEL_OPENED: l2cap_event_channel_opened_get_address(packet, event_addr); - + status = l2cap_event_channel_opened_get_status(packet); + local_cid = l2cap_event_channel_opened_get_local_cid(packet); + connection = get_avrcp_connection_for_bd_addr(event_addr, context); - local_cid = l2cap_event_channel_opened_get_local_cid(packet); - if (!connection){ - // incoming connection - connection = avrcp_create_connection(event_addr, context); - if (!connection) { - log_error("Failed to alloc connection structure"); - l2cap_disconnect(local_cid, 0); // reason isn't used - break; - } - connection->l2cap_signaling_cid = local_cid; - connection->avrcp_cid = avrcp_cid_counter++; + log_error("Failed to alloc AVRCP connection structure"); + avrcp_emit_connection_established(avrcp_callback, connection->avrcp_cid, event_addr, BTSTACK_MEMORY_ALLOC_FAILED); + l2cap_disconnect(local_cid, 0); // reason isn't used + break; } - - if (l2cap_event_channel_opened_get_status(packet)){ - log_info("L2CAP connection to connection %s failed. status code 0x%02x", - bd_addr_to_str(event_addr), l2cap_event_channel_opened_get_status(packet)); - if (connection->state == AVCTP_CONNECTION_W4_L2CAP_CONNECTED && connection->l2cap_signaling_cid == local_cid){ - avrcp_emit_connection_established(avrcp_callback, connection->avrcp_cid, event_addr, l2cap_event_channel_opened_get_status(packet)); - } - // free connection + if (status != ERROR_CODE_SUCCESS){ + log_info("L2CAP connection to connection %s failed. status code 0x%02x", bd_addr_to_str(event_addr), status); + avrcp_emit_connection_established(avrcp_callback, connection->avrcp_cid, event_addr, status); btstack_linked_list_remove(&context->connections, (btstack_linked_item_t*) connection); btstack_memory_avrcp_connection_free(connection); break; } connection->l2cap_signaling_cid = local_cid; - log_info("L2CAP_EVENT_CHANNEL_OPENED avrcp_cid 0x%02x, l2cap_signaling_cid 0x%02x",connection->avrcp_cid, connection->l2cap_signaling_cid); + log_info("L2CAP_EVENT_CHANNEL_OPENED avrcp_cid 0x%02x, l2cap_signaling_cid 0x%02x", connection->avrcp_cid, connection->l2cap_signaling_cid); connection->state = AVCTP_CONNECTION_OPENED; avrcp_emit_connection_established(avrcp_callback, connection->avrcp_cid, event_addr, ERROR_CODE_SUCCESS); - - // hack - // l2cap_create_channel(avrcp_controller_context.packet_handler, connection->remote_addr, 0x001b, l2cap_max_mtu(), NULL); break; case L2CAP_EVENT_CAN_SEND_NOW: @@ -1275,7 +1269,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe local_cid = l2cap_event_channel_closed_get_local_cid(packet); connection = get_avrcp_connection_for_l2cap_signaling_cid(local_cid, context); if (connection){ - avrcp_emit_connection_closed(avrcp_callback, local_cid); + avrcp_emit_connection_closed(avrcp_callback, connection->avrcp_cid); // free connection btstack_linked_list_remove(&context->connections, (btstack_linked_item_t*) connection); btstack_memory_avrcp_connection_free(connection); @@ -1326,9 +1320,7 @@ uint8_t avrcp_connect(bd_addr_t bd_addr, avrcp_context_t * context, uint16_t * a if (!avrcp_cid) return L2CAP_LOCAL_CID_DOES_NOT_EXIST; - *avrcp_cid = avrcp_cid_counter++; - connection->avrcp_cid = *avrcp_cid; - + *avrcp_cid = connection->avrcp_cid; connection->state = AVCTP_SIGNALING_W4_SDP_QUERY_COMPLETE; sdp_query_context.avrcp_context = context; sdp_query_context.avrcp_l2cap_psm = 0; diff --git a/test/pts/avrcp_test.c b/test/pts/avrcp_test.c index f8cddbef0..c20a013d8 100644 --- a/test/pts/avrcp_test.c +++ b/test/pts/avrcp_test.c @@ -77,124 +77,137 @@ static avdtp_context_t a2dp_sink_context; static uint16_t avrcp_cid = 0; static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ + if (packet_type != HCI_EVENT_PACKET) return; UNUSED(channel); UNUSED(size); bd_addr_t event_addr; uint16_t local_cid; - uint16_t connection_handle = 0; uint8_t status = 0xFF; - switch (packet_type) { - case HCI_EVENT_PACKET: - switch (hci_event_packet_get_type(packet)) { - - case HCI_EVENT_AVRCP_META: - switch (packet[2]){ - case AVRCP_SUBEVENT_CONNECTION_ESTABLISHED: { - local_cid = avrcp_subevent_connection_established_get_avrcp_cid(packet); - if (avrcp_cid != local_cid) { - printf("Connection is not established, expected 0x%02X l2cap cid, received 0x%02X\n", avrcp_cid, local_cid); - break; - } - - status = avrcp_subevent_connection_established_get_status(packet); - avrcp_subevent_connection_established_get_bd_addr(packet, event_addr); - if (status != ERROR_CODE_SUCCESS){ - printf("AVRCP Connection failed: status 0x%02x\n", status); - avrcp_cid = 0; - break; - } - printf("Channel successfully opened: %s, cid 0x%02x, local cid 0x%02x\n", bd_addr_to_str(event_addr), avrcp_cid, local_cid); - return; - } - case AVRCP_SUBEVENT_CONNECTION_RELEASED: - printf("Channel released: avrcp_cid 0x%02x\n", avrcp_subevent_connection_released_get_avrcp_cid(packet)); - avrcp_cid = 0; - return; - default: - break; + + switch (hci_event_packet_get_type(packet)) { + case HCI_EVENT_AVDTP_META: + switch (packet[2]){ + case AVDTP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED: + avdtp_cid = avdtp_subevent_signaling_connection_established_get_avdtp_cid(packet); + status = avdtp_subevent_signaling_connection_established_get_status(packet); + if (status != ERROR_CODE_SUCCESS){ + printf("AVDTP connection establishment failed: status 0x%02x.\n", status); + break; } - - status = packet[5]; - connection_handle = little_endian_read_16(packet, 3); - if (connection_handle != avrcp_cid) return; - - // avoid printing INTERIM status - if (status == AVRCP_CTYPE_RESPONSE_INTERIM) return; - - printf("AVRCP: command status: %s, ", avrcp_ctype2str(status)); - switch (packet[2]){ - case AVRCP_SUBEVENT_NOTIFICATION_PLAYBACK_STATUS_CHANGED: - printf("notification, playback status changed %s\n", avrcp_play_status2str(avrcp_subevent_notification_playback_status_changed_get_play_status(packet))); - return; - case AVRCP_SUBEVENT_NOTIFICATION_NOW_PLAYING_CONTENT_CHANGED: - printf("notification, playing content changed\n"); - return; - case AVRCP_SUBEVENT_NOTIFICATION_TRACK_CHANGED: - printf("notification track changed\n"); - return; - case AVRCP_SUBEVENT_NOTIFICATION_VOLUME_CHANGED: - printf("notification absolute volume changed %d\n", avrcp_subevent_notification_volume_changed_get_absolute_volume(packet)); - return; - case AVRCP_SUBEVENT_NOTIFICATION_AVAILABLE_PLAYERS_CHANGED: - printf("notification changed\n"); - return; - case AVRCP_SUBEVENT_SHUFFLE_AND_REPEAT_MODE:{ - uint8_t shuffle_mode = avrcp_subevent_shuffle_and_repeat_mode_get_shuffle_mode(packet); - uint8_t repeat_mode = avrcp_subevent_shuffle_and_repeat_mode_get_repeat_mode(packet); - printf("%s, %s\n", avrcp_shuffle2str(shuffle_mode), avrcp_repeat2str(repeat_mode)); - break; - } - case AVRCP_SUBEVENT_NOW_PLAYING_INFO:{ - uint8_t value[100]; - printf("now playing: \n"); - if (avrcp_subevent_now_playing_info_get_title_len(packet) > 0){ - memcpy(value, avrcp_subevent_now_playing_info_get_title(packet), avrcp_subevent_now_playing_info_get_title_len(packet)); - printf(" Title: %s\n", value); - } - if (avrcp_subevent_now_playing_info_get_album_len(packet) > 0){ - memcpy(value, avrcp_subevent_now_playing_info_get_album(packet), avrcp_subevent_now_playing_info_get_album_len(packet)); - printf(" Album: %s\n", value); - } - if (avrcp_subevent_now_playing_info_get_artist_len(packet) > 0){ - memcpy(value, avrcp_subevent_now_playing_info_get_artist(packet), avrcp_subevent_now_playing_info_get_artist_len(packet)); - printf(" Artist: %s\n", value); - } - if (avrcp_subevent_now_playing_info_get_genre_len(packet) > 0){ - memcpy(value, avrcp_subevent_now_playing_info_get_genre(packet), avrcp_subevent_now_playing_info_get_genre_len(packet)); - printf(" Genre: %s\n", value); - } - printf(" Track: %d\n", avrcp_subevent_now_playing_info_get_track(packet)); - printf(" Total nr. tracks: %d\n", avrcp_subevent_now_playing_info_get_total_tracks(packet)); - printf(" Song length: %d ms\n", avrcp_subevent_now_playing_info_get_song_length(packet)); - break; - } - case AVRCP_SUBEVENT_PLAY_STATUS: - printf("song length: %d ms, song position: %d ms, play status: %s\n", - avrcp_subevent_play_status_get_song_length(packet), - avrcp_subevent_play_status_get_song_position(packet), - avrcp_play_status2str(avrcp_subevent_play_status_get_play_status(packet))); - break; - case AVRCP_SUBEVENT_OPERATION_COMPLETE: - printf("operation done %s\n", avrcp_operation2str(avrcp_subevent_operation_complete_get_operation_id(packet))); - break; - case AVRCP_SUBEVENT_OPERATION_START: - printf("operation start %s\n", avrcp_operation2str(avrcp_subevent_operation_complete_get_operation_id(packet))); - break; - case AVRCP_SUBEVENT_PLAYER_APPLICATION_VALUE_RESPONSE: - // response to set shuffle and repeat mode - printf("\n"); - break; - default: - printf("Not implemented\n"); - break; - } - break; + printf("AVDTP connection established: avdtp_cid 0x%02x.\n", avdtp_cid); + break; + case AVDTP_SUBEVENT_SIGNALING_CONNECTION_RELEASED: + avdtp_cid = avdtp_subevent_signaling_connection_released_get_avdtp_cid(packet); + printf("AVDTP connection released: avdtp_cid 0x%02x.\n", avdtp_cid); + break; + default: + printf("AVDTP event not parsed.\n"); + break; + } + break; + + case HCI_EVENT_AVRCP_META: + switch (packet[2]){ + case AVRCP_SUBEVENT_CONNECTION_ESTABLISHED: { + status = avrcp_subevent_connection_established_get_status(packet); + avrcp_subevent_connection_established_get_bd_addr(packet, event_addr); + if (status != ERROR_CODE_SUCCESS){ + printf("AVRCP connection establishment failed: status 0x%02x\n", status); + avrcp_cid = 0; + return; + } + local_cid = avrcp_subevent_connection_established_get_avrcp_cid(packet); + if (avrcp_cid != 0 && avrcp_cid != local_cid) { + printf("AVRCP connection establishment failed: expected avrcp_cid 0x%02X, received 0x%02X\n", avrcp_cid, local_cid); + return; + } + avrcp_cid = local_cid; + printf("AVRCP connection established: %s, avrcp_cid 0x%02x\n", bd_addr_to_str(event_addr), avrcp_cid); + return; + } + case AVRCP_SUBEVENT_CONNECTION_RELEASED: + printf("AVRCP connection released: avrcp_cid 0x%02x\n", avrcp_subevent_connection_released_get_avrcp_cid(packet)); + avrcp_cid = 0; + return; default: break; } - break; + + local_cid = little_endian_read_16(packet, 3); + if (local_cid != avrcp_cid) return; + // avoid printing INTERIM status + status = packet[5]; + if (status == AVRCP_CTYPE_RESPONSE_INTERIM) return; + printf("AVRCP: command status: %s, ", avrcp_ctype2str(status)); + + switch (packet[2]){ + case AVRCP_SUBEVENT_NOTIFICATION_PLAYBACK_STATUS_CHANGED: + printf("notification, playback status changed %s\n", avrcp_play_status2str(avrcp_subevent_notification_playback_status_changed_get_play_status(packet))); + return; + case AVRCP_SUBEVENT_NOTIFICATION_NOW_PLAYING_CONTENT_CHANGED: + printf("notification, playing content changed\n"); + return; + case AVRCP_SUBEVENT_NOTIFICATION_TRACK_CHANGED: + printf("notification track changed\n"); + return; + case AVRCP_SUBEVENT_NOTIFICATION_VOLUME_CHANGED: + printf("notification absolute volume changed %d\n", avrcp_subevent_notification_volume_changed_get_absolute_volume(packet)); + return; + case AVRCP_SUBEVENT_NOTIFICATION_AVAILABLE_PLAYERS_CHANGED: + printf("notification changed\n"); + return; + case AVRCP_SUBEVENT_SHUFFLE_AND_REPEAT_MODE:{ + uint8_t shuffle_mode = avrcp_subevent_shuffle_and_repeat_mode_get_shuffle_mode(packet); + uint8_t repeat_mode = avrcp_subevent_shuffle_and_repeat_mode_get_repeat_mode(packet); + printf("%s, %s\n", avrcp_shuffle2str(shuffle_mode), avrcp_repeat2str(repeat_mode)); + break; + } + case AVRCP_SUBEVENT_NOW_PLAYING_INFO:{ + uint8_t value[100]; + printf("now playing: \n"); + if (avrcp_subevent_now_playing_info_get_title_len(packet) > 0){ + memcpy(value, avrcp_subevent_now_playing_info_get_title(packet), avrcp_subevent_now_playing_info_get_title_len(packet)); + printf(" Title: %s\n", value); + } + if (avrcp_subevent_now_playing_info_get_album_len(packet) > 0){ + memcpy(value, avrcp_subevent_now_playing_info_get_album(packet), avrcp_subevent_now_playing_info_get_album_len(packet)); + printf(" Album: %s\n", value); + } + if (avrcp_subevent_now_playing_info_get_artist_len(packet) > 0){ + memcpy(value, avrcp_subevent_now_playing_info_get_artist(packet), avrcp_subevent_now_playing_info_get_artist_len(packet)); + printf(" Artist: %s\n", value); + } + if (avrcp_subevent_now_playing_info_get_genre_len(packet) > 0){ + memcpy(value, avrcp_subevent_now_playing_info_get_genre(packet), avrcp_subevent_now_playing_info_get_genre_len(packet)); + printf(" Genre: %s\n", value); + } + printf(" Track: %d\n", avrcp_subevent_now_playing_info_get_track(packet)); + printf(" Total nr. tracks: %d\n", avrcp_subevent_now_playing_info_get_total_tracks(packet)); + printf(" Song length: %d ms\n", avrcp_subevent_now_playing_info_get_song_length(packet)); + break; + } + case AVRCP_SUBEVENT_PLAY_STATUS: + printf("song length: %d ms, song position: %d ms, play status: %s\n", + avrcp_subevent_play_status_get_song_length(packet), + avrcp_subevent_play_status_get_song_position(packet), + avrcp_play_status2str(avrcp_subevent_play_status_get_play_status(packet))); + break; + case AVRCP_SUBEVENT_OPERATION_COMPLETE: + printf("operation done %s\n", avrcp_operation2str(avrcp_subevent_operation_complete_get_operation_id(packet))); + break; + case AVRCP_SUBEVENT_OPERATION_START: + printf("operation start %s\n", avrcp_operation2str(avrcp_subevent_operation_complete_get_operation_id(packet))); + break; + case AVRCP_SUBEVENT_PLAYER_APPLICATION_VALUE_RESPONSE: + // response to set shuffle and repeat mode + printf("\n"); + break; + default: + printf("AVRCP event not parsed.\n"); + break; + } + break; default: - // other packet type break; } @@ -264,19 +277,19 @@ static void stdin_process(char cmd){ sep.seid = 1; switch (cmd){ case 'b': - printf("Creating L2CAP Connection to %s, BLUETOOTH_PROTOCOL_AVDTP\n", device_addr_string); + printf("Establish AVDTP sink connection to %s\n", device_addr_string); avdtp_sink_connect(device_addr, &avdtp_cid); break; case 'B': - printf("Disconnect\n"); + printf("Disconnect AVDTP sink\n"); avdtp_sink_disconnect(avdtp_cid); break; case 'c': - printf(" - Create AVRCP connection to addr %s.\n", bd_addr_to_str(device_addr)); + printf("Establish AVRCP connection to %s.\n", bd_addr_to_str(device_addr)); avrcp_controller_connect(device_addr, &avrcp_cid); break; case 'C': - printf(" - Disconnect\n"); + printf("Disconnect AVRCP\n"); avrcp_disconnect(avrcp_cid); break; @@ -284,171 +297,197 @@ static void stdin_process(char cmd){ case '\r': break; case 'q': - printf(" - get capabilities: supported events\n"); + printf("AVRCP: get capabilities: supported events\n"); avrcp_get_supported_events(avrcp_cid); break; case 'w': - printf(" - get unit info\n"); + printf("AVRCP: get unit info\n"); avrcp_unit_info(avrcp_cid); break; case 'r': - printf(" - get play status\n"); + printf("AVRCP: get play status\n"); avrcp_get_play_status(avrcp_cid); break; case 't': - printf(" - get now playing info\n"); + printf("AVRCP: get now playing info\n"); avrcp_get_now_playing_info(avrcp_cid); break; case '1': - printf(" - play\n"); + printf("AVRCP: play\n"); avrcp_play(avrcp_cid); break; case '2': - printf(" - stop\n"); + printf("AVRCP: stop\n"); avrcp_stop(avrcp_cid); break; case '3': - printf(" - pause\n"); + printf("AVRCP: pause\n"); avrcp_pause(avrcp_cid); break; case '4': - printf(" - fast forward\n"); + printf("AVRCP: fast forward\n"); avrcp_fast_forward(avrcp_cid); break; case '5': - printf(" - rewind\n"); + printf("AVRCP: rewind\n"); avrcp_rewind(avrcp_cid); break; case '6': - printf(" - forward\n"); + printf("AVRCP: forward\n"); avrcp_forward(avrcp_cid); break; case '7': - printf(" - backward\n"); + printf("AVRCP: backward\n"); avrcp_backward(avrcp_cid); break; case '8': - printf(" - volume up\n"); + printf("AVRCP: volume up\n"); avrcp_volume_up(avrcp_cid); break; case '9': - printf(" - volume down\n"); + printf("AVRCP: volume down\n"); avrcp_volume_down(avrcp_cid); break; case '0': - printf(" - mute\n"); + printf("AVRCP: mute\n"); avrcp_mute(avrcp_cid); break; case 'R': - printf(" - absolute volume of 50 percent\n"); + printf("AVRCP: absolute volume of 50 percent\n"); avrcp_set_absolute_volume(avrcp_cid, 50); break; case 'u': - printf(" - skip\n"); + printf("AVRCP: skip\n"); avrcp_skip(avrcp_cid); break; case 'i': - printf(" - query repeat and shuffle mode\n"); + printf("AVRCP: query repeat and shuffle mode\n"); avrcp_query_shuffle_and_repeat_modes(avrcp_cid); break; case 'o': - printf(" - repeat single track\n"); + printf("AVRCP: repeat single track\n"); avrcp_set_repeat_mode(avrcp_cid, AVRCP_REPEAT_MODE_SINGLE_TRACK); break; case 'x': - printf(" - repeat all tracks\n"); + printf("AVRCP: repeat all tracks\n"); avrcp_set_repeat_mode(avrcp_cid, AVRCP_REPEAT_MODE_ALL_TRACKS); break; case 'X': - printf(" - disable repeat mode\n"); + printf("AVRCP: disable repeat mode\n"); avrcp_set_repeat_mode(avrcp_cid, AVRCP_REPEAT_MODE_OFF); break; case 'z': - printf(" - shuffle all tracks\n"); + printf("AVRCP: shuffle all tracks\n"); avrcp_set_shuffle_mode(avrcp_cid, AVRCP_SHUFFLE_MODE_ALL_TRACKS); break; case 'Z': - printf(" - disable shuffle mode\n"); + printf("AVRCP: disable shuffle mode\n"); avrcp_set_shuffle_mode(avrcp_cid, AVRCP_SHUFFLE_MODE_OFF); break; case 'a': + printf("AVRCP: enable notification PLAYBACK_STATUS_CHANGED\n"); avrcp_enable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED); break; case 's': + printf("AVRCP: enable notification TRACK_CHANGED\n"); avrcp_enable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_TRACK_CHANGED); break; case 'd': + printf("AVRCP: enable notification TRACK_REACHED_END\n"); avrcp_enable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_TRACK_REACHED_END); break; case 'f': + printf("AVRCP: enable notification TRACK_REACHED_START\n"); avrcp_enable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_TRACK_REACHED_START); break; case 'g': + printf("AVRCP: enable notification PLAYBACK_POS_CHANGED\n"); avrcp_enable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_PLAYBACK_POS_CHANGED); break; case 'h': + printf("AVRCP: enable notification BATT_STATUS_CHANGED\n"); avrcp_enable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_BATT_STATUS_CHANGED); break; case 'j': + printf("AVRCP: enable notification SYSTEM_STATUS_CHANGED\n"); avrcp_enable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_SYSTEM_STATUS_CHANGED); break; case 'k': + printf("AVRCP: enable notification PLAYER_APPLICATION_SETTING_CHANGED\n"); avrcp_enable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_PLAYER_APPLICATION_SETTING_CHANGED); break; case 'l': + printf("AVRCP: enable notification NOW_PLAYING_CONTENT_CHANGED\n"); avrcp_enable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED); break; case 'm': + printf("AVRCP: enable notification AVAILABLE_PLAYERS_CHANGED\n"); avrcp_enable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_AVAILABLE_PLAYERS_CHANGED); break; case 'n': + printf("AVRCP: enable notification ADDRESSED_PLAYER_CHANGED\n"); avrcp_enable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_ADDRESSED_PLAYER_CHANGED); break; case 'y': + printf("AVRCP: enable notification UIDS_CHANGED\n"); avrcp_enable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_UIDS_CHANGED); break; case 'v': + printf("AVRCP: enable notification VOLUME_CHANGED\n"); avrcp_enable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_VOLUME_CHANGED); break; case 'A': + printf("AVRCP: disable notification PLAYBACK_STATUS_CHANGED\n"); avrcp_disable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED); break; case 'S': + printf("AVRCP: disable notification TRACK_CHANGED\n"); avrcp_disable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_TRACK_CHANGED); break; case 'D': + printf("AVRCP: disable notification TRACK_REACHED_END\n"); avrcp_disable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_TRACK_REACHED_END); break; case 'F': + printf("AVRCP: disable notification TRACK_REACHED_START\n"); avrcp_disable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_TRACK_REACHED_START); break; case 'G': + printf("AVRCP: disable notification PLAYBACK_POS_CHANGED\n"); avrcp_disable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_PLAYBACK_POS_CHANGED); break; case 'H': + printf("AVRCP: disable notification BATT_STATUS_CHANGED\n"); avrcp_disable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_BATT_STATUS_CHANGED); break; case 'J': + printf("AVRCP: disable notification SYSTEM_STATUS_CHANGED\n"); avrcp_disable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_SYSTEM_STATUS_CHANGED); break; case 'K': + printf("AVRCP: disable notification PLAYER_APPLICATION_SETTING_CHANGED\n"); avrcp_disable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_PLAYER_APPLICATION_SETTING_CHANGED); break; case 'L': + printf("AVRCP: disable notification NOW_PLAYING_CONTENT_CHANGED\n"); avrcp_disable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED); break; case 'M': + printf("AVRCP: disable notification AVAILABLE_PLAYERS_CHANGED\n"); avrcp_disable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_AVAILABLE_PLAYERS_CHANGED); break; case 'N': + printf("AVRCP: disable notification ADDRESSED_PLAYER_CHANGED\n"); avrcp_disable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_ADDRESSED_PLAYER_CHANGED); break; case 'Y': + printf("AVRCP: disable notification UIDS_CHANGED\n"); avrcp_disable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_UIDS_CHANGED); break; case 'V': + printf("AVRCP: disable notification VOLUME_CHANGED\n"); avrcp_disable_notification(avrcp_cid, AVRCP_NOTIFICATION_EVENT_VOLUME_CHANGED); break; default: