mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-01 04:20:33 +00:00
avrcp: remove connections from context, use one list of connections in avrcp. connection lookup is not yet extended to check the role
This commit is contained in:
parent
4590ebd9c1
commit
638481ded5
@ -60,6 +60,7 @@ static avrcp_context_t * sdp_query_context;
|
||||
static uint8_t attribute_value[1000];
|
||||
static const unsigned int attribute_value_buffer_size = sizeof(attribute_value);
|
||||
|
||||
static btstack_linked_list_t connections;
|
||||
|
||||
static const char * avrcp_subunit_type_name[] = {
|
||||
"MONITOR", "AUDIO", "PRINTER", "DISC", "TAPE_RECORDER_PLAYER", "TUNER",
|
||||
@ -287,9 +288,9 @@ void avrcp_create_sdp_record(uint8_t controller, uint8_t * service, uint32_t ser
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, supported_features);
|
||||
}
|
||||
|
||||
avrcp_connection_t * get_avrcp_connection_for_bd_addr(bd_addr_t addr, avrcp_context_t * context){
|
||||
avrcp_connection_t * get_avrcp_connection_for_bd_addr(bd_addr_t addr){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, (btstack_linked_list_t *) &context->connections);
|
||||
btstack_linked_list_iterator_init(&it, (btstack_linked_list_t *) &connections);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
avrcp_connection_t * connection = (avrcp_connection_t *)btstack_linked_list_iterator_next(&it);
|
||||
if (memcmp(addr, connection->remote_addr, 6) != 0) continue;
|
||||
@ -298,9 +299,9 @@ avrcp_connection_t * get_avrcp_connection_for_bd_addr(bd_addr_t addr, avrcp_cont
|
||||
return NULL;
|
||||
}
|
||||
|
||||
avrcp_connection_t * get_avrcp_connection_for_l2cap_signaling_cid(uint16_t l2cap_cid, avrcp_context_t * context){
|
||||
avrcp_connection_t * get_avrcp_connection_for_l2cap_signaling_cid(uint16_t l2cap_cid){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, (btstack_linked_list_t *) &context->connections);
|
||||
btstack_linked_list_iterator_init(&it, (btstack_linked_list_t *) &connections);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
avrcp_connection_t * connection = (avrcp_connection_t *)btstack_linked_list_iterator_next(&it);
|
||||
if (connection->l2cap_signaling_cid != l2cap_cid) continue;
|
||||
@ -309,9 +310,9 @@ avrcp_connection_t * get_avrcp_connection_for_l2cap_signaling_cid(uint16_t l2cap
|
||||
return NULL;
|
||||
}
|
||||
|
||||
avrcp_connection_t * get_avrcp_connection_for_avrcp_cid(uint16_t avrcp_cid, avrcp_context_t * context){
|
||||
avrcp_connection_t * get_avrcp_connection_for_avrcp_cid(uint16_t avrcp_cid){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, (btstack_linked_list_t *) &context->connections);
|
||||
btstack_linked_list_iterator_init(&it, (btstack_linked_list_t *) &connections);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
avrcp_connection_t * connection = (avrcp_connection_t *)btstack_linked_list_iterator_next(&it);
|
||||
if (connection->avrcp_cid != avrcp_cid) continue;
|
||||
@ -320,6 +321,38 @@ avrcp_connection_t * get_avrcp_connection_for_avrcp_cid(uint16_t avrcp_cid, avrc
|
||||
return NULL;
|
||||
}
|
||||
|
||||
avrcp_connection_t * get_avrcp_connection_for_browsing_cid(uint16_t browsing_cid){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, (btstack_linked_list_t *) &connections);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
avrcp_connection_t * connection = (avrcp_connection_t *)btstack_linked_list_iterator_next(&it);
|
||||
if (connection->avrcp_browsing_cid != browsing_cid) continue;
|
||||
return connection;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
avrcp_connection_t * get_avrcp_connection_for_browsing_l2cap_cid(uint16_t browsing_l2cap_cid){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, (btstack_linked_list_t *) &connections);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
avrcp_connection_t * connection = (avrcp_connection_t *)btstack_linked_list_iterator_next(&it);
|
||||
if (connection->browsing_connection && connection->browsing_connection->l2cap_browsing_cid != browsing_l2cap_cid) continue;
|
||||
return connection;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
avrcp_browsing_connection_t * get_avrcp_browsing_connection_for_l2cap_cid(uint16_t l2cap_cid){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, (btstack_linked_list_t *) &connections);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
avrcp_connection_t * connection = (avrcp_connection_t *)btstack_linked_list_iterator_next(&it);
|
||||
if (connection->browsing_connection && connection->browsing_connection->l2cap_browsing_cid != l2cap_cid) continue;
|
||||
return connection->browsing_connection;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void avrcp_request_can_send_now(avrcp_connection_t * connection, uint16_t l2cap_cid){
|
||||
connection->wait_to_send = 1;
|
||||
l2cap_request_can_send_now_event(l2cap_cid);
|
||||
@ -334,7 +367,7 @@ uint16_t avrcp_get_next_cid(void){
|
||||
return avrcp_cid_counter;
|
||||
}
|
||||
|
||||
static avrcp_connection_t * avrcp_create_connection(avrcp_role_t role, bd_addr_t remote_addr, avrcp_context_t * context){
|
||||
static avrcp_connection_t * avrcp_create_connection(avrcp_role_t role, bd_addr_t remote_addr){
|
||||
avrcp_connection_t * connection = btstack_memory_avrcp_connection_get();
|
||||
if (!connection){
|
||||
log_error("avrcp: not enough memory to create connection");
|
||||
@ -346,12 +379,12 @@ static avrcp_connection_t * avrcp_create_connection(avrcp_role_t role, bd_addr_t
|
||||
connection->max_num_fragments = 0xFF;
|
||||
connection->avrcp_cid = avrcp_get_next_cid();
|
||||
memcpy(connection->remote_addr, remote_addr, 6);
|
||||
btstack_linked_list_add(&context->connections, (btstack_linked_item_t *) connection);
|
||||
btstack_linked_list_add(&connections, (btstack_linked_item_t *) connection);
|
||||
return connection;
|
||||
}
|
||||
|
||||
static void avrcp_finalize_connection(avrcp_connection_t * connection, avrcp_context_t * context){
|
||||
btstack_linked_list_remove(&context->connections, (btstack_linked_item_t*) connection);
|
||||
static void avrcp_finalize_connection(avrcp_connection_t * connection){
|
||||
btstack_linked_list_remove(&connections, (btstack_linked_item_t*) connection);
|
||||
btstack_memory_avrcp_connection_free(connection);
|
||||
}
|
||||
|
||||
@ -383,7 +416,7 @@ void avrcp_emit_connection_closed(btstack_packet_handler_t callback, uint16_t av
|
||||
}
|
||||
|
||||
void avrcp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(sdp_query_context->avrcp_cid, sdp_query_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(sdp_query_context->avrcp_cid);
|
||||
if (!connection) return;
|
||||
if (connection->state != AVCTP_CONNECTION_W4_SDP_QUERY_COMPLETE) return;
|
||||
|
||||
@ -524,7 +557,7 @@ void avrcp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel,
|
||||
if (status != ERROR_CODE_SUCCESS){
|
||||
log_info("AVRCP: SDP query failed with status 0x%02x.", status);
|
||||
avrcp_emit_connection_established(sdp_query_context->avrcp_callback, connection->avrcp_cid, connection->remote_addr, status);
|
||||
avrcp_finalize_connection(connection, sdp_query_context);
|
||||
avrcp_finalize_connection(connection);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -532,7 +565,7 @@ void avrcp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel,
|
||||
connection->state = AVCTP_CONNECTION_IDLE;
|
||||
log_info("AVRCP: no suitable service found");
|
||||
avrcp_emit_connection_established(sdp_query_context->avrcp_callback, connection->avrcp_cid, connection->remote_addr, SDP_SERVICE_NOT_FOUND);
|
||||
avrcp_finalize_connection(connection, sdp_query_context);
|
||||
avrcp_finalize_connection(connection);
|
||||
break;
|
||||
}
|
||||
connection->state = AVCTP_CONNECTION_W4_L2CAP_CONNECTED;
|
||||
@ -560,7 +593,7 @@ void avrcp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
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 = avrcp_create_connection(context->role, event_addr, context);
|
||||
connection = avrcp_create_connection(context->role, event_addr);
|
||||
if (!connection) {
|
||||
log_error("Failed to alloc connection structure");
|
||||
l2cap_decline_connection(local_cid);
|
||||
@ -586,7 +619,7 @@ void avrcp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
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);
|
||||
connection = get_avrcp_connection_for_bd_addr(event_addr);
|
||||
if (!connection){
|
||||
// TODO: validate if this cannot happen. If not, drop disconnect call
|
||||
log_error("AVRCP connection lookup failed");
|
||||
@ -596,7 +629,7 @@ void avrcp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
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(context->avrcp_callback, connection->avrcp_cid, event_addr, status);
|
||||
avrcp_finalize_connection(connection, context);
|
||||
avrcp_finalize_connection(connection);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -617,10 +650,10 @@ void avrcp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
case L2CAP_EVENT_CHANNEL_CLOSED:
|
||||
// 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, context);
|
||||
connection = get_avrcp_connection_for_l2cap_signaling_cid(local_cid);
|
||||
if (connection){
|
||||
avrcp_emit_connection_closed(context->avrcp_callback, connection->avrcp_cid);
|
||||
avrcp_finalize_connection(connection, context);
|
||||
avrcp_finalize_connection(connection);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -630,12 +663,12 @@ void avrcp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
}
|
||||
|
||||
uint8_t avrcp_connect(avrcp_role_t role, bd_addr_t bd_addr, avrcp_context_t * context, uint16_t * avrcp_cid){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_bd_addr(bd_addr, context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_bd_addr(bd_addr);
|
||||
if (connection) return ERROR_CODE_COMMAND_DISALLOWED;
|
||||
|
||||
if (!sdp_client_ready()) return ERROR_CODE_COMMAND_DISALLOWED;
|
||||
|
||||
connection = avrcp_create_connection(role, bd_addr, context);
|
||||
connection = avrcp_create_connection(role, bd_addr);
|
||||
if (!connection){
|
||||
log_error("avrcp: could not allocate connection struct.");
|
||||
return BTSTACK_MEMORY_ALLOC_FAILED;
|
||||
@ -655,3 +688,7 @@ uint8_t avrcp_connect(avrcp_role_t role, bd_addr_t bd_addr, avrcp_context_t * co
|
||||
sdp_client_query_uuid16(&avrcp_handle_sdp_client_query_result, connection->remote_addr, BLUETOOTH_PROTOCOL_AVCTP);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void avrcp_init(void){
|
||||
connections = NULL;
|
||||
}
|
||||
|
@ -510,7 +510,6 @@ typedef enum {
|
||||
|
||||
typedef struct {
|
||||
avrcp_role_t role;
|
||||
btstack_linked_list_t connections;
|
||||
btstack_packet_handler_t avrcp_callback;
|
||||
btstack_packet_handler_t packet_handler;
|
||||
|
||||
@ -535,6 +534,8 @@ const char * avrcp_ctype2str(uint8_t index);
|
||||
const char * avrcp_repeat2str(uint8_t index);
|
||||
const char * avrcp_shuffle2str(uint8_t index);
|
||||
|
||||
void avrcp_init(void);
|
||||
|
||||
void avrcp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size, avrcp_context_t * context);
|
||||
|
||||
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);
|
||||
@ -543,9 +544,15 @@ void avrcp_emit_connection_established(btstack_packet_handler_t callback, uint16
|
||||
void avrcp_emit_connection_closed(btstack_packet_handler_t callback, uint16_t avrcp_cid);
|
||||
|
||||
uint8_t avrcp_cmd_opcode(uint8_t *packet, uint16_t size);
|
||||
avrcp_connection_t * get_avrcp_connection_for_l2cap_signaling_cid(uint16_t l2cap_cid, avrcp_context_t * context);
|
||||
avrcp_connection_t * get_avrcp_connection_for_avrcp_cid(uint16_t avrcp_cid, avrcp_context_t * context);
|
||||
avrcp_connection_t * get_avrcp_connection_for_bd_addr(bd_addr_t addr, avrcp_context_t * context);
|
||||
|
||||
avrcp_connection_t * get_avrcp_connection_for_l2cap_signaling_cid(uint16_t l2cap_cid);
|
||||
avrcp_connection_t * get_avrcp_connection_for_avrcp_cid(uint16_t avrcp_cid);
|
||||
avrcp_connection_t * get_avrcp_connection_for_bd_addr(bd_addr_t addr);
|
||||
|
||||
avrcp_connection_t * get_avrcp_connection_for_browsing_cid(uint16_t browsing_cid);
|
||||
avrcp_connection_t * get_avrcp_connection_for_browsing_l2cap_cid(uint16_t browsing_l2cap_cid);
|
||||
avrcp_browsing_connection_t * get_avrcp_browsing_connection_for_l2cap_cid(uint16_t l2cap_cid);
|
||||
|
||||
void avrcp_request_can_send_now(avrcp_connection_t * connection, uint16_t l2cap_cid);
|
||||
uint16_t avrcp_get_next_cid(void);
|
||||
|
||||
|
@ -51,39 +51,6 @@
|
||||
static void avrcp_browser_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size, avrcp_context_t * context);
|
||||
static void avrcp_browsing_controller_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
|
||||
static avrcp_connection_t * get_avrcp_connection_for_browsing_cid(uint16_t browsing_cid, avrcp_context_t * context){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, (btstack_linked_list_t *) &context->connections);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
avrcp_connection_t * connection = (avrcp_connection_t *)btstack_linked_list_iterator_next(&it);
|
||||
if (connection->avrcp_browsing_cid != browsing_cid) continue;
|
||||
return connection;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static avrcp_connection_t * get_avrcp_connection_for_browsing_l2cap_cid(uint16_t browsing_l2cap_cid, avrcp_context_t * context){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, (btstack_linked_list_t *) &context->connections);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
avrcp_connection_t * connection = (avrcp_connection_t *)btstack_linked_list_iterator_next(&it);
|
||||
if (connection->browsing_connection && connection->browsing_connection->l2cap_browsing_cid != browsing_l2cap_cid) continue;
|
||||
return connection;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static avrcp_browsing_connection_t * get_avrcp_browsing_connection_for_l2cap_cid(uint16_t l2cap_cid, avrcp_context_t * context){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, (btstack_linked_list_t *) &context->connections);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
avrcp_connection_t * connection = (avrcp_connection_t *)btstack_linked_list_iterator_next(&it);
|
||||
if (connection->browsing_connection && connection->browsing_connection->l2cap_browsing_cid != l2cap_cid) continue;
|
||||
return connection->browsing_connection;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void avrcp_emit_browsing_connection_established(btstack_packet_handler_t callback, uint16_t browsing_cid, bd_addr_t addr, uint8_t status){
|
||||
if (!callback) return;
|
||||
uint8_t event[12];
|
||||
@ -134,8 +101,8 @@ static avrcp_browsing_connection_t * avrcp_browsing_create_connection(avrcp_conn
|
||||
return connection;
|
||||
}
|
||||
|
||||
static uint8_t avrcp_browsing_connect(bd_addr_t remote_addr, avrcp_context_t * context, uint8_t * ertm_buffer, uint32_t size, l2cap_ertm_config_t * ertm_config, uint16_t * browsing_cid){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_bd_addr(remote_addr, context);
|
||||
static uint8_t avrcp_browsing_connect(bd_addr_t remote_addr, uint8_t * ertm_buffer, uint32_t size, l2cap_ertm_config_t * ertm_config, uint16_t * browsing_cid){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_bd_addr(remote_addr);
|
||||
|
||||
if (!avrcp_connection){
|
||||
log_error("avrcp: there is no previously established AVRCP controller connection.");
|
||||
@ -187,7 +154,7 @@ static void avrcp_browser_packet_handler(uint8_t packet_type, uint16_t channel,
|
||||
case L2CAP_EVENT_INCOMING_CONNECTION:
|
||||
l2cap_event_incoming_connection_get_address(packet, event_addr);
|
||||
local_cid = l2cap_event_incoming_connection_get_local_cid(packet);
|
||||
avrcp_connection = get_avrcp_connection_for_bd_addr(event_addr, context);
|
||||
avrcp_connection = get_avrcp_connection_for_bd_addr(event_addr);
|
||||
if (!avrcp_connection) {
|
||||
log_error("No previously created AVRCP controller connections");
|
||||
l2cap_decline_connection(local_cid);
|
||||
@ -205,7 +172,7 @@ static void avrcp_browser_packet_handler(uint8_t packet_type, uint16_t channel,
|
||||
status = l2cap_event_channel_opened_get_status(packet);
|
||||
local_cid = l2cap_event_channel_opened_get_local_cid(packet);
|
||||
|
||||
avrcp_connection = get_avrcp_connection_for_bd_addr(event_addr, context);
|
||||
avrcp_connection = get_avrcp_connection_for_bd_addr(event_addr);
|
||||
if (!avrcp_connection){
|
||||
log_error("Failed to find AVRCP connection for bd_addr %s", bd_addr_to_str(event_addr));
|
||||
avrcp_emit_browsing_connection_established(context->browsing_avrcp_callback, local_cid, event_addr, L2CAP_LOCAL_CID_DOES_NOT_EXIST);
|
||||
@ -231,7 +198,7 @@ static void avrcp_browser_packet_handler(uint8_t packet_type, uint16_t channel,
|
||||
case L2CAP_EVENT_CHANNEL_CLOSED:
|
||||
// data: event (8), len(8), channel (16)
|
||||
local_cid = l2cap_event_channel_closed_get_local_cid(packet);
|
||||
avrcp_connection = get_avrcp_connection_for_browsing_l2cap_cid(local_cid, context);
|
||||
avrcp_connection = get_avrcp_connection_for_browsing_l2cap_cid(local_cid);
|
||||
|
||||
if (avrcp_connection && avrcp_connection->browsing_connection){
|
||||
avrcp_emit_browsing_connection_closed(context->browsing_avrcp_callback, avrcp_connection->avrcp_browsing_cid);
|
||||
@ -580,7 +547,7 @@ static void avrcp_browsing_controller_packet_handler(uint8_t packet_type, uint16
|
||||
|
||||
switch (packet_type) {
|
||||
case L2CAP_DATA_PACKET:{
|
||||
browsing_connection = get_avrcp_browsing_connection_for_l2cap_cid(channel, &avrcp_controller_context);
|
||||
browsing_connection = get_avrcp_browsing_connection_for_l2cap_cid(channel);
|
||||
if (!browsing_connection) break;
|
||||
// printf("received \n");
|
||||
// printf_hexdump(packet,size);
|
||||
@ -709,7 +676,7 @@ static void avrcp_browsing_controller_packet_handler(uint8_t packet_type, uint16
|
||||
case HCI_EVENT_PACKET:
|
||||
switch (hci_event_packet_get_type(packet)){
|
||||
case L2CAP_EVENT_CAN_SEND_NOW:
|
||||
browsing_connection = get_avrcp_browsing_connection_for_l2cap_cid(channel, &avrcp_controller_context);
|
||||
browsing_connection = get_avrcp_browsing_connection_for_l2cap_cid(channel);
|
||||
if (!browsing_connection) break;
|
||||
avrcp_browsing_controller_handle_can_send_now(browsing_connection);
|
||||
break;
|
||||
@ -738,11 +705,11 @@ void avrcp_browsing_controller_register_packet_handler(btstack_packet_handler_t
|
||||
}
|
||||
|
||||
uint8_t avrcp_browsing_controller_connect(bd_addr_t bd_addr, uint8_t * ertm_buffer, uint32_t size, l2cap_ertm_config_t * ertm_config, uint16_t * avrcp_browsing_cid){
|
||||
return avrcp_browsing_connect(bd_addr, &avrcp_controller_context, ertm_buffer, size, ertm_config, avrcp_browsing_cid);
|
||||
return avrcp_browsing_connect(bd_addr, ertm_buffer, size, ertm_config, avrcp_browsing_cid);
|
||||
}
|
||||
|
||||
uint8_t avrcp_browsing_controller_disconnect(uint16_t avrcp_browsing_cid){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid);
|
||||
if (!avrcp_connection){
|
||||
log_error("avrcp_browsing_controller_disconnect: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -754,7 +721,7 @@ uint8_t avrcp_browsing_controller_disconnect(uint16_t avrcp_browsing_cid){
|
||||
}
|
||||
|
||||
uint8_t avrcp_browsing_controller_configure_incoming_connection(uint16_t avrcp_browsing_cid, uint8_t * ertm_buffer, uint32_t size, l2cap_ertm_config_t * ertm_config){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid);
|
||||
if (!avrcp_connection){
|
||||
log_error("avrcp_browsing_controller_decline_incoming_connection: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -778,7 +745,7 @@ uint8_t avrcp_browsing_controller_configure_incoming_connection(uint16_t avrcp_b
|
||||
}
|
||||
|
||||
uint8_t avrcp_browsing_controller_decline_incoming_connection(uint16_t avrcp_browsing_cid){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid);
|
||||
if (!avrcp_connection){
|
||||
log_error("avrcp_browsing_controller_decline_incoming_connection: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -794,7 +761,7 @@ uint8_t avrcp_browsing_controller_decline_incoming_connection(uint16_t avrcp_bro
|
||||
}
|
||||
|
||||
uint8_t avrcp_browsing_controller_get_item_attributes_for_scope(uint16_t avrcp_browsing_cid, uint8_t * uid, uint16_t uid_counter, uint32_t attr_bitmap, avrcp_browsing_scope_t scope){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid);
|
||||
if (!avrcp_connection){
|
||||
log_error("avrcp_browsing_controller_get_item_attributes: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -824,7 +791,7 @@ uint8_t avrcp_browsing_controller_get_item_attributes_for_scope(uint16_t avrcp_b
|
||||
* @param attribute_list
|
||||
**/
|
||||
static uint8_t avrcp_browsing_controller_get_folder_items(uint16_t avrcp_browsing_cid, avrcp_browsing_scope_t scope, uint32_t start_item, uint32_t end_item, uint32_t attr_bitmap){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid);
|
||||
if (!avrcp_connection){
|
||||
log_error("avrcp_browsing_controller_disconnect: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -865,7 +832,7 @@ uint8_t avrcp_browsing_controller_browse_now_playing_list(uint16_t avrcp_browsin
|
||||
|
||||
|
||||
uint8_t avrcp_browsing_controller_set_browsed_player(uint16_t avrcp_browsing_cid, uint16_t browsed_player_id){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid);
|
||||
if (!avrcp_connection){
|
||||
log_error("avrcp_browsing_controller_change_path: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -889,7 +856,7 @@ uint8_t avrcp_browsing_controller_set_browsed_player(uint16_t avrcp_browsing_cid
|
||||
* @param folder_uid 8 bytes long
|
||||
**/
|
||||
uint8_t avrcp_browsing_controller_change_path(uint16_t avrcp_browsing_cid, uint8_t direction, uint8_t * folder_uid){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid);
|
||||
if (!avrcp_connection){
|
||||
log_error("avrcp_browsing_controller_change_path: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -926,7 +893,7 @@ uint8_t avrcp_browsing_controller_go_down_one_level(uint16_t avrcp_browsing_cid,
|
||||
}
|
||||
|
||||
uint8_t avrcp_browsing_controller_search(uint16_t avrcp_browsing_cid, uint16_t search_str_len, char * search_str){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid);
|
||||
if (!avrcp_connection){
|
||||
log_error("avrcp_browsing_controller_change_path: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -957,7 +924,7 @@ uint8_t avrcp_browsing_controller_search(uint16_t avrcp_browsing_cid, uint16_t s
|
||||
}
|
||||
|
||||
uint8_t avrcp_browsing_controller_get_total_nr_items_for_scope(uint16_t avrcp_browsing_cid, avrcp_browsing_scope_t scope){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid(avrcp_browsing_cid);
|
||||
if (!avrcp_connection){
|
||||
log_error("avrcp_browsing_controller_change_path: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
|
@ -120,8 +120,8 @@ static uint8_t request_pass_through_release_control_cmd(avrcp_connection_t * con
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static inline uint8_t request_pass_through_press_control_cmd(uint16_t avrcp_cid, avrcp_operation_id_t opid, uint16_t playback_speed, uint8_t continuous_fast_forward_cmd, avrcp_context_t * context){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, context);
|
||||
static inline uint8_t request_pass_through_press_control_cmd(uint16_t avrcp_cid, avrcp_operation_id_t opid, uint16_t playback_speed, uint8_t continuous_fast_forward_cmd){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -153,11 +153,11 @@ static inline uint8_t request_pass_through_press_control_cmd(uint16_t avrcp_cid,
|
||||
}
|
||||
|
||||
static uint8_t request_single_pass_through_press_control_cmd(uint16_t avrcp_cid, avrcp_operation_id_t opid, uint16_t playback_speed){
|
||||
return request_pass_through_press_control_cmd(avrcp_cid, opid, playback_speed, 0, &avrcp_controller_context);
|
||||
return request_pass_through_press_control_cmd(avrcp_cid, opid, playback_speed, 0);
|
||||
}
|
||||
|
||||
static uint8_t request_continuous_pass_through_press_control_cmd(uint16_t avrcp_cid, avrcp_operation_id_t opid, uint16_t playback_speed){
|
||||
return request_pass_through_press_control_cmd(avrcp_cid, opid, playback_speed, 1, &avrcp_controller_context);
|
||||
return request_pass_through_press_control_cmd(avrcp_cid, opid, playback_speed, 1);
|
||||
}
|
||||
|
||||
#define AVRCP_CMD_BUFFER_SIZE 30
|
||||
@ -907,14 +907,14 @@ static void avrcp_controller_packet_handler(uint8_t packet_type, uint16_t channe
|
||||
|
||||
switch (packet_type) {
|
||||
case L2CAP_DATA_PACKET:
|
||||
connection = get_avrcp_connection_for_l2cap_signaling_cid(channel, &avrcp_controller_context);
|
||||
connection = get_avrcp_connection_for_l2cap_signaling_cid(channel);
|
||||
if (!connection) break;
|
||||
avrcp_handle_l2cap_data_packet_for_signaling_connection(connection, packet, size);
|
||||
break;
|
||||
case HCI_EVENT_PACKET:
|
||||
switch (hci_event_packet_get_type(packet)){
|
||||
case L2CAP_EVENT_CAN_SEND_NOW:
|
||||
connection = get_avrcp_connection_for_l2cap_signaling_cid(channel, &avrcp_controller_context);
|
||||
connection = get_avrcp_connection_for_l2cap_signaling_cid(channel);
|
||||
if (!connection) break;
|
||||
avrcp_controller_handle_can_send_now(connection);
|
||||
break;
|
||||
@ -928,8 +928,8 @@ static void avrcp_controller_packet_handler(uint8_t packet_type, uint16_t channe
|
||||
}
|
||||
|
||||
void avrcp_controller_init(void){
|
||||
avrcp_init();
|
||||
avrcp_controller_context.role = AVRCP_CONTROLLER;
|
||||
avrcp_controller_context.connections = NULL;
|
||||
avrcp_controller_context.packet_handler = avrcp_controller_packet_handler;
|
||||
l2cap_register_service(&avrcp_controller_packet_handler, BLUETOOTH_PROTOCOL_AVCTP, 0xffff, LEVEL_2);
|
||||
}
|
||||
@ -947,7 +947,7 @@ uint8_t avrcp_controller_connect(bd_addr_t bd_addr, uint16_t * avrcp_cid){
|
||||
}
|
||||
|
||||
uint8_t avrcp_controller_unit_info(uint16_t avrcp_cid){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_unit_info: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -967,7 +967,7 @@ uint8_t avrcp_controller_unit_info(uint16_t avrcp_cid){
|
||||
}
|
||||
|
||||
uint8_t avrcp_controller_subunit_info(uint16_t avrcp_cid){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_unit_info: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -988,7 +988,7 @@ uint8_t avrcp_controller_subunit_info(uint16_t avrcp_cid){
|
||||
}
|
||||
|
||||
static uint8_t avrcp_controller_get_capabilities(uint16_t avrcp_cid, uint8_t capability_id){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_get_capabilities: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1068,7 +1068,7 @@ uint8_t avrcp_controller_rewind(uint16_t avrcp_cid){
|
||||
/* start cmds */
|
||||
|
||||
uint8_t avrcp_controller_release_press_and_hold_cmd(uint16_t avrcp_cid){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_stop_play: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1112,7 +1112,7 @@ uint8_t avrcp_controller_press_and_hold_mute(uint16_t avrcp_cid){
|
||||
/* stop continuous cmds */
|
||||
|
||||
uint8_t avrcp_controller_get_play_status(uint16_t avrcp_cid){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_get_play_status: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1134,7 +1134,7 @@ uint8_t avrcp_controller_get_play_status(uint16_t avrcp_cid){
|
||||
}
|
||||
|
||||
uint8_t avrcp_controller_enable_notification(uint16_t avrcp_cid, avrcp_notification_event_id_t event_id){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_get_play_status: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1144,7 +1144,7 @@ uint8_t avrcp_controller_enable_notification(uint16_t avrcp_cid, avrcp_notificat
|
||||
}
|
||||
|
||||
uint8_t avrcp_controller_disable_notification(uint16_t avrcp_cid, avrcp_notification_event_id_t event_id){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_get_play_status: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1154,7 +1154,7 @@ uint8_t avrcp_controller_disable_notification(uint16_t avrcp_cid, avrcp_notifica
|
||||
}
|
||||
|
||||
uint8_t avrcp_controller_set_addressed_player(uint16_t avrcp_cid, uint16_t addressed_player_id){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_get_capabilities: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1186,7 +1186,7 @@ uint8_t avrcp_controller_set_addressed_player(uint16_t avrcp_cid, uint16_t addre
|
||||
}
|
||||
|
||||
uint8_t avrcp_controller_get_now_playing_info(uint16_t avrcp_cid){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_get_capabilities: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1222,7 +1222,7 @@ uint8_t avrcp_controller_get_now_playing_info(uint16_t avrcp_cid){
|
||||
}
|
||||
|
||||
uint8_t avrcp_controller_set_absolute_volume(uint16_t avrcp_cid, uint8_t volume){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_get_capabilities: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1252,7 +1252,7 @@ uint8_t avrcp_controller_set_absolute_volume(uint16_t avrcp_cid, uint8_t volume)
|
||||
}
|
||||
|
||||
uint8_t avrcp_controller_query_shuffle_and_repeat_modes(uint16_t avrcp_cid){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_get_capabilities: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1281,7 +1281,7 @@ uint8_t avrcp_controller_query_shuffle_and_repeat_modes(uint16_t avrcp_cid){
|
||||
}
|
||||
|
||||
static uint8_t avrcp_controller_set_current_player_application_setting_value(uint16_t avrcp_cid, uint8_t attr_id, uint8_t attr_value){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_get_capabilities: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1322,7 +1322,7 @@ uint8_t avrcp_controller_set_repeat_mode(uint16_t avrcp_cid, avrcp_repeat_mode_t
|
||||
}
|
||||
|
||||
uint8_t avrcp_controller_disconnect(uint16_t avrcp_cid){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_get_capabilities: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1337,7 +1337,7 @@ uint8_t avrcp_controller_disconnect(uint16_t avrcp_cid){
|
||||
}
|
||||
|
||||
uint8_t avrcp_controller_play_item_for_scope(uint16_t avrcp_cid, uint8_t * uid, uint16_t uid_counter, avrcp_browsing_scope_t scope){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("Could not find a connection with cid 0%02x.", avrcp_cid);
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1377,7 +1377,7 @@ uint8_t avrcp_controller_play_item_for_scope(uint16_t avrcp_cid, uint8_t * uid,
|
||||
}
|
||||
|
||||
uint8_t avrcp_controller_add_item_from_scope_to_now_playing_list(uint16_t avrcp_cid, uint8_t * uid, uint16_t uid_counter, avrcp_browsing_scope_t scope){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("Could not find a connection with cid 0%02x.", avrcp_cid);
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1417,7 +1417,7 @@ uint8_t avrcp_controller_add_item_from_scope_to_now_playing_list(uint16_t avrcp_
|
||||
}
|
||||
|
||||
uint8_t avrcp_controller_set_max_num_fragments(uint16_t avrcp_cid, uint8_t max_num_fragments){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_controller_play_item: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1427,7 +1427,7 @@ uint8_t avrcp_controller_set_max_num_fragments(uint16_t avrcp_cid, uint8_t max_n
|
||||
}
|
||||
|
||||
uint8_t avrcp_controller_send_custom_command(uint16_t avrcp_cid, avrcp_command_type_t command_type, avrcp_subunit_type_t subunit_type, avrcp_subunit_id_t subunit_id, avrcp_command_opcode_t command_opcode, const uint8_t * command_buffer, uint16_t command_len){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_controller_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_controller_play_item: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
|
@ -449,7 +449,7 @@ static uint8_t avrcp_target_response_addressed_player_changed_interim(avrcp_conn
|
||||
// }
|
||||
|
||||
static uint8_t avrcp_target_pass_through_response(uint16_t avrcp_cid, avrcp_command_type_t cmd_type, avrcp_operation_id_t opid, uint8_t operands_length, uint8_t operand){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_target_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("Could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -485,7 +485,7 @@ uint8_t avrcp_target_operation_not_implemented(uint16_t avrcp_cid, avrcp_operati
|
||||
}
|
||||
|
||||
void avrcp_target_set_unit_info(uint16_t avrcp_cid, avrcp_subunit_type_t unit_type, uint32_t company_id){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_target_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_target_operation_reject: could not find a connection.");
|
||||
return;
|
||||
@ -495,7 +495,7 @@ void avrcp_target_set_unit_info(uint16_t avrcp_cid, avrcp_subunit_type_t unit_ty
|
||||
}
|
||||
|
||||
void avrcp_target_set_subunit_info(uint16_t avrcp_cid, avrcp_subunit_type_t subunit_type, const uint8_t * subunit_info_data, uint16_t subunit_info_data_size){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_target_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_target_operation_reject: could not find a connection.");
|
||||
return;
|
||||
@ -549,7 +549,7 @@ static uint8_t avrcp_target_subunit_info(avrcp_connection_t * connection, uint8_
|
||||
}
|
||||
|
||||
static inline uint8_t avrcp_prepare_vendor_dependent_response(uint16_t avrcp_cid, avrcp_connection_t ** out_connection, avrcp_pdu_id_t pdu_id, uint16_t param_length){
|
||||
*out_connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_target_context);
|
||||
*out_connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!*out_connection){
|
||||
log_error("avrcp tartget: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -632,7 +632,7 @@ static uint8_t avrcp_target_store_media_attr(avrcp_connection_t * connection, av
|
||||
}
|
||||
|
||||
uint8_t avrcp_target_set_playback_status(uint16_t avrcp_cid, avrcp_playback_status_t playback_status){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_target_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_unit_info: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -646,7 +646,7 @@ uint8_t avrcp_target_set_playback_status(uint16_t avrcp_cid, avrcp_playback_stat
|
||||
}
|
||||
|
||||
void avrcp_target_set_now_playing_info(uint16_t avrcp_cid, const avrcp_track_t * current_track, uint16_t total_tracks){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_target_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_unit_info: could not find a connection. cid 0x%02x\n", avrcp_cid);
|
||||
return;
|
||||
@ -674,7 +674,7 @@ void avrcp_target_set_now_playing_info(uint16_t avrcp_cid, const avrcp_track_t *
|
||||
}
|
||||
|
||||
uint8_t avrcp_target_track_changed(uint16_t avrcp_cid, uint8_t * track_id){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_target_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_target_track_changed: could not find connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -690,7 +690,7 @@ uint8_t avrcp_target_track_changed(uint16_t avrcp_cid, uint8_t * track_id){
|
||||
}
|
||||
|
||||
uint8_t avrcp_target_playing_content_changed(uint16_t avrcp_cid){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_target_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_target_playing_content_changed: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -703,7 +703,7 @@ uint8_t avrcp_target_playing_content_changed(uint16_t avrcp_cid){
|
||||
}
|
||||
|
||||
uint8_t avrcp_target_addressed_player_changed(uint16_t avrcp_cid, uint16_t player_id, uint16_t uid_counter){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_target_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_unit_info: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -719,7 +719,7 @@ uint8_t avrcp_target_addressed_player_changed(uint16_t avrcp_cid, uint16_t playe
|
||||
}
|
||||
|
||||
uint8_t avrcp_target_battery_status_changed(uint16_t avrcp_cid, avrcp_battery_status_t battery_status){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_target_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_unit_info: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -734,7 +734,7 @@ uint8_t avrcp_target_battery_status_changed(uint16_t avrcp_cid, avrcp_battery_st
|
||||
}
|
||||
|
||||
uint8_t avrcp_target_volume_changed(uint16_t avrcp_cid, uint8_t volume_percentage){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_target_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_unit_info: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -1126,14 +1126,14 @@ static void avrcp_target_packet_handler(uint8_t packet_type, uint16_t channel, u
|
||||
avrcp_connection_t * connection;
|
||||
switch (packet_type) {
|
||||
case L2CAP_DATA_PACKET:
|
||||
connection = get_avrcp_connection_for_l2cap_signaling_cid(channel, &avrcp_target_context);
|
||||
connection = get_avrcp_connection_for_l2cap_signaling_cid(channel);
|
||||
if (!connection) break;
|
||||
avrcp_handle_l2cap_data_packet_for_signaling_connection(connection, packet, size);
|
||||
break;
|
||||
case HCI_EVENT_PACKET:
|
||||
switch (hci_event_packet_get_type(packet)){
|
||||
case L2CAP_EVENT_CAN_SEND_NOW:{
|
||||
connection = get_avrcp_connection_for_l2cap_signaling_cid(channel, &avrcp_target_context);
|
||||
connection = get_avrcp_connection_for_l2cap_signaling_cid(channel);
|
||||
if (!connection) {
|
||||
log_error("Connection not found\n");
|
||||
break;
|
||||
@ -1239,8 +1239,8 @@ static void avrcp_target_packet_handler(uint8_t packet_type, uint16_t channel, u
|
||||
}
|
||||
|
||||
void avrcp_target_init(void){
|
||||
avrcp_init();
|
||||
avrcp_target_context.role = AVRCP_TARGET;
|
||||
avrcp_target_context.connections = NULL;
|
||||
avrcp_target_context.packet_handler = avrcp_target_packet_handler;
|
||||
l2cap_register_service(&avrcp_target_packet_handler, BLUETOOTH_PROTOCOL_AVCTP, 0xffff, LEVEL_2);
|
||||
}
|
||||
@ -1258,7 +1258,7 @@ uint8_t avrcp_target_connect(bd_addr_t bd_addr, uint16_t * avrcp_cid){
|
||||
}
|
||||
|
||||
uint8_t avrcp_target_disconnect(uint16_t avrcp_cid){
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid, &avrcp_target_context);
|
||||
avrcp_connection_t * connection = get_avrcp_connection_for_avrcp_cid(avrcp_cid);
|
||||
if (!connection){
|
||||
log_error("avrcp_get_capabilities: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
|
Loading…
x
Reference in New Issue
Block a user