avrcp: added missing event

This commit is contained in:
Milanka Ringwald 2017-03-01 15:53:53 +01:00
parent e222d6a026
commit 1e1e0942d6
3 changed files with 437 additions and 223 deletions

View File

@ -109,7 +109,7 @@ static const char * avrcp_subunit_type_name[] = {
"VENDOR_UNIQUE", "RESERVED_FOR_ALL_SUBUNIT_TYPES",
"EXTENDED_TO_NEXT_BYTE", "UNIT", "ERROR"
};
static const char * subunit2str(uint16_t index){
const char * avrcp_subunit2str(uint16_t index){
if (index <= 11) return avrcp_subunit_type_name[index];
if (index >= 0x1C && index <= 0x1F) return avrcp_subunit_type_name[index - 0x10];
return avrcp_subunit_type_name[16];
@ -122,7 +122,7 @@ static const char * avrcp_event_name[] = {
"PLAYER_APPLICATION_SETTING_CHANGED", "NOW_PLAYING_CONTENT_CHANGED",
"AVAILABLE_PLAYERS_CHANGED", "ADDRESSED_PLAYER_CHANGED", "UIDS_CHANGED", "VOLUME_CHANGED"
};
static const char * event2str(uint16_t index){
const char * avrcp_event2str(uint16_t index){
if (index <= 0x0d) return avrcp_event_name[index];
return avrcp_event_name[0];
}
@ -133,7 +133,7 @@ static const char * avrcp_operation_name[] = {
"VOLUME_UP", "VOLUME_DOWN", "MUTE", "PLAY", "STOP", "PAUSE", "NOT SUPPORTED",
"REWIND", "FAST_FORWARD", "NOT SUPPORTED", "FORWARD", "BACKWARD" // 0x4C
};
static const char * operation2str(uint8_t index){
const char * avrcp_operation2str(uint8_t index){
if (index >= 0x3B && index <= 0x4C) return avrcp_operation_name[index - 0x3B];
return avrcp_operation_name[0];
}
@ -141,7 +141,7 @@ static const char * operation2str(uint8_t index){
static const char * avrcp_media_attribute_id_name[] = {
"NONE", "TITLE", "ARTIST", "ALBUM", "TRACK", "TOTAL TRACKS", "GENRE", "SONG LENGTH"
};
static const char * attribute2str(uint8_t index){
const char * avrcp_attribute2str(uint8_t index){
if (index >= 1 && index <= 7) return avrcp_media_attribute_id_name[index];
return avrcp_media_attribute_id_name[0];
}
@ -150,7 +150,7 @@ static const char * avrcp_play_status_name[] = {
"STOPPED", "PLAYING", "PAUSED", "FORWARD SEEK", "REVERSE SEEK",
"ERROR" // 0xFF
};
static const char * play_status2str(uint8_t index){
const char * avrcp_play_status2str(uint8_t index){
if (index >= 1 && index <= 4) return avrcp_play_status_name[index];
return avrcp_play_status_name[5];
}
@ -173,10 +173,35 @@ static const char * avrcp_ctype_name[] = {
"RESERVED",
"INTERIM"
};
static const char * ctype2str(uint8_t index){
return avrcp_ctype_name[index];
const char * avrcp_ctype2str(uint8_t index){
if (index >= 0 && index < sizeof(avrcp_ctype_name)){
return avrcp_ctype_name[index];
}
return "NONE";
}
static const char * avrcp_shuffle_mode_name[] = {
"SHUFFLE OFF",
"SHUFFLE ALL TRACKS",
"SHUFFLE GROUP"
};
const char * avrcp_shuffle2str(uint8_t index){
if (index >= 1 && index <= 3) return avrcp_shuffle_mode_name[index-1];
return "NONE";
}
static const char * avrcp_repeat_mode_name[] = {
"REPEAT OFF",
"REPEAT SINGLE TRACK",
"REPEAT ALL TRACKS",
"REPEAT GROUP"
};
const char * avrcp_repeat2str(uint8_t index){
if (index >= 1 && index <= 4) return avrcp_repeat_mode_name[index-1];
return "NONE";
}
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
static void avrcp_create_sdp_record(uint8_t controller, uint8_t * service, uint32_t service_record_handle, uint8_t browsing, uint16_t supported_features, const char * service_name, const char * service_provider_name){
@ -332,13 +357,27 @@ static void avrcp_emit_connection_established(btstack_packet_handler_t callback,
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
}
static void avrcp_emit_operation_status(btstack_packet_handler_t callback, uint8_t subevent, uint16_t con_handle, uint8_t status, uint8_t operation_id){
if (!callback) return;
uint8_t event[7];
int pos = 0;
event[pos++] = HCI_EVENT_AVRCP_META;
event[pos++] = sizeof(event) - 2;
event[pos++] = subevent;
little_endian_store_16(event, pos, con_handle);
pos += 2;
event[pos++] = status;
event[pos++] = operation_id;
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
}
static void avrcp_emit_connection_closed(btstack_packet_handler_t callback, uint16_t con_handle){
if (!callback) return;
uint8_t event[5];
int pos = 0;
event[pos++] = HCI_EVENT_AVRCP_META;
event[pos++] = sizeof(event) - 2;
event[pos++] = AVRCP_SUBEVENT_CONNECTION_CLOSED;
event[pos++] = AVRCP_SUBEVENT_CONNECTION_RELEASED;
little_endian_store_16(event, pos, con_handle);
pos += 2;
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
@ -421,7 +460,7 @@ static void request_pass_through_release_control_cmd(avrcp_connection_t * connec
static void request_pass_through_press_control_cmd(uint16_t con_handle, avrcp_operation_id_t opid, uint16_t playback_speed){
avrcp_connection_t * connection = get_avrcp_connection_for_con_handle(con_handle);
if (!connection){
log_error("avrcp: coud not find a connection.");
log_error("avrcp: could not find a connection.");
return;
}
if (connection->state != AVCTP_CONNECTION_OPENED) return;
@ -563,7 +602,6 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
uint8_t unit_type = operands[1] >> 3;
uint8_t unit = operands[1] & 0x07;
uint32_t company_id = operands[2] << 16 | operands[3] << 8 | operands[4];
printf(" UNIT INFO response: subunit type %s\n", subunit2str(subunit_type));
log_info(" UNIT INFO response: ctype 0x%02x (0C), subunit_type 0x%02x (1F), subunit_id 0x%02x (07), opcode 0x%02x (30), unit_type 0x%02x, unit %d, company_id 0x%06x",
ctype, subunit_type, subunit_id, opcode, unit_type, unit, company_id );
break;
@ -591,8 +629,8 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
// printf(" VENDOR DEPENDENT response: ctype 0x%02x (0C), subunit_type 0x%02x (1F), subunit_id 0x%02x (07), opcode 0x%02x (30), unit_type 0x%02x, unit %d, company_id 0x%06x\n",
// ctype, subunit_type, subunit_id, opcode, unit_type, unit, company_id );
//if (ctype == AVRCP_CTYPE_RESPONSE_INTERIM) return;
printf(" VENDOR DEPENDENT response: pdu id 0x%02x, param_length %d, status %s\n", pdu_id, param_length, ctype2str(ctype));
// if (ctype == AVRCP_CTYPE_RESPONSE_INTERIM) return;
log_info(" VENDOR DEPENDENT response: pdu id 0x%02x, param_length %d, status %s", pdu_id, param_length, avrcp_ctype2str(ctype));
switch (pdu_id){
case AVRCP_PDU_ID_GetCurrentPlayerApplicationSettingValue:{
uint8_t num_attributes = packet[pos++];
@ -616,36 +654,49 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
avrcp_emit_repeat_and_shuffle_mode(avrcp_callback, connection->con_handle, ctype, repeat_mode, shuffle_mode);
break;
}
case AVRCP_PDU_ID_SetPlayerApplicationSettingValue:
printf("AVRCP_PDU_ID_SetPlayerApplicationSettingValue Response \n");
case AVRCP_PDU_ID_SetPlayerApplicationSettingValue:{
uint8_t event[6];
int offset = 0;
event[offset++] = HCI_EVENT_AVRCP_META;
event[offset++] = sizeof(event) - 2;
event[offset++] = AVRCP_SUBEVENT_PLAYER_APPLICATION_VALUE_RESPONSE;
little_endian_store_16(event, offset, connection->con_handle);
offset += 2;
event[offset++] = ctype;
(*avrcp_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
break;
}
case AVRCP_PDU_ID_SET_ABSOLUTE_VOLUME:{
uint8_t absolute_volume = packet[pos++];
printf("Absolute volume %d\n", absolute_volume);
uint8_t event[7];
int offset = 0;
event[offset++] = HCI_EVENT_AVRCP_META;
event[offset++] = sizeof(event) - 2;
event[offset++] = AVRCP_SUBEVENT_SET_ABSOLUTE_VOLUME_RESPONSE;
little_endian_store_16(event, offset, connection->con_handle);
offset += 2;
event[offset++] = ctype;
event[offset++] = packet[pos++];
(*avrcp_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
break;
}
case AVRCP_PDU_ID_GET_CAPABILITIES:{
printf_hexdump(packet+pos,size-pos);
avrcp_capability_id_t capability_id = packet[pos++];
uint8_t capability_count = packet[pos++];
printf(" capability id %02x, count %02x\n", capability_id, capability_count);
printf_hexdump(packet+pos,size-pos);
int i;
switch (capability_id){
case AVRCP_CAPABILITY_ID_COMPANY:
printf("Supported companies %d: \n", capability_count);
// log_info("Supported companies %d: ", capability_count);
for (i = 0; i < capability_count; i++){
uint32_t company_id = big_endian_read_24(packet, pos);
pos += 3;
printf(" 0x%06x, \n", company_id);
log_info(" 0x%06x, ", company_id);
}
printf("\n");
break;
case AVRCP_CAPABILITY_ID_EVENT:
printf("Supported events %d: \n", capability_count);
// log_info("Supported events %d: ", capability_count);
for (i = 0; i < capability_count; i++){
uint8_t event_id = packet[pos++];
printf(" 0x%02x %s\n", event_id, event2str(event_id));
log_info(" 0x%02x %s", event_id, avrcp_event2str(event_id));
}
break;
}
@ -656,8 +707,23 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
pos += 4;
uint32_t song_position = big_endian_read_32(packet, pos);
pos += 4;
uint8_t status = packet[pos];
printf(" GET_PLAY_STATUS length 0x%04X, position 0x%04X, status %s\n", song_length, song_position, play_status2str(status));
uint8_t play_status = packet[pos];
// log_info(" GET_PLAY_STATUS length 0x%04X, position 0x%04X, status %s", song_length, song_position, avrcp_play_status2str(play_status));
uint8_t event[15];
int offset = 0;
event[offset++] = HCI_EVENT_AVRCP_META;
event[offset++] = sizeof(event) - 2;
event[offset++] = AVRCP_SUBEVENT_PLAY_STATUS;
little_endian_store_16(event, offset, connection->con_handle);
offset += 2;
event[offset++] = ctype;
little_endian_store_32(event, offset, song_length);
offset += 4;
little_endian_store_32(event, offset, song_position);
offset += 4;
event[offset++] = play_status;
(*avrcp_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
break;
}
case AVRCP_PDU_ID_REGISTER_NOTIFICATION:{
@ -670,6 +736,7 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
connection->notifications_enabled |= event_mask;
// clear registration bit
connection->notifications_to_register &= reset_event_mask;
connection->state = AVCTP_CONNECTION_OPENED;
// printf("INTERIM notifications_enabled 0x%2x, notifications_to_register 0x%2x\n", connection->notifications_enabled, connection->notifications_to_register);
break;
case AVRCP_CTYPE_RESPONSE_CHANGED_STABLE:
@ -691,29 +758,68 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
break;
}
uint8_t status;
printf(" REGISTER_NOTIFICATION: ");
switch (event_id){
case AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED:
status = packet[pos];
printf("EVENT_PLAYBACK_STATUS_CHANGED status %s\n", play_status2str(status));
case AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED:{
uint8_t event[7];
int offset = 0;
event[offset++] = HCI_EVENT_AVRCP_META;
event[offset++] = sizeof(event) - 2;
event[offset++] = AVRCP_SUBEVENT_NOTIFICATION_PLAYBACK_STATUS_CHANGED;
little_endian_store_16(event, offset, connection->con_handle);
offset += 2;
event[offset++] = ctype;
event[offset++] = packet[pos];
(*avrcp_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
break;
case AVRCP_NOTIFICATION_EVENT_TRACK_CHANGED:
status = packet[pos++];
printf("EVENT_VOLUME_CHANGED status %s\n", play_status2str(status));
}
case AVRCP_NOTIFICATION_EVENT_TRACK_CHANGED:{
uint8_t event[7];
int offset = 0;
event[offset++] = HCI_EVENT_AVRCP_META;
event[offset++] = sizeof(event) - 2;
event[offset++] = AVRCP_SUBEVENT_NOTIFICATION_TRACK_CHANGED;
little_endian_store_16(event, offset, connection->con_handle);
offset += 2;
event[offset++] = ctype;
event[offset++] = packet[pos];
(*avrcp_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
break;
case AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED:
printf("EVENT_NOW_PLAYING_CONTENT_CHANGED \n");
}
case AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED:{
uint8_t event[6];
int offset = 0;
event[offset++] = HCI_EVENT_AVRCP_META;
event[offset++] = sizeof(event) - 2;
event[offset++] = AVRCP_SUBEVENT_NOTIFICATION_NOW_PLAYING_CONTENT_CHANGED;
little_endian_store_16(event, offset, connection->con_handle);
offset += 2;
event[offset++] = ctype;
(*avrcp_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
break;
case AVRCP_NOTIFICATION_EVENT_AVAILABLE_PLAYERS_CHANGED:
printf("EVENT_AVAILABLE_PLAYERS_CHANGED \n");
}
case AVRCP_NOTIFICATION_EVENT_AVAILABLE_PLAYERS_CHANGED:{
uint8_t event[6];
int offset = 0;
event[offset++] = HCI_EVENT_AVRCP_META;
event[offset++] = sizeof(event) - 2;
event[offset++] = AVRCP_SUBEVENT_NOTIFICATION_AVAILABLE_PLAYERS_CHANGED;
little_endian_store_16(event, offset, connection->con_handle);
offset += 2;
event[offset++] = ctype;
(*avrcp_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
break;
}
case AVRCP_NOTIFICATION_EVENT_VOLUME_CHANGED:{
uint8_t absolute_volume = packet[pos++] & 0x7F;
printf("EVENT_VOLUME_CHANGED: absolute_volume %d\n", absolute_volume);
uint8_t event[7];
int offset = 0;
event[offset++] = HCI_EVENT_AVRCP_META;
event[offset++] = sizeof(event) - 2;
event[offset++] = AVRCP_SUBEVENT_NOTIFICATION_VOLUME_CHANGED;
little_endian_store_16(event, offset, connection->con_handle);
offset += 2;
event[offset++] = ctype;
event[offset++] = packet[pos++] & 0x7F;
(*avrcp_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
break;
}
// case AVRCP_NOTIFICATION_EVENT_PLAYER_APPLICATION_SETTING_CHANGED:{
@ -736,7 +842,7 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
// pos += 2;
// break;
default:
printf("not implemented\n");
log_info("avrcp: not implemented");
break;
}
if (connection->notifications_to_register != 0){
@ -744,6 +850,7 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
}
break;
}
case AVRCP_PDU_ID_GET_ELEMENT_ATTRIBUTES:{
uint8_t num_attributes = packet[pos++];
int i;
@ -770,7 +877,7 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
uint16_t value_len = sizeof(value) <= attr_value_length? sizeof(value) - 1 : attr_value_length;
memcpy(value, packet+pos, value_len);
value[value_len] = 0;
printf("Now Playing Info %s: %s \n", attribute2str(attr_id), value);
// printf("Now Playing Info %s: %s \n", attribute2str(attr_id), value);
// end debug
if ((attr_id >= 1) || (attr_id <= AVRCP_MEDIA_ATTR_COUNT)) {
@ -859,7 +966,7 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
}
}
event[1] = pos - 2;
printf_hexdump(event, pos);
// printf_hexdump(event, pos);
(*avrcp_callback)(HCI_EVENT_PACKET, 0, event, pos);
break;
}
@ -876,16 +983,18 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
opcode = packet[pos++];
uint8_t operation_id = packet[pos++];
if (connection->state == AVCTP_W4_STOP){
avrcp_emit_operation_status(avrcp_callback, AVRCP_SUBEVENT_OPERATION_START, connection->con_handle, ctype, operation_id);
}
if (connection->state == AVCTP_CONNECTION_OPENED) {
// RELEASE response
operation_id = operation_id & 0x7F;
avrcp_emit_operation_status(avrcp_callback, AVRCP_SUBEVENT_OPERATION_COMPLETE, connection->con_handle, ctype, operation_id);
}
if (connection->state == AVCTP_W2_SEND_RELEASE_COMMAND){
// PRESS response
request_pass_through_release_control_cmd(connection);
}
printf("Operation %s, status %s\n", operation2str(operation_id), ctype2str(ctype));
break;
}
default:
@ -904,6 +1013,13 @@ static void avrcp_handle_can_send_now(avrcp_connection_t * connection){
connection->state = AVCTP_W2_RECEIVE_RESPONSE;
break;
case AVCTP_CONNECTION_OPENED:
if (connection->disconnect){
connection->wait_to_send = 0;
connection->disconnect = 0;
connection->state = AVCTP_CONNECTION_W4_L2CAP_DISCONNECTED;
l2cap_disconnect(connection->l2cap_signaling_cid, 0);
return;
}
if (connection->notifications_to_register != 0){
for (i = 1; i < 13; i++){
if (connection->notifications_to_register & (1<<i)){
@ -920,6 +1036,16 @@ static void avrcp_handle_can_send_now(avrcp_connection_t * connection){
avrcp_send_cmd(connection->l2cap_signaling_cid, connection);
}
static avrcp_connection_t * avrcp_create_connection(bd_addr_t remote_addr){
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;
memcpy(connection->remote_addr, remote_addr, 6);
btstack_linked_list_add(&avrcp_connections, (btstack_linked_item_t *) connection);
return connection;
}
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
bd_addr_t event_addr;
hci_con_handle_t con_handle;
@ -939,6 +1065,14 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
case L2CAP_EVENT_INCOMING_CONNECTION:
l2cap_event_incoming_connection_get_address(packet, event_addr);
local_cid = l2cap_event_incoming_connection_get_local_cid(packet);
connection = get_avrcp_connection_for_bd_addr(event_addr);
if (!connection){
connection = avrcp_create_connection(event_addr);
connection->state = AVCTP_CONNECTION_W4_L2CAP_CONNECTED;
l2cap_accept_connection(local_cid);
break;
}
break;
case L2CAP_EVENT_CHANNEL_OPENED:
@ -962,7 +1096,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
local_cid = l2cap_event_channel_opened_get_local_cid(packet);
// printf("L2CAP_EVENT_CHANNEL_OPENED: Channel successfully opened: %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x, remote cid 0x%02x\n",
// bd_addr_to_str(event_addr), con_handle, psm, local_cid, l2cap_event_channel_opened_get_remote_cid(packet));
if (connection->l2cap_signaling_cid == 0) {
connection->l2cap_signaling_cid = local_cid;
connection->con_handle = con_handle;
@ -982,10 +1115,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
// data: event (8), len(8), channel (16)
local_cid = l2cap_event_channel_closed_get_local_cid(packet);
connection = get_avrcp_connection_for_l2cap_signaling_cid(local_cid);
printf(" -> L2CAP_EVENT_CHANNEL_CLOSED cid 0x%0x\n", local_cid);
if (connection){
printf("connection closed\n");
avrcp_emit_connection_closed(avrcp_callback, connection->con_handle);
btstack_linked_list_remove(&avrcp_connections, (btstack_linked_item_t*) connection);
break;
@ -1013,23 +1143,13 @@ void avrcp_register_packet_handler(btstack_packet_handler_t callback){
avrcp_callback = callback;
}
static avrcp_connection_t * avrcp_create_connection(bd_addr_t remote_addr){
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;
memcpy(connection->remote_addr, remote_addr, 6);
btstack_linked_list_add(&avrcp_connections, (btstack_linked_item_t *) connection);
return connection;
}
void avrcp_connect(bd_addr_t bd_addr){
avrcp_connection_t * connection = get_avrcp_connection_for_bd_addr(bd_addr);
if (!connection){
connection = avrcp_create_connection(bd_addr);
}
if (!connection){
log_error("avrcp: coud not find or create a connection.");
log_error("avrcp: could not find or create a connection.");
return;
}
if (connection->state != AVCTP_CONNECTION_IDLE) return;
@ -1040,7 +1160,7 @@ void avrcp_connect(bd_addr_t bd_addr){
void avrcp_unit_info(uint16_t con_handle){
avrcp_connection_t * connection = get_avrcp_connection_for_con_handle(con_handle);
if (!connection){
log_error("avrcp_unit_info: coud not find a connection.");
log_error("avrcp_unit_info: could not find a connection.");
return;
}
if (connection->state != AVCTP_CONNECTION_OPENED) return;
@ -1059,7 +1179,7 @@ void avrcp_unit_info(uint16_t con_handle){
static void avrcp_get_capabilities(uint16_t con_handle, uint8_t capability_id){
avrcp_connection_t * connection = get_avrcp_connection_for_con_handle(con_handle);
if (!connection){
log_error("avrcp_get_capabilities: coud not find a connection.");
log_error("avrcp_get_capabilities: could not find a connection.");
return;
}
if (connection->state != AVCTP_CONNECTION_OPENED) return;
@ -1116,22 +1236,22 @@ void avrcp_volume_up(uint16_t con_handle){
request_pass_through_press_control_cmd(con_handle, AVRCP_OPERATION_ID_VOLUME_UP, 0);
}
void avrcp_start_volume_down(uint16_t con_handle){
void avrcp_volume_down(uint16_t con_handle){
request_pass_through_press_control_cmd(con_handle, AVRCP_OPERATION_ID_VOLUME_DOWN, 0);
}
void avrcp_start_mute(uint16_t con_handle){
void avrcp_mute(uint16_t con_handle){
request_pass_through_press_control_cmd(con_handle, AVRCP_OPERATION_ID_MUTE, 0);
}
void avrcp_start_skip(uint16_t con_handle){
void avrcp_skip(uint16_t con_handle){
request_pass_through_press_control_cmd(con_handle, AVRCP_OPERATION_ID_SKIP, 0);
}
void avrcp_stop_rewind(uint16_t con_handle){
avrcp_connection_t * connection = get_avrcp_connection_for_con_handle(con_handle);
if (!connection){
log_error("avrcp_stop_rewind: coud not find a connection.");
log_error("avrcp_stop_rewind: could not find a connection.");
return;
}
if (connection->state != AVCTP_W4_STOP) return;
@ -1145,7 +1265,7 @@ void avrcp_start_fast_forward(uint16_t con_handle){
void avrcp_stop_fast_forward(uint16_t con_handle){
avrcp_connection_t * connection = get_avrcp_connection_for_con_handle(con_handle);
if (!connection){
log_error("avrcp_stop_fast_forward: coud not find a connection.");
log_error("avrcp_stop_fast_forward: could not find a connection.");
return;
}
if (connection->state != AVCTP_W4_STOP) return;
@ -1155,7 +1275,7 @@ void avrcp_stop_fast_forward(uint16_t con_handle){
void avrcp_get_play_status(uint16_t con_handle){
avrcp_connection_t * connection = get_avrcp_connection_for_con_handle(con_handle);
if (!connection){
log_error("avrcp_get_play_status: coud not find a connection.");
log_error("avrcp_get_play_status: could not find a connection.");
return;
}
if (connection->state != AVCTP_CONNECTION_OPENED) return;
@ -1177,7 +1297,7 @@ void avrcp_get_play_status(uint16_t con_handle){
void avrcp_enable_notification(uint16_t con_handle, avrcp_notification_event_id_t event_id){
avrcp_connection_t * connection = get_avrcp_connection_for_con_handle(con_handle);
if (!connection){
log_error("avrcp_get_play_status: coud not find a connection.");
log_error("avrcp_get_play_status: could not find a connection.");
return;
}
avrcp_register_notification(connection, event_id);
@ -1186,7 +1306,7 @@ void avrcp_enable_notification(uint16_t con_handle, avrcp_notification_event_id_
void avrcp_disable_notification(uint16_t con_handle, avrcp_notification_event_id_t event_id){
avrcp_connection_t * connection = get_avrcp_connection_for_con_handle(con_handle);
if (!connection){
log_error("avrcp_get_play_status: coud not find a connection.");
log_error("avrcp_get_play_status: could not find a connection.");
return;
}
connection->notifications_to_deregister |= (1 << event_id);
@ -1195,7 +1315,7 @@ void avrcp_disable_notification(uint16_t con_handle, avrcp_notification_event_id
void avrcp_get_now_playing_info(uint16_t con_handle){
avrcp_connection_t * connection = get_avrcp_connection_for_con_handle(con_handle);
if (!connection){
log_error("avrcp_get_capabilities: coud not find a connection.");
log_error("avrcp_get_capabilities: could not find a connection.");
return;
}
if (connection->state != AVCTP_CONNECTION_OPENED) return;
@ -1231,7 +1351,7 @@ void avrcp_get_now_playing_info(uint16_t con_handle){
void avrcp_set_absolute_volume(uint16_t con_handle, uint8_t volume){
avrcp_connection_t * connection = get_avrcp_connection_for_con_handle(con_handle);
if (!connection){
log_error("avrcp_get_capabilities: coud not find a connection.");
log_error("avrcp_get_capabilities: could not find a connection.");
return;
}
if (connection->state != AVCTP_CONNECTION_OPENED) return;
@ -1260,7 +1380,7 @@ void avrcp_set_absolute_volume(uint16_t con_handle, uint8_t volume){
void avrcp_query_shuffle_and_repeat_modes(uint16_t con_handle){
avrcp_connection_t * connection = get_avrcp_connection_for_con_handle(con_handle);
if (!connection){
log_error("avrcp_get_capabilities: coud not find a connection.");
log_error("avrcp_get_capabilities: could not find a connection.");
return;
}
if (connection->state != AVCTP_CONNECTION_OPENED) return;
@ -1325,3 +1445,16 @@ void avrcp_set_repeat_mode(uint16_t con_handle, avrcp_repeat_mode_t mode){
if (mode < AVRCP_REPEAT_MODE_OFF || mode > AVRCP_REPEAT_MODE_GROUP) return;
avrcp_set_current_player_application_setting_value(con_handle, 0x02, mode);
}
void avrcp_disconnect(uint16_t con_handle){
avrcp_connection_t * connection = get_avrcp_connection_for_con_handle(con_handle);
if (!connection){
log_error("avrcp_get_capabilities: could not find a connection.");
return;
}
if (connection->state != AVCTP_CONNECTION_OPENED) return;
if (connection->state == AVCTP_CONNECTION_W4_L2CAP_DISCONNECTED) return;
connection->disconnect = 1;
avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid);
}

View File

@ -204,6 +204,8 @@ typedef struct {
uint16_t notifications_enabled;
uint16_t notifications_to_register;
uint16_t notifications_to_deregister;
uint8_t disconnect;
} avrcp_connection_t;
typedef enum {
@ -267,7 +269,7 @@ void avrcp_register_packet_handler(btstack_packet_handler_t callback);
* @param bd_addr
*/
void avrcp_connect(bd_addr_t bd_addr);
void avrcp_disconnect(uint16_t con_handle);
/**
* @brief Unit info.
* @param con_handle
@ -283,45 +285,45 @@ void avrcp_get_supported_events(uint16_t con_handle);
/**
* @brief Play.
* @brief Play. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
* @param con_handle
*/
void avrcp_play(uint16_t con_handle);
/**
* @brief Stop.
* @brief Stop. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
* @param con_handle
*/
void avrcp_stop(uint16_t con_handle);
/**
* @brief Pause.
* @brief Pause. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
* @param con_handle
*/
void avrcp_pause(uint16_t con_handle);
/**
* @brief Fast forward.
* @brief Fast forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
* @param con_handle
*/
void avrcp_start_fast_forward(uint16_t con_handle);
void avrcp_stop_fast_forward(uint16_t con_handle);
/**
* @brief Rewind.
* @brief Rewind. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
* @param con_handle
*/
void avrcp_start_rewind(uint16_t con_handle);
void avrcp_stop_rewind(uint16_t con_handle);
/**
* @brief Forward.
* @brief Forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
* @param con_handle
*/
void avrcp_forward(uint16_t con_handle);
/**
* @brief Backward.
* @brief Backward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
* @param con_handle
*/
void avrcp_backward(uint16_t con_handle);
@ -335,7 +337,7 @@ void avrcp_backward(uint16_t con_handle);
void avrcp_get_play_status(uint16_t con_handle);
/**
* @brief Register notification.
* @brief Register notification. Response via AVRCP_SUBEVENT_ENABLE_NOTIFICATION_COMPLETE.
* @param con_handle
* @param event_id
*/
@ -349,53 +351,62 @@ void avrcp_disable_notification(uint16_t con_handle, avrcp_notification_event_id
void avrcp_get_now_playing_info(uint16_t con_handle);
/**
* @brief Set absolute volume 0-127 (corresponds to 0-100%)
* @brief Set absolute volume 0-127 (corresponds to 0-100%). Response via AVRCP_SUBEVENT_SET_ABSOLUTE_VOLUME_RESPONSE
* @param con_handle
*/
void avrcp_set_absolute_volume(uint16_t con_handle, uint8_t volume);
/**
* @brief Turns the volume to high.
* @brief Turns the volume to high. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
* @param con_handle
*/
void avrcp_volume_up(uint16_t con_handle);
/**
* @brief Turns the volume to low.
* @brief Turns the volume to low. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
* @param con_handle
*/
void avrcp_start_volume_down(uint16_t con_handle);
void avrcp_volume_down(uint16_t con_handle);
/**
* @brief Puts the sound out.
* @brief Puts the sound out. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
* @param con_handle
*/
void avrcp_start_mute(uint16_t con_handle);
void avrcp_mute(uint16_t con_handle);
/**
* @brief Skip to next playing media.
* @brief Skip to next playing media. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
* @param con_handle
*/
void avrcp_start_skip(uint16_t con_handle);
void avrcp_skip(uint16_t con_handle);
/**
* @brief Query repeat and shuffle mode.
* @brief Query repeat and shuffle mode. Response via AVRCP_SUBEVENT_SHUFFLE_AND_REPEAT_MODE.
* @param con_handle
*/
void avrcp_query_shuffle_and_repeat_modes(uint16_t con_handle);
/**
* @brief Set shuffle mode.
* @brief Set shuffle mode. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
* @param con_handle
*/
void avrcp_set_shuffle_mode(uint16_t con_handle, avrcp_shuffle_mode_t mode);
/**
* @brief Set repeat mode.
* @brief Set repeat mode. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
* @param con_handle
*/
void avrcp_set_repeat_mode(uint16_t con_handle, avrcp_repeat_mode_t mode);
const char * avrcp_subunit2str(uint16_t index);
const char * avrcp_event2str(uint16_t index);
const char * avrcp_operation2str(uint8_t index);
const char * avrcp_attribute2str(uint8_t index);
const char * avrcp_play_status2str(uint8_t index);
const char * avrcp_ctype2str(uint8_t index);
const char * avrcp_repeat2str(uint8_t index);
const char * avrcp_shuffle2str(uint8_t index);
/* API_END */
#if defined __cplusplus
}

View File

@ -65,73 +65,130 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
static bd_addr_t device_addr;
// iPhone SE
static const char * device_addr_string = "BC:EC:5D:E6:15:03";
// static const char * device_addr_string = "BC:EC:5D:E6:15:03";
// static const char * device_addr_string = "D8:BB:2C:DF:F1:08";
// iPhone 6
static const char * device_addr_string = "D8:BB:2C:DF:F1:08";
static uint16_t con_handle = 0;
static uint8_t sdp_avrcp_controller_service_buffer[150];
static uint16_t avrcp_con_handle = 0;
static uint8_t sdp_avrcp_controller_service_buffer[200];
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
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_DISCONNECTION_COMPLETE:
// connection closed -> quit test app
printf("--- avrcp_test: HCI_EVENT_DISCONNECTION_COMPLETE\n");
printf("AVRCP: HCI_EVENT_DISCONNECTION_COMPLETE\n");
break;
case HCI_EVENT_AVRCP_META:
printf("app: ");
switch (packet[2]){
case AVRCP_SUBEVENT_CONNECTION_ESTABLISHED:
con_handle = avrcp_subevent_connection_established_get_con_handle(packet);
case AVRCP_SUBEVENT_CONNECTION_ESTABLISHED: {
status = avrcp_subevent_connection_established_get_status(packet);
avrcp_con_handle = avrcp_subevent_connection_established_get_con_handle(packet);
local_cid = avrcp_subevent_connection_established_get_local_cid(packet);
avrcp_subevent_connection_established_get_bd_addr(packet, event_addr);
printf("AVRCP_SUBEVENT_CONNECTION_ESTABLISHED: Channel successfully opened: %s, handle 0x%02x, local cid 0x%02x\n", bd_addr_to_str(event_addr), con_handle, local_cid);
printf("Channel successfully opened: %s, handle 0x%02x, local cid 0x%02x\n", bd_addr_to_str(event_addr), avrcp_con_handle, local_cid);
// automatically enable notifications
avrcp_enable_notification(avrcp_con_handle, AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED);
//avrcp_enable_notification(avrcp_con_handle, AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED);
return;
}
case AVRCP_SUBEVENT_CONNECTION_RELEASED:
printf("Channel released: con_handle 0x%02x\n", avrcp_subevent_connection_released_get_con_handle(packet));
avrcp_con_handle = 0;
return;
default:
break;
}
case AVRCP_SUBEVENT_CONNECTION_CLOSED:
printf("AVRCP_SUBEVENT_CONNECTION_RELEASED: con_handle 0x%02x\n", avrcp_subevent_connection_closed_get_con_handle(packet));
con_handle = 0;
status = packet[5];
connection_handle = little_endian_read_16(packet, 3);
if (connection_handle != avrcp_con_handle) return;
// avoid printing INTERIM status
switch (packet[2]){
case AVRCP_SUBEVENT_NOTIFICATION_PLAYBACK_STATUS_CHANGED:
case AVRCP_SUBEVENT_NOTIFICATION_NOW_PLAYING_CONTENT_CHANGED:
case AVRCP_SUBEVENT_NOTIFICATION_TRACK_CHANGED:
case AVRCP_SUBEVENT_NOTIFICATION_VOLUME_CHANGED:
case AVRCP_SUBEVENT_NOTIFICATION_AVAILABLE_PLAYERS_CHANGED:
if (status == AVRCP_CTYPE_RESPONSE_INTERIM) return;
break;
default:
break;
}
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_playback_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 %d\n", avrcp_subevent_notification_track_changed_get_track_status(packet));
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("AVRCP_SUBEVENT_SHUFFLE_AND_REPEAT_MODE: repeat %d, shuffle %d\n", repeat_mode, shuffle_mode);
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:
printf("Now Playing Info: \n");
printf_hexdump(packet, size);
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){
printf(" Title: %s\n", avrcp_subevent_now_playing_info_get_title(packet));
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){
printf(" Album: %s\n", avrcp_subevent_now_playing_info_get_album(packet));
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){
printf(" Artist: %s\n", avrcp_subevent_now_playing_info_get_artist(packet));
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){
printf(" Genre: %s\n", avrcp_subevent_now_playing_info_get_genre(packet));
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("AVRCP_SUBEVENT_PLAY_STATUS\n");
// 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
break;
default:
printf("--- avrcp_test: Not implemented\n");
printf("Not implemented\n");
break;
}
break;
@ -143,6 +200,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
// other packet type
break;
}
}
@ -151,32 +209,30 @@ static void show_usage(void){
gap_local_bd_addr(iut_address);
printf("\n--- Bluetooth AVRCP Test Console %s ---\n", bd_addr_to_str(iut_address));
printf("c - create connection to addr %s\n", bd_addr_to_str(device_addr));
printf("C - disconnect\n");
printf("i - get unit info\n");
printf("e - get capabilities\n");
printf("l - play\n");
printf("s - stop\n");
printf("p - pause\n");
printf("w - fast_forward\n");
printf("r - start_rewind\n");
printf("R - stop_rewind\n");
printf("f - forward\n");
printf("b - backward\n");
printf("S - get play status\n");
printf("n - enable notification, AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED\n");
printf("N - disable notification, AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED\n");
printf("I - get now playing info\n");
printf("u - volume up\n");
printf("d - volume down\n");
printf("a - absolute volume of %d percent\n", 5000/127);
printf("m - mute\n");
printf("k - skip\n");
printf("q - query repeat and shuffle mode\n");
printf("x - set repeat mode: SINGLE_TRACK\n");
printf("X - disable repeat mode\n");
printf("y - set shuffle mode ALL_TRACKS\n");
printf("Y - disable shuffle mode\n");
printf("D - disconnect\n");
printf("\n--- Bluetooth AVRCP Commands ---\n");
printf("i - get play status\n");
printf("j - get now playing info\n");
printf("k - play\n");
printf("K - stop\n");
printf("L - pause\n");
printf("m - start fast forward\n");
printf("M - stop fast forward\n");
printf("n - start rewind\n");
printf("N - stop rewind\n");
printf("o - forward\n");
printf("O - backward\n");
printf("p - volume up\n");
printf("P - volume down\n");
printf("r - absolute volume of 50 percent\n");
printf("s - mute\n");
printf("t - skip\n");
printf("u - query repeat and shuffle mode\n");
printf("v - repeat single track\n");
printf("x - repeat all tracks\n");
printf("X - disable repeat mode\n");
printf("z - shuffle all tracks\n");
printf("Z - disable shuffle mode\n");
printf("Ctrl-c - exit\n");
printf("---\n");
@ -187,93 +243,107 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
UNUSED(callback_type);
int cmd = btstack_stdin_read();
printf("- execute command %c\n", cmd);
switch (cmd){
case 'c':
printf(" - Create AVRCP connection to addr %s.\n", bd_addr_to_str(device_addr));
avrcp_connect(device_addr);
break;
case 'D':
printf(" - Disconnect\n");
avrcp_disconnect(avrcp_con_handle);
break;
case 'i':
avrcp_unit_info(con_handle);
printf(" - get play status\n");
avrcp_get_play_status(avrcp_con_handle);
break;
case 'e':
avrcp_get_supported_events(con_handle);
break;
case 'l':
avrcp_play(con_handle);
break;
case 's':
avrcp_stop(con_handle);
break;
case 'p':
avrcp_pause(con_handle);
break;
case 'w':
avrcp_start_fast_forward(con_handle);
break;
case 'W':
avrcp_stop_fast_forward(con_handle);
break;
case 'r':
avrcp_start_rewind(con_handle);
break;
case 'R':
avrcp_stop_rewind(con_handle);
break;
case 'f':
avrcp_forward(con_handle);
break;
case 'b':
avrcp_backward(con_handle);
break;
case 'S':
avrcp_get_play_status(con_handle);
break;
case 'n':
avrcp_enable_notification(con_handle, AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED);
avrcp_enable_notification(con_handle, AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED);
break;
case 'N':
avrcp_disable_notification(con_handle, AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED);
avrcp_disable_notification(con_handle, AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED);
break;
case 'I':
avrcp_get_now_playing_info(con_handle);
break;
case 'a':
avrcp_set_absolute_volume(con_handle, 50);
break;
case 'u':
avrcp_volume_up(con_handle);
break;
case 'd':
avrcp_start_volume_down(con_handle);
break;
case 'm':
avrcp_start_mute(con_handle);
case 'j':
printf(" - get now playing info\n");
avrcp_get_now_playing_info(avrcp_con_handle);
break;
case 'k':
avrcp_start_skip(con_handle);
printf(" - play\n");
avrcp_play(avrcp_con_handle);
break;
case 'q':
avrcp_query_shuffle_and_repeat_modes(con_handle);
case 'K':
printf(" - stop\n");
avrcp_stop(avrcp_con_handle);
break;
case 'L':
printf(" - pause\n");
avrcp_pause(avrcp_con_handle);
break;
case 'm':
printf(" - start fast forward\n");
avrcp_start_fast_forward(avrcp_con_handle);
break;
case 'M':
printf(" - stop fast forward\n");
avrcp_stop_fast_forward(avrcp_con_handle);
break;
case 'n':
printf(" - start rewind\n");
avrcp_start_rewind(avrcp_con_handle);
break;
case 'N':
printf(" - stop rewind\n");
avrcp_stop_rewind(avrcp_con_handle);
break;
case 'o':
printf(" - forward\n");
avrcp_forward(avrcp_con_handle);
break;
case 'O':
printf(" - backward\n");
avrcp_backward(avrcp_con_handle);
break;
case 'p':
printf(" - volume up\n");
avrcp_volume_up(avrcp_con_handle);
break;
case 'P':
printf(" - volume down\n");
avrcp_volume_down(avrcp_con_handle);
break;
case 'r':
printf(" - absolute volume of 50 percent\n");
avrcp_set_absolute_volume(avrcp_con_handle, 50);
break;
case 's':
printf(" - mute\n");
avrcp_mute(avrcp_con_handle);
break;
case 't':
printf(" - skip\n");
avrcp_skip(avrcp_con_handle);
break;
case 'u':
printf(" - query repeat and shuffle mode\n");
avrcp_query_shuffle_and_repeat_modes(avrcp_con_handle);
break;
case 'v':
printf(" - repeat single track\n");
avrcp_set_repeat_mode(avrcp_con_handle, AVRCP_REPEAT_MODE_SINGLE_TRACK);
break;
case 'x':
avrcp_set_repeat_mode(con_handle, AVRCP_REPEAT_MODE_SINGLE_TRACK);
printf(" - repeat all tracks\n");
avrcp_set_repeat_mode(avrcp_con_handle, AVRCP_REPEAT_MODE_ALL_TRACKS);
break;
case 'X':
avrcp_set_repeat_mode(con_handle, AVRCP_REPEAT_MODE_OFF);
printf(" - disable repeat mode\n");
avrcp_set_repeat_mode(avrcp_con_handle, AVRCP_REPEAT_MODE_OFF);
break;
case 'y':
avrcp_set_shuffle_mode(con_handle, AVRCP_SHUFFLE_MODE_ALL_TRACKS);
case 'z':
printf(" - shuffle all tracks\n");
avrcp_set_shuffle_mode(avrcp_con_handle, AVRCP_SHUFFLE_MODE_ALL_TRACKS);
break;
case 'Y':
avrcp_set_shuffle_mode(con_handle, AVRCP_SHUFFLE_MODE_OFF);
case 'Z':
printf(" - disable shuffle mode\n");
avrcp_set_shuffle_mode(avrcp_con_handle, AVRCP_SHUFFLE_MODE_OFF);
break;
default:
show_usage();
break;
}
}
@ -281,7 +351,7 @@ int btstack_main(int argc, const char * argv[]);
int btstack_main(int argc, const char * argv[]){
UNUSED(argc);
(void)argv;
avrcp_con_handle = 0;
/* Register for HCI events */
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);