From 6eb7ba29dafa47b87d98e47879f04a047134076d Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Wed, 1 Mar 2017 16:00:09 +0100 Subject: [PATCH] avrcp: events definition --- src/btstack_defines.h | 110 +++++++++++++- src/btstack_event.h | 303 ++++++++++++++++++++++++++++++++++++++- src/classic/avdtp_sink.c | 1 + 3 files changed, 407 insertions(+), 7 deletions(-) diff --git a/src/btstack_defines.h b/src/btstack_defines.h index fbc80b9cd..379594781 100644 --- a/src/btstack_defines.h +++ b/src/btstack_defines.h @@ -1321,7 +1321,7 @@ typedef uint8_t sm_key_t[16]; * @param media_codec_information_len * @param media_codec_information */ -#define AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CONFIGURATION 0x0A +#define AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CONFIGURATION 0x0A /** AVRCP Subevent */ @@ -1334,14 +1334,14 @@ typedef uint8_t sm_key_t[16]; * @param local_cid * @param bd_addr */ -#define AVRCP_SUBEVENT_CONNECTION_ESTABLISHED 0x01 +#define AVRCP_SUBEVENT_CONNECTION_ESTABLISHED 0x01 /** * @format 1H * @param subevent_code * @param con_handle */ -#define AVRCP_SUBEVENT_CONNECTION_CLOSED 0x02 +#define AVRCP_SUBEVENT_CONNECTION_RELEASED 0x02 /** * @format 1H1114JVJVJVJV @@ -1360,7 +1360,7 @@ typedef uint8_t sm_key_t[16]; * @param genre_len * @param genre */ -#define AVRCP_SUBEVENT_NOW_PLAYING_INFO 0x03 +#define AVRCP_SUBEVENT_NOW_PLAYING_INFO 0x03 /** * @format 1H111 @@ -1370,6 +1370,106 @@ typedef uint8_t sm_key_t[16]; * @param repeat_mode * @param shuffle_mode */ -#define AVRCP_SUBEVENT_SHUFFLE_AND_REPEAT_MODE 0x04 +#define AVRCP_SUBEVENT_SHUFFLE_AND_REPEAT_MODE 0x04 + +/** + * @format 1H1441 + * @param subevent_code + * @param con_handle + * @param status + * @param song_length + * @param song_position + * @param play_status + */ + #define AVRCP_SUBEVENT_PLAY_STATUS 0x05 + +/** + * @format 1H11 + * @param subevent_code + * @param con_handle + * @param status + * @param playback_status + */ +#define AVRCP_SUBEVENT_NOTIFICATION_PLAYBACK_STATUS_CHANGED 0x06 + +/** + * @format 1H11 + * @param subevent_code + * @param con_handle + * @param status + * @param track_status + */ +#define AVRCP_SUBEVENT_NOTIFICATION_TRACK_CHANGED 0x07 + +/** + * @format 1H1 + * @param subevent_code + * @param con_handle + * @param status + */ +#define AVRCP_SUBEVENT_NOTIFICATION_NOW_PLAYING_CONTENT_CHANGED 0x08 + +/** + * @format 1H1 + * @param subevent_code + * @param con_handle + * @param status + */ +#define AVRCP_SUBEVENT_NOTIFICATION_AVAILABLE_PLAYERS_CHANGED 0x09 + +/** + * @format 1H11 + * @param subevent_code + * @param con_handle + * @param status + * @param absolute_volume + */ +#define AVRCP_SUBEVENT_NOTIFICATION_VOLUME_CHANGED 0x0A + +/** + * @format 1H11 + * @param subevent_code + * @param con_handle + * @param status + * @param absolute_volume + */ +#define AVRCP_SUBEVENT_SET_ABSOLUTE_VOLUME_RESPONSE 0x0B + +/** + * @format 1H11 + * @param subevent_code + * @param con_handle + * @param status + * @param notification_id + */ +#define AVRCP_SUBEVENT_ENABLE_NOTIFICATION_COMPLETE 0x0C + +/** + * @format 1H11 + * @param subevent_code + * @param con_handle + * @param status + * @param operation_id + */ +#define AVRCP_SUBEVENT_OPERATION_START 0x0D + +/** + * @format 1H11 + * @param subevent_code + * @param con_handle + * @param status + * @param operation_id + */ +#define AVRCP_SUBEVENT_OPERATION_COMPLETE 0x0E + +/** + * @format 1H1 + * @param subevent_code + * @param con_handle + * @param status + */ +#define AVRCP_SUBEVENT_PLAYER_APPLICATION_VALUE_RESPONSE 0x0F + + #endif diff --git a/src/btstack_event.h b/src/btstack_event.h index 9f925bd6a..3d49d45e7 100644 --- a/src/btstack_event.h +++ b/src/btstack_event.h @@ -4291,12 +4291,12 @@ static inline void avrcp_subevent_connection_established_get_bd_addr(const uint8 } /** - * @brief Get field con_handle from event AVRCP_SUBEVENT_CONNECTION_CLOSED + * @brief Get field con_handle from event AVRCP_SUBEVENT_CONNECTION_RELEASED * @param event packet * @return con_handle * @note: btstack_type H */ -static inline hci_con_handle_t avrcp_subevent_connection_closed_get_con_handle(const uint8_t * event){ +static inline hci_con_handle_t avrcp_subevent_connection_released_get_con_handle(const uint8_t * event){ return little_endian_read_16(event, 3); } @@ -4455,6 +4455,305 @@ static inline uint8_t avrcp_subevent_shuffle_and_repeat_mode_get_shuffle_mode(co return event[7]; } +/** + * @brief Get field con_handle from event AVRCP_SUBEVENT_PLAY_STATUS + * @param event packet + * @return con_handle + * @note: btstack_type H + */ +static inline hci_con_handle_t avrcp_subevent_play_status_get_con_handle(const uint8_t * event){ + return little_endian_read_16(event, 3); +} +/** + * @brief Get field status from event AVRCP_SUBEVENT_PLAY_STATUS + * @param event packet + * @return status + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_play_status_get_status(const uint8_t * event){ + return event[5]; +} +/** + * @brief Get field song_length from event AVRCP_SUBEVENT_PLAY_STATUS + * @param event packet + * @return song_length + * @note: btstack_type 4 + */ +static inline uint32_t avrcp_subevent_play_status_get_song_length(const uint8_t * event){ + return little_endian_read_32(event, 6); +} +/** + * @brief Get field song_position from event AVRCP_SUBEVENT_PLAY_STATUS + * @param event packet + * @return song_position + * @note: btstack_type 4 + */ +static inline uint32_t avrcp_subevent_play_status_get_song_position(const uint8_t * event){ + return little_endian_read_32(event, 10); +} +/** + * @brief Get field play_status from event AVRCP_SUBEVENT_PLAY_STATUS + * @param event packet + * @return play_status + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_play_status_get_play_status(const uint8_t * event){ + return event[14]; +} + +/** + * @brief Get field con_handle from event AVRCP_SUBEVENT_NOTIFICATION_PLAYBACK_STATUS_CHANGED + * @param event packet + * @return con_handle + * @note: btstack_type H + */ +static inline hci_con_handle_t avrcp_subevent_notification_playback_status_changed_get_con_handle(const uint8_t * event){ + return little_endian_read_16(event, 3); +} +/** + * @brief Get field status from event AVRCP_SUBEVENT_NOTIFICATION_PLAYBACK_STATUS_CHANGED + * @param event packet + * @return status + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_notification_playback_status_changed_get_status(const uint8_t * event){ + return event[5]; +} +/** + * @brief Get field playback_status from event AVRCP_SUBEVENT_NOTIFICATION_PLAYBACK_STATUS_CHANGED + * @param event packet + * @return playback_status + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_notification_playback_status_changed_get_playback_status(const uint8_t * event){ + return event[6]; +} + +/** + * @brief Get field con_handle from event AVRCP_SUBEVENT_NOTIFICATION_TRACK_CHANGED + * @param event packet + * @return con_handle + * @note: btstack_type H + */ +static inline hci_con_handle_t avrcp_subevent_notification_track_changed_get_con_handle(const uint8_t * event){ + return little_endian_read_16(event, 3); +} +/** + * @brief Get field status from event AVRCP_SUBEVENT_NOTIFICATION_TRACK_CHANGED + * @param event packet + * @return status + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_notification_track_changed_get_status(const uint8_t * event){ + return event[5]; +} +/** + * @brief Get field track_status from event AVRCP_SUBEVENT_NOTIFICATION_TRACK_CHANGED + * @param event packet + * @return track_status + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_notification_track_changed_get_track_status(const uint8_t * event){ + return event[6]; +} + +/** + * @brief Get field con_handle from event AVRCP_SUBEVENT_NOTIFICATION_NOW_PLAYING_CONTENT_CHANGED + * @param event packet + * @return con_handle + * @note: btstack_type H + */ +static inline hci_con_handle_t avrcp_subevent_notification_now_playing_content_changed_get_con_handle(const uint8_t * event){ + return little_endian_read_16(event, 3); +} +/** + * @brief Get field status from event AVRCP_SUBEVENT_NOTIFICATION_NOW_PLAYING_CONTENT_CHANGED + * @param event packet + * @return status + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_notification_now_playing_content_changed_get_status(const uint8_t * event){ + return event[5]; +} + +/** + * @brief Get field con_handle from event AVRCP_SUBEVENT_NOTIFICATION_AVAILABLE_PLAYERS_CHANGED + * @param event packet + * @return con_handle + * @note: btstack_type H + */ +static inline hci_con_handle_t avrcp_subevent_notification_available_players_changed_get_con_handle(const uint8_t * event){ + return little_endian_read_16(event, 3); +} +/** + * @brief Get field status from event AVRCP_SUBEVENT_NOTIFICATION_AVAILABLE_PLAYERS_CHANGED + * @param event packet + * @return status + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_notification_available_players_changed_get_status(const uint8_t * event){ + return event[5]; +} + +/** + * @brief Get field con_handle from event AVRCP_SUBEVENT_NOTIFICATION_VOLUME_CHANGED + * @param event packet + * @return con_handle + * @note: btstack_type H + */ +static inline hci_con_handle_t avrcp_subevent_notification_volume_changed_get_con_handle(const uint8_t * event){ + return little_endian_read_16(event, 3); +} +/** + * @brief Get field status from event AVRCP_SUBEVENT_NOTIFICATION_VOLUME_CHANGED + * @param event packet + * @return status + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_notification_volume_changed_get_status(const uint8_t * event){ + return event[5]; +} +/** + * @brief Get field absolute_volume from event AVRCP_SUBEVENT_NOTIFICATION_VOLUME_CHANGED + * @param event packet + * @return absolute_volume + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_notification_volume_changed_get_absolute_volume(const uint8_t * event){ + return event[6]; +} + +/** + * @brief Get field con_handle from event AVRCP_SUBEVENT_SET_ABSOLUTE_VOLUME_RESPONSE + * @param event packet + * @return con_handle + * @note: btstack_type H + */ +static inline hci_con_handle_t avrcp_subevent_set_absolute_volume_response_get_con_handle(const uint8_t * event){ + return little_endian_read_16(event, 3); +} +/** + * @brief Get field status from event AVRCP_SUBEVENT_SET_ABSOLUTE_VOLUME_RESPONSE + * @param event packet + * @return status + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_set_absolute_volume_response_get_status(const uint8_t * event){ + return event[5]; +} +/** + * @brief Get field absolute_volume from event AVRCP_SUBEVENT_SET_ABSOLUTE_VOLUME_RESPONSE + * @param event packet + * @return absolute_volume + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_set_absolute_volume_response_get_absolute_volume(const uint8_t * event){ + return event[6]; +} + +/** + * @brief Get field con_handle from event AVRCP_SUBEVENT_ENABLE_NOTIFICATION_COMPLETE + * @param event packet + * @return con_handle + * @note: btstack_type H + */ +static inline hci_con_handle_t avrcp_subevent_enable_notification_complete_get_con_handle(const uint8_t * event){ + return little_endian_read_16(event, 3); +} +/** + * @brief Get field status from event AVRCP_SUBEVENT_ENABLE_NOTIFICATION_COMPLETE + * @param event packet + * @return status + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_enable_notification_complete_get_status(const uint8_t * event){ + return event[5]; +} +/** + * @brief Get field notification_id from event AVRCP_SUBEVENT_ENABLE_NOTIFICATION_COMPLETE + * @param event packet + * @return notification_id + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_enable_notification_complete_get_notification_id(const uint8_t * event){ + return event[6]; +} + +/** + * @brief Get field con_handle from event AVRCP_SUBEVENT_OPERATION_START + * @param event packet + * @return con_handle + * @note: btstack_type H + */ +static inline hci_con_handle_t avrcp_subevent_operation_start_get_con_handle(const uint8_t * event){ + return little_endian_read_16(event, 3); +} +/** + * @brief Get field status from event AVRCP_SUBEVENT_OPERATION_START + * @param event packet + * @return status + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_operation_start_get_status(const uint8_t * event){ + return event[5]; +} +/** + * @brief Get field operation_id from event AVRCP_SUBEVENT_OPERATION_START + * @param event packet + * @return operation_id + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_operation_start_get_operation_id(const uint8_t * event){ + return event[6]; +} + +/** + * @brief Get field con_handle from event AVRCP_SUBEVENT_OPERATION_COMPLETE + * @param event packet + * @return con_handle + * @note: btstack_type H + */ +static inline hci_con_handle_t avrcp_subevent_operation_complete_get_con_handle(const uint8_t * event){ + return little_endian_read_16(event, 3); +} +/** + * @brief Get field status from event AVRCP_SUBEVENT_OPERATION_COMPLETE + * @param event packet + * @return status + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_operation_complete_get_status(const uint8_t * event){ + return event[5]; +} +/** + * @brief Get field operation_id from event AVRCP_SUBEVENT_OPERATION_COMPLETE + * @param event packet + * @return operation_id + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_operation_complete_get_operation_id(const uint8_t * event){ + return event[6]; +} + +/** + * @brief Get field con_handle from event AVRCP_SUBEVENT_PLAYER_APPLICATION_VALUE_RESPONSE + * @param event packet + * @return con_handle + * @note: btstack_type H + */ +static inline hci_con_handle_t avrcp_subevent_player_application_value_response_get_con_handle(const uint8_t * event){ + return little_endian_read_16(event, 3); +} +/** + * @brief Get field status from event AVRCP_SUBEVENT_PLAYER_APPLICATION_VALUE_RESPONSE + * @param event packet + * @return status + * @note: btstack_type 1 + */ +static inline uint8_t avrcp_subevent_player_application_value_response_get_status(const uint8_t * event){ + return event[5]; +} + /* API_END */ diff --git a/src/classic/avdtp_sink.c b/src/classic/avdtp_sink.c index e724ab086..edb5e63dd 100644 --- a/src/classic/avdtp_sink.c +++ b/src/classic/avdtp_sink.c @@ -642,6 +642,7 @@ void avdtp_sink_connect(bd_addr_t bd_addr){ void avdtp_sink_disconnect(uint16_t con_handle){ avdtp_connection_t * connection = get_avdtp_connection_for_con_handle(con_handle); + if (!connection) return; if (connection->state == AVDTP_SIGNALING_CONNECTION_IDLE) return; if (connection->state == AVDTP_SIGNALING_CONNECTION_W4_L2CAP_DISCONNECTED) return;