From 8e327cec10bfcb1af86beea1b9213146212fccc6 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 26 Apr 2022 13:22:03 -0700 Subject: [PATCH] btmon: Add support for decoding Broadcast Audio Annoucements This adds support for decoding Broadcast Audio Announcements as shown on: Basic Audio Profile / Profile Specification Page 34 of 146 Table 3.14: Broadcast Source AD format when transmitting Broadcast Audio Announcements < HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 36 Handle: 0x00 Operation: Complete extended advertising data (0x03) Fragment preference: Minimize fragmentation (0x01) Data length: 0x20 Service Data: Broadcast Audio Announcement (0x1852) Broadcast ID: 904177 (0x0dcbf1) Name (complete): Broadcast Audio Source Signed-off-by: Manika Shrivastava Signed-off-by: Ayush Garg --- monitor/packet.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index 4b43368..619553e 100755 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -3300,11 +3300,44 @@ static void print_uuid128_list(const char *label, const void *data, } } +static void print_broadcast_annoucement(const uint8_t *data, uint8_t data_len) +{ + uint32_t bid; + + if (data_len < 3) { + print_hex_field(" Data", data, data_len); + return; + } + + bid = get_le24(data); + print_field("Broadcast ID: %u (0x%06x)", bid, bid); +} + +static const struct service_data_decoder { + uint16_t uuid; + void (*func)(const uint8_t *data, uint8_t data_len); +} service_data_decoders[] = { + { 0x1852, print_broadcast_annoucement } +}; + static void print_service_data(const uint8_t *data, uint8_t data_len) { uint16_t uuid = get_le16(&data[0]); + size_t i; print_field("Service Data: %s (0x%4.4x)", bt_uuid16_to_str(uuid), uuid); + + for (i = 0; i < ARRAY_SIZE(service_data_decoders); i++) { + const struct service_data_decoder *decoder; + + decoder = &service_data_decoders[i]; + + if (decoder->uuid == uuid) { + decoder->func(&data[2], data_len - 2); + return; + } + } + print_hex_field(" Data", &data[2], data_len - 2); } -- 2.7.4