diff --git a/src/btstack_defines.h b/src/btstack_defines.h index 658d9a132..2d92bc305 100644 --- a/src/btstack_defines.h +++ b/src/btstack_defines.h @@ -2949,9 +2949,10 @@ typedef uint8_t sm_key_t[16]; #define AVRCP_SUBEVENT_GET_CAPABILITY_COMPANY_ID_DONE 0x27 /** - * @format 121LV + * @format 1211LV * @param subevent_code * @param avrcp_cid + * @param command_type * @param pdu_id * @param params_len * @param params diff --git a/src/btstack_event.h b/src/btstack_event.h index b279cded7..29da9237e 100644 --- a/src/btstack_event.h +++ b/src/btstack_event.h @@ -9195,6 +9195,15 @@ static inline uint8_t avrcp_subevent_get_capability_company_id_done_get_status(c static inline uint16_t avrcp_subevent_custom_command_response_get_avrcp_cid(const uint8_t * event){ return little_endian_read_16(event, 3); } +/** + * @brief Get field command_type from event AVRCP_SUBEVENT_CUSTOM_COMMAND_RESPONSE + * @param event packet + * @return command_type + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_custom_command_response_get_command_type(const uint8_t * event){ + return event[5]; +} /** * @brief Get field pdu_id from event AVRCP_SUBEVENT_CUSTOM_COMMAND_RESPONSE * @param event packet @@ -9202,7 +9211,7 @@ static inline uint16_t avrcp_subevent_custom_command_response_get_avrcp_cid(cons * @note: btstack_type 1 */ static inline uint8_t avrcp_subevent_custom_command_response_get_pdu_id(const uint8_t * event){ - return event[5]; + return event[6]; } /** * @brief Get field params_len from event AVRCP_SUBEVENT_CUSTOM_COMMAND_RESPONSE @@ -9211,7 +9220,7 @@ static inline uint8_t avrcp_subevent_custom_command_response_get_pdu_id(const ui * @note: btstack_type L */ static inline uint16_t avrcp_subevent_custom_command_response_get_params_len(const uint8_t * event){ - return little_endian_read_16(event, 6); + return little_endian_read_16(event, 7); } /** * @brief Get field params from event AVRCP_SUBEVENT_CUSTOM_COMMAND_RESPONSE @@ -9220,7 +9229,7 @@ static inline uint16_t avrcp_subevent_custom_command_response_get_params_len(con * @note: btstack_type V */ static inline const uint8_t * avrcp_subevent_custom_command_response_get_params(const uint8_t * event){ - return &event[8]; + return &event[9]; } /** diff --git a/src/classic/avrcp_controller.c b/src/classic/avrcp_controller.c index 962ea8005..1e5a6f8d3 100644 --- a/src/classic/avrcp_controller.c +++ b/src/classic/avrcp_controller.c @@ -129,7 +129,8 @@ static void avrcp_controller_prepare_custom_command_response(avrcp_connection_t in_place_buffer[pos++] = AVRCP_SUBEVENT_CUSTOM_COMMAND_RESPONSE; little_endian_store_16(in_place_buffer, pos, connection->avrcp_cid); pos += 2; - in_place_buffer[pos++] = connection->pdu_id; + in_place_buffer[pos++] = (uint8_t)connection->command_type; + in_place_buffer[pos++] = (uint8_t)connection->pdu_id; little_endian_store_16(in_place_buffer, pos, response_len); pos += 2; in_place_buffer[1] = pos + response_len - 2; @@ -1166,12 +1167,21 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec } default: // custom command response comes here - if (pdu_id == connection->pdu_id) { - uint8_t *in_place_buffer = packet + pos - 8; - avrcp_controller_prepare_custom_command_response(connection, param_length, - in_place_buffer); - (*avrcp_controller_context.avrcp_callback)(HCI_EVENT_PACKET, 0, in_place_buffer, - param_length + 8); + switch (pdu_id){ + case AVRCP_PDU_ID_REQUEST_ABORT_CONTINUING_RESPONSE: + avrcp_controller_emit_now_playing_info_event_done(avrcp_controller_context.avrcp_callback, connection->avrcp_cid, ctype, 0); + break; + default: + if (pdu_id != connection->pdu_id) { + break; + } + uint8_t *in_place_buffer = packet + pos - 9; + avrcp_controller_prepare_custom_command_response(connection, param_length, + in_place_buffer); + (*avrcp_controller_context.avrcp_callback)(HCI_EVENT_PACKET, 0, in_place_buffer, + param_length + 9); + + break; } break; }