All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 2/4] btmon: Add support for decoding Broadcast Audio Annoucements
Date: Tue, 26 Apr 2022 16:03:45 -0700	[thread overview]
Message-ID: <20220426230347.857783-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20220426230347.857783-1-luiz.dentz@gmail.com>

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

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


  reply	other threads:[~2022-04-26 23:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26 23:03 [PATCH BlueZ 1/4] btmon: Add proper decoding to Service Data UUID Luiz Augusto von Dentz
2022-04-26 23:03 ` Luiz Augusto von Dentz [this message]
2022-04-26 23:03 ` [PATCH BlueZ 3/4] btmon: Add support for decoding Basic Audio Annoucements Luiz Augusto von Dentz
2022-04-26 23:03 ` [PATCH BlueZ 4/4] btmon: Fix not decoding LC3 id Luiz Augusto von Dentz
2022-04-27  2:18 ` [BlueZ,1/4] btmon: Add proper decoding to Service Data UUID bluez.test.bot
2022-04-28 22:30 ` [PATCH BlueZ 1/4] " patchwork-bot+bluetooth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220426230347.857783-2-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.