avrcp_controller: introduce first and last index for iteration over avrcp_notification_event_id_t items

This commit is contained in:
Milanka Ringwald 2021-10-26 16:05:47 +02:00
parent bce3db218b
commit 99845bb758
2 changed files with 6 additions and 4 deletions

View File

@ -167,6 +167,7 @@ typedef enum {
} avrcp_pdu_id_t;
typedef enum {
AVRCP_NOTIFICATION_EVENT_FIRST_INDEX = 0x01,
AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED = 0x01, // Change in playback status of the current track.
AVRCP_NOTIFICATION_EVENT_TRACK_CHANGED = 0x02, // Change of current track
AVRCP_NOTIFICATION_EVENT_TRACK_REACHED_END = 0x03, // Reached end of a track
@ -180,7 +181,8 @@ typedef enum {
AVRCP_NOTIFICATION_EVENT_ADDRESSED_PLAYER_CHANGED = 0x0b, // The Addressed Player has been changed, see 6.9.2.
AVRCP_NOTIFICATION_EVENT_UIDS_CHANGED = 0x0c, // The UIDs have changed, see 6.10.3.3.
AVRCP_NOTIFICATION_EVENT_VOLUME_CHANGED = 0x0d, // The volume has been changed locally on the TG, see 6.13.3.
AVRCP_NOTIFICATION_EVENT_MAX_VALUE = 0x0e
AVRCP_NOTIFICATION_EVENT_MAX_VALUE = 0x0e,
AVRCP_NOTIFICATION_EVENT_LAST_INDEX = 0x0e
} avrcp_notification_event_id_t;

View File

@ -110,7 +110,7 @@ static void avrcp_controller_emit_supported_events(avrcp_connection_t * connecti
uint8_t ctype = (uint8_t) AVRCP_CTYPE_RESPONSE_CHANGED_STABLE;
uint8_t event_id;
for (event_id = (uint8_t) AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED; event_id < (uint8_t) AVRCP_NOTIFICATION_EVENT_MAX_VALUE; event_id++){
for (event_id = (uint8_t) AVRCP_NOTIFICATION_EVENT_FIRST_INDEX; event_id < (uint8_t) AVRCP_NOTIFICATION_EVENT_LAST_INDEX; event_id++){
if ( (connection->remote_supported_notifications & (1<<event_id)) == 0){
continue;
}
@ -875,7 +875,7 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
connection->state = AVCTP_CONNECTION_OPENED;
#ifdef ENABLE_LOG_INFO
// page, extention code (1)
// page, extension code (1)
pos++;
uint8_t unit_type = packet[pos] >> 3;
uint8_t max_subunit_ID = packet[pos] & 0x07;
@ -1179,7 +1179,7 @@ static void avrcp_controller_handle_can_send_now(avrcp_connection_t * connection
// send register notification if queued
if (connection->notifications_to_register != 0){
uint8_t event_id;
for (event_id = 1; event_id <= AVRCP_NOTIFICATION_EVENT_VOLUME_CHANGED; event_id++){
for (event_id = (uint8_t)AVRCP_NOTIFICATION_EVENT_FIRST_INDEX; event_id < (uint8_t)AVRCP_NOTIFICATION_EVENT_LAST_INDEX; event_id++){
if (connection->notifications_to_register & (1<<event_id)){
connection->notifications_to_register &= ~ (1 << event_id);
avrcp_send_register_notification(connection, event_id);