Skip to content

Channel Sounding and RAP fixes

Cheng Jiang linux-bluetooth 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest15 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15gatt-database: Drop stale device state for removed bondssrc/device.c src/gatt-database.c src/gatt-database.h+30 -02 replies
2/15shared/rap: Reset the readable Ranging Counters per connectionsrc/shared/rap.c+11 -00 replies
3/15shared/rap: Subscribe on-demand data with the requested transportdoc/org.bluez.ChannelSounding1.rst src/shared/rap.c+28 -90 replies
4/15shared/rap: Subscribe to Ranging Data when a measurement startsprofiles/ranging/rap.c src/shared/rap.c src/shared/rap.h+36 -30 replies
5/15client/cs: Fix use-after-free in stop_measurement_replyclient/cs.c+12 -30 replies
6/15shared/hci: Look up the connection handle on the right linklib/bluetooth/hci.h profiles/ranging/rap.c src/shared/hci.c +2 more+11 -100 replies
7/15profiles/ranging: Let the Reflector run the CS setup phaseclient/cs.c doc/org.bluez.ChannelSounding1.rst profiles/ranging/rap.c +1 more+43 -670 replies
8/15profiles/ranging: Let StartMeasurement() pick the Initiator for Bothprofiles/ranging/rap_hci.c+36 -230 replies
9/15profiles/ranging: Take the CS role from Config Completeprofiles/ranging/rap_hci.c src/shared/rap.h+20 -100 replies
10/15profiles/ranging: Act on a CS configuration created by the peerprofiles/ranging/rap_hci.c+35 -70 replies
11/15profiles/ranging: Keep a peer-driven setup from being rewoundprofiles/ranging/rap_hci.c+10 -00 replies
12/15profiles/ranging: Defer CS Security Enable until the link is encryptedprofiles/ranging/rap_hci.c+65 -130 replies
13/15profiles/ranging: Choose the CS antenna configuration from both endsprofiles/ranging/rap_hci.c+125 -00 replies
14/15profiles/ranging: Do not start a procedure after StopMeasurement()profiles/ranging/rap_hci.c+20 -10 replies
15/15shared/rap: Start the Real-time timeout when the procedure startssrc/shared/rap.c+8 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH BlueZ 00/15] Channel Sounding and RAP fixes

This series fixes problems found while running the RAP Requester (RREQ), RAS Server (RAS/SR) and GAP CS test cases against PTS. So far the Channel Sounding code had mostly been used between two BlueZ devices, with the local side creating the configuration as the Initiator. The test cases also cover the Reflector role, a configuration created by the peer, peers with different antenna counts and every Ranging Data mode, and most of the fixes are for those paths.

The patches do not depend on how the CS session is created; they apply to the existing session set up from the RAP profile probe. Creating a session for a peer without the Ranging Service is a separate question, which I sent to the list earlier and is not part of this series.

GATT database and RAS (patches 1-4 and 15)
==========================================

1. A device removed while disconnected kept its CCC state in the GATT database, and it was restored when the device paired again. Drop it from device_remove().

2. The Ranging Counters read from Ranging Data Ready and Ranging Data Overwritten are scoped to the connection (RAS v1.0 3.4 and 3.5), but were never cleared, so a new connection read the counter of the previous one. Clear them in bt_rap_detach().

3. On-demand Ranging Data was always subscribed with notifications, while the RAS Control Point, which only supports indications, followed the requested transport; with notifications no On-demand transfer could be requested. Follow RAS v1.0 Table 3.1: the requested transport for On-demand Ranging Data, indications for the Control Point, and indications for Ready and Overwritten whenever the server supports them.

4. Reading RAS Features subscribed to Real-time Ranging Data at connection time, when no procedure is running yet, so the 5 s timer disabled it again. Subscribe when StartMeasurement() is called instead, unless SetRangingDataMode() already did, and use On-demand when the peer lacks Real-time Ranging Data (RAP v1.0 4.4.2).

15. RAP v1.0 4.4.1.1 counts the 5 s Real-time timeout from the start of the CS procedure, but the timer started when the CCCD was written, possibly seconds earlier. Start it from CS Procedure Enable Complete.

bluetoothctl and shared/hci (patches 5-6)
=========================================

5. Fix a use-after-free in the StopMeasurement() reply of bluetoothctl, where the Active=false property change had already freed the session.

6. bt_hci_get_conn_handle() always listed the connections of hci0 and took the first link matching the address, which could be a BR/EDR ACL or an old link being torn down. Use the right controller index and match the link type; this adds LE_LINK to lib/bluetooth/hci.h, replacing the local copy in hcitool.

CS role and setup in profiles/ranging (patches 7-14)
====================================================

These depend on each other and are best applied in order.

7. StartMeasurement() returned early for a Reflector, so it never ran the setup phase and dropped every event the remote Initiator drove. Run the setup phase for the Reflector too, subscribe to Ranging Data as for an Initiator (the RAP roles are independent of the CS roles), and do not send Procedure Enable on stop when no procedure runs.

8. With Role_Enable permitting both roles, the GAP role decided which one was used. Since the setup phase only runs from StartMeasurement(), take the Initiator role, and tolerate the LL Procedure Collision that two simultaneous configuration requests can cause.

9. Config Complete overwrote the Role_Enable value with the negotiated role, so a second StartMeasurement() sent an invalid Role_Enable. Keep the two in separate fields, and do not send Procedure Enable from a Reflector.

10. Config Complete was only parsed in the state reached during a local setup, so a configuration created by the peer was dropped. Parse it in any state, ignore events for other links, and ignore a removal whose parameters are undefined.

11. The Set Default Settings response rewound a setup the peer had already advanced, and an Initiator then created a second configuration. Only advance from the initial state.

12. CS Security Enable needs an encrypted link (Core v6.2 Vol 4 Part E 7.8.133). When the configuration completed before encryption, the command was never sent. Defer it to the Encryption Change event.

13. The antenna configuration was always ACI 7 (2:2) unless the application set another, which a single-antenna Controller on either end rejects. Choose one that fits both ends' capabilities and the negotiated role (Core v6.2 Vol 6 Part A, Table 5.3).

14. A StopMeasurement() during the setup phase did not stop it, and the Initiator went on to create a configuration and enable a procedure. Remember the stop until the next StartMeasurement().

Testing
=======

Each patch builds with --enable-maintainer-mode and unit/test-rap passes. The PTS runs (PTS 8.14.0, Qualcomm controller) used a BlueZ 5.86 based tree carrying these fixes.

Cheng Jiang (15):
gatt-database: Drop stale device state for removed bonds shared/rap: Reset the readable Ranging Counters per connection shared/rap: Subscribe on-demand data with the requested transport shared/rap: Subscribe to Ranging Data when a measurement starts client/cs: Fix use-after-free in stop_measurement_reply shared/hci: Look up the connection handle on the right link profiles/ranging: Let the Reflector run the CS setup phase profiles/ranging: Let StartMeasurement() pick the Initiator for Both profiles/ranging: Take the CS role from Config Complete profiles/ranging: Act on a CS configuration created by the peer profiles/ranging: Keep a peer-driven setup from being rewound profiles/ranging: Defer CS Security Enable until the link is encrypted profiles/ranging: Choose the CS antenna configuration from both ends profiles/ranging: Do not start a procedure after StopMeasurement() shared/rap: Start the Real-time timeout when the procedure starts

 client/cs.c                        |  40 +--
 doc/org.bluez.ChannelSounding1.rst |  21 +-
 lib/bluetooth/hci.h                |   1 +
 profiles/ranging/rap.c             |  16 +-
 profiles/ranging/rap_hci.c         | 414 +++++++++++++++++++++++------
 src/device.c                       |   3 +
 src/gatt-database.c                |  25 ++
 src/gatt-database.h                |   2 +
 src/shared/hci.c                   |  12 +-
 src/shared/hci.h                   |   2 +-
 src/shared/rap.c                   |  82 +++++-
 src/shared/rap.h                   |   6 +-
 tools/hcitool.c                    |   3 -
 13 files changed, 484 insertions(+), 143 deletions(-)
Signature · 1 line
2.43.0