* [PATCH BlueZ v2 1/3] device: Fix btd_device_connect_services not discovering
@ 2026-04-08 18:22 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
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2026-04-08 18:22 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
btd_device_connect_services would not attempt to discover in case the
selected bearer is BR/EDR and once discover is complete then it shall
proceed with connecting the services.
---
src/adapter.c | 9 ---------
src/device.c | 27 +++++++++++++++++++++++++--
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 04568dae6e98..46b89526fcaf 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3686,14 +3686,6 @@ struct device_connect_data {
DBusMessage *msg;
};
-static void device_browse_cb(struct btd_device *dev, int err, void *user_data)
-{
- DBG("err %d (%s)", err, strerror(-err));
-
- if (!err)
- btd_device_connect_services(dev, NULL);
-}
-
static void device_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
{
struct device_connect_data *data = user_data;
@@ -3726,7 +3718,6 @@ static void device_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
}
device_discover_services(device);
- device_wait_for_svc_complete(device, device_browse_cb, NULL);
g_io_channel_unref(io);
dbus_message_unref(data->msg);
diff --git a/src/device.c b/src/device.c
index cfbde307bcc9..e762aea2797c 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2705,6 +2705,17 @@ static uint8_t select_conn_bearer(struct btd_device *dev)
return dev->bdaddr_type;
}
+static void device_browse_cb(struct btd_device *dev, int err, void *user_data)
+{
+ DBG("err %d (%s)", err, strerror(-err));
+
+ /* If there are not errors with discovery proceed conecting services */
+ if (!err) {
+ dev->pending = create_pending_list(dev, NULL);
+ connect_next(dev);
+ }
+}
+
int btd_device_connect_services(struct btd_device *dev, GSList *services)
{
GSList *l;
@@ -2724,8 +2735,20 @@ int btd_device_connect_services(struct btd_device *dev, GSList *services)
return device_connect_le(dev);
}
- if (!dev->bredr_state.svc_resolved)
- return -ENOENT;
+ if (!dev->bredr_state.svc_resolved) {
+ int err;
+
+ err = device_discover_services(dev);
+ if (err)
+ return err;
+
+ /* Wait for service discovery to complete before connecting to
+ * profiles.
+ */
+ device_wait_for_svc_complete(dev, device_browse_cb, NULL);
+
+ return 0;
+ }
if (services) {
for (l = services; l; l = g_slist_next(l)) {
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ v2 2/3] client: Prompt user to start scanning on connect command
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 ` Luiz Augusto von Dentz
2026-04-08 18:22 ` [PATCH BlueZ v2 3/3] client: Stop discovery when connected with filter.auto_connect Luiz Augusto von Dentz
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2026-04-08 18:22 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If connect command don't find the device object make it prompt the
user to start scanning and set discovery filter pattern to given
address and mark it to auto-connect:
[bluetoothctl]> connect XX:XX:XX:XX:XX:XX
Device XX:XX:XX:XX:XX:XX not available
[XX:XX:XX:XX:XX:XX] Scan and connect (yes,no): y
SetDiscoveryFilter success
Discovery started
[NEW] Device XX:XX:XX:XX:XX:XX
[NEW] BREDR /org/bluez/hci0/dev_XX:XX:XX:XX:XX:XX
[CHG] Device XX:XX:XX:XX:XX:XX Connected: yes
[CHG] BREDR XX:XX:XX:XX:XX:XX Connected: yes
---
client/main.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/client/main.c b/client/main.c
index cb016a579f31..c04998bb0a9a 100644
--- a/client/main.c
+++ b/client/main.c
@@ -2210,6 +2210,37 @@ static void connect_reply(DBusMessage *message, void *user_data)
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}
+static void prompt_scan_connect(const char *input, void *user_data)
+{
+ char *address = user_data;
+
+ if (!strcmp(input, "yes") || !strcmp(input, "y")) {
+ dbus_bool_t enable = TRUE;
+
+ free(filter.pattern);
+ filter.pattern = address;
+ filter.auto_connect = true;
+
+ filter.set = false;
+ set_discovery_filter(false);
+
+ if (!g_dbus_proxy_method_call(default_ctrl->proxy,
+ "StartDiscovery",
+ NULL, start_discovery_reply,
+ GUINT_TO_POINTER(enable),
+ NULL)) {
+ bt_shell_printf("Failed to start discovery\n");
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ return;
+ }
+
+ free(address);
+
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+}
+
static void cmd_connect(int argc, char *argv[])
{
struct connection_data *data;
@@ -2223,7 +2254,9 @@ static void cmd_connect(int argc, char *argv[])
proxy = find_proxy_by_address(default_ctrl->devices, argv[1]);
if (!proxy) {
bt_shell_printf("Device %s not available\n", argv[1]);
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ bt_shell_prompt_input(argv[1], "Scan and connect (yes,no):",
+ prompt_scan_connect, strdup(argv[1]));
+ return;
}
data = new0(struct connection_data, 1);
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ v2 3/3] client: Stop discovery when connected with filter.auto_connect
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
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
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2026-04-08 18:22 UTC (permalink / raw)
To: linux-bluetooth
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [BlueZ,v2,1/3] device: Fix btd_device_connect_services not discovering
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 ` [PATCH BlueZ v2 3/3] client: Stop discovery when connected with filter.auto_connect Luiz Augusto von Dentz
@ 2026-04-08 20:30 ` bluez.test.bot
2026-04-09 20:00 ` [PATCH BlueZ v2 1/3] " patchwork-bot+bluetooth
3 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2026-04-08 20:30 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 1311 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1078829
---Test result---
Test Summary:
CheckPatch PENDING 0.33 seconds
GitLint PENDING 0.40 seconds
BuildEll PASS 20.33 seconds
BluezMake PASS 667.96 seconds
MakeCheck PASS 19.13 seconds
MakeDistcheck PASS 246.18 seconds
CheckValgrind PASS 293.08 seconds
CheckSmatch PASS 351.43 seconds
bluezmakeextell PASS 182.70 seconds
IncrementalBuild PENDING 0.32 seconds
ScanBuild PASS 1031.50 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
https://github.com/bluez/bluez/pull/2024/checks
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH BlueZ v2 1/3] device: Fix btd_device_connect_services not discovering
2026-04-08 18:22 [PATCH BlueZ v2 1/3] device: Fix btd_device_connect_services not discovering Luiz Augusto von Dentz
` (2 preceding siblings ...)
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 ` patchwork-bot+bluetooth
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2026-04-09 20:00 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Wed, 8 Apr 2026 14:22:21 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> btd_device_connect_services would not attempt to discover in case the
> selected bearer is BR/EDR and once discover is complete then it shall
> proceed with connecting the services.
> ---
> src/adapter.c | 9 ---------
> src/device.c | 27 +++++++++++++++++++++++++--
> 2 files changed, 25 insertions(+), 11 deletions(-)
Here is the summary with links:
- [BlueZ,v2,1/3] device: Fix btd_device_connect_services not discovering
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=418306daec60
- [BlueZ,v2,2/3] client: Prompt user to start scanning on connect command
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c8527a27723b
- [BlueZ,v2,3/3] client: Stop discovery when connected with filter.auto_connect
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=44e54e39ae1a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-09 20:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH BlueZ v2 3/3] client: Stop discovery when connected with filter.auto_connect Luiz Augusto von Dentz
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox