From: z4pdyy@gmail.com
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2] client: Avoid scan prompt when discovery is already active
Date: Sat, 8 Aug 2026 22:05:17 +0200 [thread overview]
Message-ID: <20260808200806.134373-1-z4pdyy@gmail.com> (raw)
From: z4pdy <305461556+z4pdy@users.noreply.github.com>
Check the adapter's Discovering property before prompting the user
to start scanning. This avoids prompting to scan when discovery is
already in progress, which previously resulted
in an org.bluez.Error.InProgress error.
Changes in v2:
- Move variable declarations to the beginning of cmd_connect()
to fix the ISO C90 build failure.
---
client/main.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/client/main.c b/client/main.c
index b5cad8afc..069e20485 100644
--- a/client/main.c
+++ b/client/main.c
@@ -2290,6 +2290,8 @@ static void cmd_connect(int argc, char *argv[])
const char *method = "Connect";
char profile[128] = "";
GDBusProxy *proxy;
+ dbus_bool_t discovering;
+ DBusMessageIter iter;
if (check_default_ctrl() == FALSE)
return bt_shell_noninteractive_quit(EXIT_FAILURE);
@@ -2297,8 +2299,18 @@ 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]);
- bt_shell_prompt_input(argv[1], "Scan and connect (yes,no):",
- prompt_scan_connect, strdup(argv[1]));
+
+ if (g_dbus_proxy_get_property(default_ctrl->proxy,
+ "Discovering", &iter)) {
+ dbus_message_iter_get_basic(&iter, &discovering);
+
+ if (!discovering)
+ bt_shell_prompt_input(argv[1],
+ "Scan and connect (yes,no):",
+ prompt_scan_connect,
+ strdup(argv[1]));
+
+ }
return;
}
--
2.55.0
next reply other threads:[~2026-08-08 20:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-08 20:05 z4pdyy [this message]
2026-08-08 21:24 ` [BlueZ,v2] client: Avoid scan prompt when discovery is already active bluez.test.bot
2026-08-11 20:20 ` [PATCH BlueZ v2] " 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=20260808200806.134373-1-z4pdyy@gmail.com \
--to=z4pdyy@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