Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ v3 0/9] monitor: Decode Periodic Advertising with Responses
@ 2026-11-19  8:16 Roland Schober
  2026-11-19  8:16 ` [PATCH BlueZ v3 1/9] monitor: Fix handle decoding of status_handle_rsp Roland Schober
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Roland Schober @ 2026-11-19  8:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Roland Schober

This series teaches btmon the HCI commands and events of Periodic
Advertising with Responses (PAwR, Bluetooth 5.4). Until now they were
only listed by name in the opcode table and the events were printed as
unknown.

It is meant as the first step towards supporting the PAwR advertiser
role in the kernel and in BlueZ, which is what an access point of the
Electronic Shelf Label profile needs: being able to read the traces
comes before changing anything else.

Patches 1 to 6 fix existing decoders which the new ones use or which
were found on the way:
 - the Connection_Handle returned by the Periodic Advertising Sync
   Transfer commands and by LE Remove ISO Data Path was read as one
   octet,
 - LE Periodic Advertising Report trusted Data_Length and
   LE Extended Create Connection trusted the number of PHY parameter
   blocks, so truncated packets made them decode octets outside the
   packet,
 - the LE Set Periodic Advertising commands printed the advertising
   handle as a connection handle,
 - LE Periodic Advertising Report printed an unavailable TX power as
   127 dBm and named the AoD CTE type with 1 us slots AoA,
 - LE PAST Received printed the handle twice and decoded the clock
   accuracy as a BR/EDR one.

Patch 7 splits the LE Periodic Advertising Report decoding into
helpers without changing its output, so that patch 9 can share it.

Patch 8 decodes the five commands and patch 9 the six events,
including the [v2] variants of existing events.

Testing: I have no controller with PAwR support at hand yet. The
commands were sent with hcitool to a controller which rejects them, so
that btmon decodes what the host sent, and the events and the
successful command responses were decoded from hand-made btsnoop
traces. Every command and event of these traces was also fed to the
decoders cut to every length, in a buffer of exactly that size, with
AddressSanitizer, which found no read beyond a packet. The output for
well formed packets of the existing decoders was compared with the
current tree.

v3:
 - Add patches 4, 5 and 6, and print the advertising handle, the TX
   power and the CTE type the same way in the new decoders.
 - Patch 2: also report octets beyond Data_Length.
 - Patch 3: report extra PHY parameter blocks, and do not report the
   remaining PHYs as unknown after a truncated block.
 - Patch 8: reuse the [v1] decoder for LE Set Periodic Advertising
   Parameters [v2], print 0x00 subevent timings as none, check
   Response_Data_Length, and match LE Extended Create Connection [v2]
   with the events which complete it.
 - Patch 9: Data_Status 0xff keeps its reserved meaning in the [v1]
   LE Periodic Advertising Report, LE Enhanced Connection Complete [v2]
   is matched with the command which started the connection.
 - Patches 8 and 9: report a subevent data command or a response
   report with fewer entries than announced.

v2:
 - Add patches 2 and 3. The two problems Copilot found in v1 were in
   the [v2] decoders, but they came from the [v1] decoders they reuse,
   so they are fixed there.
 - The patch which splits the LE Periodic Advertising Report decoding
   keeps the new Data_Length check in the shared helper.

Roland Schober (9):
  monitor: Fix handle decoding of status_handle_rsp
  monitor: Fix data length of LE PA Report decoding
  monitor: Fix PHY decoding of LE Ext Create Connection
  monitor: Fix advertising handle of LE PA commands
  monitor: Fix TX power and CTE Type of LE PA Report
  monitor: Fix LE PAST Received decoding
  monitor: Split LE PA Report decoding into helpers
  monitor: Add PAwR HCI commands decoding
  monitor: Add PAwR HCI events decoding

 monitor/analyze.c |   1 +
 monitor/bt.h      | 174 ++++++++++++++
 monitor/packet.c  | 585 +++++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 708 insertions(+), 52 deletions(-)

-- 
2.47.3


^ permalink raw reply	[flat|nested] 12+ messages in thread
* [PATCH BlueZ v2 1/6] monitor: Fix handle decoding of status_handle_rsp
@ 2026-11-19  7:13 Roland Schober
  2026-11-19  9:41 ` monitor: Decode Periodic Advertising with Responses bluez.test.bot
  0 siblings, 1 reply; 12+ messages in thread
From: Roland Schober @ 2026-11-19  7:13 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Roland Schober

status_handle_rsp() decodes the return parameters of commands which
return a Status followed by a Connection_Handle, but it only reads the
first octet of the two octets of the handle, so any handle above 255 is
printed wrong.

With LE Periodic Advertising Set Info Transfer returning handle 3585:

> HCI Event: Command Complete (0x0e) plen 6
      LE Periodic Advertising Set Info Transfer (0x08|0x005b) ncmd 1
        Status: Unknown Connection Identifier (0x02)
        Connection handle: 1

Read the handle as a 16-bit value:

        Connection handle: 3585

Fixes: b73d4bb9e3c9 ("monitor: Decode LE Periodic Advertising Sync Transfer command")
Assisted-by: Claude:claude-fable-5-2
---
 monitor/packet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/monitor/packet.c b/monitor/packet.c
index eddf8706a..4ff24092e 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -4976,7 +4976,7 @@ static void status_handle_rsp(uint16_t index, const void *data, uint8_t size)
 	uint8_t status = *((const uint8_t *) data);
 
 	print_status(status);
-	print_field("Connection handle: %d", get_u8(data + 1));
+	print_field("Connection handle: %d", get_le16(data + 1));
 }
 
 static void status_bdaddr_rsp(uint16_t index, const void *data, uint8_t size)
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-11-19  9:53 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19  8:16 [PATCH BlueZ v3 0/9] monitor: Decode Periodic Advertising with Responses Roland Schober
2026-11-19  8:16 ` [PATCH BlueZ v3 1/9] monitor: Fix handle decoding of status_handle_rsp Roland Schober
2026-11-19  9:53   ` monitor: Decode Periodic Advertising with Responses bluez.test.bot
2026-11-19  8:16 ` [PATCH BlueZ v3 2/9] monitor: Fix data length of LE PA Report decoding Roland Schober
2026-11-19  8:16 ` [PATCH BlueZ v3 3/9] monitor: Fix PHY decoding of LE Ext Create Connection Roland Schober
2026-11-19  8:16 ` [PATCH BlueZ v3 4/9] monitor: Fix advertising handle of LE PA commands Roland Schober
2026-11-19  8:16 ` [PATCH BlueZ v3 5/9] monitor: Fix TX power and CTE Type of LE PA Report Roland Schober
2026-11-19  8:16 ` [PATCH BlueZ v3 6/9] monitor: Fix LE PAST Received decoding Roland Schober
2026-11-19  8:16 ` [PATCH BlueZ v3 7/9] monitor: Split LE PA Report decoding into helpers Roland Schober
2026-11-19  8:16 ` [PATCH BlueZ v3 8/9] monitor: Add PAwR HCI commands decoding Roland Schober
2026-11-19  8:16 ` [PATCH BlueZ v3 9/9] monitor: Add PAwR HCI events decoding Roland Schober
  -- strict thread matches above, loose matches on Subject: below --
2026-11-19  7:13 [PATCH BlueZ v2 1/6] monitor: Fix handle decoding of status_handle_rsp Roland Schober
2026-11-19  9:41 ` monitor: Decode Periodic Advertising with Responses bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox