mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-10 06:44:32 +00:00
avrcp browsing: add done event
This commit is contained in:
parent
ed0df7b276
commit
e30788a349
@ -136,6 +136,8 @@ int btstack_main(int argc, const char * argv[]){
|
||||
|
||||
// Initialize AVRCP Browsing Controller, HCI events will be sent to the AVRCP Controller callback.
|
||||
avrcp_browsing_controller_init();
|
||||
// // Register AVRCP for HCI events.
|
||||
// avrcp_browsing_controller_register_packet_handler(&avrcp_browsing_controller_packet_handler);
|
||||
|
||||
// Initialize SDP.
|
||||
sdp_init();
|
||||
|
@ -110,6 +110,10 @@ typedef uint8_t sm_key_t[16];
|
||||
|
||||
// PBAP data
|
||||
#define PBAP_DATA_PACKET 0x0e
|
||||
|
||||
// AVRCP browsing data
|
||||
#define AVRCP_BROWSING_DATA_PACKET 0x0f
|
||||
|
||||
|
||||
// debug log messages
|
||||
#define LOG_MESSAGE_PACKET 0xfc
|
||||
@ -1803,6 +1807,15 @@ typedef uint8_t sm_key_t[16];
|
||||
*/
|
||||
#define AVRCP_SUBEVENT_BROWSING_CONNECTION_RELEASED 0x1C
|
||||
|
||||
|
||||
/**
|
||||
* @format 12
|
||||
* @param subevent_code
|
||||
* @param browsing_cid
|
||||
*/
|
||||
#define AVRCP_SUBEVENT_BROWSING_MEDIA_ITEM_DONE 0x1D
|
||||
|
||||
|
||||
/**
|
||||
* @format 121BH1
|
||||
* @param subevent_code
|
||||
|
@ -5750,6 +5750,16 @@ static inline uint16_t avrcp_subevent_browsing_connection_released_get_browsing_
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field browsing_cid from event AVRCP_SUBEVENT_BROWSING_MEDIA_ITEM_DONE
|
||||
* @param event packet
|
||||
* @return browsing_cid
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t avrcp_subevent_browsing_media_item_done_get_browsing_cid(const uint8_t * event){
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field goep_cid from event GOEP_SUBEVENT_CONNECTION_OPENED
|
||||
* @param event packet
|
||||
|
@ -240,22 +240,6 @@ void avrcp_browser_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t
|
||||
}
|
||||
}
|
||||
|
||||
static void avrcp_handle_l2cap_data_packet_for_browsing_connection(avrcp_browsing_connection_t * connection, uint8_t *packet, uint16_t size){
|
||||
UNUSED(size);
|
||||
|
||||
int pos = 3;
|
||||
avrcp_pdu_id_t pdu_id = packet[pos++];
|
||||
|
||||
switch(pdu_id){
|
||||
case AVRCP_PDU_ID_GET_FOLDER_ITEMS:
|
||||
printf("AVRCP_PDU_ID_GET_FOLDER_ITEMS response \n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
connection->state = AVCTP_CONNECTION_OPENED;
|
||||
}
|
||||
|
||||
static int avrcp_browsing_controller_send_get_folder_items_cmd(uint16_t cid, avrcp_browsing_connection_t * connection){
|
||||
uint8_t command[100];
|
||||
int pos = 0;
|
||||
@ -299,14 +283,52 @@ static void avrcp_browsing_controller_handle_can_send_now(avrcp_browsing_connect
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void avrcp_browsing_controller_emit_done(btstack_packet_handler_t callback, uint16_t browsing_cid){
|
||||
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_BROWSING_MEDIA_ITEM_DONE;
|
||||
little_endian_store_16(event, pos, browsing_cid);
|
||||
pos += 2;
|
||||
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
static void avrcp_browsing_controller_handle_l2cap_data_packet(avrcp_connection_t * connection, uint8_t *packet, uint16_t size){
|
||||
UNUSED(size);
|
||||
printf("avrcp_browsing_controller_handle_l2cap_data_packet \n");
|
||||
printf_hexdump(packet, size);
|
||||
|
||||
int pos = 3;
|
||||
avrcp_pdu_id_t pdu_id = packet[pos++];
|
||||
|
||||
switch(pdu_id){
|
||||
case AVRCP_PDU_ID_GET_FOLDER_ITEMS:
|
||||
printf("AVRCP_PDU_ID_GET_FOLDER_ITEMS response \n");
|
||||
|
||||
avrcp_browsing_controller_emit_done(avrcp_controller_context.avrcp_callback, connection->avrcp_browsing_cid);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
connection->state = AVCTP_CONNECTION_OPENED;
|
||||
}
|
||||
|
||||
static void avrcp_browsing_controller_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
avrcp_browsing_connection_t * connection;
|
||||
avrcp_connection_t * avrcp_connection;
|
||||
printf("avrcp_browsing_controller_packet_handler, packet type 0%02x\n", packet_type);
|
||||
|
||||
switch (packet_type) {
|
||||
case L2CAP_DATA_PACKET:
|
||||
connection = get_avrcp_browsing_connection_for_l2cap_cid(channel, &avrcp_controller_context);
|
||||
if (!connection) break;
|
||||
avrcp_handle_l2cap_data_packet_for_browsing_connection(connection, packet, size);
|
||||
avrcp_connection = get_avrcp_connection_for_browsing_l2cap_cid(channel, &avrcp_controller_context);
|
||||
if (!avrcp_connection){
|
||||
printf("connection not found 0%2x\n", channel);
|
||||
break;
|
||||
}
|
||||
avrcp_browsing_controller_handle_l2cap_data_packet(avrcp_connection, packet, size);
|
||||
break;
|
||||
case HCI_EVENT_PACKET:
|
||||
switch (hci_event_packet_get_type(packet)){
|
||||
|
@ -60,6 +60,12 @@ extern "C" {
|
||||
*/
|
||||
void avrcp_browsing_controller_init(void);
|
||||
|
||||
/**
|
||||
* @brief Register callback for the AVRCP Browsing Controller client.
|
||||
* @param callback
|
||||
*/
|
||||
// void avrcp_browsing_controller_register_packet_handler(btstack_packet_handler_t callback);
|
||||
|
||||
/**
|
||||
* @brief Connect to device with a Bluetooth address.
|
||||
* @param bd_addr
|
||||
|
@ -72,7 +72,7 @@ void avrcp_controller_create_sdp_record(uint8_t * service, uint32_t service_reco
|
||||
void avrcp_controller_init(void);
|
||||
|
||||
/**
|
||||
* @brief Register callback for the AVRCP Sink client.
|
||||
* @brief Register callback for the AVRCP Controller client.
|
||||
* @param callback
|
||||
*/
|
||||
void avrcp_controller_register_packet_handler(btstack_packet_handler_t callback);
|
||||
|
Loading…
x
Reference in New Issue
Block a user