From: Naga Bhavani Akella <naga.akella@oss.qualcomm.com>
To: linux-bluetooth@vger.kernel.org
Cc: luiz.dentz@gmail.com, quic_mohamull@quicinc.com,
quic_hbandi@quicinc.com, quic_anubhavg@quicinc.com,
Naga Bhavani Akella <nakella@qti.qualcomm.com>
Subject: [PATCH BlueZ v2 5/5] client: Add CS distance display support to bluetoothctl
Date: Wed, 12 Aug 2026 15:33:45 +0530 [thread overview]
Message-ID: <20260812100345.2956271-6-naga.akella@oss.qualcomm.com> (raw)
In-Reply-To: <20260812100345.2956271-1-naga.akella@oss.qualcomm.com>
From: Naga Bhavani Akella <nakella@qti.qualcomm.com>
Track org.bluez.CSDistance1 proxies and append/remove
them on InterfacesAdded/InterfacesRemoved.
Print the DistanceMeters property on PropertiesChanged,
and show it under info option alongside the existing
Battery Percentage and CS Active properties.
---
client/cs.c | 2 +-
client/cs.h | 1 +
client/main.c | 33 +++++++++++++++++++++++++++++++++
3 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/client/cs.c b/client/cs.c
index 9f069589d..fd2270a51 100644
--- a/client/cs.c
+++ b/client/cs.c
@@ -303,7 +303,7 @@ static const char *cs_resolve_address(const char *address)
}
/* Find the ChannelSounding1 proxy for the device at the given object path. */
-static GDBusProxy *cs_find_proxy(const char *dev_path)
+GDBusProxy *cs_find_proxy(const char *dev_path)
{
GDBusProxy *proxy;
const char *path;
diff --git a/client/cs.h b/client/cs.h
index 243d2a72b..fbf7ff954 100644
--- a/client/cs.h
+++ b/client/cs.h
@@ -16,3 +16,4 @@ void cs_device_disconnected(const char *dev_path);
void cs_measurement_started(GDBusProxy *proxy);
void cs_measurement_stopped(GDBusProxy *proxy);
void cs_set_device_list(GList **devices);
+GDBusProxy *cs_find_proxy(const char *dev_path);
diff --git a/client/main.c b/client/main.c
index b5cad8afc..1fd00a786 100644
--- a/client/main.c
+++ b/client/main.c
@@ -69,6 +69,7 @@ static char *default_local_attr;
static GDBusProxy *default_attr;
static GList *ctrl_list;
static GList *battery_proxies;
+static GList *cs_distance_proxies;
static const char *agent_arguments[] = {
"on",
@@ -121,8 +122,10 @@ static void disconnect_handler(DBusConnection *connection, void *user_data)
g_list_free_full(ctrl_list, proxy_leak);
g_list_free_full(battery_proxies, proxy_leak);
+ g_list_free_full(cs_distance_proxies, proxy_leak);
ctrl_list = NULL;
battery_proxies = NULL;
+ cs_distance_proxies = NULL;
default_ctrl = NULL;
cs_set_device_list(NULL);
@@ -358,6 +361,16 @@ static void battery_removed(GDBusProxy *proxy)
battery_proxies = g_list_remove(battery_proxies, proxy);
}
+static void cs_distance_added(GDBusProxy *proxy)
+{
+ cs_distance_proxies = g_list_append(cs_distance_proxies, proxy);
+}
+
+static void cs_distance_removed(GDBusProxy *proxy)
+{
+ cs_distance_proxies = g_list_remove(cs_distance_proxies, proxy);
+}
+
static void device_added(GDBusProxy *proxy)
{
DBusMessageIter iter;
@@ -531,6 +544,8 @@ static void proxy_added(GDBusProxy *proxy, void *user_data)
bearer_added(proxy);
} else if (!strcmp(interface, "org.bluez.ChannelSounding1")) {
cs_proxy_added(proxy);
+ } else if (!strcmp(interface, "org.bluez.CSDistance1")) {
+ cs_distance_added(proxy);
}
}
@@ -664,6 +679,8 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data)
bearer_removed(proxy);
} else if (!strcmp(interface, "org.bluez.ChannelSounding1")) {
cs_proxy_removed(proxy);
+ } else if (!strcmp(interface, "org.bluez.CSDistance1")) {
+ cs_distance_removed(proxy);
}
}
@@ -843,6 +860,9 @@ static void property_changed(GDBusProxy *proxy, const char *name,
else
cs_measurement_stopped(proxy);
}
+ } else if (!strcmp(interface, "org.bluez.CSDistance1")) {
+ if (!strcmp(name, "DistanceMeters"))
+ print_property(proxy, "DistanceMeters");
}
}
@@ -1882,6 +1902,8 @@ static void cmd_info(int argc, char *argv[])
{
GDBusProxy *proxy;
GDBusProxy *battery_proxy;
+ GDBusProxy *cs_proxy;
+ GDBusProxy *cs_distance_proxy;
GDBusProxy *bearer;
DBusMessageIter iter;
const char *address;
@@ -1934,6 +1956,17 @@ static void cmd_info(int argc, char *argv[])
print_property_with_label(battery_proxy, "Percentage",
"Battery Percentage");
+ cs_proxy = cs_find_proxy(g_dbus_proxy_get_path(proxy));
+ if (cs_proxy)
+ print_property_with_label(cs_proxy, "Active",
+ "CS Session Active");
+
+ cs_distance_proxy = find_proxies_by_path(cs_distance_proxies,
+ g_dbus_proxy_get_path(proxy));
+ if (cs_distance_proxy)
+ print_property_with_label(cs_distance_proxy, "DistanceMeters",
+ "CS DistanceMeters");
+
bearer = find_proxies_by_iface(default_ctrl->bearers,
g_dbus_proxy_get_path(proxy),
"org.bluez.Bearer.BREDR1");
--
next prev parent reply other threads:[~2026-08-12 10:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 10:03 [PATCH BlueZ v2 0/5] Add CS distance provider implementation Naga Bhavani Akella
2026-08-12 10:03 ` [PATCH BlueZ v2 1/5] doc: Add org.bluez.CSDistance1 documentation Naga Bhavani Akella
2026-08-12 11:33 ` Add CS distance provider implementation bluez.test.bot
2026-08-12 10:03 ` [PATCH BlueZ v2 2/5] doc: Add org.bluez.CSDistanceProvider documentation Naga Bhavani Akella
2026-08-12 10:03 ` [PATCH BlueZ v2 3/5] doc: Add org.bluez.CSDistanceProviderManager documentation Naga Bhavani Akella
2026-08-12 10:03 ` [PATCH BlueZ v2 4/5] rap: Add CS Distance provider D-Bus API Naga Bhavani Akella
2026-08-12 10:03 ` Naga Bhavani Akella [this message]
2026-08-18 19:54 ` [PATCH BlueZ v2 0/5] Add CS distance provider implementation Luiz Augusto von Dentz
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=20260812100345.2956271-6-naga.akella@oss.qualcomm.com \
--to=naga.akella@oss.qualcomm.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=nakella@qti.qualcomm.com \
--cc=quic_anubhavg@quicinc.com \
--cc=quic_hbandi@quicinc.com \
--cc=quic_mohamull@quicinc.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.