From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 1/2] emulator/btdev: Add LE Set Host Feature V2 command emulation
Date: Tue, 26 May 2026 13:03:08 -0400 [thread overview]
Message-ID: <20260526170309.3529062-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add emulation for LE Set Host Feature V2 (0x2097) command which
uses a 16-bit bit_number field (vs 8-bit in v1) to allow setting
extended LE feature bits. The command bit is set at byte 47 bit 4
as defined in bt.h.
Assisted-by: OpenCode:claude-opus-4.6
---
emulator/btdev.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/emulator/btdev.c b/emulator/btdev.c
index ad2e025d1b45..3206caf5be86 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -7907,11 +7907,40 @@ static int cmd_le_read_all_remote_features(struct btdev *dev, const void *data,
return 0;
}
+static int cmd_set_host_feature_v2(struct btdev *dev, const void *data,
+ uint8_t len)
+{
+ const struct bt_hci_cmd_le_set_host_feature_v2 *cmd = data;
+ uint8_t status = BT_HCI_ERR_SUCCESS;
+ uint16_t bit = le16_to_cpu(cmd->bit_number);
+ uint8_t page = bit / 8;
+ uint8_t mask = BIT(bit % 8);
+
+ /* Only allow setting host controlled features */
+ if (page >= sizeof(dev->le_features)) {
+ status = BT_HCI_ERR_INVALID_PARAMETERS;
+ goto done;
+ }
+
+ if (cmd->bit_value)
+ dev->le_features[page] |= mask;
+ else
+ dev->le_features[page] &= ~mask;
+
+done:
+ cmd_complete(dev, BT_HCI_CMD_LE_SET_HOST_FEATURE_V2, &status,
+ sizeof(status));
+
+ return 0;
+}
+
#define CMD_LE_60 \
CMD(BT_HCI_CMD_LE_READ_ALL_LOCAL_FEATURES, \
cmd_le_read_all_local_features, NULL), \
CMD(BT_HCI_CMD_LE_READ_ALL_REMOTE_FEATURES, \
- cmd_le_read_all_remote_features, NULL)
+ cmd_le_read_all_remote_features, NULL), \
+ CMD(BT_HCI_CMD_LE_SET_HOST_FEATURE_V2, \
+ cmd_set_host_feature_v2, NULL)
static const struct btdev_cmd cmd_le_6_0[] = {
CMD_COMMON_ALL,
@@ -7930,6 +7959,7 @@ static void set_le_60_commands(struct btdev *btdev)
{
btdev->commands[47] |= BIT(2); /* LE Read All Local Features */
btdev->commands[47] |= BIT(3); /* LE Read All Remote Features */
+ btdev->commands[47] |= BIT(4); /* LE Set Host Feature V2 */
btdev->cmds = cmd_le_6_0;
}
--
2.53.0
next 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 Luiz Augusto von Dentz [this message]
2026-05-26 17:03 ` [PATCH BlueZ v1 2/2] monitor: Add decoding support for LE Set Host Feature V2 Luiz Augusto von Dentz
2026-05-26 18:24 ` [BlueZ,v1,1/2] emulator/btdev: Add LE Set Host Feature V2 command emulation 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-1-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