public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1 1/2] device: Fix btd_device_connect_services not discovering
@ 2026-04-07 21:12 Luiz Augusto von Dentz
  2026-04-07 21:12 ` [PATCH BlueZ v1 2/2] client: Prompt user to start scanning on connect command Luiz Augusto von Dentz
  2026-04-07 22:19 ` [BlueZ,v1,1/2] device: Fix btd_device_connect_services not discovering bluez.test.bot
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2026-04-07 21:12 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] 3+ messages in thread

* [PATCH BlueZ v1 2/2] client: Prompt user to start scanning on connect command
  2026-04-07 21:12 [PATCH BlueZ v1 1/2] device: Fix btd_device_connect_services not discovering Luiz Augusto von Dentz
@ 2026-04-07 21:12 ` Luiz Augusto von Dentz
  2026-04-07 22:19 ` [BlueZ,v1,1/2] device: Fix btd_device_connect_services not discovering bluez.test.bot
  1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2026-04-07 21:12 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] 3+ messages in thread

* RE: [BlueZ,v1,1/2] device: Fix btd_device_connect_services not discovering
  2026-04-07 21:12 [PATCH BlueZ v1 1/2] device: Fix btd_device_connect_services not discovering Luiz Augusto von Dentz
  2026-04-07 21:12 ` [PATCH BlueZ v1 2/2] client: Prompt user to start scanning on connect command Luiz Augusto von Dentz
@ 2026-04-07 22:19 ` bluez.test.bot
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-04-07 22:19 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=1078371

---Test result---

Test Summary:
CheckPatch                    PENDING   0.35 seconds
GitLint                       PENDING   0.48 seconds
BuildEll                      PASS      20.04 seconds
BluezMake                     PASS      633.51 seconds
MakeCheck                     PASS      18.28 seconds
MakeDistcheck                 PASS      242.67 seconds
CheckValgrind                 PASS      291.12 seconds
CheckSmatch                   PASS      345.76 seconds
bluezmakeextell               PASS      180.75 seconds
IncrementalBuild              PENDING   0.43 seconds
ScanBuild                     PASS      1014.54 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/2023/checks

---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-07 22:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-07 21:12 [PATCH BlueZ v1 1/2] device: Fix btd_device_connect_services not discovering Luiz Augusto von Dentz
2026-04-07 21:12 ` [PATCH BlueZ v1 2/2] client: Prompt user to start scanning on connect command Luiz Augusto von Dentz
2026-04-07 22:19 ` [BlueZ,v1,1/2] device: Fix btd_device_connect_services not discovering bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox