From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 3/3] client: Stop discovery when connected with filter.auto_connect
Date: Wed, 8 Apr 2026 14:22:23 -0400 [thread overview]
Message-ID: <20260408182223.295711-3-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20260408182223.295711-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If device was connected via filter.auto_connect method (e.g. connect or
scan.auto_connect) stop the discovery session after the device connects.
---
client/main.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/client/main.c b/client/main.c
index c04998bb0a9a..57fa138880ed 100644
--- a/client/main.c
+++ b/client/main.c
@@ -687,6 +687,14 @@ static GDBusProxy *find_proxies_by_path(GList *source, const char *path)
return NULL;
}
+static bool filter_match_pattern(const char *pattern)
+{
+ if (!filter.active || !filter.pattern || !pattern)
+ return false;
+
+ return !strcmp(filter.pattern, pattern);
+}
+
static void property_changed(GDBusProxy *proxy, const char *name,
DBusMessageIter *iter, void *user_data)
{
@@ -699,12 +707,11 @@ static void property_changed(GDBusProxy *proxy, const char *name,
if (default_ctrl && proxy_is_child(proxy,
default_ctrl->proxy) == TRUE) {
DBusMessageIter addr_iter;
+ const char *address = NULL;
char *str;
if (g_dbus_proxy_get_property(proxy, "Address",
&addr_iter) == TRUE) {
- const char *address;
-
dbus_message_iter_get_basic(&addr_iter,
&address);
str = g_strdup_printf("[" COLORED_CHG
@@ -721,6 +728,19 @@ static void property_changed(GDBusProxy *proxy, const char *name,
set_default_device(proxy, NULL);
else if (!connected && default_dev == proxy)
set_default_device(NULL, NULL);
+
+ /* If the device is connected and the filter
+ * is auto_connect and it matches the pattern,
+ * stop discovery.
+ */
+ if (connected && filter.auto_connect &&
+ filter_match_pattern(address))
+ g_dbus_proxy_method_call(
+ default_ctrl->proxy,
+ "StopDiscovery",
+ NULL, NULL,
+ GUINT_TO_POINTER(false),
+ NULL);
}
print_iter(str, name, iter);
--
2.53.0
next prev parent reply other threads:[~2026-04-08 18:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 18:22 [PATCH BlueZ v2 1/3] device: Fix btd_device_connect_services not discovering Luiz Augusto von Dentz
2026-04-08 18:22 ` [PATCH BlueZ v2 2/3] client: Prompt user to start scanning on connect command Luiz Augusto von Dentz
2026-04-08 18:22 ` Luiz Augusto von Dentz [this message]
2026-04-08 20:30 ` [BlueZ,v2,1/3] device: Fix btd_device_connect_services not discovering bluez.test.bot
2026-04-09 20:00 ` [PATCH BlueZ v2 1/3] " patchwork-bot+bluetooth
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=20260408182223.295711-3-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/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