device: Better "Connect" debug
Subsystems (2)
v2 cover device: Better "Connect" debug
Re-sent with the correct prefix...
Changes since v1:
- Add client-side error decoding
Bastien Nocera (2):
client: Add client-side error decoding
device: Better "Connect" debug
Makefile.tools | 2 ++ client/error.c | 37 +++++++++++++++++++++++++++++++++++++ client/error.h | 11 +++++++++++ client/main.c | 5 +++-- src/device.c | 36 +++++++++++++++++++++++++++++------- 5 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 client/error.c create mode 100644 client/error.h
Signature · 1 line
2.47.1
PATCH v2 1/2 client: Add client-side error decoding
The D-Bus errors returned in a number of cases aren't in human-readable form, but instead exist as "codes" (listed in src/error.h).
This new function will allow us to convert those to human-readable form.
--- Makefile.tools | 2 ++ client/error.c | 36 ++++++++++++++++++++++++++++++++++++ client/error.h | 11 +++++++++++ 3 files changed, 49 insertions(+) create mode 100644 client/error.c create mode 100644 client/error.h
Makefile.tools +2 -0
@@ -10,6 +10,8 @@ client_bluetoothctl_SOURCES = client/main.c \ client/advertising.c \ client/adv_monitor.h \ client/adv_monitor.c \ + client/error.h \ + client/error.c \ client/gatt.h client/gatt.c \ client/admin.h client/admin.c \ client/player.h client/player.c \
client/error.c new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* +* BlueZ - Bluetooth protocol stack for Linux +* +* Copyright (C) 2025 Bastien Nocera <[email protected]> +* +* +*/ + +#include <stddef.h> +#include <glib.h> +#include "error.h" + +struct { +const char *error_code; +const char *str; +} error_codes[] = { + {"br-connection-profile-unavailable" ,"Exhausted the list of BR/EDR profiles to connect to" }, + {"br-connection-busy" ,"Cannot connect, connection busy" }, + {"br-connection-adapter-not-powered" ,"Cannot connect, adapter is not powered" }, +}; + +const char *error_code_to_str (const char *error_code) +{ +unsigned int i; + +if (error_code ==NULL ) +return NULL ; + +for (i =0 ; i <G_N_ELEMENTS (error_codes); i++) { +if (g_str_equal (error_codes[i].error_code, error_code)) +return error_codes[i].str; + } +return error_code; +}
client/error.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* +* BlueZ - Bluetooth protocol stack for Linux +* +* Copyright (C) 2025 Bastien Nocera <[email protected]> +* +* +*/ + +const char *error_code_to_str (const char *error_code);
Signature · 1 line
2.47.1
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=927506
---Test result---
Test Summary:
CheckPatch PENDING 0.22 seconds GitLint PENDING 0.20 seconds BuildEll PASS 20.35 seconds BluezMake PASS 1541.57 seconds MakeCheck PASS 13.32 seconds MakeDistcheck PASS 159.16 seconds CheckValgrind PASS 214.70 seconds CheckSmatch PASS 270.60 seconds bluezmakeextell PASS 98.24 seconds IncrementalBuild PENDING 0.25 seconds ScanBuild PASS 858.86 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
PATCH v2 2/2 device: Better "Connect" debug
In reply to Bastien NoceraOutput clearer debug information so that it's possible to follow the decisions made by the bluetoothd daemon when a client such as bluetoothctl or the GNOME Bluetooth settings ask it to connect to a device.
--- client/error.c | 1 + client/main.c | 5 +++-- src/device.c | 36 +++++++++++++++++++++++++++++------- 3 files changed, 33 insertions(+), 9 deletions(-)
client/error.c +1 -0
@@ -19,6 +19,7 @@ struct { { "br-connection-profile-unavailable", "Exhausted the list of BR/EDR profiles to connect to" }, { "br-connection-busy", "Cannot connect, connection busy" }, { "br-connection-adapter-not-powered", "Cannot connect, adapter is not powered" }, + { "br-connection-page-timeout", "Device is unpowered or not in range" }, };const char *error_code_to_str (const char *error_code)
client/main.c +3 -2
@@ -30,6 +30,7 @@#include "gdbus/gdbus.h" #include "print.h" #include "agent.h" +#include "error.h" #include "gatt.h" #include "advertising.h" #include "adv_monitor.h"
@@ -1977,8 +1978,8 @@ static void connect_reply(DBusMessage *message, void *user_data)dbus_error_init (&error);if (dbus_set_error_from_message (&error, message) == TRUE) { -bt_shell_printf ("Failed to connect: %s %s\n" , error.name, - error.message); +bt_shell_printf ("Failed to connect: %s: %s\n" , error.name, +error_code_to_str (error.message));dbus_error_free (&error);return bt_shell_noninteractive_quit (EXIT_FAILURE ); }
src/device.c +29 -7
@@ -2477,8 +2477,9 @@ static DBusMessage *connect_profiles(struct btd_device *dev, uint8_t bdaddr_typeDBG ("%s %s, client %s" , dev->path, uuid ? uuid :"(all)" ,dbus_message_get_sender (msg)); -if (dev->pending || dev->connect || dev->browse) +if (dev->pending || dev->connect || dev->browse) {return btd_error_in_progress_str (msg,ERR_BREDR_CONN_BUSY ); + }if (!btd_adapter_get_powered (dev->adapter)) { return btd_error_not_ready_str(msg,
@@ -2497,6 +2498,7 @@ static DBusMessage *connect_profiles(struct btd_device *dev, uint8_t bdaddr_type "Connect") && find_service_with_state(dev->services, BTD_SERVICE_STATE_CONNECTED)) { + DBG("Already connected to services"); return dbus_message_new_method_return(msg); } else { return btd_error_not_available_str(msg,
@@ -2509,8 +2511,10 @@ static DBusMessage *connect_profiles(struct btd_device *dev, uint8_t bdaddr_type err =connect_next (dev);if (err <0 ) { -if (err == -EALREADY ) +if (err == -EALREADY ) { +DBG ("Already connected" );return dbus_message_new_method_return (msg); + }return btd_error_failed (msg,btd_error_bredr_conn_from_errno (err)); }
@@ -2583,12 +2587,20 @@ static uint8_t select_conn_bearer(struct btd_device *dev)return dev->bdaddr_type; } +static const char *bdaddr_type_strs[] = { +"BR/EDR" , +"LE public" , +"LE random" +}; +static DBusMessage *dev_connect (DBusConnection *conn,DBusMessage *msg,void *user_data) {struct btd_device *dev = user_data;uint8_t bdaddr_type; +DBG ("Calling \"Connect\" for device %s" , dev->path); +if (dev->bredr_state.connected) {/* * Check if services have been resolved and there is at least
@@ -2596,20 +2608,30 @@ static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg,*/ if (dev->bredr_state.svc_resolved &&find_service_with_state (dev->services, -BTD_SERVICE_STATE_CONNECTED )) +BTD_SERVICE_STATE_CONNECTED )) { bdaddr_type = dev->bdaddr_type; -else +DBG ("Selecting address type %s, as BR/EDR services are resolved " +" and connected" , bdaddr_type_strs[dev->bdaddr_type]); + }else { bdaddr_type =BDADDR_BREDR ; - }else if (dev->le_state.connected && dev->bredr) +DBG ("Selecting address type BR/EDR, as services not resolved " +"or not connected" ); + } + }else if (dev->le_state.connected && dev->bredr) { bdaddr_type =BDADDR_BREDR ; -else +DBG ("Selecting address type BR/EDR, as LE already connected" ); + }else { bdaddr_type =select_conn_bearer (dev); +DBG ("Selecting address type %s" , bdaddr_type_strs[dev->bdaddr_type]); + }if (bdaddr_type !=BDADDR_BREDR ) {int err; -if (dev->le_state.connected) +if (dev->le_state.connected) { +DBG ("Device already connected through LE" );return dbus_message_new_method_return (msg); + }btd_device_set_temporary (dev, false);
Signature · 1 line
2.47.1
Luiz Augusto von Dentz
maintainerHi Bastien,
Quoted 16 lines · Bastien Nocera
Output clearer debug information so that it's possible to follow the decisions made by the bluetoothd daemon when a client such as bluetoothctl or the GNOME Bluetooth settings ask it to connect to a device.
--- client/error.c | 1 + client/main.c | 5 +++-- src/device.c | 36 +++++++++++++++++++++++++++++------- 3 files changed, 33 insertions(+), 9 deletions(-)client/error.c +0
-0
client/error.c struct { · line 22
Quoted 4 lines
client/error.c +1
-0@@ -19,6 +19,7 @@ struct { { "br-connection-profile-unavailable", "Exhausted the list of BR/EDR profiles to connect to" }, { "br-connection-busy", "Cannot connect, connection busy" }, { "br-connection-adapter-not-powered", "Cannot connect, adapter is not powered" }, + { "br-connection-page-timeout", "Device is unpowered or not in range" },
Not really following why do you want to translate the error message in bluetoothctl and not directly on bluetoothd side? Well perhaps there could be application expecting these strings to be sort of errors code really, in that case perhaps this is valid but I'd rather have it output both error.message and its description, but I would begin by defining them in the documentation:
https://github.com/bluez/bluez/blob/master/doc/org.bluez.Device.rst#void-connect
Right now we only document the error.code not the error.message
Quoted 122 lines
client/error.c +0
-0};const char *error_code_to_str (const char *error_code)client/main.c +3
-2@@ -30,6 +30,7 @@#include "gdbus/gdbus.h" #include "print.h" #include "agent.h" +#include "error.h" #include "gatt.h" #include "advertising.h" #include "adv_monitor.h" @@ -1977,8 +1978,8 @@ static void connect_reply(DBusMessage *message, void *user_data)dbus_error_init (&error);if (dbus_set_error_from_message (&error, message) == TRUE) { -bt_shell_printf ("Failed to connect: %s %s\n" , error.name, - error.message); +bt_shell_printf ("Failed to connect: %s: %s\n" , error.name, +error_code_to_str (error.message));dbus_error_free (&error);return bt_shell_noninteractive_quit (EXIT_FAILURE ); }src/device.c +29
-8@@ -2477,8 +2477,9 @@ static DBusMessage *connect_profiles(struct btd_device *dev, uint8_t bdaddr_typeDBG ("%s %s, client %s" , dev->path, uuid ? uuid :"(all)" ,dbus_message_get_sender (msg)); -if (dev->pending || dev->connect || dev->browse) +if (dev->pending || dev->connect || dev->browse) {return btd_error_in_progress_str (msg,ERR_BREDR_CONN_BUSY ); + }if (!btd_adapter_get_powered (dev->adapter)) { return btd_error_not_ready_str(msg,@@ -2497,6 +2498,7 @@ static DBusMessage *connect_profiles(struct btd_device *dev, uint8_t bdaddr_type "Connect") && find_service_with_state(dev->services, BTD_SERVICE_STATE_CONNECTED)) { + DBG("Already connected to services"); return dbus_message_new_method_return(msg); } else { return btd_error_not_available_str(msg,@@ -2509,8 +2511,10 @@ static DBusMessage *connect_profiles(struct btd_device *dev, uint8_t bdaddr_type err =connect_next (dev);if (err <0 ) { -if (err == -EALREADY ) +if (err == -EALREADY ) { +DBG ("Already connected" );return dbus_message_new_method_return (msg); + }return btd_error_failed (msg,btd_error_bredr_conn_from_errno (err)); }@@ -2583,12 +2587,20 @@ static uint8_t select_conn_bearer(struct btd_device *dev)return dev->bdaddr_type; } +static const char *bdaddr_type_strs[] = { +"BR/EDR" , +"LE public" , +"LE random" +}; +static DBusMessage *dev_connect (DBusConnection *conn,DBusMessage *msg,void *user_data) {struct btd_device *dev = user_data;uint8_t bdaddr_type; +DBG ("Calling \"Connect\" for device %s" , dev->path); +if (dev->bredr_state.connected) {/* * Check if services have been resolved and there is at least @@ -2596,20 +2608,30 @@ static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg,*/ if (dev->bredr_state.svc_resolved &&find_service_with_state (dev->services, -BTD_SERVICE_STATE_CONNECTED )) +BTD_SERVICE_STATE_CONNECTED )) { bdaddr_type = dev->bdaddr_type; -else +DBG ("Selecting address type %s, as BR/EDR services are resolved " +" and connected" , bdaddr_type_strs[dev->bdaddr_type]); + }else { bdaddr_type =BDADDR_BREDR ; - }else if (dev->le_state.connected && dev->bredr) +DBG ("Selecting address type BR/EDR, as services not resolved " +"or not connected" ); + } + }else if (dev->le_state.connected && dev->bredr) { bdaddr_type =BDADDR_BREDR ; -else +DBG ("Selecting address type BR/EDR, as LE already connected" ); + }else { bdaddr_type =select_conn_bearer (dev); +DBG ("Selecting address type %s" , bdaddr_type_strs[dev->bdaddr_type]); + }if (bdaddr_type !=BDADDR_BREDR ) {int err; -if (dev->le_state.connected) +if (dev->le_state.connected) { +DBG ("Device already connected through LE" );return dbus_message_new_method_return (msg); + }btd_device_set_temporary (dev, false); --2.47.1
Signature · 1 line
Luiz Augusto von Dentz
Quoted 39 lines · Luiz Augusto von Dentz
Hi Bastien,
Quoted 17 lines · Bastien Nocera
Output clearer debug information so that it's possible to follow the
decisions made by the bluetoothd daemon when a client such as bluetoothctl or the GNOME Bluetooth settings ask it to connect to a device.
---
client/error.c | 1 +
client/main.c | 5 +++--
src/device.c | 36 +++++++++++++++++++++++++++++-------3 files changed, 33 insertions(+), 9 deletions(-)client/error.c +0
-0@@ -19,6 +19,7 @@ struct {Quoted 8 lines
{ "br-connection-profile-unavailable", "Exhausted the list of BR/EDR profiles to connect to" },
{ "br-connection-busy", "Cannot connect, connection busy" },
{ "br-connection-adapter-not-powered", "Cannot connect, adapter is not powered" },
+ { "br-connection-page-timeout", "Device is unpowered or not in range" },Not really following why do you want to translate the error message in
bluetoothctl and not directly on bluetoothd side? Well perhaps there could be application expecting these strings to be sort of errors code
really, in that case perhaps this is valid but I'd rather have it output both error.message and its description, but I would begin by defining them in the documentation:
Quoted 3 lines
https://github.com/bluez/bluez/blob/master/doc/org.bluez.Device.rst#void-connect
Right now we only document the error.code not the error.message
I'd like to give the opportunity to front-ends to still be able to differentiate the different errors, but also dump in their logs a human-readable version of the error if they don't want to differentiate it in the UI.
What do you think of passing:
error code = org.bluez.Error.Failed
error.message = "BlueZ.Error:br-connection-page-timeout:Device is unpowered or not in range"
This would be a bit similar to how GDBus (the GLib one) encodes object error codes over the wire:
https://gitlab.gnome.org/GNOME/glib/blob/glib-2-80/gio/gdbuserror.c#L410
This means that we can get nicer error messages in bluetoothctl, and front-ends like gnome-bluetooth can use the error code to translate it to other languages, or present it differently.
What do you think?
Quoted 152 lines
Quoted 150 lines
};
const char *error_code_to_str(const char
*error_code)client/main.c +3
-2@@ -30,6 +30,7 @@ #include "gdbus/gdbus.h" #include "print.h" #include "agent.h" +#include "error.h" #include "gatt.h" #include "advertising.h" #include "adv_monitor.h"@@ -1977,8 +1978,8 @@ static void connect_reply(DBusMessage *message, void *user_data) dbus_error_init(&error); if (dbus_set_error_from_message(&error, message) == TRUE) { - bt_shell_printf("Failed to connect: %s %s\n", error.name, - error.message); + bt_shell_printf("Failed to connect: %s: %s\n", error.name, + error_code_to_str(error.message));
dbus_error_free(&error);
returnbt_shell_noninteractive_quit(EXIT_FAILURE); }src/device.c +0
-0@@ -2477,8 +2477,9 @@ static DBusMessage *connect_profiles(struct
btd_device*dev,uint8_tbdaddr_type
DBG("%s %s, client %s",dev->path, uuid ? uuid : "(all)",dbus_message_get_sender(msg));- if (dev->pending || dev->connect || dev->browse) + if (dev->pending || dev->connect || dev->browse) {return
btd_error_in_progress_str(msg, ERR_BREDR_CONN_BUSY);
+ }if (!btd_adapter_get_powered(dev->adapter)) { return btd_error_not_ready_str(msg,
src/device.c +0
-0@@ -2497,6 +2498,7 @@ static DBusMessage *connect_profiles(struct
btd_device*dev,uint8_tbdaddr_type
"Connect") &&
find_service_with_state(dev-Quoted 1 line
services,
BTD_SERVICE_STATE_CONNECTED)) {
+DBG("Already connected to services");
returndbus_message_new_method_return(msg);
} else {
return btd_error_not_available_str(msg,src/device.c +0
-0@@ -2509,8 +2511,10 @@ static DBusMessage *connect_profiles(struct
btd_device*dev,uint8_tbdaddr_typeerr =
connect_next(dev);
if (err < 0) {
- if (err ==-EALREADY)
+ if (err ==-EALREADY) {
+DBG("Already connected");
returndbus_message_new_method_return(msg); + }
return btd_error_failed(msg,btd_error_bredr_conn_from_errno(err));
}src/device.c +6
-0@@ -2583,12 +2587,20 @@ static uint8_t select_conn_bearer(struct btd_device *dev) return dev->bdaddr_type; } +static const char *bdaddr_type_strs[] = { + "BR/EDR", + "LE public", + "LE random" +}; +static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg,
void*user_data)
{
structbtd_device*dev =user_data;
uint8_tbdaddr_type;+
DBG("Calling \"Connect\" for device %s", dev->path); +
if (dev->bredr_state.connected) {
/*
* Check if services have been resolved and there is at leastsrc/device.c +0
-0@@ -2596,20 +2608,30 @@ static DBusMessage*dev_connect(DBusConnection *conn, DBusMessage *msg, */ if (
dev->bredr_state.svc_resolved&& find_service_with_state(dev->services, -BTD_SERVICE_STATE_CONNECTED))
+BTD_SERVICE_STATE_CONNECTED)) {
bdaddr_type=dev->bdaddr_type; - else
+ DBG("Selecting address type %s, as BR/EDR services are resolved "
+ " and connected", bdaddr_type_strs[dev-Quoted 1 line
bdaddr_type]);+ } else {
bdaddr_type=BDADDR_BREDR;
- } else if (dev->le_state.connected&&dev->bredr) + DBG("Selecting address type BR/EDR, as services not resolved "
+ "or not connected");
+ }
+ } else if (dev->le_state.connected&&dev->bredr) {bdaddr_type=BDADDR_BREDR;
- else
+DBG("Selecting address type BR/EDR, as LE already connected");
+ } else {
bdaddr_type=select_conn_bearer(dev); +DBG("Selecting address type %s", bdaddr_type_strs[dev->bdaddr_type]);
+ }if (
bdaddr_type!=BDADDR_BREDR) {
int err;- if (
dev->le_state.connected)
+ if (dev->le_state.connected) {
+DBG("Device already connected through LE"); returndbus_message_new_method_return(msg); + }
btd_device_set_temporary(dev, false);--
2.47.1
Luiz Augusto von Dentz
maintainerHi Bastien,
Quoted 59 lines · Bastien Nocera
Quoted 39 lines · Luiz Augusto von Dentz
Hi Bastien,
Quoted 24 lines · Bastien Nocera
Output clearer debug information so that it's possible to follow the
decisions made by the bluetoothd daemon when a client such as bluetoothctl or the GNOME Bluetooth settings ask it to connect to a device.--- client/error.c | 1 + client/main.c | 5 +++-- src/device.c | 36 +++++++++++++++++++++++++++++------- 3 files changed, 33 insertions(+), 9 deletions(-)client/error.c +1
-0@@ -19,6 +19,7 @@ struct { { "br-connection-profile-unavailable", "Exhausted the list of BR/EDR profiles to connect to" }, { "br-connection-busy", "Cannot connect, connection busy" }, { "br-connection-adapter-not-powered", "Cannot connect, adapter is not powered" }, + { "br-connection-page-timeout", "Device is unpowered or notQuoted 1 line
in range" },
Not really following why do you want to translate the error message in
bluetoothctl and not directly on bluetoothd side? Well perhaps there could be application expecting these strings to be sort of errors code
really, in that case perhaps this is valid but I'd rather have it output both error.message and its description, but I would begin by defining them in the documentation:Quoted 3 lines
https://github.com/bluez/bluez/blob/master/doc/org.bluez.Device.rst#void-connect
Right now we only document the error.code not the error.message
I'd like to give the opportunity to front-ends to still be able to differentiate the different errors, but also dump in their logs a human-readable version of the error if they don't want to differentiate it in the UI.
What do you think of passing:
error code = org.bluez.Error.Failed
error.message = "BlueZ.Error:br-connection-page-timeout:Device is unpowered or not in range"This would be a bit similar to how GDBus (the GLib one) encodes object error codes over the wire:
https://gitlab.gnome.org/GNOME/glib/blob/glib-2-80/gio/gdbuserror.c#L410
Quoted 5 lines
This means that we can get nicer error messages in bluetoothctl, and front-ends like gnome-bluetooth can use the error code to translate it to other languages, or present it differently.
What do you think?
I fine with that, like I said for me the error message was sort of free format but perhaps it is not for some application reading into it as they expect the string to work as error (sub)code, in that case changing these string may actually be considered breaking an API, honestly I don't know if we should consider adding more error codes and leave the message as free format otherwise this will keep happening.
Quoted 153 lines
Quoted 152 lines
Quoted 150 lines
};
const char *error_code_to_str(const char
*error_code)client/main.c +3
-2@@ -30,6 +30,7 @@#include "gdbus/gdbus.h" #include "print.h" #include "agent.h" +#include "error.h" #include "gatt.h" #include "advertising.h" #include "adv_monitor.h" @@ -1977,8 +1978,8 @@ static void connect_reply(DBusMessage *message, void *user_data)dbus_error_init (&error);if (dbus_set_error_from_message (&error, message) == TRUE) { -bt_shell_printf ("Failed to connect: %s %s\n" , error.name, - error.message); +bt_shell_printf ("Failed to connect: %s: %s\n" , error.name, +error_code_to_str (error.message));dbus_error_free(&error); return bt_shell_noninteractive_quit(EXIT_FAILURE); }src/device.c +0
-0@@ -2477,8 +2477,9 @@ static DBusMessage *connect_profiles(struct
btd_device*dev,uint8_tbdaddr_typeDBG("%s %s, client %s", dev->path, uuid ? uuid : "(all)",
dbus_message_get_sender(msg));src/device.c +1
-1-if (dev->pending || dev->connect || dev->browse) +if (dev->pending || dev->connect || dev->browse) { return btd_error_in_progress_str(msg,
ERR_BREDR_CONN_BUSY);src/device.c +1
-0+ }if (!btd_adapter_get_powered (dev->adapter)) { return btd_error_not_ready_str(msg,@@ -2497,6 +2498,7 @@ static DBusMessage *connect_profiles(struct
btd_device*dev,uint8_tbdaddr_type"Connect")&&
find_service_with_state(dev-Quoted 1 line
services,
BTD_SERVICE_STATE_CONNECTED)) {
+ DBG("Already connected to
services");
returndbus_message_new_method_return(msg); } else { returnbtd_error_not_available_str(msg,
src/device.c +0
-0@@ -2509,8 +2511,10 @@ static DBusMessage *connect_profiles(struct
btd_device*dev,uint8_tbdaddr_typeerr = connect_next(dev); if (err < 0) {src/device.c +3
-1-if (err == -EALREADY ) +if (err == -EALREADY ) { +DBG ("Already connected" );return dbus_message_new_method_return (msg); + } return btd_error_failed(msg,btd_error_bredr_conn_from_errno(err)); }src/device.c +8
-0@@ -2583,12 +2587,20 @@ static uint8_t select_conn_bearer(struct btd_device *dev)return dev->bdaddr_type; } +static const char *bdaddr_type_strs[] = { +"BR/EDR" , +"LE public" , +"LE random" +}; +static DBusMessage *dev_connect (DBusConnection *conn,DBusMessage *msg,void *user_data) {struct btd_device *dev = user_data;uint8_t bdaddr_type; +DBG ("Calling \"Connect\" for device %s" , dev->path); +if (dev->bredr_state.connected) { /* * Check if services have been resolved and thereis at least
src/device.c +2
-2@@ -2596,20 +2608,30 @@ static DBusMessage*dev_connect(DBusConnection *conn, DBusMessage *msg, */ if (dev->bredr_state.svc_resolved &&find_service_with_state (dev->services, -BTD_SERVICE_STATE_CONNECTED )) + BTD_SERVICE_STATE_CONNECTED)) { bdaddr_type = dev->bdaddr_type; - else + DBG("Selecting address type %s, as BR/EDRservices are resolved "
+ " and connected", bdaddr_type_strs[dev-Quoted 1 line
bdaddr_type]);src/device.c +2
-1+ }else { bdaddr_type =BDADDR_BREDR ; - }else if (dev->le_state.connected && dev->bredr) + DBG("Selecting address type BR/EDR, asservices not resolved "
src/device.c +4
-1+ "or not connected"); + } + }else if (dev->le_state.connected && dev->bredr) { bdaddr_type =BDADDR_BREDR ; - else + DBG("Selecting address type BR/EDR, as LE alreadyconnected");
src/device.c +2
-0+ }else { bdaddr_type =select_conn_bearer (dev); + DBG("Selecting address type %s",bdaddr_type_strs[dev->bdaddr_type]);
src/device.c +4
-2+ }if (bdaddr_type !=BDADDR_BREDR ) {int err; -if (dev->le_state.connected) +if (dev->le_state.connected) { +DBG ("Device already connected through LE" );return dbus_message_new_method_return (msg); + }btd_device_set_temporary (dev, false); --2.47.1
Signature · 1 line
Luiz Augusto von Dentz