mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-28 00:35:42 +00:00
avrcp: handle overrun and using existing cid
This commit is contained in:
parent
095ad46240
commit
298aeecde0
@ -372,14 +372,18 @@ void avrcp_request_can_send_now(avrcp_connection_t * connection, uint16_t l2cap_
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint16_t avrcp_get_next_cid(void){
|
uint16_t avrcp_get_next_cid(avrcp_role_t role){
|
||||||
avrcp_cid_counter++;
|
do {
|
||||||
if (avrcp_cid_counter == 0){
|
if (avrcp_cid_counter == 0xffff) {
|
||||||
avrcp_cid_counter = 1;
|
avrcp_cid_counter = 1;
|
||||||
|
} else {
|
||||||
|
avrcp_cid_counter++;
|
||||||
}
|
}
|
||||||
|
} while (get_avrcp_connection_for_avrcp_cid(role, avrcp_cid_counter) != NULL) ;
|
||||||
return avrcp_cid_counter;
|
return avrcp_cid_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static avrcp_connection_t * avrcp_create_connection(avrcp_role_t role, bd_addr_t remote_addr){
|
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();
|
avrcp_connection_t * connection = btstack_memory_avrcp_connection_get();
|
||||||
if (!connection){
|
if (!connection){
|
||||||
@ -391,7 +395,7 @@ static avrcp_connection_t * avrcp_create_connection(avrcp_role_t role, bd_addr_t
|
|||||||
connection->role = role;
|
connection->role = role;
|
||||||
connection->transaction_label = 0xFF;
|
connection->transaction_label = 0xFF;
|
||||||
connection->max_num_fragments = 0xFF;
|
connection->max_num_fragments = 0xFF;
|
||||||
connection->avrcp_cid = avrcp_get_next_cid();
|
connection->avrcp_cid = avrcp_get_next_cid(role);
|
||||||
log_info("avrcp_create_connection, role %d, avrcp cid 0x%02x", role, connection->avrcp_cid);
|
log_info("avrcp_create_connection, role %d, avrcp cid 0x%02x", role, connection->avrcp_cid);
|
||||||
memcpy(connection->remote_addr, remote_addr, 6);
|
memcpy(connection->remote_addr, remote_addr, 6);
|
||||||
btstack_linked_list_add(&connections, (btstack_linked_item_t *) connection);
|
btstack_linked_list_add(&connections, (btstack_linked_item_t *) connection);
|
||||||
|
@ -561,7 +561,7 @@ avrcp_connection_t * get_avrcp_connection_for_browsing_l2cap_cid(avrcp_role_t ro
|
|||||||
avrcp_browsing_connection_t * get_avrcp_browsing_connection_for_l2cap_cid(avrcp_role_t role, uint16_t l2cap_cid);
|
avrcp_browsing_connection_t * get_avrcp_browsing_connection_for_l2cap_cid(avrcp_role_t role, uint16_t l2cap_cid);
|
||||||
|
|
||||||
void avrcp_request_can_send_now(avrcp_connection_t * connection, 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);
|
uint16_t avrcp_get_next_cid(avrcp_role_t role);
|
||||||
|
|
||||||
// SDP query
|
// SDP query
|
||||||
void avrcp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
void avrcp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||||
|
@ -48,9 +48,22 @@
|
|||||||
|
|
||||||
#define PSM_AVCTP_BROWSING 0x001b
|
#define PSM_AVCTP_BROWSING 0x001b
|
||||||
|
|
||||||
|
static uint16_t avrcp_browsing_cid = 0;
|
||||||
|
|
||||||
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_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 void avrcp_browsing_controller_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||||
|
|
||||||
|
static uint16_t avrcp_browsing_get_next_cid(avrcp_role_t role){
|
||||||
|
do {
|
||||||
|
if (avrcp_browsing_cid == 0xffff) {
|
||||||
|
avrcp_browsing_cid = 1;
|
||||||
|
} else {
|
||||||
|
avrcp_browsing_cid++;
|
||||||
|
}
|
||||||
|
} while (get_avrcp_connection_for_browsing_l2cap_cid(role, avrcp_browsing_cid) != NULL) ;
|
||||||
|
return avrcp_browsing_cid;
|
||||||
|
}
|
||||||
|
|
||||||
static void avrcp_emit_browsing_connection_established(btstack_packet_handler_t callback, uint16_t browsing_cid, bd_addr_t addr, uint8_t status){
|
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;
|
if (!callback) return;
|
||||||
uint8_t event[12];
|
uint8_t event[12];
|
||||||
@ -96,7 +109,7 @@ static avrcp_browsing_connection_t * avrcp_browsing_create_connection(avrcp_conn
|
|||||||
avrcp_browsing_connection_t * connection = btstack_memory_avrcp_browsing_connection_get();
|
avrcp_browsing_connection_t * connection = btstack_memory_avrcp_browsing_connection_get();
|
||||||
connection->state = AVCTP_CONNECTION_IDLE;
|
connection->state = AVCTP_CONNECTION_IDLE;
|
||||||
connection->transaction_label = 0xFF;
|
connection->transaction_label = 0xFF;
|
||||||
avrcp_connection->avrcp_browsing_cid = avrcp_get_next_cid();
|
avrcp_connection->avrcp_browsing_cid = avrcp_get_next_cid(avrcp_connection->role);
|
||||||
avrcp_connection->browsing_connection = connection;
|
avrcp_connection->browsing_connection = connection;
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user