From aff3a7a6bfb0154ccd2421d8de430e5943293d41 Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Fri, 8 Oct 2021 15:19:01 +0200 Subject: [PATCH] example/a2dp_source_demo: report initial battery and volume status --- example/a2dp_source_demo.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/example/a2dp_source_demo.c b/example/a2dp_source_demo.c index e220bfd8c..c3b3aa7bc 100644 --- a/example/a2dp_source_demo.c +++ b/example/a2dp_source_demo.c @@ -842,18 +842,37 @@ static void avrcp_controller_packet_handler(uint8_t packet_type, uint16_t channe if (!media_tracker.avrcp_cid) return; // ignore INTERIM status - if (status == AVRCP_CTYPE_RESPONSE_INTERIM) return; + if (status == AVRCP_CTYPE_RESPONSE_INTERIM){ + switch (packet[2]){ + case AVRCP_SUBEVENT_NOTIFICATION_VOLUME_CHANGED: + printf("AVRCP Controller: Initial absolute volume %d %%\n", avrcp_subevent_notification_volume_changed_get_absolute_volume(packet) * 100 / 127); + break; + case AVRCP_SUBEVENT_NOTIFICATION_EVENT_BATT_STATUS_CHANGED: + // see avrcp_battery_status_t + printf("AVRCP Controller: Initial battery status %d\n", avrcp_subevent_notification_event_batt_status_changed_get_battery_status(packet)); + break; + default: + break; + } + return; + } + switch (packet[2]){ case AVRCP_SUBEVENT_NOTIFICATION_VOLUME_CHANGED: printf("AVRCP Controller: notification absolute volume changed %d %%\n", avrcp_subevent_notification_volume_changed_get_absolute_volume(packet) * 100 / 127); break; + case AVRCP_SUBEVENT_NOTIFICATION_EVENT_BATT_STATUS_CHANGED: + // see avrcp_battery_status_t + printf("AVRCP Controller: battery status changed %d\n", avrcp_subevent_notification_event_batt_status_changed_get_battery_status(packet)); + break; case AVRCP_SUBEVENT_GET_CAPABILITY_EVENT_ID: printf("Remote supports EVENT_ID 0x%02x\n", avrcp_subevent_get_capability_event_id_get_event_id(packet)); break; case AVRCP_SUBEVENT_GET_CAPABILITY_EVENT_ID_DONE: printf("automatically enable notifications\n"); avrcp_controller_enable_notification(media_tracker.avrcp_cid, AVRCP_NOTIFICATION_EVENT_VOLUME_CHANGED); + avrcp_controller_enable_notification(media_tracker.avrcp_cid, AVRCP_NOTIFICATION_EVENT_BATT_STATUS_CHANGED); break; default: break;