Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 2/2] monitor: Add decoding support for LE Set Host Feature V2
Date: Tue, 26 May 2026 13:03:09 -0400	[thread overview]
Message-ID: <20260526170309.3529062-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20260526170309.3529062-1-luiz.dentz@gmail.com>

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

Add decoding support for LE Set Host Feature V2 (0x2097) command
which uses a 16-bit bit_number field to support extended LE feature
pages:

< HCI Command: LE Set Host F.. (0x08|0x0097) plen 3
        Bit Number: 32
        Features[0/0][8]:
        00 00 00 00 01 00 00 00                          ........
          Connected Isochronous Stream (Host Support)
        Bit Value: 1
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Host Feature V2 (0x08|0x0097) ncmd 1
        Status: Success (0x00)

Assisted-by: OpenCode:claude-opus-4.6
---
 monitor/bt.h     |  7 +++++++
 monitor/packet.c | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/monitor/bt.h b/monitor/bt.h
index a849c18a96b5..6efccb27e758 100644
--- a/monitor/bt.h
+++ b/monitor/bt.h
@@ -3186,6 +3186,13 @@ struct bt_hci_rsp_le_cs_test {
 #define BT_HCI_CMD_LE_CS_TEST_END		0x2096
 #define BT_HCI_BIT_LE_CS_TEST_END		BT_HCI_CMD_BIT(23, 4)
 
+#define BT_HCI_CMD_LE_SET_HOST_FEATURE_V2	0x2097
+#define BT_HCI_BIT_LE_SET_HOST_FEATURE_V2	BT_HCI_CMD_BIT(47, 4)
+struct bt_hci_cmd_le_set_host_feature_v2 {
+	uint16_t bit_number;
+	uint8_t  bit_value;
+} __attribute__ ((packed));
+
 #define BT_HCI_CMD_LE_FSU			0x209d
 #define BT_HCI_BIT_LE_FSU			BT_HCI_CMD_BIT(48, 1)
 struct bt_hci_cmd_le_fsu {
diff --git a/monitor/packet.c b/monitor/packet.c
index 41f0226c39f8..dcb067ce874f 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -9820,6 +9820,33 @@ static void le_cs_test_cmd(uint16_t index, const void *data, uint8_t size)
 		cmd->override_parameters_length);
 }
 
+static void le_set_host_feature_v2_cmd(uint16_t index, const void *data,
+							uint8_t size)
+{
+	const struct bt_hci_cmd_le_set_host_feature_v2 *cmd = data;
+	uint8_t page;
+	uint8_t features[24] = {};
+	uint16_t bit_number = le16_to_cpu(cmd->bit_number);
+
+	print_field("Bit Number: %u", bit_number);
+
+	if (bit_number < 64) {
+		features[bit_number / 8] |= (1 << (bit_number % 8));
+		print_features(0, features, 0x01);
+	} else {
+		uint16_t bit;
+
+		page = (bit_number - 64) / 24 + 1;
+		/* Adjust the bit number to be relative to the page */
+		bit = (bit_number - 64) % 24;
+		/* Set the bit in the features array */
+		features[bit / 8] |= (1 << ((bit % 8)));
+		print_features(page, features, 0x01);
+	}
+
+	print_field("Bit Value: %u", cmd->bit_value);
+}
+
 static void le_cs_test_rsp(uint16_t index, const void *data, uint8_t size)
 {
 	const struct bt_hci_rsp_le_cs_test *rsp = data;
@@ -11013,6 +11040,11 @@ static const struct opcode_data opcode_table[] = {
 				true},
 	{ BT_HCI_CMD_LE_CS_TEST_END, BT_HCI_BIT_LE_CS_TEST_END,
 				"LE CS Test End" },
+	{ BT_HCI_CMD_LE_SET_HOST_FEATURE_V2, BT_HCI_BIT_LE_SET_HOST_FEATURE_V2,
+			"LE Set Host Feature V2",
+			le_set_host_feature_v2_cmd,
+			sizeof(struct bt_hci_cmd_le_set_host_feature_v2),
+			true, status_rsp, 1, true },
 	{ BT_HCI_CMD_LE_FSU, BT_HCI_BIT_LE_FSU,
 				"LE Frame Space Update", le_fsu_cmd,
 				sizeof(struct bt_hci_cmd_le_fsu),
-- 
2.53.0


  reply	other threads:[~2026-05-26 17:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-26 17:03 [PATCH BlueZ v1 1/2] emulator/btdev: Add LE Set Host Feature V2 command emulation Luiz Augusto von Dentz
2026-05-26 17:03 ` Luiz Augusto von Dentz [this message]
2026-05-26 18:24 ` [BlueZ,v1,1/2] " bluez.test.bot
2026-05-27 21:30 ` [PATCH BlueZ v1 1/2] " 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=20260526170309.3529062-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox