From: Roland Schober <rolandschober1968@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: luiz.dentz@gmail.com, Roland Schober <rolandschober1968@gmail.com>
Subject: [RFC PATCH BlueZ v3 10/12] emulator/btdev: Keep advertising sets with PA enabled
Date: Thu, 3 Dec 2026 23:15:30 +0100 [thread overview]
Message-ID: <20261203221532.682750-11-rolandschober1968@gmail.com> (raw)
In-Reply-To: <20261203221532.682750-1-rolandschober1968@gmail.com>
LE Remove Advertising Set and LE Clear Advertising Sets are answered
with Command Disallowed while periodic advertising is enabled on the
set, as the specification says.
The set is the one named in LE Set Periodic Advertising Parameters.
LE Set Periodic Advertising Enable took any handle so far: it is now
answered with Unknown Advertising Identifier for a set which does not
exist, and with Command Disallowed for a set other than the one with
the parameters.
Assisted-by: Claude:claude-fable-5-2
---
emulator/btdev.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/emulator/btdev.c b/emulator/btdev.c
index fc5cfb1ba..5ea22acbf 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -268,6 +268,7 @@ struct btdev {
uint16_t le_pa_max_interval;
uint8_t le_pa_data_len;
uint8_t le_pa_data[MAX_PA_DATA_LEN];
+ uint8_t le_pa_handle;
uint8_t le_ltk[16];
uint8_t hdt_def_mic_len;
uint8_t hdt_def_format;
@@ -5990,7 +5991,8 @@ static int cmd_remove_adv_set(struct btdev *dev, const void *data,
return 0;
}
- if (ext_adv->enable) {
+ if (ext_adv->enable || (dev->le_pa_enable &&
+ dev->le_pa_handle == cmd->handle)) {
status = BT_HCI_ERR_COMMAND_DISALLOWED;
cmd_complete(dev, BT_HCI_CMD_LE_REMOVE_ADV_SET, &status,
sizeof(status));
@@ -6012,6 +6014,13 @@ static int cmd_clear_adv_sets(struct btdev *dev, const void *data,
const struct queue_entry *entry;
uint8_t status = BT_HCI_ERR_SUCCESS;
+ if (dev->le_pa_enable) {
+ status = BT_HCI_ERR_COMMAND_DISALLOWED;
+ cmd_complete(dev, BT_HCI_CMD_LE_CLEAR_ADV_SETS, &status,
+ sizeof(status));
+ return 0;
+ }
+
for (entry = queue_get_entries(dev->le_ext_adv); entry;
entry = entry->next) {
struct le_ext_adv *ext_adv = entry->data;
@@ -6048,6 +6057,7 @@ static int cmd_set_pa_params(struct btdev *dev, const void *data,
dev->le_pa_properties = le16_to_cpu(cmd->properties);
dev->le_pa_min_interval = cmd->min_interval;
dev->le_pa_max_interval = cmd->max_interval;
+ dev->le_pa_handle = cmd->handle;
}
cmd_complete(dev, BT_HCI_CMD_LE_SET_PA_PARAMS, &status,
@@ -6282,7 +6292,12 @@ static int cmd_set_pa_enable(struct btdev *dev, const void *data, uint8_t len)
if (len != sizeof(*cmd))
return -EINVAL;
- if (dev->le_pa_enable == cmd->enable) {
+ if (!queue_find(dev->le_ext_adv, match_ext_adv_handle,
+ UINT_TO_PTR(cmd->handle))) {
+ status = BT_HCI_ERR_UNKNOWN_ADVERTISING_ID;
+ } else if (cmd->handle != dev->le_pa_handle ||
+ dev->le_pa_enable == cmd->enable) {
+ /* There is one train, on the set which has the parameters */
status = BT_HCI_ERR_COMMAND_DISALLOWED;
} else {
dev->le_pa_enable = cmd->enable;
--
2.47.3
next prev parent reply other threads:[~2026-12-03 22:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 22:15 [RFC PATCH BlueZ v3 00/12] Periodic advertising and PAwR over MGMT Roland Schober
2026-12-03 22:15 ` [RFC PATCH BlueZ v3 01/12] doc/mgmt: Add PA and PAwR commands and events Roland Schober
2026-12-04 8:23 ` Periodic advertising and PAwR over MGMT bluez.test.bot
2026-12-03 22:15 ` [RFC PATCH BlueZ v3 02/12] lib/mgmt: Add periodic advertising and PAwR definitions Roland Schober
2026-12-03 22:15 ` [RFC PATCH BlueZ v3 03/12] monitor: Decode PA and PAwR MGMT commands and events Roland Schober
2026-12-03 22:15 ` [RFC PATCH BlueZ v3 04/12] client/mgmt: Fix length of byte arrays with empty entries Roland Schober
2026-12-03 22:15 ` [RFC PATCH BlueZ v3 05/12] client/mgmt: Refuse negative values in byte arrays Roland Schober
2026-12-03 22:15 ` [RFC PATCH BlueZ v3 06/12] client/mgmt: Add pa-params, pa-data and pawr-serve commands Roland Schober
2026-12-03 22:15 ` [RFC PATCH BlueZ v3 07/12] monitor: Add PAwR HCI definitions Roland Schober
2026-12-03 22:15 ` [RFC PATCH BlueZ v3 08/12] emulator/btdev: Check the length of PA commands Roland Schober
2026-12-03 22:15 ` [RFC PATCH BlueZ v3 09/12] emulator/btdev: Keep the advertising set after a timeout Roland Schober
2026-12-03 22:15 ` Roland Schober [this message]
2026-12-03 22:15 ` [RFC PATCH BlueZ v3 11/12] emulator/btdev: Add PAwR advertiser Roland Schober
2026-12-03 22:15 ` [RFC PATCH BlueZ v3 12/12] mgmt-tester: Add periodic advertising and PAwR tests Roland Schober
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=20261203221532.682750-11-rolandschober1968@gmail.com \
--to=rolandschober1968@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
/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