[PATCH BlueZ 2/4] btmon: Add support for decoding Broadcast Audio Annoucements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

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
---
 monitor/packet.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/monitor/packet.c b/monitor/packet.c
index 471b0dd4d..b376d5a8b 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -3301,11 +3301,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.35.1




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux