Linux bluetooth development
 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 09/11] client: Add Channel Sounding ranging data mode control
Date: Thu,  1 Oct 2026 21:18:55 +0800	[thread overview]
Message-ID: <20261001131900.707485-10-cheng.jiang@oss.qualcomm.com> (raw)
In-Reply-To: <20261001131900.707485-1-cheng.jiang@oss.qualcomm.com>

Add a "ranging-data-mode" command to the Channel Sounding submenu that
selects how Ranging Data is received from a peer (disabled, real-time or
on-demand) and the CCCD transport (notify or indicate), invoking the
ChannelSounding1.SetRangingDataMode method on the device.

Add an advertising helper so the Responder can advertise the Ranging
Service UUID for discovery, together with a getter for the default
LEAdvertisingManager proxy it needs.

Assisted-by: Claude:claude-opus-4.8
---
 client/cs.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)

diff --git a/client/cs.c b/client/cs.c
index 7533d053b..5d9f6ca31 100644
--- a/client/cs.c
+++ b/client/cs.c
@@ -1429,6 +1429,85 @@ static void cmd_cs_stop(int argc, char *argv[])
 		bt_shell_printf("Failed to send StopMeasurement\n");
 }
 
+/* ---- ranging-data-mode ---- */
+
+static void ranging_data_mode_setup(DBusMessageIter *iter, void *user_data)
+{
+	uint16_t values = PTR_TO_UINT(user_data);
+	uint8_t mode = values & 0xff;
+	uint8_t transport = values >> 8;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, &mode);
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, &transport);
+}
+
+static void ranging_data_mode_reply(DBusMessage *message, void *user_data)
+{
+	DBusError error;
+
+	dbus_error_init(&error);
+	if (dbus_set_error_from_message(&error, message)) {
+		bt_shell_printf("SetRangingDataMode failed: %s\n", error.message);
+		dbus_error_free(&error);
+		return;
+	}
+
+	bt_shell_printf("Ranging Data mode updated\n");
+}
+
+static void cmd_cs_ranging_data_mode(int argc, char *argv[])
+{
+	const char *dev_path;
+	GDBusProxy *proxy;
+	uint8_t mode;
+	uint8_t transport = 0x01;
+
+	if (argc < 3 || argc > 4) {
+		bt_shell_printf("Usage: ranging-data-mode <dev_addr>"
+				" <disabled/realtime/ondemand> [notify/indicate]\n");
+		return;
+	}
+
+	if (!strcmp(argv[2], "disabled"))
+		mode = 0x00;
+	else if (!strcmp(argv[2], "realtime"))
+		mode = 0x01;
+	else if (!strcmp(argv[2], "ondemand"))
+		mode = 0x02;
+	else {
+		bt_shell_printf("Invalid Ranging Data mode: %s\n", argv[2]);
+		return;
+	}
+
+	if (argc == 4) {
+		if (!strcmp(argv[3], "notify"))
+			transport = 0x01;
+		else if (!strcmp(argv[3], "indicate"))
+			transport = 0x02;
+		else {
+			bt_shell_printf("Invalid Ranging Data transport: %s\n", argv[3]);
+			return;
+		}
+	}
+
+	dev_path = cs_resolve_address(argv[1]);
+	if (!dev_path) {
+		bt_shell_printf("Device %s not found\n", argv[1]);
+		return;
+	}
+
+	proxy = cs_find_proxy(dev_path);
+	if (!proxy) {
+		bt_shell_printf("No ChannelSounding1 interface for that device\n");
+		return;
+	}
+
+	if (!g_dbus_proxy_method_call(proxy, "SetRangingDataMode",
+				ranging_data_mode_setup, ranging_data_mode_reply,
+				UINT_TO_PTR(mode | (transport << 8)), NULL))
+		bt_shell_printf("Failed to send SetRangingDataMode\n");
+}
+
 /* ---- show ---- */
 
 static void cmd_cs_show(int argc, char *argv[])
@@ -1545,6 +1624,9 @@ static const struct bt_shell_menu cs_menu = {
 				cmd_cs_stop,
 				"Stop the active distance measurement;"
 				" address required when multiple are active" },
+	{ "ranging-data-mode", "<dev_addr> <disabled/realtime/ondemand> [notify/indicate]",
+				cmd_cs_ranging_data_mode,
+				"Set RAP Requester Ranging Data subscription mode" },
 	{ "show",   NULL,
 				cmd_cs_show,
 				"Show active session id and current"
-- 
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 ` [PATCH 08/11] profiles/ranging: Expose requester ranging data mode over D-Bus Cheng Jiang
2026-10-01 13:18 ` Cheng Jiang [this message]
2026-10-01 13:18 ` [PATCH 10/11] doc: Document Channel Sounding ranging data mode control 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-10-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox