mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
avrcp browsing: move avrcp_browsing_disconnect to public avrcp.h API
This commit is contained in:
parent
b99ca858cd
commit
ace5ab2a3d
@ -87,13 +87,13 @@ static bd_addr_t device_addr;
|
||||
#endif
|
||||
|
||||
static uint16_t avrcp_cid = 0;
|
||||
static uint8_t avrcp_connected = 0;
|
||||
static bool avrcp_connected = false;
|
||||
|
||||
static uint16_t browsing_cid = 0;
|
||||
static uint8_t avrcp_browsing_connected = 0;
|
||||
static uint8_t sdp_avrcp_browsing_controller_service_buffer[200];
|
||||
|
||||
static uint8_t browsing_query_active = 0;
|
||||
static bool browsing_query_active = false;
|
||||
static avrcp_media_item_context_t media_item_context;
|
||||
|
||||
typedef struct {
|
||||
@ -252,7 +252,7 @@ static void avrcp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t
|
||||
}
|
||||
|
||||
avrcp_cid = local_cid;
|
||||
avrcp_connected = 1;
|
||||
avrcp_connected = true;
|
||||
avrcp_subevent_connection_established_get_bd_addr(packet, adress);
|
||||
printf("AVRCP: Connected to %s, cid 0x%02x\n", bd_addr_to_str(adress), avrcp_cid);
|
||||
return;
|
||||
@ -261,7 +261,7 @@ static void avrcp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t
|
||||
case AVRCP_SUBEVENT_CONNECTION_RELEASED:
|
||||
printf("AVRCP: Channel released: cid 0x%02x\n", avrcp_subevent_connection_released_get_avrcp_cid(packet));
|
||||
avrcp_cid = 0;
|
||||
avrcp_connected = 0;
|
||||
avrcp_connected = false;
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
@ -274,7 +274,7 @@ static void avrcp_browsing_controller_packet_handler(uint8_t packet_type, uint16
|
||||
switch(packet_type){
|
||||
case AVRCP_BROWSING_DATA_PACKET:
|
||||
pos = 0;
|
||||
browsing_query_active = 1;
|
||||
browsing_query_active = true;
|
||||
avrcp_browsing_item_type_t data_type = (avrcp_browsing_item_type_t)packet[pos++];
|
||||
pos += 2; // length
|
||||
|
||||
@ -419,7 +419,7 @@ static void avrcp_browsing_controller_packet_handler(uint8_t packet_type, uint16
|
||||
return;
|
||||
|
||||
case AVRCP_SUBEVENT_BROWSING_DONE:
|
||||
browsing_query_active = 0;
|
||||
browsing_query_active = false;
|
||||
browsing_uid_counter = 0;
|
||||
if (avrcp_subevent_browsing_done_get_browsing_status(packet) != AVRCP_BROWSING_ERROR_CODE_SUCCESS){
|
||||
printf("AVRCP Browsing query done with browsing status 0x%02x, bluetooth status 0x%02x.\n",
|
||||
|
@ -976,4 +976,16 @@ uint8_t avrcp_browsing_connect(bd_addr_t remote_addr, avrcp_role_t avrcp_role, b
|
||||
return l2cap_create_ertm_channel(avrcp_browsing_packet_handler, remote_addr, avrcp_connection->browsing_l2cap_psm,
|
||||
&connection->ertm_config, connection->ertm_buffer, connection->ertm_buffer_size, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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.");
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
if (avrcp_connection->browsing_connection->state != AVCTP_CONNECTION_OPENED) return ERROR_CODE_COMMAND_DISALLOWED;
|
||||
|
||||
l2cap_disconnect(avrcp_connection->browsing_connection->l2cap_browsing_cid, 0);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -611,6 +611,14 @@ uint8_t avrcp_disconnect(uint16_t avrcp_cid);
|
||||
*/
|
||||
uint8_t avrcp_browsing_connect(bd_addr_t remote_addr, avrcp_role_t avrcp_role, btstack_packet_handler_t avrcp_browsing_packet_handler, uint8_t * ertm_buffer, uint32_t ertm_buffer_size, l2cap_ertm_config_t * ertm_config, uint16_t * avrcp_browsing_cid);
|
||||
|
||||
/**
|
||||
* @brief Disconnect from AVRCP Browsing service
|
||||
* @param avrcp_browsing_cid
|
||||
* @param avrcp_role
|
||||
* @returns status
|
||||
*/
|
||||
uint8_t avrcp_browsing_disconnect(uint16_t avrcp_browsing_cid, avrcp_role_t avrcp_role);
|
||||
|
||||
/* API_END */
|
||||
|
||||
avrcp_browsing_connection_t * avrcp_browsing_create_connection(avrcp_connection_t * avrcp_connection);
|
||||
|
@ -645,15 +645,7 @@ uint8_t avrcp_browsing_controller_connect(bd_addr_t bd_addr, uint8_t * ertm_buff
|
||||
}
|
||||
|
||||
uint8_t avrcp_browsing_controller_disconnect(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_disconnect: 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;
|
||||
|
||||
l2cap_disconnect(avrcp_connection->browsing_connection->l2cap_browsing_cid, 0);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
return avrcp_browsing_disconnect(avrcp_browsing_cid, AVRCP_CONTROLLER);
|
||||
}
|
||||
|
||||
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){
|
||||
|
@ -350,15 +350,7 @@ uint8_t avrcp_browsing_target_connect(bd_addr_t bd_addr, uint8_t * ertm_buffer,
|
||||
}
|
||||
|
||||
uint8_t avrcp_browsing_target_disconnect(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_target_disconnect: 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;
|
||||
|
||||
l2cap_disconnect(avrcp_connection->browsing_connection->l2cap_browsing_cid, 0);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
return avrcp_browsing_disconnect(avrcp_browsing_cid, AVRCP_TARGET);
|
||||
}
|
||||
|
||||
uint8_t avrcp_browsing_target_configure_incoming_connection(uint16_t avrcp_browsing_cid, uint8_t * ertm_buffer, uint32_t size, l2cap_ertm_config_t * ertm_config){
|
||||
|
Loading…
x
Reference in New Issue
Block a user