mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
avrcp browsing: move decline incoming connection to avrcp API
This commit is contained in:
parent
a634435223
commit
f9294da585
@ -387,7 +387,7 @@ static void avrcp_browsing_packet_handler(uint8_t packet_type, uint16_t channel,
|
||||
printf("AVRCP_SUBEVENT_INCOMING_BROWSING_CONNECTION cid 0x%02x\n", local_cid);
|
||||
if (browsing_cid != 0 && browsing_cid != local_cid) {
|
||||
printf("AVRCP Browsing Client connection failed, expected 0x%02X l2cap cid, received 0x%02X\n", browsing_cid, local_cid);
|
||||
avrcp_browsing_controller_decline_incoming_connection(browsing_cid);
|
||||
avrcp_browsing_decline_incoming_connection(browsing_cid);
|
||||
return;
|
||||
}
|
||||
browsing_cid = local_cid;
|
||||
|
@ -1273,12 +1273,10 @@ uint8_t avrcp_browsing_configure_incoming_connection(uint16_t avrcp_browsing_cid
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
if (!connection_controller->browsing_connection){
|
||||
log_error("avrcp_browsing_configure_incoming_connection: browsing connection in a wrong state.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
|
||||
if (connection_controller->browsing_connection->state != AVCTP_CONNECTION_W4_ERTM_CONFIGURATION){
|
||||
log_error("avrcp_browsing_configure_incoming_connection: browsing connection in a wrong state.");
|
||||
return ERROR_CODE_COMMAND_DISALLOWED;
|
||||
}
|
||||
|
||||
@ -1295,10 +1293,39 @@ uint8_t avrcp_browsing_configure_incoming_connection(uint16_t avrcp_browsing_cid
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
uint8_t avrcp_browsing_decline_incoming_connection(uint16_t avrcp_browsing_cid){
|
||||
avrcp_connection_t * connection_controller = get_avrcp_connection_for_browsing_cid_for_role(AVRCP_CONTROLLER, avrcp_browsing_cid);
|
||||
if (!connection_controller){
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
avrcp_connection_t * connection_target = get_avrcp_connection_for_browsing_cid_for_role(AVRCP_TARGET, avrcp_browsing_cid);
|
||||
if (!connection_target){
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
|
||||
if (!connection_controller->browsing_connection){
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
if (!connection_controller->browsing_connection){
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
|
||||
if (connection_controller->browsing_connection->state != AVCTP_CONNECTION_W4_ERTM_CONFIGURATION){
|
||||
return ERROR_CODE_COMMAND_DISALLOWED;
|
||||
}
|
||||
|
||||
l2cap_decline_connection(connection_controller->browsing_connection->l2cap_browsing_cid);
|
||||
|
||||
avrcp_browsing_finalize_connection(connection_controller);
|
||||
avrcp_browsing_finalize_connection(connection_target);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t avrcp_browsing_disconnect(uint16_t avrcp_browsing_cid, avrcp_role_t avrcp_role){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid_for_role(avrcp_role, avrcp_browsing_cid);
|
||||
if (!avrcp_connection){
|
||||
log_error("avrcp_browsing_controller_disconnect: could not find a connection.");
|
||||
log_error("Could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
if (avrcp_connection->browsing_connection->state != AVCTP_CONNECTION_OPENED) return ERROR_CODE_COMMAND_DISALLOWED;
|
||||
|
@ -623,7 +623,7 @@ void avrcp_browsing_register_packet_handler(btstack_packet_handler_t callback);
|
||||
uint8_t avrcp_browsing_connect(bd_addr_t remote_addr, uint8_t * ertm_buffer, uint32_t ertm_buffer_size, l2cap_ertm_config_t * ertm_config, uint16_t * avrcp_browsing_cid);
|
||||
|
||||
/**
|
||||
* @brief Configure incoming connection.
|
||||
* @brief Configure incoming connection for Browsing Service.
|
||||
* @param avrcp_browsing_cid
|
||||
* @param ertm_buffer
|
||||
* @param ertm_buffer_size
|
||||
@ -632,6 +632,13 @@ uint8_t avrcp_browsing_connect(bd_addr_t remote_addr, uint8_t * ertm_buffer, uin
|
||||
*/
|
||||
uint8_t avrcp_browsing_configure_incoming_connection(uint16_t avrcp_browsing_cid, uint8_t * ertm_buffer, uint32_t ertm_buffer_size, l2cap_ertm_config_t * ertm_config);
|
||||
|
||||
/**
|
||||
* @brief Decline incoming connection Browsing Service.
|
||||
* @param avrcp_browsing_cid
|
||||
* @returns status
|
||||
*/
|
||||
uint8_t avrcp_browsing_decline_incoming_connection(uint16_t avrcp_browsing_cid);
|
||||
|
||||
/**
|
||||
* @brief Disconnect from AVRCP Browsing service
|
||||
* @param avrcp_browsing_cid
|
||||
|
@ -519,23 +519,6 @@ uint8_t avrcp_browsing_controller_disconnect(uint16_t avrcp_browsing_cid){
|
||||
return avrcp_browsing_disconnect(avrcp_browsing_cid, AVRCP_CONTROLLER);
|
||||
}
|
||||
|
||||
|
||||
uint8_t avrcp_browsing_controller_decline_incoming_connection(uint16_t avrcp_browsing_cid){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid_for_role(AVRCP_CONTROLLER, 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;
|
||||
}
|
||||
if (!avrcp_connection->browsing_connection) return ERROR_CODE_SUCCESS;
|
||||
if (avrcp_connection->browsing_connection->state > AVCTP_CONNECTION_W4_ERTM_CONFIGURATION) return ERROR_CODE_COMMAND_DISALLOWED;
|
||||
|
||||
l2cap_decline_connection(avrcp_connection->browsing_connection->l2cap_browsing_cid);
|
||||
// free connection
|
||||
btstack_memory_avrcp_browsing_connection_free(avrcp_connection->browsing_connection);
|
||||
avrcp_connection->browsing_connection = NULL;
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
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_for_role(AVRCP_CONTROLLER, avrcp_browsing_cid);
|
||||
if (!avrcp_connection){
|
||||
|
@ -109,13 +109,6 @@ void avrcp_browsing_controller_init(void);
|
||||
*/
|
||||
void avrcp_browsing_controller_register_packet_handler(btstack_packet_handler_t callback);
|
||||
|
||||
/**
|
||||
* @brief Decline incoming connection.
|
||||
* @param avrcp_browsing_cid
|
||||
* @returns status
|
||||
*/
|
||||
uint8_t avrcp_browsing_controller_decline_incoming_connection(uint16_t avrcp_browsing_cid);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Disconnect from AVRCP target
|
||||
|
@ -216,22 +216,6 @@ uint8_t avrcp_browsing_target_disconnect(uint16_t avrcp_browsing_cid){
|
||||
return avrcp_browsing_disconnect(avrcp_browsing_cid, AVRCP_TARGET);
|
||||
}
|
||||
|
||||
uint8_t avrcp_browsing_target_decline_incoming_connection(uint16_t avrcp_browsing_cid){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid_for_role(AVRCP_TARGET, avrcp_browsing_cid);
|
||||
if (!avrcp_connection){
|
||||
log_error("avrcp_browsing_decline_incoming_connection: could not find a connection.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
if (!avrcp_connection->browsing_connection) return ERROR_CODE_SUCCESS;
|
||||
if (avrcp_connection->browsing_connection->state > AVCTP_CONNECTION_W4_ERTM_CONFIGURATION) return ERROR_CODE_COMMAND_DISALLOWED;
|
||||
|
||||
l2cap_decline_connection(avrcp_connection->browsing_connection->l2cap_browsing_cid);
|
||||
// free connection
|
||||
btstack_memory_avrcp_browsing_connection_free(avrcp_connection->browsing_connection);
|
||||
avrcp_connection->browsing_connection = NULL;
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t avrcp_subevent_browsing_get_folder_items_response(uint16_t avrcp_browsing_cid, uint16_t uid_counter, uint8_t * attr_list, uint16_t attr_list_size){
|
||||
avrcp_connection_t * avrcp_connection = get_avrcp_connection_for_browsing_cid_for_role(AVRCP_TARGET, avrcp_browsing_cid);
|
||||
if (!avrcp_connection){
|
||||
|
@ -66,14 +66,6 @@ void avrcp_browsing_target_init(void);
|
||||
*/
|
||||
void avrcp_browsing_target_register_packet_handler(btstack_packet_handler_t callback);
|
||||
|
||||
/**
|
||||
* @brief Decline incoming connection.
|
||||
* @param avrcp_browsing_cid
|
||||
* @returns status
|
||||
*/
|
||||
uint8_t avrcp_browsing_target_decline_incoming_connection(uint16_t avrcp_browsing_cid);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Disconnect from AVRCP target
|
||||
* @param avrcp_browsing_cid
|
||||
|
Loading…
x
Reference in New Issue
Block a user