From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796336157; b=2AiTHGXhnjyYkWB2OVNiDNhsxgoUBo5/42C3+z1REBp2stVRersWK6VVKEFeCnjX/9r6 qZcZm4CUf+A1KXpVg/l/NDJjvA/Wy1HKro8x+oaoSHpb26EcfhP3a/A22ILDam/MsF1FI 7hB60r5hfFFrIyvei/JZwyOpeh58Kj1vUaV4/ll7RQ4H3EmBk4WTO1D8iCMgrx3ht37KV zffZ6qAq+48B+chMedGFdK8l/XIn65yKB8K0nteZ+QXmID2+jmUiiGAsa5Dz/IiYY0wDM aZSG3SF+jWZwDdyLbtDFb922l7nXbR9k6ctk6u8UeRzPOQx/mWPJjTLDD2Fb8mSJjWA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796336157; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=e1xp4yj63ORxGzdnss4cGOxHaDWPkZLF0K9GuLfQBQw=; b=rCv9TCbbEFhrt12qSDiU5YWHjET++MfGSpoguRMw25z3CjnESzSyInbXn5SETJQhtcm7 eVRWG1D+xWb9aAkdFGDzvyBGxWz+6AZbASkow+b84pM4o19SHAFfS6xkNuGFK9DaCuzHl eUB8EAWO3ioYR1bMDzhsAdiAR7qDwLtJiO5TaEzPZy6oDF54JMf03YiidnvUtz2rJccz7 vukDNilbMhMixW8OChCb2aUEvAikbe2MPHWD+xerSLcmDOC8SNzejFPb5cKT2/phfA7uV evCH58sUzAF1M1YLYK/jlR68Uo5XW6aPcNbBubg+RHSy0KNN6XZsu1OUrcuSxx+NqCg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=xDp4eY4b; arc=none smtp.remote-ip=209.85.128.41 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 627D9606A322 for ; Thu, 3 Dec 2026 22:15:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 627D9606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=xDp4eY4b Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4bb6756bb1cso221465e9.2 for ; Thu, 03 Dec 2026 14:15:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796336156; x=1796940956; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=e1xp4yj63ORxGzdnss4cGOxHaDWPkZLF0K9GuLfQBQw=; b=xDp4eY4btDNVK/MnooxYyPVm6e0sq0QZWkTpuajYjEpzVr6jNFkfE1rzfabgIUiy+u B/fYsrJkBar8QJobQJg0c0hANqsrjraiDezSg/v//mRSjt2E0B00Mb95Xn1ojbUYhfPO 626ZgydPbqNcnLSEvLkbo/+TM4kHQQVEY+qc3rZ2I+eC+B5oy7nXXfalIIASrriwOqGv wBxcR0FntEmhVOdVRrPwc9B+3CphkZKcaVxTNpvm5LCM3XksDCr4epHENp1gvuscTXJ6 Shx1hbvUteNw5DMdniEw293kpLIiEgUw2Rd/+r17v+XIByI3BlHhGsPOdix7mbaWsyvi bUAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796336156; x=1796940956; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=e1xp4yj63ORxGzdnss4cGOxHaDWPkZLF0K9GuLfQBQw=; b=Q2iwmMqZ/ae0ytl9lw+Z0MRoLfTX9dkp+n3fQnb5+G3v9LtPV5C4xmCPcC+L84ELsn IqDpU9/W50b/BvP6bpnrCyHBYwgnYNJGITU/JaAZX7i5RcMblk+4eqkqD1JZu1R7jpPI 351WnjrDlvUlw2CdlnWe9CY8uVwuNf8ecnycBCWDPGcbn5WQMJ400od/MsnfBh9WKUrr bdXCCLrvYLIECOWCdJHl04ofW1a9sn4Par3bSsIACVmXVz0TS7oKZu1c+XqR7WV6fkL8 XxW5Y0PxuIjypcF5BavF6GkAr18ODEJilpm0Wn3mQCFR3WeUx9dHiuaX1WrKfBK+UkSj F+NQ== X-Gm-Message-State: APuU4Z8zf4FGfuF7qmoGnL2jAbb5gudgaGfjrAeIljXxU5HuTQwoitYW /GuFmvRf/hdusq5wxqsdxcVG/lBqeYBfPGSQxT9TVVKfreCjdV5eB0ABzT+oNldJ X-Gm-Gg: AZFdTZcUkGP/DcdFl+hiIk7pCoDlHt7BP9HHhbfWpNZEdflTPoxun89mJ8uzA8zppPD zxnF5362cnuLPD6vSGPFBhZGwFRjjr8NBzDctc2Ia23VCkMCrSNv172/7f4y+1n0Exi4j5KoToI Tfg0ug9ankvUiYlRcXdhCCczx+ce/x/PiPshXJ6rMucyplTccjW7VX88mIFUXsJznCiEju8OCTR ZOhMOYpu18jm3n6PtchPfpBL8XF6w8sQKFqgPTuNkAm3RHNEO7gJ8kFqNUZkgUm5ubOye+vPUe3 OYggwXTqSUYEyZPwGWoyvhM15oUDuKOvJYSIcSepmeUd29DhoBLguIaCFZs3FQV2BCR92fYcM32 SWwuetoyPl1LfUXPmjmr6Nim8xb8qkmLYTmYafE8ZcmTjfiZ0ELfAddyZ8c7wTde45Hn6TZk/iB 7qKBL1WAoegJfAAZ1M604qpHCOr2zGK7vJVK5bXJ9jjkvsI1/0vyP5b0zBb3+gqeZ25ECJPq+rB Gu37qAqPrYDY8Hs6O2dGigAZdv6ZSpFYpomvBk0MwsGKeKDXxmBVtHKCkSKKbisKQnNS8jdlcHY ua7lE4ZueUAOFBlI5ud+HZV8iyg8j6Hzoif+BVm1hgCQ1lAV X-Received: by 2002:a05:6000:2484:b0:490:6e0f:a01d with SMTP id ffacd0b85a97d-4d1e263d131mr360455f8f.1.1796336155683; Thu, 03 Dec 2026 14:15:55 -0800 (PST) Received: from schinder.fritz.box ([2001:9e8:b39a:7900:a13b:fe74:8c9c:c788]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d17435e11fsm1584273f8f.51.2026.12.03.14.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 14:15:55 -0800 (PST) From: Roland Schober To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, Roland Schober Subject: [RFC PATCH BlueZ v3 00/12] Periodic advertising and PAwR over MGMT Date: Thu, 3 Dec 2026 23:15:20 +0100 Message-ID: <20261203221532.682750-1-rolandschober1968@gmail.com> X-Mailer: git-send-email 2.47.3 X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This is the user space side of the kernel RFC "[RFC PATCH v2 0/6] Bluetooth: Periodic advertising and PAwR over MGMT": a MGMT interface for periodic advertising and for the advertiser side of Periodic Advertising with Responses (PAwR), with emulator support and tests. The interface is the one of v1. The kernel series is at v2 for one more fix: the train of an instance whose advertising timed out went on. Patch 1 documents the three commands and two events in doc/mgmt-protocol.rst; it is the place to comment on the interface. Patch 2 adds the definitions, patch 3 the btmon decoding. Patches 4 and 5 fix how btmgmt reads a byte array, which the new commands use: the length with empty entries, and negative values. Patch 6 adds three btmgmt commands: pa-params sends Add Periodic Advertising Parameters, pa-data sends Add Periodic Advertising Data, pawr-serve answers the subevent data requests and prints the response reports. Plain periodic advertising: btmgmt add-ext-adv-params -P 1M 1 btmgmt pa-params 1 0x50 0x50 btmgmt pa-data 1 0x05 0xff 0x59 0x00 0x01 0x02 btmgmt add-ext-adv-data 1 A PAwR train with 5 subevents of 5 response slots: btmgmt add-ext-adv-params -P 1M 1 btmgmt pa-params 1 0xff 0xff 5 0x30 8 0x50 5 btmgmt pawr-serve 1 5 5 & btmgmt add-ext-adv-data 1 Patches 7 to 11 are the emulator: - Patch 7 adds the PAwR HCI definitions to bt.h. They are the ones of my btmon series "monitor: Decode Periodic Advertising with Responses", which is not applied yet; the patch is dropped here when that series is in. - Patch 8 gives the handlers which patches 10 and 11 extend a check of the command length. - Patch 9 keeps the advertising set when the duration of its advertising ends. The emulator freed it, also with periodic advertising enabled on it. - Patch 10 makes the emulator refuse to remove an advertising set while periodic advertising is enabled on it, as a controller does. The kernel needs "Bluetooth: hci_sync: Disable PA before removing an advertising set" for this, which is part of the kernel RFC and which I also sent on its own. Without it the broadcast cases of test/functional/test_bap.py fail, as the CI run of v1 showed. - Patch 11 adds the PAwR advertiser to controllers of version 6.0 and later: the parameters [v2], the subevent data requests once per periodic advertising interval, and the subevent data command, which refuses data that was not asked for. Nothing is transmitted: the responder side and the response reports are not emulated yet. Patch 12 adds 33 mgmt-tester cases. They need the kernel series; on a kernel without it they fail. The case with a timeout needs v2 of it. Also tested with the kernel RFC in QEMU against the Nordic SoftDevice Controller on a simulated nRF52 (BabbleSim), with Zephyr's periodic_sync_rsp sample as the responder. That run covers what the emulator does not: a synchronised responder and its response reports. The D-Bus API is not part of this RFC; it follows when the MGMT interface is agreed. For PAwR I expect bluetoothd to keep the data of each subevent and to answer the data requests itself, since a D-Bus round trip per request does not fit the controller's lead time. v3: - Emulator: check the length of LE Set Periodic Advertising Parameters [v2] (Copilot), and of the commands whose handlers the series extends (new patch 8). The handlers were then fed truncated, extended and random commands under AddressSanitizer. - btmgmt pawr-serve: tell the shell that the command stays running, so that the lines of a script after it are run (Copilot). Print a response report which has no responses. - btmgmt: refuse negative values in a byte array (new patch 5). - Emulator: LE Set Periodic Advertising Enable checks its handle. It is refused for a set which does not exist, and for a set other than the one with the parameters. - Emulator: keep the advertising set when the duration of its advertising ends (new patch 9). With the check above, a train on a set which was freed that way could not be disabled any more. - doc/mgmt-protocol.rst: subevent data which was not requested fails with Busy. - mgmt-tester: new case for an instance with a timeout and a train. The kernel has to disable the train and remove the set when the advertising of the set ends, which v2 of the kernel series does. - mgmt-tester: the "Sent twice" case uses an interval of 2 s, so the second answer is out before the next request. The "too many subevents" case breaks no other rule than the number. - Rebased. v2: - btmgmt pawr-serve: do not write beyond the command buffer, send data which does not fit one command in several, check the arguments before the running configuration is changed, and replace an earlier pawr-serve instead of answering twice. Copilot found these four. - btmgmt: refuse numbers out of range, take the data from all remaining arguments, size the buffer which prints a response for the largest data length. Add patch 4 and the commands to doc/bluetoothctl-mgmt.rst. - Emulator: a refused LE Set Periodic Advertising Enable leaves the train as it is (Copilot). Check the response slot spacing against the subevent interval, refuse a command which names a subevent twice, and forget the subevents of a set which is removed. - Emulator: answer Command Disallowed for subevent data before the first request, for a second command for one subevent and for a subevent the train does not have, as the Core Specification lists it. v1 answered Too Early and Too Late, which are for data that misses its subevent in time; the patch with their definitions is dropped. - mgmt-tester: send the two commands of the "two commands" test without waiting for the first reply (Copilot), use a periodic advertising interval of 400 ms, which leaves time to answer, and add a case for a subevent the train does not have. - doc/mgmt-protocol.rst: a command takes the data of up to 15 subevents. - The trace in the commit message of patch 3 is a complete excerpt. - Shorter subjects for patches 1, 3, 7 and 8 (now 1, 3, 10 and 11). - Rebased. Roland Schober (12): doc/mgmt: Add PA and PAwR commands and events lib/mgmt: Add periodic advertising and PAwR definitions monitor: Decode PA and PAwR MGMT commands and events client/mgmt: Fix length of byte arrays with empty entries client/mgmt: Refuse negative values in byte arrays client/mgmt: Add pa-params, pa-data and pawr-serve commands monitor: Add PAwR HCI definitions emulator/btdev: Check the length of PA commands emulator/btdev: Keep the advertising set after a timeout emulator/btdev: Keep advertising sets with PA enabled emulator/btdev: Add PAwR advertiser mgmt-tester: Add periodic advertising and PAwR tests client/mgmt.c | 384 ++++++++++++- doc/bluetoothctl-mgmt.rst | 51 ++ doc/mgmt-protocol.rst | 210 +++++++ emulator/btdev.c | 337 ++++++++++- lib/bluetooth/mgmt.h | 74 +++ monitor/bt.h | 174 ++++++ monitor/packet.c | 204 +++++++ tools/mgmt-tester.c | 1119 +++++++++++++++++++++++++++++++++++++ 8 files changed, 2544 insertions(+), 9 deletions(-) base-commit: 736384fcdc45dc343c8109317510f4e2a31bd7fb -- 2.47.3