All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cheng Jiang <cheng.jiang@oss.qualcomm.com>
To: linux-bluetooth@vger.kernel.org
Cc: jinwang.li@oss.qualcomm.com, wei.deng@oss.qualcomm.com,
	xiuzhuo.shang@oss.qualcomm.com, shuai.zhang@oss.qualcomm.com,
	Cheng Jiang <cheng.jiang@oss.qualcomm.com>
Subject: [PATCH 08/11] profiles/ranging: Expose requester ranging data mode over D-Bus
Date: Thu,  1 Oct 2026 21:18:54 +0800	[thread overview]
Message-ID: <20261001131900.707485-9-cheng.jiang@oss.qualcomm.com> (raw)
In-Reply-To: <20261001131900.707485-1-cheng.jiang@oss.qualcomm.com>

Add a SetRangingDataMode method to the Channel Sounding interface so a
client can select how Ranging Data is received from the peer (Real-time
or On-demand) and the CCCD transport to use, wiring through to
bt_rap_set_ranging_data_mode().

When a measurement stops, disable the Real-time Ranging Data
subscription so the peer receives the CCCD disable that the requester
owns.

Assisted-by: Claude:claude-opus-4.8
---
 profiles/ranging/rap.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/profiles/ranging/rap.c b/profiles/ranging/rap.c
index b494d188c..de9cd3d1c 100644
--- a/profiles/ranging/rap.c
+++ b/profiles/ranging/rap.c
@@ -878,6 +878,12 @@ static DBusMessage *stop_measurement(DBusConnection *conn,
 
 	bt_rap_hci_set_procedure_data_cb(data->hci_sm, NULL, NULL, NULL);
 
+	/* The Requester owns the Real-time CCCD subscription. Unregister it when
+	 * the procedure ends so the peer receives the required CCCD disable. */
+	if (!bt_rap_disable_realtime_ranging(data->rap))
+		return g_dbus_create_error(msg, DBUS_ERROR_FAILED,
+					"Disable Real-time Ranging Data failed");
+
 	memset(&data->active_session, 0, sizeof(data->active_session));
 
 	g_dbus_emit_property_changed(btd_get_dbus_connection(),
@@ -887,6 +893,30 @@ static DBusMessage *stop_measurement(DBusConnection *conn,
 	return dbus_message_new_method_return(msg);
 }
 
+static DBusMessage *set_ranging_data_mode(DBusConnection *conn,
+					DBusMessage *msg, void *user_data)
+{
+	struct rap_data *data = user_data;
+	uint8_t mode;
+	uint8_t transport;
+
+	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_BYTE, &mode,
+					DBUS_TYPE_BYTE, &transport,
+					DBUS_TYPE_INVALID))
+		return g_dbus_create_error(msg, DBUS_ERROR_INVALID_ARGS,
+					"Expected Ranging Data mode byte");
+
+	if (mode > BT_RAP_RANGING_DATA_ONDEMAND)
+		return g_dbus_create_error(msg, DBUS_ERROR_INVALID_ARGS,
+					"Invalid Ranging Data mode");
+
+	if (!bt_rap_set_ranging_data_mode(data->rap, mode, transport))
+		return g_dbus_create_error(msg, DBUS_ERROR_FAILED,
+					"Set Ranging Data mode failed");
+
+	return dbus_message_new_method_return(msg);
+}
+
 static const GDBusMethodTable cs_dbus_methods[] = {
 	{ GDBUS_METHOD("StartMeasurement",
 			GDBUS_ARGS({ "params", "a{sv}" }),
@@ -896,6 +926,10 @@ static const GDBusMethodTable cs_dbus_methods[] = {
 			NULL,
 			NULL,
 			stop_measurement) },
+	{ GDBUS_METHOD("SetRangingDataMode",
+			GDBUS_ARGS({ "mode", "y" }, { "transport", "y" }),
+			NULL,
+			set_ranging_data_mode) },
 	{ }
 };
 
-- 
2.43.0


  parent reply	other threads:[~2026-10-01 13:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01 13:18 [PATCH 00/11] Ranging Profile and Ranging Service PTS fixes Cheng Jiang
2026-10-01 13:18 ` [PATCH 01/11] shared/gatt-client: Allow registering notify with explicit CCC value Cheng Jiang
2026-10-01 16:03   ` Ranging Profile and Ranging Service PTS fixes bluez.test.bot
2026-10-01 13:18 ` [PATCH 02/11] shared/gatt-db: Add gatt_db_attribute_indicate() Cheng Jiang
2026-10-01 15:48   ` Luiz Augusto von Dentz
2026-10-09  8:45     ` Cheng Jiang
2026-10-01 13:18 ` [PATCH 03/11] shared/rap: Honor CCCD transport for RAS on-demand ranging data Cheng Jiang
2026-10-01 13:18 ` [PATCH 04/11] shared/rap: Add RAS Control Point Abort Operation Cheng Jiang
2026-10-01 13:18 ` [PATCH 05/11] shared/rap: Shorten the requester Control Point response timeout Cheng Jiang
2026-10-01 13:18 ` [PATCH 06/11] shared/rap: Add real-time ranging data delivery on the responder Cheng Jiang
2026-10-01 13:18 ` [PATCH 07/11] shared/rap: Add requester ranging data subscription API Cheng Jiang
2026-10-01 13:18 ` Cheng Jiang [this message]
2026-10-01 13:18 ` [PATCH 09/11] client: Add Channel Sounding ranging data mode control Cheng Jiang
2026-10-01 13:18 ` [PATCH 10/11] doc: Document " Cheng Jiang
2026-10-01 13:18 ` [PATCH 11/11] doc/qualification: Add RAP/RAS PTS qualification results Cheng Jiang

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=20261001131900.707485-9-cheng.jiang@oss.qualcomm.com \
    --to=cheng.jiang@oss.qualcomm.com \
    --cc=jinwang.li@oss.qualcomm.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=shuai.zhang@oss.qualcomm.com \
    --cc=wei.deng@oss.qualcomm.com \
    --cc=xiuzhuo.shang@oss.qualcomm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.