* [PATCH BlueZ] client: Support single profile connection/disconnection
@ 2025-03-02 16:47 Arkadiusz Bokowy
2025-03-02 18:05 ` [BlueZ] " bluez.test.bot
2025-03-03 18:23 ` [PATCH BlueZ] " Luiz Augusto von Dentz
0 siblings, 2 replies; 11+ messages in thread
From: Arkadiusz Bokowy @ 2025-03-02 16:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Arkadiusz Bokowy
---
client/main.c | 93 ++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 80 insertions(+), 13 deletions(-)
diff --git a/client/main.c b/client/main.c
index feb21a116..e4ed692ec 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1969,13 +1969,44 @@ static void cmd_remove(int argc, char *argv[])
remove_device(proxy);
}
+struct connection_data {
+ GDBusProxy *proxy;
+ char *uuid;
+};
+
+static void connection_setup(DBusMessageIter *iter, void *user_data)
+{
+ struct connection_data *data = user_data;
+
+ if (!data->uuid)
+ return;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &data->uuid);
+}
+
+static void format_connection_profile(char *output, size_t size,
+ const char *uuid)
+{
+ const char *text;
+
+ text = bt_uuidstr_to_str(uuid);
+ if (!text)
+ text = uuid;
+
+ snprintf(output, size, " profile \"%s\"", text);
+}
+
static void connect_reply(DBusMessage *message, void *user_data)
{
- GDBusProxy *proxy = user_data;
+ struct connection_data *data = user_data;
+ GDBusProxy *proxy = data->proxy;
DBusError error;
dbus_error_init(&error);
+ g_free(data->uuid);
+ g_free(data);
+
if (dbus_set_error_from_message(&error, message) == TRUE) {
bt_shell_printf("Failed to connect: %s %s\n", error.name,
error.message);
@@ -1991,6 +2022,9 @@ static void connect_reply(DBusMessage *message, void *user_data)
static void cmd_connect(int argc, char *argv[])
{
+ struct connection_data *data;
+ const char *method = "Connect";
+ char profile[128] = "";
GDBusProxy *proxy;
if (check_default_ctrl() == FALSE)
@@ -2002,31 +2036,49 @@ static void cmd_connect(int argc, char *argv[])
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- if (g_dbus_proxy_method_call(proxy, "Connect", NULL, connect_reply,
- proxy, NULL) == FALSE) {
+ data = new0(struct connection_data, 1);
+ data->proxy = proxy;
+
+ if (argc == 3) {
+ method = "ConnectProfile";
+ data->uuid = g_strdup(argv[2]);
+ format_connection_profile(profile, sizeof(profile), argv[2]);
+ }
+
+ if (g_dbus_proxy_method_call(proxy, method, connection_setup,
+ connect_reply, data, NULL) == FALSE) {
bt_shell_printf("Failed to connect\n");
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- bt_shell_printf("Attempting to connect to %s\n", argv[1]);
+ bt_shell_printf("Attempting to connect%s to %s\n", profile, argv[1]);
}
static void disconn_reply(DBusMessage *message, void *user_data)
{
- GDBusProxy *proxy = user_data;
+ struct connection_data *data = user_data;
+ const bool profile_disconnected = data->uuid != NULL;
+ GDBusProxy *proxy = data->proxy;
DBusError error;
dbus_error_init(&error);
+ g_free(data->uuid);
+ g_free(data);
+
if (dbus_set_error_from_message(&error, message) == TRUE) {
bt_shell_printf("Failed to disconnect: %s\n", error.name);
dbus_error_free(&error);
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- bt_shell_printf("Successful disconnected\n");
+ bt_shell_printf("Disconnection successful\n");
- if (proxy == default_dev)
+ /* If only a single profile was disconnected, the device itself might
+ * still be connected. In that case, let the property change handler
+ * take care of setting the default device to NULL.
+ */
+ if (proxy == default_dev && !profile_disconnected)
set_default_device(NULL, NULL);
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
@@ -2034,19 +2086,31 @@ static void disconn_reply(DBusMessage *message, void *user_data)
static void cmd_disconn(int argc, char *argv[])
{
+ struct connection_data *data;
+ const char *method = "Disconnect";
+ char profile[128] = "";
GDBusProxy *proxy;
proxy = find_device(argc, argv);
if (!proxy)
return bt_shell_noninteractive_quit(EXIT_FAILURE);
- if (g_dbus_proxy_method_call(proxy, "Disconnect", NULL, disconn_reply,
- proxy, NULL) == FALSE) {
+ data = new0(struct connection_data, 1);
+ data->proxy = proxy;
+
+ if (argc == 3) {
+ method = "DisconnectProfile";
+ data->uuid = g_strdup(argv[2]);
+ format_connection_profile(profile, sizeof(profile), argv[2]);
+ }
+
+ if (g_dbus_proxy_method_call(proxy, method, connection_setup,
+ disconn_reply, data, NULL) == FALSE) {
bt_shell_printf("Failed to disconnect\n");
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- bt_shell_printf("Attempting to disconnect from %s\n",
+ bt_shell_printf("Attempting to disconnect%s from %s\n", profile,
proxy_address(proxy));
}
@@ -3241,10 +3305,13 @@ static const struct bt_shell_menu main_menu = {
dev_generator },
{ "remove", "<dev>", cmd_remove, "Remove device",
dev_generator },
- { "connect", "<dev>", cmd_connect, "Connect device",
- dev_generator },
- { "disconnect", "[dev]", cmd_disconn, "Disconnect device",
+ { "connect", "<dev> [uuid]", cmd_connect,
+ "Connect a device and all its profiles or "
+ "optionally connect a single profile only",
dev_generator },
+ { "disconnect", "[dev] [uuid]", cmd_disconn,
+ "Disconnect a device or optionally disconnect "
+ "a single profile only", dev_generator },
{ "wake", "[dev] [on/off]", cmd_wake, "Get/Set wake support",
dev_generator },
{ } },
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* RE: [BlueZ] client: Support single profile connection/disconnection
2025-03-02 16:47 [PATCH BlueZ] client: Support single profile connection/disconnection Arkadiusz Bokowy
@ 2025-03-02 18:05 ` bluez.test.bot
2025-03-03 18:23 ` [PATCH BlueZ] " Luiz Augusto von Dentz
1 sibling, 0 replies; 11+ messages in thread
From: bluez.test.bot @ 2025-03-02 18:05 UTC (permalink / raw)
To: linux-bluetooth, arkadiusz.bokowy
[-- Attachment #1: Type: text/plain, Size: 1260 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=939378
---Test result---
Test Summary:
CheckPatch PENDING 0.20 seconds
GitLint PENDING 0.22 seconds
BuildEll PASS 20.33 seconds
BluezMake PASS 1436.96 seconds
MakeCheck PASS 12.76 seconds
MakeDistcheck PASS 158.28 seconds
CheckValgrind PASS 213.64 seconds
CheckSmatch PASS 282.65 seconds
bluezmakeextell PASS 97.53 seconds
IncrementalBuild PENDING 0.26 seconds
ScanBuild PASS 858.16 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:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH BlueZ] client: Support single profile connection/disconnection
2025-03-02 16:47 [PATCH BlueZ] client: Support single profile connection/disconnection Arkadiusz Bokowy
2025-03-02 18:05 ` [BlueZ] " bluez.test.bot
@ 2025-03-03 18:23 ` Luiz Augusto von Dentz
2025-03-03 19:51 ` [PATCH BlueZ v2] " Arkadiusz Bokowy
1 sibling, 1 reply; 11+ messages in thread
From: Luiz Augusto von Dentz @ 2025-03-03 18:23 UTC (permalink / raw)
To: Arkadiusz Bokowy; +Cc: linux-bluetooth
Hi Arkadiusz,
On Sun, Mar 2, 2025 at 11:47 AM Arkadiusz Bokowy
<arkadiusz.bokowy@gmail.com> wrote:
>
> ---
> client/main.c | 93 ++++++++++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 80 insertions(+), 13 deletions(-)
>
> diff --git a/client/main.c b/client/main.c
> index feb21a116..e4ed692ec 100644
> --- a/client/main.c
> +++ b/client/main.c
> @@ -1969,13 +1969,44 @@ static void cmd_remove(int argc, char *argv[])
> remove_device(proxy);
> }
>
> +struct connection_data {
> + GDBusProxy *proxy;
> + char *uuid;
> +};
> +
> +static void connection_setup(DBusMessageIter *iter, void *user_data)
> +{
> + struct connection_data *data = user_data;
> +
> + if (!data->uuid)
> + return;
> +
> + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &data->uuid);
> +}
> +
> +static void format_connection_profile(char *output, size_t size,
> + const char *uuid)
> +{
> + const char *text;
> +
> + text = bt_uuidstr_to_str(uuid);
> + if (!text)
> + text = uuid;
> +
> + snprintf(output, size, " profile \"%s\"", text);
> +}
> +
> static void connect_reply(DBusMessage *message, void *user_data)
> {
> - GDBusProxy *proxy = user_data;
> + struct connection_data *data = user_data;
> + GDBusProxy *proxy = data->proxy;
> DBusError error;
>
> dbus_error_init(&error);
>
> + g_free(data->uuid);
> + g_free(data);
> +
> if (dbus_set_error_from_message(&error, message) == TRUE) {
> bt_shell_printf("Failed to connect: %s %s\n", error.name,
> error.message);
> @@ -1991,6 +2022,9 @@ static void connect_reply(DBusMessage *message, void *user_data)
>
> static void cmd_connect(int argc, char *argv[])
> {
> + struct connection_data *data;
> + const char *method = "Connect";
> + char profile[128] = "";
> GDBusProxy *proxy;
>
> if (check_default_ctrl() == FALSE)
> @@ -2002,31 +2036,49 @@ static void cmd_connect(int argc, char *argv[])
> return bt_shell_noninteractive_quit(EXIT_FAILURE);
> }
>
> - if (g_dbus_proxy_method_call(proxy, "Connect", NULL, connect_reply,
> - proxy, NULL) == FALSE) {
> + data = new0(struct connection_data, 1);
> + data->proxy = proxy;
> +
> + if (argc == 3) {
> + method = "ConnectProfile";
> + data->uuid = g_strdup(argv[2]);
> + format_connection_profile(profile, sizeof(profile), argv[2]);
> + }
> +
> + if (g_dbus_proxy_method_call(proxy, method, connection_setup,
> + connect_reply, data, NULL) == FALSE) {
> bt_shell_printf("Failed to connect\n");
> return bt_shell_noninteractive_quit(EXIT_FAILURE);
> }
>
> - bt_shell_printf("Attempting to connect to %s\n", argv[1]);
> + bt_shell_printf("Attempting to connect%s to %s\n", profile, argv[1]);
> }
>
> static void disconn_reply(DBusMessage *message, void *user_data)
> {
> - GDBusProxy *proxy = user_data;
> + struct connection_data *data = user_data;
> + const bool profile_disconnected = data->uuid != NULL;
> + GDBusProxy *proxy = data->proxy;
> DBusError error;
>
> dbus_error_init(&error);
>
> + g_free(data->uuid);
> + g_free(data);
> +
> if (dbus_set_error_from_message(&error, message) == TRUE) {
> bt_shell_printf("Failed to disconnect: %s\n", error.name);
> dbus_error_free(&error);
> return bt_shell_noninteractive_quit(EXIT_FAILURE);
> }
>
> - bt_shell_printf("Successful disconnected\n");
> + bt_shell_printf("Disconnection successful\n");
>
> - if (proxy == default_dev)
> + /* If only a single profile was disconnected, the device itself might
> + * still be connected. In that case, let the property change handler
> + * take care of setting the default device to NULL.
> + */
> + if (proxy == default_dev && !profile_disconnected)
> set_default_device(NULL, NULL);
>
> return bt_shell_noninteractive_quit(EXIT_SUCCESS);
> @@ -2034,19 +2086,31 @@ static void disconn_reply(DBusMessage *message, void *user_data)
>
> static void cmd_disconn(int argc, char *argv[])
> {
> + struct connection_data *data;
> + const char *method = "Disconnect";
> + char profile[128] = "";
> GDBusProxy *proxy;
>
> proxy = find_device(argc, argv);
> if (!proxy)
> return bt_shell_noninteractive_quit(EXIT_FAILURE);
>
> - if (g_dbus_proxy_method_call(proxy, "Disconnect", NULL, disconn_reply,
> - proxy, NULL) == FALSE) {
> + data = new0(struct connection_data, 1);
> + data->proxy = proxy;
> +
> + if (argc == 3) {
> + method = "DisconnectProfile";
> + data->uuid = g_strdup(argv[2]);
> + format_connection_profile(profile, sizeof(profile), argv[2]);
> + }
> +
> + if (g_dbus_proxy_method_call(proxy, method, connection_setup,
> + disconn_reply, data, NULL) == FALSE) {
> bt_shell_printf("Failed to disconnect\n");
> return bt_shell_noninteractive_quit(EXIT_FAILURE);
> }
>
> - bt_shell_printf("Attempting to disconnect from %s\n",
> + bt_shell_printf("Attempting to disconnect%s from %s\n", profile,
> proxy_address(proxy));
> }
>
> @@ -3241,10 +3305,13 @@ static const struct bt_shell_menu main_menu = {
> dev_generator },
> { "remove", "<dev>", cmd_remove, "Remove device",
> dev_generator },
> - { "connect", "<dev>", cmd_connect, "Connect device",
> - dev_generator },
> - { "disconnect", "[dev]", cmd_disconn, "Disconnect device",
> + { "connect", "<dev> [uuid]", cmd_connect,
> + "Connect a device and all its profiles or "
> + "optionally connect a single profile only",
> dev_generator },
> + { "disconnect", "[dev] [uuid]", cmd_disconn,
> + "Disconnect a device or optionally disconnect "
> + "a single profile only", dev_generator },
Great idea, but let's update the documentation as well so it reflects
this change (client/bluetoothctl.rst), also it is probably worth
adding a few examples like connect/disconnect all/hfp/a2dp, etc.
> { "wake", "[dev] [on/off]", cmd_wake, "Get/Set wake support",
> dev_generator },
> { } },
> --
> 2.39.5
>
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH BlueZ v2] client: Support single profile connection/disconnection
2025-03-03 18:23 ` [PATCH BlueZ] " Luiz Augusto von Dentz
@ 2025-03-03 19:51 ` Arkadiusz Bokowy
2025-03-03 21:11 ` [BlueZ,v2] " bluez.test.bot
2025-03-03 21:13 ` [PATCH BlueZ v2] " Luiz Augusto von Dentz
0 siblings, 2 replies; 11+ messages in thread
From: Arkadiusz Bokowy @ 2025-03-03 19:51 UTC (permalink / raw)
To: luiz.dentz; +Cc: arkadiusz.bokowy, linux-bluetooth
---
client/bluetoothctl.rst | 20 +++++++--
client/main.c | 93 +++++++++++++++++++++++++++++++++++------
src/uuid-helper.c | 32 +++++++-------
3 files changed, 114 insertions(+), 31 deletions(-)
diff --git a/client/bluetoothctl.rst b/client/bluetoothctl.rst
index b6c2efa35..c60bf719f 100644
--- a/client/bluetoothctl.rst
+++ b/client/bluetoothctl.rst
@@ -9,7 +9,7 @@ Bluetooth Control Command Line Tool
:Version: BlueZ
:Copyright: Free use of this software is granted under the terms of the GNU
Lesser General Public Licenses (LGPL).
-:Date: November 2022
+:Date: March 2024
:Manual section: 1
:Manual group: Linux System Administration
@@ -262,6 +262,13 @@ Connect device.
This will initiate a connection to a device.
+By default this commands tries to connect all the profiles the remote device
+supports and have been flagged as auto-connectable. In case when the UUID of
+the remote service is given only that service will be connected. The UUID can
+be either a short form (16-bit UUID) or a long form (128-bit UUID). There are
+also some special values for well-known profiles like "a2dp-sink",
+"a2dp-source", "hfp-hf", "hfp-ag", "ftp" or "spp".
+
To connect with an LE device the controller must have an active scan report of
the device it wants to connect to.
@@ -269,17 +276,24 @@ If no advertising report is received before the timeout a
le-connection-abort-by-local error will be issued. In that case either try
again to connect assuming the device is advertising.
-:Usage: **> connect <dev>**
+:Usage: **> connect <dev> [uuid]**
+:Example: **> connect 1C:48:F9:9D:81:5C hsp-hs**
+:Example: **> connect 1C:48:F9:9D:81:5C 00001108-0000-1000-8000-00805f9b34fb**
+:Example: **> connect 1C:48:F9:9D:81:5C 0x1108**
disconnect
----------
Disconnect device.
+By default this commands disconnects all profiles and then terminates the
+connection. In case when the UUID of the remote service is given only that
+service will be disconnected.
+
For LE when disconnecting from an active connection the device address is not
needed.
-:Usage: **> disconnect <dev>**
+:Usage: **> disconnect <dev> [uuid]**
info
----
diff --git a/client/main.c b/client/main.c
index 6b938da3f..3f2bfcf6b 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1981,13 +1981,44 @@ static void cmd_remove(int argc, char *argv[])
remove_device(proxy);
}
+struct connection_data {
+ GDBusProxy *proxy;
+ char *uuid;
+};
+
+static void connection_setup(DBusMessageIter *iter, void *user_data)
+{
+ struct connection_data *data = user_data;
+
+ if (!data->uuid)
+ return;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &data->uuid);
+}
+
+static void format_connection_profile(char *output, size_t size,
+ const char *uuid)
+{
+ const char *text;
+
+ text = bt_uuidstr_to_str(uuid);
+ if (!text)
+ text = uuid;
+
+ snprintf(output, size, " profile \"%s\"", text);
+}
+
static void connect_reply(DBusMessage *message, void *user_data)
{
- GDBusProxy *proxy = user_data;
+ struct connection_data *data = user_data;
+ GDBusProxy *proxy = data->proxy;
DBusError error;
dbus_error_init(&error);
+ g_free(data->uuid);
+ g_free(data);
+
if (dbus_set_error_from_message(&error, message) == TRUE) {
bt_shell_printf("Failed to connect: %s %s\n", error.name,
error.message);
@@ -2003,6 +2034,9 @@ static void connect_reply(DBusMessage *message, void *user_data)
static void cmd_connect(int argc, char *argv[])
{
+ struct connection_data *data;
+ const char *method = "Connect";
+ char profile[128] = "";
GDBusProxy *proxy;
if (check_default_ctrl() == FALSE)
@@ -2014,31 +2048,49 @@ static void cmd_connect(int argc, char *argv[])
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- if (g_dbus_proxy_method_call(proxy, "Connect", NULL, connect_reply,
- proxy, NULL) == FALSE) {
+ data = new0(struct connection_data, 1);
+ data->proxy = proxy;
+
+ if (argc == 3) {
+ method = "ConnectProfile";
+ data->uuid = g_strdup(argv[2]);
+ format_connection_profile(profile, sizeof(profile), argv[2]);
+ }
+
+ if (g_dbus_proxy_method_call(proxy, method, connection_setup,
+ connect_reply, data, NULL) == FALSE) {
bt_shell_printf("Failed to connect\n");
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- bt_shell_printf("Attempting to connect to %s\n", argv[1]);
+ bt_shell_printf("Attempting to connect%s to %s\n", profile, argv[1]);
}
static void disconn_reply(DBusMessage *message, void *user_data)
{
- GDBusProxy *proxy = user_data;
+ struct connection_data *data = user_data;
+ const bool profile_disconnected = data->uuid != NULL;
+ GDBusProxy *proxy = data->proxy;
DBusError error;
dbus_error_init(&error);
+ g_free(data->uuid);
+ g_free(data);
+
if (dbus_set_error_from_message(&error, message) == TRUE) {
bt_shell_printf("Failed to disconnect: %s\n", error.name);
dbus_error_free(&error);
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- bt_shell_printf("Successful disconnected\n");
+ bt_shell_printf("Disconnection successful\n");
- if (proxy == default_dev)
+ /* If only a single profile was disconnected, the device itself might
+ * still be connected. In that case, let the property change handler
+ * take care of setting the default device to NULL.
+ */
+ if (proxy == default_dev && !profile_disconnected)
set_default_device(NULL, NULL);
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
@@ -2046,19 +2098,31 @@ static void disconn_reply(DBusMessage *message, void *user_data)
static void cmd_disconn(int argc, char *argv[])
{
+ struct connection_data *data;
+ const char *method = "Disconnect";
+ char profile[128] = "";
GDBusProxy *proxy;
proxy = find_device(argc, argv);
if (!proxy)
return bt_shell_noninteractive_quit(EXIT_FAILURE);
- if (g_dbus_proxy_method_call(proxy, "Disconnect", NULL, disconn_reply,
- proxy, NULL) == FALSE) {
+ data = new0(struct connection_data, 1);
+ data->proxy = proxy;
+
+ if (argc == 3) {
+ method = "DisconnectProfile";
+ data->uuid = g_strdup(argv[2]);
+ format_connection_profile(profile, sizeof(profile), argv[2]);
+ }
+
+ if (g_dbus_proxy_method_call(proxy, method, connection_setup,
+ disconn_reply, data, NULL) == FALSE) {
bt_shell_printf("Failed to disconnect\n");
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- bt_shell_printf("Attempting to disconnect from %s\n",
+ bt_shell_printf("Attempting to disconnect%s from %s\n", profile,
proxy_address(proxy));
}
@@ -3253,10 +3317,13 @@ static const struct bt_shell_menu main_menu = {
dev_generator },
{ "remove", "<dev>", cmd_remove, "Remove device",
dev_generator },
- { "connect", "<dev>", cmd_connect, "Connect device",
- dev_generator },
- { "disconnect", "[dev]", cmd_disconn, "Disconnect device",
+ { "connect", "<dev> [uuid]", cmd_connect,
+ "Connect a device and all its profiles or "
+ "optionally connect a single profile only",
dev_generator },
+ { "disconnect", "[dev] [uuid]", cmd_disconn,
+ "Disconnect a device or optionally disconnect "
+ "a single profile only", dev_generator },
{ "wake", "[dev] [on/off]", cmd_wake, "Get/Set wake support",
dev_generator },
{ } },
diff --git a/src/uuid-helper.c b/src/uuid-helper.c
index f32ee0a85..640592fd2 100644
--- a/src/uuid-helper.c
+++ b/src/uuid-helper.c
@@ -101,29 +101,31 @@ static struct {
const char *name;
uint16_t class;
} bt_services[] = {
- { "pbap", PBAP_SVCLASS_ID },
- { "sap", SAP_SVCLASS_ID },
- { "ftp", OBEX_FILETRANS_SVCLASS_ID },
- { "bpp", BASIC_PRINTING_SVCLASS_ID },
+ { "a2dp-sink", AUDIO_SINK_SVCLASS_ID },
+ { "a2dp-source",AUDIO_SOURCE_SVCLASS_ID },
{ "bip", IMAGING_SVCLASS_ID },
- { "synch", IRMC_SYNC_SVCLASS_ID },
+ { "bpp", BASIC_PRINTING_SVCLASS_ID },
{ "dun", DIALUP_NET_SVCLASS_ID },
- { "opp", OBEX_OBJPUSH_SVCLASS_ID },
{ "fax", FAX_SVCLASS_ID },
- { "spp", SERIAL_PORT_SVCLASS_ID },
- { "hsp", HEADSET_SVCLASS_ID },
- { "hsp-hs", HEADSET_SVCLASS_ID },
- { "hsp-ag", HEADSET_AGW_SVCLASS_ID },
+ { "ftp", OBEX_FILETRANS_SVCLASS_ID },
+ { "gnss", GNSS_SERVER_SVCLASS_ID },
{ "hfp", HANDSFREE_SVCLASS_ID },
- { "hfp-hf", HANDSFREE_SVCLASS_ID },
{ "hfp-ag", HANDSFREE_AGW_SVCLASS_ID },
- { "pbap-pce", PBAP_PCE_SVCLASS_ID },
- { "pbap-pse", PBAP_PSE_SVCLASS_ID },
- { "map-mse", MAP_MSE_SVCLASS_ID },
+ { "hfp-hf", HANDSFREE_SVCLASS_ID },
+ { "hsp", HEADSET_SVCLASS_ID },
+ { "hsp-ag", HEADSET_AGW_SVCLASS_ID },
+ { "hsp-hs", HEADSET_SVCLASS_ID },
{ "map-mas", MAP_MSE_SVCLASS_ID },
{ "map-mce", MAP_MCE_SVCLASS_ID },
{ "map-mns", MAP_MCE_SVCLASS_ID },
- { "gnss", GNSS_SERVER_SVCLASS_ID },
+ { "map-mse", MAP_MSE_SVCLASS_ID },
+ { "opp", OBEX_OBJPUSH_SVCLASS_ID },
+ { "pbap", PBAP_SVCLASS_ID },
+ { "pbap-pce", PBAP_PCE_SVCLASS_ID },
+ { "pbap-pse", PBAP_PSE_SVCLASS_ID },
+ { "sap", SAP_SVCLASS_ID },
+ { "spp", SERIAL_PORT_SVCLASS_ID },
+ { "synch", IRMC_SYNC_SVCLASS_ID },
{ }
};
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* RE: [BlueZ,v2] client: Support single profile connection/disconnection
2025-03-03 19:51 ` [PATCH BlueZ v2] " Arkadiusz Bokowy
@ 2025-03-03 21:11 ` bluez.test.bot
2025-03-03 21:13 ` [PATCH BlueZ v2] " Luiz Augusto von Dentz
1 sibling, 0 replies; 11+ messages in thread
From: bluez.test.bot @ 2025-03-03 21:11 UTC (permalink / raw)
To: linux-bluetooth, arkadiusz.bokowy
[-- Attachment #1: Type: text/plain, Size: 1260 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=939743
---Test result---
Test Summary:
CheckPatch PENDING 0.22 seconds
GitLint PENDING 0.19 seconds
BuildEll PASS 20.29 seconds
BluezMake PASS 1486.28 seconds
MakeCheck PASS 13.01 seconds
MakeDistcheck PASS 156.62 seconds
CheckValgrind PASS 213.03 seconds
CheckSmatch PASS 282.52 seconds
bluezmakeextell PASS 97.56 seconds
IncrementalBuild PENDING 0.33 seconds
ScanBuild PASS 863.01 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:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH BlueZ v2] client: Support single profile connection/disconnection
2025-03-03 19:51 ` [PATCH BlueZ v2] " Arkadiusz Bokowy
2025-03-03 21:11 ` [BlueZ,v2] " bluez.test.bot
@ 2025-03-03 21:13 ` Luiz Augusto von Dentz
2025-03-04 6:19 ` [PATCH BlueZ v3 1/3] uuid-helper: Add A2DP to the list of known profiles Arkadiusz Bokowy
1 sibling, 1 reply; 11+ messages in thread
From: Luiz Augusto von Dentz @ 2025-03-03 21:13 UTC (permalink / raw)
To: Arkadiusz Bokowy; +Cc: linux-bluetooth
Hi Arkadiusz,
On Mon, Mar 3, 2025 at 2:51 PM Arkadiusz Bokowy
<arkadiusz.bokowy@gmail.com> wrote:
>
> ---
> client/bluetoothctl.rst | 20 +++++++--
Documentation shall be split into its own patch.
> client/main.c | 93 +++++++++++++++++++++++++++++++++++------
Same for uuid-helper.
> src/uuid-helper.c | 32 +++++++-------
> 3 files changed, 114 insertions(+), 31 deletions(-)
>
> diff --git a/client/bluetoothctl.rst b/client/bluetoothctl.rst
> index b6c2efa35..c60bf719f 100644
> --- a/client/bluetoothctl.rst
> +++ b/client/bluetoothctl.rst
> @@ -9,7 +9,7 @@ Bluetooth Control Command Line Tool
> :Version: BlueZ
> :Copyright: Free use of this software is granted under the terms of the GNU
> Lesser General Public Licenses (LGPL).
> -:Date: November 2022
> +:Date: March 2024
> :Manual section: 1
> :Manual group: Linux System Administration
>
> @@ -262,6 +262,13 @@ Connect device.
>
> This will initiate a connection to a device.
>
> +By default this commands tries to connect all the profiles the remote device
> +supports and have been flagged as auto-connectable. In case when the UUID of
> +the remote service is given only that service will be connected. The UUID can
> +be either a short form (16-bit UUID) or a long form (128-bit UUID). There are
> +also some special values for well-known profiles like "a2dp-sink",
> +"a2dp-source", "hfp-hf", "hfp-ag", "ftp" or "spp".
> +
> To connect with an LE device the controller must have an active scan report of
> the device it wants to connect to.
>
> @@ -269,17 +276,24 @@ If no advertising report is received before the timeout a
> le-connection-abort-by-local error will be issued. In that case either try
> again to connect assuming the device is advertising.
>
> -:Usage: **> connect <dev>**
> +:Usage: **> connect <dev> [uuid]**
> +:Example: **> connect 1C:48:F9:9D:81:5C hsp-hs**
> +:Example: **> connect 1C:48:F9:9D:81:5C 00001108-0000-1000-8000-00805f9b34fb**
> +:Example: **> connect 1C:48:F9:9D:81:5C 0x1108**
>
> disconnect
> ----------
>
> Disconnect device.
>
> +By default this commands disconnects all profiles and then terminates the
> +connection. In case when the UUID of the remote service is given only that
> +service will be disconnected.
> +
> For LE when disconnecting from an active connection the device address is not
> needed.
>
> -:Usage: **> disconnect <dev>**
> +:Usage: **> disconnect <dev> [uuid]**
>
> info
> ----
> diff --git a/client/main.c b/client/main.c
> index 6b938da3f..3f2bfcf6b 100644
> --- a/client/main.c
> +++ b/client/main.c
> @@ -1981,13 +1981,44 @@ static void cmd_remove(int argc, char *argv[])
> remove_device(proxy);
> }
>
> +struct connection_data {
> + GDBusProxy *proxy;
> + char *uuid;
> +};
> +
> +static void connection_setup(DBusMessageIter *iter, void *user_data)
> +{
> + struct connection_data *data = user_data;
> +
> + if (!data->uuid)
> + return;
> +
> + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &data->uuid);
> +}
> +
> +static void format_connection_profile(char *output, size_t size,
> + const char *uuid)
> +{
> + const char *text;
> +
> + text = bt_uuidstr_to_str(uuid);
> + if (!text)
> + text = uuid;
> +
> + snprintf(output, size, " profile \"%s\"", text);
> +}
> +
> static void connect_reply(DBusMessage *message, void *user_data)
> {
> - GDBusProxy *proxy = user_data;
> + struct connection_data *data = user_data;
> + GDBusProxy *proxy = data->proxy;
> DBusError error;
>
> dbus_error_init(&error);
>
> + g_free(data->uuid);
> + g_free(data);
> +
> if (dbus_set_error_from_message(&error, message) == TRUE) {
> bt_shell_printf("Failed to connect: %s %s\n", error.name,
> error.message);
> @@ -2003,6 +2034,9 @@ static void connect_reply(DBusMessage *message, void *user_data)
>
> static void cmd_connect(int argc, char *argv[])
> {
> + struct connection_data *data;
> + const char *method = "Connect";
> + char profile[128] = "";
> GDBusProxy *proxy;
>
> if (check_default_ctrl() == FALSE)
> @@ -2014,31 +2048,49 @@ static void cmd_connect(int argc, char *argv[])
> return bt_shell_noninteractive_quit(EXIT_FAILURE);
> }
>
> - if (g_dbus_proxy_method_call(proxy, "Connect", NULL, connect_reply,
> - proxy, NULL) == FALSE) {
> + data = new0(struct connection_data, 1);
> + data->proxy = proxy;
> +
> + if (argc == 3) {
> + method = "ConnectProfile";
> + data->uuid = g_strdup(argv[2]);
> + format_connection_profile(profile, sizeof(profile), argv[2]);
> + }
> +
> + if (g_dbus_proxy_method_call(proxy, method, connection_setup,
> + connect_reply, data, NULL) == FALSE) {
> bt_shell_printf("Failed to connect\n");
> return bt_shell_noninteractive_quit(EXIT_FAILURE);
> }
>
> - bt_shell_printf("Attempting to connect to %s\n", argv[1]);
> + bt_shell_printf("Attempting to connect%s to %s\n", profile, argv[1]);
> }
>
> static void disconn_reply(DBusMessage *message, void *user_data)
> {
> - GDBusProxy *proxy = user_data;
> + struct connection_data *data = user_data;
> + const bool profile_disconnected = data->uuid != NULL;
> + GDBusProxy *proxy = data->proxy;
> DBusError error;
>
> dbus_error_init(&error);
>
> + g_free(data->uuid);
> + g_free(data);
> +
> if (dbus_set_error_from_message(&error, message) == TRUE) {
> bt_shell_printf("Failed to disconnect: %s\n", error.name);
> dbus_error_free(&error);
> return bt_shell_noninteractive_quit(EXIT_FAILURE);
> }
>
> - bt_shell_printf("Successful disconnected\n");
> + bt_shell_printf("Disconnection successful\n");
>
> - if (proxy == default_dev)
> + /* If only a single profile was disconnected, the device itself might
> + * still be connected. In that case, let the property change handler
> + * take care of setting the default device to NULL.
> + */
> + if (proxy == default_dev && !profile_disconnected)
> set_default_device(NULL, NULL);
>
> return bt_shell_noninteractive_quit(EXIT_SUCCESS);
> @@ -2046,19 +2098,31 @@ static void disconn_reply(DBusMessage *message, void *user_data)
>
> static void cmd_disconn(int argc, char *argv[])
> {
> + struct connection_data *data;
> + const char *method = "Disconnect";
> + char profile[128] = "";
> GDBusProxy *proxy;
>
> proxy = find_device(argc, argv);
> if (!proxy)
> return bt_shell_noninteractive_quit(EXIT_FAILURE);
>
> - if (g_dbus_proxy_method_call(proxy, "Disconnect", NULL, disconn_reply,
> - proxy, NULL) == FALSE) {
> + data = new0(struct connection_data, 1);
> + data->proxy = proxy;
> +
> + if (argc == 3) {
> + method = "DisconnectProfile";
> + data->uuid = g_strdup(argv[2]);
> + format_connection_profile(profile, sizeof(profile), argv[2]);
> + }
> +
> + if (g_dbus_proxy_method_call(proxy, method, connection_setup,
> + disconn_reply, data, NULL) == FALSE) {
> bt_shell_printf("Failed to disconnect\n");
> return bt_shell_noninteractive_quit(EXIT_FAILURE);
> }
>
> - bt_shell_printf("Attempting to disconnect from %s\n",
> + bt_shell_printf("Attempting to disconnect%s from %s\n", profile,
> proxy_address(proxy));
> }
>
> @@ -3253,10 +3317,13 @@ static const struct bt_shell_menu main_menu = {
> dev_generator },
> { "remove", "<dev>", cmd_remove, "Remove device",
> dev_generator },
> - { "connect", "<dev>", cmd_connect, "Connect device",
> - dev_generator },
> - { "disconnect", "[dev]", cmd_disconn, "Disconnect device",
> + { "connect", "<dev> [uuid]", cmd_connect,
> + "Connect a device and all its profiles or "
> + "optionally connect a single profile only",
> dev_generator },
> + { "disconnect", "[dev] [uuid]", cmd_disconn,
> + "Disconnect a device or optionally disconnect "
> + "a single profile only", dev_generator },
> { "wake", "[dev] [on/off]", cmd_wake, "Get/Set wake support",
> dev_generator },
> { } },
> diff --git a/src/uuid-helper.c b/src/uuid-helper.c
> index f32ee0a85..640592fd2 100644
> --- a/src/uuid-helper.c
> +++ b/src/uuid-helper.c
> @@ -101,29 +101,31 @@ static struct {
> const char *name;
> uint16_t class;
> } bt_services[] = {
> - { "pbap", PBAP_SVCLASS_ID },
> - { "sap", SAP_SVCLASS_ID },
> - { "ftp", OBEX_FILETRANS_SVCLASS_ID },
> - { "bpp", BASIC_PRINTING_SVCLASS_ID },
> + { "a2dp-sink", AUDIO_SINK_SVCLASS_ID },
> + { "a2dp-source",AUDIO_SOURCE_SVCLASS_ID },
> { "bip", IMAGING_SVCLASS_ID },
> - { "synch", IRMC_SYNC_SVCLASS_ID },
> + { "bpp", BASIC_PRINTING_SVCLASS_ID },
> { "dun", DIALUP_NET_SVCLASS_ID },
> - { "opp", OBEX_OBJPUSH_SVCLASS_ID },
> { "fax", FAX_SVCLASS_ID },
> - { "spp", SERIAL_PORT_SVCLASS_ID },
> - { "hsp", HEADSET_SVCLASS_ID },
> - { "hsp-hs", HEADSET_SVCLASS_ID },
> - { "hsp-ag", HEADSET_AGW_SVCLASS_ID },
> + { "ftp", OBEX_FILETRANS_SVCLASS_ID },
> + { "gnss", GNSS_SERVER_SVCLASS_ID },
> { "hfp", HANDSFREE_SVCLASS_ID },
> - { "hfp-hf", HANDSFREE_SVCLASS_ID },
> { "hfp-ag", HANDSFREE_AGW_SVCLASS_ID },
> - { "pbap-pce", PBAP_PCE_SVCLASS_ID },
> - { "pbap-pse", PBAP_PSE_SVCLASS_ID },
> - { "map-mse", MAP_MSE_SVCLASS_ID },
> + { "hfp-hf", HANDSFREE_SVCLASS_ID },
> + { "hsp", HEADSET_SVCLASS_ID },
> + { "hsp-ag", HEADSET_AGW_SVCLASS_ID },
> + { "hsp-hs", HEADSET_SVCLASS_ID },
> { "map-mas", MAP_MSE_SVCLASS_ID },
> { "map-mce", MAP_MCE_SVCLASS_ID },
> { "map-mns", MAP_MCE_SVCLASS_ID },
> - { "gnss", GNSS_SERVER_SVCLASS_ID },
> + { "map-mse", MAP_MSE_SVCLASS_ID },
> + { "opp", OBEX_OBJPUSH_SVCLASS_ID },
> + { "pbap", PBAP_SVCLASS_ID },
> + { "pbap-pce", PBAP_PCE_SVCLASS_ID },
> + { "pbap-pse", PBAP_PSE_SVCLASS_ID },
> + { "sap", SAP_SVCLASS_ID },
> + { "spp", SERIAL_PORT_SVCLASS_ID },
> + { "synch", IRMC_SYNC_SVCLASS_ID },
> { }
These may need to go in a separate patch.
> };
>
> --
> 2.39.5
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH BlueZ v3 1/3] uuid-helper: Add A2DP to the list of known profiles
2025-03-03 21:13 ` [PATCH BlueZ v2] " Luiz Augusto von Dentz
@ 2025-03-04 6:19 ` Arkadiusz Bokowy
2025-03-04 6:19 ` [PATCH BlueZ v3 2/3] client: Support single profile connection/disconnection Arkadiusz Bokowy
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Arkadiusz Bokowy @ 2025-03-04 6:19 UTC (permalink / raw)
To: luiz.dentz; +Cc: arkadiusz.bokowy, linux-bluetooth
---
src/uuid-helper.c | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/src/uuid-helper.c b/src/uuid-helper.c
index f32ee0a85..640592fd2 100644
--- a/src/uuid-helper.c
+++ b/src/uuid-helper.c
@@ -101,29 +101,31 @@ static struct {
const char *name;
uint16_t class;
} bt_services[] = {
- { "pbap", PBAP_SVCLASS_ID },
- { "sap", SAP_SVCLASS_ID },
- { "ftp", OBEX_FILETRANS_SVCLASS_ID },
- { "bpp", BASIC_PRINTING_SVCLASS_ID },
+ { "a2dp-sink", AUDIO_SINK_SVCLASS_ID },
+ { "a2dp-source",AUDIO_SOURCE_SVCLASS_ID },
{ "bip", IMAGING_SVCLASS_ID },
- { "synch", IRMC_SYNC_SVCLASS_ID },
+ { "bpp", BASIC_PRINTING_SVCLASS_ID },
{ "dun", DIALUP_NET_SVCLASS_ID },
- { "opp", OBEX_OBJPUSH_SVCLASS_ID },
{ "fax", FAX_SVCLASS_ID },
- { "spp", SERIAL_PORT_SVCLASS_ID },
- { "hsp", HEADSET_SVCLASS_ID },
- { "hsp-hs", HEADSET_SVCLASS_ID },
- { "hsp-ag", HEADSET_AGW_SVCLASS_ID },
+ { "ftp", OBEX_FILETRANS_SVCLASS_ID },
+ { "gnss", GNSS_SERVER_SVCLASS_ID },
{ "hfp", HANDSFREE_SVCLASS_ID },
- { "hfp-hf", HANDSFREE_SVCLASS_ID },
{ "hfp-ag", HANDSFREE_AGW_SVCLASS_ID },
- { "pbap-pce", PBAP_PCE_SVCLASS_ID },
- { "pbap-pse", PBAP_PSE_SVCLASS_ID },
- { "map-mse", MAP_MSE_SVCLASS_ID },
+ { "hfp-hf", HANDSFREE_SVCLASS_ID },
+ { "hsp", HEADSET_SVCLASS_ID },
+ { "hsp-ag", HEADSET_AGW_SVCLASS_ID },
+ { "hsp-hs", HEADSET_SVCLASS_ID },
{ "map-mas", MAP_MSE_SVCLASS_ID },
{ "map-mce", MAP_MCE_SVCLASS_ID },
{ "map-mns", MAP_MCE_SVCLASS_ID },
- { "gnss", GNSS_SERVER_SVCLASS_ID },
+ { "map-mse", MAP_MSE_SVCLASS_ID },
+ { "opp", OBEX_OBJPUSH_SVCLASS_ID },
+ { "pbap", PBAP_SVCLASS_ID },
+ { "pbap-pce", PBAP_PCE_SVCLASS_ID },
+ { "pbap-pse", PBAP_PSE_SVCLASS_ID },
+ { "sap", SAP_SVCLASS_ID },
+ { "spp", SERIAL_PORT_SVCLASS_ID },
+ { "synch", IRMC_SYNC_SVCLASS_ID },
{ }
};
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH BlueZ v3 2/3] client: Support single profile connection/disconnection
2025-03-04 6:19 ` [PATCH BlueZ v3 1/3] uuid-helper: Add A2DP to the list of known profiles Arkadiusz Bokowy
@ 2025-03-04 6:19 ` Arkadiusz Bokowy
2025-03-04 6:19 ` [PATCH BlueZ v3 3/3] client: Document connect/disconnect optional profile argument Arkadiusz Bokowy
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: Arkadiusz Bokowy @ 2025-03-04 6:19 UTC (permalink / raw)
To: luiz.dentz; +Cc: arkadiusz.bokowy, linux-bluetooth
---
client/main.c | 93 ++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 80 insertions(+), 13 deletions(-)
diff --git a/client/main.c b/client/main.c
index 6b938da3f..3f2bfcf6b 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1981,13 +1981,44 @@ static void cmd_remove(int argc, char *argv[])
remove_device(proxy);
}
+struct connection_data {
+ GDBusProxy *proxy;
+ char *uuid;
+};
+
+static void connection_setup(DBusMessageIter *iter, void *user_data)
+{
+ struct connection_data *data = user_data;
+
+ if (!data->uuid)
+ return;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &data->uuid);
+}
+
+static void format_connection_profile(char *output, size_t size,
+ const char *uuid)
+{
+ const char *text;
+
+ text = bt_uuidstr_to_str(uuid);
+ if (!text)
+ text = uuid;
+
+ snprintf(output, size, " profile \"%s\"", text);
+}
+
static void connect_reply(DBusMessage *message, void *user_data)
{
- GDBusProxy *proxy = user_data;
+ struct connection_data *data = user_data;
+ GDBusProxy *proxy = data->proxy;
DBusError error;
dbus_error_init(&error);
+ g_free(data->uuid);
+ g_free(data);
+
if (dbus_set_error_from_message(&error, message) == TRUE) {
bt_shell_printf("Failed to connect: %s %s\n", error.name,
error.message);
@@ -2003,6 +2034,9 @@ static void connect_reply(DBusMessage *message, void *user_data)
static void cmd_connect(int argc, char *argv[])
{
+ struct connection_data *data;
+ const char *method = "Connect";
+ char profile[128] = "";
GDBusProxy *proxy;
if (check_default_ctrl() == FALSE)
@@ -2014,31 +2048,49 @@ static void cmd_connect(int argc, char *argv[])
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- if (g_dbus_proxy_method_call(proxy, "Connect", NULL, connect_reply,
- proxy, NULL) == FALSE) {
+ data = new0(struct connection_data, 1);
+ data->proxy = proxy;
+
+ if (argc == 3) {
+ method = "ConnectProfile";
+ data->uuid = g_strdup(argv[2]);
+ format_connection_profile(profile, sizeof(profile), argv[2]);
+ }
+
+ if (g_dbus_proxy_method_call(proxy, method, connection_setup,
+ connect_reply, data, NULL) == FALSE) {
bt_shell_printf("Failed to connect\n");
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- bt_shell_printf("Attempting to connect to %s\n", argv[1]);
+ bt_shell_printf("Attempting to connect%s to %s\n", profile, argv[1]);
}
static void disconn_reply(DBusMessage *message, void *user_data)
{
- GDBusProxy *proxy = user_data;
+ struct connection_data *data = user_data;
+ const bool profile_disconnected = data->uuid != NULL;
+ GDBusProxy *proxy = data->proxy;
DBusError error;
dbus_error_init(&error);
+ g_free(data->uuid);
+ g_free(data);
+
if (dbus_set_error_from_message(&error, message) == TRUE) {
bt_shell_printf("Failed to disconnect: %s\n", error.name);
dbus_error_free(&error);
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- bt_shell_printf("Successful disconnected\n");
+ bt_shell_printf("Disconnection successful\n");
- if (proxy == default_dev)
+ /* If only a single profile was disconnected, the device itself might
+ * still be connected. In that case, let the property change handler
+ * take care of setting the default device to NULL.
+ */
+ if (proxy == default_dev && !profile_disconnected)
set_default_device(NULL, NULL);
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
@@ -2046,19 +2098,31 @@ static void disconn_reply(DBusMessage *message, void *user_data)
static void cmd_disconn(int argc, char *argv[])
{
+ struct connection_data *data;
+ const char *method = "Disconnect";
+ char profile[128] = "";
GDBusProxy *proxy;
proxy = find_device(argc, argv);
if (!proxy)
return bt_shell_noninteractive_quit(EXIT_FAILURE);
- if (g_dbus_proxy_method_call(proxy, "Disconnect", NULL, disconn_reply,
- proxy, NULL) == FALSE) {
+ data = new0(struct connection_data, 1);
+ data->proxy = proxy;
+
+ if (argc == 3) {
+ method = "DisconnectProfile";
+ data->uuid = g_strdup(argv[2]);
+ format_connection_profile(profile, sizeof(profile), argv[2]);
+ }
+
+ if (g_dbus_proxy_method_call(proxy, method, connection_setup,
+ disconn_reply, data, NULL) == FALSE) {
bt_shell_printf("Failed to disconnect\n");
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- bt_shell_printf("Attempting to disconnect from %s\n",
+ bt_shell_printf("Attempting to disconnect%s from %s\n", profile,
proxy_address(proxy));
}
@@ -3253,10 +3317,13 @@ static const struct bt_shell_menu main_menu = {
dev_generator },
{ "remove", "<dev>", cmd_remove, "Remove device",
dev_generator },
- { "connect", "<dev>", cmd_connect, "Connect device",
- dev_generator },
- { "disconnect", "[dev]", cmd_disconn, "Disconnect device",
+ { "connect", "<dev> [uuid]", cmd_connect,
+ "Connect a device and all its profiles or "
+ "optionally connect a single profile only",
dev_generator },
+ { "disconnect", "[dev] [uuid]", cmd_disconn,
+ "Disconnect a device or optionally disconnect "
+ "a single profile only", dev_generator },
{ "wake", "[dev] [on/off]", cmd_wake, "Get/Set wake support",
dev_generator },
{ } },
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH BlueZ v3 3/3] client: Document connect/disconnect optional profile argument
2025-03-04 6:19 ` [PATCH BlueZ v3 1/3] uuid-helper: Add A2DP to the list of known profiles Arkadiusz Bokowy
2025-03-04 6:19 ` [PATCH BlueZ v3 2/3] client: Support single profile connection/disconnection Arkadiusz Bokowy
@ 2025-03-04 6:19 ` Arkadiusz Bokowy
2025-03-04 7:15 ` [BlueZ,v3,1/3] uuid-helper: Add A2DP to the list of known profiles bluez.test.bot
2025-03-04 14:40 ` [PATCH BlueZ v3 1/3] " patchwork-bot+bluetooth
3 siblings, 0 replies; 11+ messages in thread
From: Arkadiusz Bokowy @ 2025-03-04 6:19 UTC (permalink / raw)
To: luiz.dentz; +Cc: arkadiusz.bokowy, linux-bluetooth
---
client/bluetoothctl.rst | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/client/bluetoothctl.rst b/client/bluetoothctl.rst
index b6c2efa35..fb0999626 100644
--- a/client/bluetoothctl.rst
+++ b/client/bluetoothctl.rst
@@ -9,7 +9,7 @@ Bluetooth Control Command Line Tool
:Version: BlueZ
:Copyright: Free use of this software is granted under the terms of the GNU
Lesser General Public Licenses (LGPL).
-:Date: November 2022
+:Date: March 2024
:Manual section: 1
:Manual group: Linux System Administration
@@ -262,6 +262,13 @@ Connect device.
This will initiate a connection to a device.
+By default this commands tries to connect all the profiles the remote device
+supports and have been flagged as auto-connectable. In case when the UUID of
+the remote service is given only that service will be connected. The UUID can
+be either a short form (16-bit UUID) or a long form (128-bit UUID). There are
+also some special values for well-known profiles like "a2dp-sink",
+"a2dp-source", "hfp-hf", "hfp-ag", "ftp" or "spp".
+
To connect with an LE device the controller must have an active scan report of
the device it wants to connect to.
@@ -269,17 +276,25 @@ If no advertising report is received before the timeout a
le-connection-abort-by-local error will be issued. In that case either try
again to connect assuming the device is advertising.
-:Usage: **> connect <dev>**
+:Usage: **> connect <dev> [uuid]**
+:Example: **> connect 1C:48:F9:9D:81:5C**
+:Example: **> connect 1C:48:F9:9D:81:5C hsp-hs**
+:Example: **> connect 1C:48:F9:9D:81:5C 00001108-0000-1000-8000-00805f9b34fb**
+:Example: **> connect 1C:48:F9:9D:81:5C 0x1108**
disconnect
----------
Disconnect device.
+By default this commands disconnects all profiles and then terminates the
+connection. In case when the UUID of the remote service is given only that
+service will be disconnected.
+
For LE when disconnecting from an active connection the device address is not
needed.
-:Usage: **> disconnect <dev>**
+:Usage: **> disconnect <dev> [uuid]**
info
----
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* RE: [BlueZ,v3,1/3] uuid-helper: Add A2DP to the list of known profiles
2025-03-04 6:19 ` [PATCH BlueZ v3 1/3] uuid-helper: Add A2DP to the list of known profiles Arkadiusz Bokowy
2025-03-04 6:19 ` [PATCH BlueZ v3 2/3] client: Support single profile connection/disconnection Arkadiusz Bokowy
2025-03-04 6:19 ` [PATCH BlueZ v3 3/3] client: Document connect/disconnect optional profile argument Arkadiusz Bokowy
@ 2025-03-04 7:15 ` bluez.test.bot
2025-03-04 14:40 ` [PATCH BlueZ v3 1/3] " patchwork-bot+bluetooth
3 siblings, 0 replies; 11+ messages in thread
From: bluez.test.bot @ 2025-03-04 7:15 UTC (permalink / raw)
To: linux-bluetooth, arkadiusz.bokowy
[-- Attachment #1: Type: text/plain, Size: 1260 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=939880
---Test result---
Test Summary:
CheckPatch PENDING 0.18 seconds
GitLint PENDING 0.20 seconds
BuildEll PASS 20.42 seconds
BluezMake PASS 1436.81 seconds
MakeCheck PASS 13.83 seconds
MakeDistcheck PASS 157.70 seconds
CheckValgrind PASS 213.77 seconds
CheckSmatch PASS 283.34 seconds
bluezmakeextell PASS 97.93 seconds
IncrementalBuild PENDING 0.33 seconds
ScanBuild PASS 865.64 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:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH BlueZ v3 1/3] uuid-helper: Add A2DP to the list of known profiles
2025-03-04 6:19 ` [PATCH BlueZ v3 1/3] uuid-helper: Add A2DP to the list of known profiles Arkadiusz Bokowy
` (2 preceding siblings ...)
2025-03-04 7:15 ` [BlueZ,v3,1/3] uuid-helper: Add A2DP to the list of known profiles bluez.test.bot
@ 2025-03-04 14:40 ` patchwork-bot+bluetooth
3 siblings, 0 replies; 11+ messages in thread
From: patchwork-bot+bluetooth @ 2025-03-04 14:40 UTC (permalink / raw)
To: Arkadiusz Bokowy; +Cc: luiz.dentz, linux-bluetooth
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Tue, 4 Mar 2025 07:19:57 +0100 you wrote:
> ---
> src/uuid-helper.c | 32 +++++++++++++++++---------------
> 1 file changed, 17 insertions(+), 15 deletions(-)
Here is the summary with links:
- [BlueZ,v3,1/3] uuid-helper: Add A2DP to the list of known profiles
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=7a09d207fd9a
- [BlueZ,v3,2/3] client: Support single profile connection/disconnection
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=2f48028af3a8
- [BlueZ,v3,3/3] client: Document connect/disconnect optional profile argument
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=524fa22ed19e
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] 11+ messages in thread
end of thread, other threads:[~2025-03-04 14:39 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-02 16:47 [PATCH BlueZ] client: Support single profile connection/disconnection Arkadiusz Bokowy
2025-03-02 18:05 ` [BlueZ] " bluez.test.bot
2025-03-03 18:23 ` [PATCH BlueZ] " Luiz Augusto von Dentz
2025-03-03 19:51 ` [PATCH BlueZ v2] " Arkadiusz Bokowy
2025-03-03 21:11 ` [BlueZ,v2] " bluez.test.bot
2025-03-03 21:13 ` [PATCH BlueZ v2] " Luiz Augusto von Dentz
2025-03-04 6:19 ` [PATCH BlueZ v3 1/3] uuid-helper: Add A2DP to the list of known profiles Arkadiusz Bokowy
2025-03-04 6:19 ` [PATCH BlueZ v3 2/3] client: Support single profile connection/disconnection Arkadiusz Bokowy
2025-03-04 6:19 ` [PATCH BlueZ v3 3/3] client: Document connect/disconnect optional profile argument Arkadiusz Bokowy
2025-03-04 7:15 ` [BlueZ,v3,1/3] uuid-helper: Add A2DP to the list of known profiles bluez.test.bot
2025-03-04 14:40 ` [PATCH BlueZ v3 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