org.bluez.Device: Introduced PreferredBearer
Luiz Augusto von Dentz
maintainerPATCH v2 1/3 org.bluez.Device: Introduced PreferredBearer
From: Luiz Augusto von Dentz <[email protected]>
This introduces PreferredBearer property which can be used to indicate what bearer shall be connected first rather than just using last seen bearer which may not work always since it seems some devices sometimes advertises on LE bearer but expects connections over BR/EDR e.g:
https://github.com/bluez/bluez/issues/1092
Also with the introduction of LE Audio this might become even more of a problem since most likely users would like to select which bearer to use rather than using the last-seen policy.
--- doc/org.bluez.Device.rst | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
doc/org.bluez.Device.rst +28 -1
@@ -40,7 +40,8 @@ void Connect() are skip and check latest seen bearer. 3. Connect last seen bearer, in case the timestamps are the same BR/EDR - takes precedence. + takes precedence, or in case **PreferredBearer** has been set to a + specific bearer then that is used instead. Possible errors:
@@ -346,3 +347,29 @@ array{object, dict} Sets [readonly, experimental] :byte Rank: Rank of the device in the Set. + +string PreferredBearer [readwrite, optional, experimental] +`````````````````````````````````````````````````````````` + + Indicate the preferred bearer when initiating a connection, only + available for dual-mode devices. + + When changing from "bredr" to "le" the device will be removed from the + 'auto-connect' list so it won't automatically be connected when + adverting. + + Note: Changes only take effect when the device is disconnected. + + Possible values: + + :"last-seen": + + Connect to last seen bearer first. Default. + + :"bredr": + + Connect to BR/EDR first. + + :"le": + + Connect to LE first.
Signature · 1 line
2.48.1
Luiz Augusto von Dentz
maintainerPATCH v2 2/3 device: Add implementation of PreferredBearer
From: Luiz Augusto von Dentz <[email protected]>
This adds initial implementation of PreferredBearer.
--- src/device.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 3 deletions(-)
src/device.c +92 -3
@@ -152,6 +152,7 @@ struct svc_callback {/* Per-bearer (LE or BR/EDR) device state */ struct bearer_state { +bool prefer;bool paired;bool bonded;bool connected;
@@ -2543,10 +2544,12 @@ static uint8_t select_conn_bearer(struct btd_device *dev)time_t bredr_last =NVAL_TIME , le_last =NVAL_TIME ;time_t current =time (NULL ); -/* Prefer bonded bearer in case only one is bonded */ -if (dev->bredr_state.bonded && !dev->le_state.bonded ) +/* Use preferred bearer or bonded bearer in case only one is bonded */ +if (dev->bredr_state.prefer || + (dev->bredr_state.bonded && !dev->le_state.bonded))return BDADDR_BREDR ; -else if (!dev->bredr_state.bonded && dev->le_state.bonded) +else if (dev->le_state.prefer || + (!dev->bredr_state.bonded && dev->le_state.bonded))return dev->bdaddr_type;/* If the address is random it can only be connected over LE */
@@ -3340,6 +3343,88 @@ static const GDBusMethodTable device_methods[] = { { } }; +static const char *device_prefer_bearer_str (struct btd_device *device) +{ +if (device->bredr_state.prefer) +return "bredr" ; +else if (device->le_state.prefer) +return "le" ; +else +return "last-seen" ; +} + +static gboolean +dev_property_get_prefer_bearer (const GDBusPropertyTable *property, +DBusMessageIter *iter,void *data) +{ +struct btd_device *device = data; +const char *str =device_prefer_bearer_str (device); + +dbus_message_iter_append_basic (iter,DBUS_TYPE_STRING , &str); + +return TRUE; +} + +static void +dev_property_set_prefer_bearer (const GDBusPropertyTable *property, +DBusMessageIter *value, +GDBusPendingPropertySet id,void *data) +{ +struct btd_device *device = data; +const char *str; + +if (dbus_message_iter_get_arg_type (value) !=DBUS_TYPE_STRING ) { +g_dbus_pending_property_error (id, +ERROR_INTERFACE ".InvalidArguments" , +"Invalid arguments in method call" ); +return ; + } + +dbus_message_iter_get_basic (value, &str); + +if (strcasecmp (str,"last-seen" ) ==0 ) { + device->bredr_state.prefer = false; + device->le_state.prefer = false; + }else if (strcasecmp (str,"bredr" ) ==0 ) { + device->bredr_state.prefer = true; + device->le_state.prefer = false; +/* Remove device from auto-connect list so the kernel does not +* attempt to auto-connect to it in case it starts advertising. +*/ +device_set_auto_connect (device, FALSE); + }else if (strcasecmp (str,"le" ) ==0 ) { + device->le_state.prefer = true; + device->bredr_state.prefer = false; +/* Add device to auto-connect list */ +device_set_auto_connect (device, TRUE); + }else { +g_dbus_pending_property_error (id, +ERROR_INTERFACE ".InvalidArguments" , +"Invalid arguments in method call" ); +return ; + } + +g_dbus_emit_property_changed (dbus_conn, device->path, +DEVICE_INTERFACE ,"PreferredBearer" ); + +g_dbus_pending_property_success (id); +} + +static gboolean +dev_property_prefer_bearer_exists (const GDBusPropertyTable *property, +void *data) +{ +struct btd_device *device = data; + +/* Check if both BR/EDR and LE bearer are connected/bonded */ +if ((device->bredr_state.connected || device->bredr_state.bonded) && + device->le_state.connected || device->le_state.bonded) +return TRUE; + +/* Check if both BR/EDR and LE are connectable */ +return device->bredr_state.connectable && device->le_state.connectable; +} +static const GDBusPropertyTable device_properties[] = { {"Address" ,"s" , dev_property_get_address }, {"AddressType" ,"s" , property_get_address_type },
@@ -3378,6 +3463,10 @@ static const GDBusPropertyTable device_properties[] = { dev_property_wake_allowed_exist }, {"Sets" ,"a{oa{sv}}" , dev_property_get_set,NULL , dev_property_set_exists }, + { "PreferredBearer", "s", dev_property_get_prefer_bearer, + dev_property_set_prefer_bearer, + dev_property_prefer_bearer_exists, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL }, { } };
Signature · 1 line
2.48.1
Luiz Augusto von Dentz
maintainerPATCH v2 3/3 client: Add support get/set PreferredBearer
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This adds support for PreferredBearer which is printed with the likes of info command:
bluetoothctl> info <addr>
...
PreferredBearer: last-seen
It also introduces a new command to get/set the PreferredBearer:
[bluetoothctl]> bearer --help
Get/Set preferred bearer
Usage:
bearer <dev> [last-seen/bredr/le]
[bluetoothctl]> bearer <addr>
PreferredBearer: last-seen
[bluetoothctl]> bearer <addr> le
bluetoothd: @ MGMT Command: Add Device (0x0033) plen 8
LE Address: <addr>
Action: Auto-connect remote device (0x02)
[CHG] Device <addr> PreferredBearer: le
Changing le succeeded
[bluetoothctl]> bearer <addr>
PreferredBearer: le
[bluetoothctl]> bearer <addr> bredr
bluetoothd: @ MGMT Command: Remove Device (0x0034) plen 7
LE Address: <addr>
[CHG] Device <addr> PreferredBearer: bredr Changing bredr succeeded
--- client/main.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
client/main.c +27 -0
@@ -1714,6 +1714,7 @@ static void cmd_info(int argc, char *argv[])print_property (proxy,"AdvertisingFlags" );print_property (proxy,"AdvertisingData" );print_property (proxy,"Sets" ); +print_property (proxy,"PreferredBearer" ); battery_proxy =find_proxies_by_path (battery_proxies,g_dbus_proxy_get_path (proxy));
@@ -2086,6 +2087,30 @@ static void cmd_wake(int argc, char *argv[])return bt_shell_noninteractive_quit (EXIT_FAILURE ); } +static void cmd_bearer (int argc,char *argv[]) +{ +GDBusProxy *proxy; +char *str; + + proxy =find_device (argc, argv); +if (!proxy) +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + +if (argc <=2 ) { +print_property (proxy,"PreferredBearer" ); +return ; + } + + str =strdup (argv[2 ]); + +if (g_dbus_proxy_set_property_basic (proxy,"PreferredBearer" , +DBUS_TYPE_STRING , &str, + generic_callback, str, free)) +return ; + +return bt_shell_noninteractive_quit (EXIT_FAILURE ); +} +static void cmd_list_attributes (int argc,char *argv[]) {GDBusProxy *proxy;
@@ -3247,6 +3272,8 @@ static const struct bt_shell_menu main_menu = { dev_generator }, {"wake" ,"[dev] [on/off]" , cmd_wake,"Get/Set wake support" , dev_generator }, + { "bearer", "<dev> [last-seen/bredr/le]", cmd_bearer, + "Get/Set preferred bearer", dev_generator }, { } }, };
Signature · 1 line
2.48.1
Luiz Augusto von Dentz
maintainerRe: [PATCH BlueZ v2 3/3] client: Add support get/set PreferredBearer
Hi Pauli, Bastien,
Quoted 89 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This adds support for PreferredBearer which is printed with the likes of info command:
bluetoothctl> info <addr>
...
PreferredBearer: last-seenIt also introduces a new command to get/set the PreferredBearer:
[bluetoothctl]> bearer --help
Get/Set preferred bearer
Usage:
bearer <dev> [last-seen/bredr/le][bluetoothctl]> bearer <addr>
PreferredBearer: last-seen
[bluetoothctl]> bearer <addr> le
bluetoothd: @ MGMT Command: Add Device (0x0033) plen 8
LE Address: <addr>
Action: Auto-connect remote device (0x02)
[CHG] Device <addr> PreferredBearer: le
Changing le succeeded
[bluetoothctl]> bearer <addr>
PreferredBearer: le
[bluetoothctl]> bearer <addr> bredr
bluetoothd: @ MGMT Command: Remove Device (0x0034) plen 7
LE Address: <addr>
[CHG] Device <addr> PreferredBearer: bredr Changing bredr succeeded--- client/main.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)client/main.c +27
-1@@ -1714,6 +1714,7 @@ static void cmd_info(int argc, char *argv[])print_property (proxy,"AdvertisingFlags" );print_property (proxy,"AdvertisingData" );print_property (proxy,"Sets" ); +print_property (proxy,"PreferredBearer" ); battery_proxy =find_proxies_by_path (battery_proxies,g_dbus_proxy_get_path (proxy));@@ -2086,6 +2087,30 @@ static void cmd_wake(int argc, char *argv[])return bt_shell_noninteractive_quit (EXIT_FAILURE ); } +static void cmd_bearer (int argc,char *argv[]) +{ +GDBusProxy *proxy; +char *str; + + proxy =find_device (argc, argv); +if (!proxy) +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + +if (argc <=2 ) { +print_property (proxy,"PreferredBearer" ); +return ; + } + + str =strdup (argv[2 ]); + +if (g_dbus_proxy_set_property_basic (proxy,"PreferredBearer" , +DBUS_TYPE_STRING , &str, + generic_callback, str, free)) +return ; + +return bt_shell_noninteractive_quit (EXIT_FAILURE ); +} +static void cmd_list_attributes (int argc,char *argv[]) {GDBusProxy *proxy;@@ -3247,6 +3272,8 @@ static const struct bt_shell_menu main_menu = { dev_generator }, {"wake" ,"[dev] [on/off]" , cmd_wake,"Get/Set wake support" , dev_generator }, + { "bearer", "<dev> [last-seen/bredr/le]", cmd_bearer, + "Get/Set preferred bearer", dev_generator }, { } }, }; --
Quoted 1 line
2.48.1
So I went ahead and implemented the idea of having PreferredBearer, this works great when setting bredr it really stops from connecting to LE, the said the other way around when setting to le seems to confuse some headsets like EarFun and it ends up connecting both bearers:
[EarFun Air Pro 3]> transport.show
Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd1
UUID: Sink PAC (00002bc9-0000-1000-8000-00805f9b34fb)
Codec: 0x06 (6)
Configuration.#0: len 0x02 type 0x01
Configuration.Sampling Frequency: 16 Khz (0x03)
Configuration.#1: len 0x02 type 0x02
Configuration.Frame Duration: 7.5 ms (0x00)
Configuration.#2: len 0x05 type 0x03
Configuration.Location: 0x00000001
Configuration.Location: Front Left (0x00000001)
Configuration.#3: len 0x03 type 0x04
Configuration.Frame Length: 30 (0x001e)
Configuration.#4: len 0x02 type 0x05
Configuration.Frame Blocks per SDU: 1 (0x01)
Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41
State: idle
Volume: 0x00c8 (200)
Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0
QoS.CIG: 0x00 (0)
QoS.CIS: 0x00 (0)
QoS.Framing: 0x00 (0)
QoS.PresentationDelay: 0x00009c40 (40000)
QoS.Interval: 0x00001d4c (7500)
QoS.Latency: 0x0008 (8)
QoS.SDU: 0x001e (30)
QoS.PHY: 0x02 (2)
QoS.Retransmissions: 0x02 (2)
Location: 0x00000003 (3)
Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd3
Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd2
UUID: Sink PAC (00002bc9-0000-1000-8000-00805f9b34fb)
Codec: 0x06 (6)
Configuration.#0: len 0x02 type 0x01
Configuration.Sampling Frequency: 16 Khz (0x03)
Configuration.#1: len 0x02 type 0x02
Configuration.Frame Duration: 7.5 ms (0x00)
Configuration.#2: len 0x05 type 0x03
Configuration.Location: 0x00000002
Configuration.Location: Front Right (0x00000002)
Configuration.#3: len 0x03 type 0x04
Configuration.Frame Length: 30 (0x001e)
Configuration.#4: len 0x02 type 0x05
Configuration.Frame Blocks per SDU: 1 (0x01)
Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41
State: idle
Volume: 0x00c8 (200)
Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0
QoS.CIG: 0x00 (0)
QoS.CIS: 0x01 (1)
QoS.Framing: 0x00 (0)
QoS.PresentationDelay: 0x00009c40 (40000)
QoS.Interval: 0x00001d4c (7500)
QoS.Latency: 0x0008 (8)
QoS.SDU: 0x001e (30)
QoS.PHY: 0x02 (2)
QoS.Retransmissions: 0x02 (2)
Location: 0x00000003 (3)
Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd4
Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd3
UUID: Source PAC (00002bcb-0000-1000-8000-00805f9b34fb)
Codec: 0x06 (6)
Configuration.#0: len 0x02 type 0x01
Configuration.Sampling Frequency: 48 Khz (0x08)
Configuration.#1: len 0x02 type 0x02
Configuration.Frame Duration: 7.5 ms (0x00)
Configuration.#2: len 0x05 type 0x03
Configuration.Location: 0x00000001
Configuration.Location: Front Left (0x00000001)
Configuration.#3: len 0x03 type 0x04
Configuration.Frame Length: 90 (0x005a)
Configuration.#4: len 0x02 type 0x05
Configuration.Frame Blocks per SDU: 1 (0x01)
Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41
State: idle
Volume: 0x00c8 (200)
Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0
QoS.CIG: 0x00 (0)
QoS.CIS: 0x00 (0)
QoS.Framing: 0x00 (0)
QoS.PresentationDelay: 0x00009c40 (40000)
QoS.Interval: 0x00001d4c (7500)
QoS.Latency: 0x000f (15)
QoS.SDU: 0x005a (90)
QoS.PHY: 0x02 (2)
QoS.Retransmissions: 0x05 (5)
Location: 0x00000003 (3)
Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd1
Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd4
UUID: Source PAC (00002bcb-0000-1000-8000-00805f9b34fb)
Codec: 0x06 (6)
Configuration.#0: len 0x02 type 0x01
Configuration.Sampling Frequency: 48 Khz (0x08)
Configuration.#1: len 0x02 type 0x02
Configuration.Frame Duration: 7.5 ms (0x00)
Configuration.#2: len 0x05 type 0x03
Configuration.Location: 0x00000002
Configuration.Location: Front Right (0x00000002)
Configuration.#3: len 0x03 type 0x04
Configuration.Frame Length: 90 (0x005a)
Configuration.#4: len 0x02 type 0x05
Configuration.Frame Blocks per SDU: 1 (0x01)
Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41
State: idle
Volume: 0x00c8 (200)
Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0
QoS.CIG: 0x00 (0)
QoS.CIS: 0x01 (1)
QoS.Framing: 0x00 (0)
QoS.PresentationDelay: 0x00009c40 (40000)
QoS.Interval: 0x00001d4c (7500)
QoS.Latency: 0x000f (15)
QoS.SDU: 0x005a (90)
QoS.PHY: 0x02 (2)
QoS.Retransmissions: 0x05 (5)
Location: 0x00000003 (3)
Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd2
Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/fd5
UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb)
Codec: 0x02 (2)
Media Codec: MPEG24
Object Types: MPEG-4 AAC LC
Frequencies: 48kHz
Channels: 2
Bitrate: 320000
VBR: Yes
Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41
State: idle
Delay: 0x0960 (2400)
Volume: 0x0064 (100)We might need to check if other devices have such behavior, perhaps the headset is saving the last bearer it connected to so it tries to restore it or something like that, this may messes up with that, in the other hand the bearer can be selected even before first connecting so we may decide to default to bredr instead of last seen for this type of devices (Classic+LE Audio).
Anyway there are some pieces left that I still need to implement like save the bearer in the storage so when the daemon is reloaded, or in case of reboot, it restores the last mode properly.
Signature · 1 line
Luiz Augusto von Dentz
Luiz Augusto von Dentz
maintainerRe: [PATCH BlueZ v2 3/3] client: Add support get/set PreferredBearer
Hi Pauli,
Quoted 223 lines · Luiz Augusto von Dentz
Hi Pauli, Bastien,
Quoted 89 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This adds support for PreferredBearer which is printed with the likes of info command:
bluetoothctl> info <addr>
...
PreferredBearer: last-seenIt also introduces a new command to get/set the PreferredBearer:
[bluetoothctl]> bearer --help
Get/Set preferred bearer
Usage:
bearer <dev> [last-seen/bredr/le][bluetoothctl]> bearer <addr>
PreferredBearer: last-seen
[bluetoothctl]> bearer <addr> le
bluetoothd: @ MGMT Command: Add Device (0x0033) plen 8
LE Address: <addr>
Action: Auto-connect remote device (0x02)
[CHG] Device <addr> PreferredBearer: le
Changing le succeeded
[bluetoothctl]> bearer <addr>
PreferredBearer: le
[bluetoothctl]> bearer <addr> bredr
bluetoothd: @ MGMT Command: Remove Device (0x0034) plen 7
LE Address: <addr>
[CHG] Device <addr> PreferredBearer: bredr Changing bredr succeeded--- client/main.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)client/main.c +27
-1@@ -1714,6 +1714,7 @@ static void cmd_info(int argc, char *argv[])print_property (proxy,"AdvertisingFlags" );print_property (proxy,"AdvertisingData" );print_property (proxy,"Sets" ); +print_property (proxy,"PreferredBearer" ); battery_proxy =find_proxies_by_path (battery_proxies,g_dbus_proxy_get_path (proxy));@@ -2086,6 +2087,30 @@ static void cmd_wake(int argc, char *argv[])return bt_shell_noninteractive_quit (EXIT_FAILURE ); } +static void cmd_bearer (int argc,char *argv[]) +{ +GDBusProxy *proxy; +char *str; + + proxy =find_device (argc, argv); +if (!proxy) +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + +if (argc <=2 ) { +print_property (proxy,"PreferredBearer" ); +return ; + } + + str =strdup (argv[2 ]); + +if (g_dbus_proxy_set_property_basic (proxy,"PreferredBearer" , +DBUS_TYPE_STRING , &str, + generic_callback, str, free)) +return ; + +return bt_shell_noninteractive_quit (EXIT_FAILURE ); +} +static void cmd_list_attributes (int argc,char *argv[]) {GDBusProxy *proxy;@@ -3247,6 +3272,8 @@ static const struct bt_shell_menu main_menu = { dev_generator }, {"wake" ,"[dev] [on/off]" , cmd_wake,"Get/Set wake support" , dev_generator }, + { "bearer", "<dev> [last-seen/bredr/le]", cmd_bearer, + "Get/Set preferred bearer", dev_generator }, { } }, }; --Quoted 1 line
2.48.1
So I went ahead and implemented the idea of having PreferredBearer, this works great when setting bredr it really stops from connecting to LE, the said the other way around when setting to le seems to confuse some headsets like EarFun and it ends up connecting both bearers:
[EarFun Air Pro 3]> transport.show
Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd1UUID: Sink PAC (00002bc9-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 16 Khz (0x03) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000001 Configuration.Location: Front Left (0x00000001) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 30 (0x001e) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0 QoS.CIG: 0x00 (0) QoS.CIS: 0x00 (0) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x0008 (8) QoS.SDU: 0x001e (30) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x02 (2) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd3 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd2 UUID: Sink PAC (00002bc9-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 16 Khz (0x03) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000002 Configuration.Location: Front Right (0x00000002) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 30 (0x001e) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0 QoS.CIG: 0x00 (0) QoS.CIS: 0x01 (1) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x0008 (8) QoS.SDU: 0x001e (30) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x02 (2) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd4 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd3 UUID: Source PAC (00002bcb-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 48 Khz (0x08) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000001 Configuration.Location: Front Left (0x00000001) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 90 (0x005a) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0 QoS.CIG: 0x00 (0) QoS.CIS: 0x00 (0) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x000f (15) QoS.SDU: 0x005a (90) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x05 (5) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd1 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd4 UUID: Source PAC (00002bcb-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 48 Khz (0x08) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000002 Configuration.Location: Front Right (0x00000002) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 90 (0x005a) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0 QoS.CIG: 0x00 (0) QoS.CIS: 0x01 (1) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x000f (15) QoS.SDU: 0x005a (90) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x05 (5) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd2 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/fd5 UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb) Codec: 0x02 (2) Media Codec: MPEG24 Object Types: MPEG-4 AAC LC
Quoted 8 lines
Frequencies: 48kHz
Channels: 2
Bitrate: 320000
VBR: Yes
Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41
State: idle
Delay: 0x0960 (2400)
Volume: 0x0064 (100)Forgot to mention, but with the above transports it seems to confuse the gnome audio output selection, it doesn't seem to be able to mix A2DP and BAP transports for some reason, so when I select the device it enables BAP but A2DP is not shown as an option.
Quoted 13 lines
We might need to check if other devices have such behavior, perhaps the headset is saving the last bearer it connected to so it tries to restore it or something like that, this may messes up with that, in the other hand the bearer can be selected even before first connecting so we may decide to default to bredr instead of last seen for this type of devices (Classic+LE Audio).
Anyway there are some pieces left that I still need to implement like save the bearer in the storage so when the daemon is reloaded, or in case of reboot, it restores the last mode properly.
--
Luiz Augusto von Dentz
Signature · 1 line
Luiz Augusto von Dentz
Re: [PATCH BlueZ v2 3/3] client: Add support get/set PreferredBearer
ti, 2025-02-25 kello 17:12 -0500, Luiz Augusto von Dentz kirjoitti:
Quoted 236 lines
Hi Pauli,
Quoted 223 lines · Luiz Augusto von Dentz
Hi Pauli, Bastien,
Quoted 89 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This adds support for PreferredBearer which is printed with the likes of info command:
bluetoothctl> info <addr>
...
PreferredBearer: last-seenIt also introduces a new command to get/set the PreferredBearer:
[bluetoothctl]> bearer --help
Get/Set preferred bearer
Usage:
bearer <dev> [last-seen/bredr/le][bluetoothctl]> bearer <addr>
PreferredBearer: last-seen
[bluetoothctl]> bearer <addr> le
bluetoothd: @ MGMT Command: Add Device (0x0033) plen 8
LE Address: <addr>
Action: Auto-connect remote device (0x02)
[CHG] Device <addr> PreferredBearer: le
Changing le succeeded
[bluetoothctl]> bearer <addr>
PreferredBearer: le
[bluetoothctl]> bearer <addr> bredr
bluetoothd: @ MGMT Command: Remove Device (0x0034) plen 7
LE Address: <addr>
[CHG] Device <addr> PreferredBearer: bredr Changing bredr succeeded--- client/main.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)client/main.c +27
-1@@ -1714,6 +1714,7 @@ static void cmd_info(int argc, char *argv[])print_property (proxy,"AdvertisingFlags" );print_property (proxy,"AdvertisingData" );print_property (proxy,"Sets" ); +print_property (proxy,"PreferredBearer" ); battery_proxy =find_proxies_by_path (battery_proxies,g_dbus_proxy_get_path (proxy));@@ -2086,6 +2087,30 @@ static void cmd_wake(int argc, char *argv[])return bt_shell_noninteractive_quit (EXIT_FAILURE ); } +static void cmd_bearer (int argc,char *argv[]) +{ +GDBusProxy *proxy; +char *str; + + proxy =find_device (argc, argv); +if (!proxy) +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + +if (argc <=2 ) { +print_property (proxy,"PreferredBearer" ); +return ; + } + + str =strdup (argv[2 ]); + +if (g_dbus_proxy_set_property_basic (proxy,"PreferredBearer" , +DBUS_TYPE_STRING , &str, + generic_callback, str, free)) +return ; + +return bt_shell_noninteractive_quit (EXIT_FAILURE ); +} +static void cmd_list_attributes (int argc,char *argv[]) {GDBusProxy *proxy;@@ -3247,6 +3272,8 @@ static const struct bt_shell_menu main_menu = { dev_generator }, {"wake" ,"[dev] [on/off]" , cmd_wake,"Get/Set wake support" , dev_generator }, + { "bearer", "<dev> [last-seen/bredr/le]", cmd_bearer, + "Get/Set preferred bearer", dev_generator }, { } }, }; --Quoted 1 line
2.48.1
So I went ahead and implemented the idea of having PreferredBearer, this works great when setting bredr it really stops from connecting to LE, the said the other way around when setting to le seems to confuse some headsets like EarFun and it ends up connecting both bearers:
[EarFun Air Pro 3]> transport.show
Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd1UUID: Sink PAC (00002bc9-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 16 Khz (0x03) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000001 Configuration.Location: Front Left (0x00000001) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 30 (0x001e) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0 QoS.CIG: 0x00 (0) QoS.CIS: 0x00 (0) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x0008 (8) QoS.SDU: 0x001e (30) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x02 (2) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd3 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd2 UUID: Sink PAC (00002bc9-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 16 Khz (0x03) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000002 Configuration.Location: Front Right (0x00000002) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 30 (0x001e) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0 QoS.CIG: 0x00 (0) QoS.CIS: 0x01 (1) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x0008 (8) QoS.SDU: 0x001e (30) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x02 (2) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd4 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd3 UUID: Source PAC (00002bcb-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 48 Khz (0x08) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000001 Configuration.Location: Front Left (0x00000001) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 90 (0x005a) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0 QoS.CIG: 0x00 (0) QoS.CIS: 0x00 (0) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x000f (15) QoS.SDU: 0x005a (90) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x05 (5) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd1 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd4 UUID: Source PAC (00002bcb-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 48 Khz (0x08) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000002 Configuration.Location: Front Right (0x00000002) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 90 (0x005a) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0 QoS.CIG: 0x00 (0) QoS.CIS: 0x01 (1) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x000f (15) QoS.SDU: 0x005a (90) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x05 (5) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd2 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/fd5 UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb) Codec: 0x02 (2) Media Codec: MPEG24 Object Types: MPEG-4 AAC LCQuoted 8 lines
Frequencies: 48kHz Channels: 2 Bitrate: 320000 VBR: Yes Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Delay: 0x0960 (2400) Volume: 0x0064 (100)
Quoted 4 lines
Forgot to mention, but with the above transports it seems to confuse the gnome audio output selection, it doesn't seem to be able to mix A2DP and BAP transports for some reason, so when I select the device it enables BAP but A2DP is not shown as an option.
I'll have to see if I can reproduce that on current PW master branch.
The visibility of profiles in theory should only cares about whether the UUIDs appear in both device properties and transport.
Signature · 1 line
Pauli Virtanen
Luiz Augusto von Dentz
maintainerRe: [PATCH BlueZ v2 3/3] client: Add support get/set PreferredBearer
Hi Pauli,
Quoted 243 lines · Pauli Virtanen
ti, 2025-02-25 kello 17:12 -0500, Luiz Augusto von Dentz kirjoitti:
Quoted 236 lines
Hi Pauli,
Quoted 223 lines · Luiz Augusto von Dentz
Hi Pauli, Bastien,
Quoted 89 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This adds support for PreferredBearer which is printed with the likes of info command:
bluetoothctl> info <addr>
...
PreferredBearer: last-seenIt also introduces a new command to get/set the PreferredBearer:
[bluetoothctl]> bearer --help
Get/Set preferred bearer
Usage:
bearer <dev> [last-seen/bredr/le][bluetoothctl]> bearer <addr>
PreferredBearer: last-seen
[bluetoothctl]> bearer <addr> le
bluetoothd: @ MGMT Command: Add Device (0x0033) plen 8
LE Address: <addr>
Action: Auto-connect remote device (0x02)
[CHG] Device <addr> PreferredBearer: le
Changing le succeeded
[bluetoothctl]> bearer <addr>
PreferredBearer: le
[bluetoothctl]> bearer <addr> bredr
bluetoothd: @ MGMT Command: Remove Device (0x0034) plen 7
LE Address: <addr>
[CHG] Device <addr> PreferredBearer: bredr Changing bredr succeeded--- client/main.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)client/main.c +27
-1@@ -1714,6 +1714,7 @@ static void cmd_info(int argc, char *argv[])print_property (proxy,"AdvertisingFlags" );print_property (proxy,"AdvertisingData" );print_property (proxy,"Sets" ); +print_property (proxy,"PreferredBearer" ); battery_proxy =find_proxies_by_path (battery_proxies,g_dbus_proxy_get_path (proxy));@@ -2086,6 +2087,30 @@ static void cmd_wake(int argc, char *argv[])return bt_shell_noninteractive_quit (EXIT_FAILURE ); } +static void cmd_bearer (int argc,char *argv[]) +{ +GDBusProxy *proxy; +char *str; + + proxy =find_device (argc, argv); +if (!proxy) +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + +if (argc <=2 ) { +print_property (proxy,"PreferredBearer" ); +return ; + } + + str =strdup (argv[2 ]); + +if (g_dbus_proxy_set_property_basic (proxy,"PreferredBearer" , +DBUS_TYPE_STRING , &str, + generic_callback, str, free)) +return ; + +return bt_shell_noninteractive_quit (EXIT_FAILURE ); +} +static void cmd_list_attributes (int argc,char *argv[]) {GDBusProxy *proxy;@@ -3247,6 +3272,8 @@ static const struct bt_shell_menu main_menu = { dev_generator }, {"wake" ,"[dev] [on/off]" , cmd_wake,"Get/Set wake support" , dev_generator }, + { "bearer", "<dev> [last-seen/bredr/le]", cmd_bearer, + "Get/Set preferred bearer", dev_generator }, { } }, }; --Quoted 1 line
2.48.1
So I went ahead and implemented the idea of having PreferredBearer, this works great when setting bredr it really stops from connecting to LE, the said the other way around when setting to le seems to confuse some headsets like EarFun and it ends up connecting both bearers:
[EarFun Air Pro 3]> transport.show
Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd1UUID: Sink PAC (00002bc9-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 16 Khz (0x03) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000001 Configuration.Location: Front Left (0x00000001) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 30 (0x001e) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0 QoS.CIG: 0x00 (0) QoS.CIS: 0x00 (0) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x0008 (8) QoS.SDU: 0x001e (30) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x02 (2) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd3 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd2 UUID: Sink PAC (00002bc9-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 16 Khz (0x03) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000002 Configuration.Location: Front Right (0x00000002) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 30 (0x001e) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0 QoS.CIG: 0x00 (0) QoS.CIS: 0x01 (1) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x0008 (8) QoS.SDU: 0x001e (30) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x02 (2) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd4 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd3 UUID: Source PAC (00002bcb-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 48 Khz (0x08) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000001 Configuration.Location: Front Left (0x00000001) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 90 (0x005a) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0 QoS.CIG: 0x00 (0) QoS.CIS: 0x00 (0) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x000f (15) QoS.SDU: 0x005a (90) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x05 (5) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd1 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd4 UUID: Source PAC (00002bcb-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 48 Khz (0x08) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000002 Configuration.Location: Front Right (0x00000002) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 90 (0x005a) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0 QoS.CIG: 0x00 (0) QoS.CIS: 0x01 (1) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x000f (15) QoS.SDU: 0x005a (90) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x05 (5) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd2 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/fd5 UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb) Codec: 0x02 (2) Media Codec: MPEG24 Object Types: MPEG-4 AAC LCQuoted 8 lines
Frequencies: 48kHz Channels: 2 Bitrate: 320000 VBR: Yes Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Delay: 0x0960 (2400) Volume: 0x0064 (100)Quoted 4 lines
Forgot to mention, but with the above transports it seems to confuse the gnome audio output selection, it doesn't seem to be able to mix A2DP and BAP transports for some reason, so when I select the device it enables BAP but A2DP is not shown as an option.
Quoted 4 lines
I'll have to see if I can reproduce that on current PW master branch.
The visibility of profiles in theory should only cares about whether the UUIDs appear in both device properties and transport.
I think I will merge these changes since the property is marked as experimental; we can always change it or revert later.
Signature · 1 line
Luiz Augusto von Dentz
Re: [PATCH BlueZ v2 3/3] client: Add support get/set PreferredBearer
Hi,
to, 2025-03-06 kello 11:41 -0500, Luiz Augusto von Dentz kirjoitti:
Quoted 244 lines · Pauli Virtanen
Quoted 243 lines
ti, 2025-02-25 kello 17:12 -0500, Luiz Augusto von Dentz kirjoitti:
Quoted 240 lines
Hi Pauli,
Quoted 223 lines · Luiz Augusto von Dentz
Hi Pauli, Bastien,
Quoted 89 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This adds support for PreferredBearer which is printed with the likes of info command:
bluetoothctl> info <addr>
...
PreferredBearer: last-seenIt also introduces a new command to get/set the PreferredBearer:
[bluetoothctl]> bearer --help
Get/Set preferred bearer
Usage:
bearer <dev> [last-seen/bredr/le][bluetoothctl]> bearer <addr>
PreferredBearer: last-seen
[bluetoothctl]> bearer <addr> le
bluetoothd: @ MGMT Command: Add Device (0x0033) plen 8
LE Address: <addr>
Action: Auto-connect remote device (0x02)
[CHG] Device <addr> PreferredBearer: le
Changing le succeeded
[bluetoothctl]> bearer <addr>
PreferredBearer: le
[bluetoothctl]> bearer <addr> bredr
bluetoothd: @ MGMT Command: Remove Device (0x0034) plen 7
LE Address: <addr>
[CHG] Device <addr> PreferredBearer: bredr Changing bredr succeeded--- client/main.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)client/main.c +27
-1@@ -1714,6 +1714,7 @@ static void cmd_info(int argc, char *argv[])print_property (proxy,"AdvertisingFlags" );print_property (proxy,"AdvertisingData" );print_property (proxy,"Sets" ); +print_property (proxy,"PreferredBearer" ); battery_proxy =find_proxies_by_path (battery_proxies,g_dbus_proxy_get_path (proxy));@@ -2086,6 +2087,30 @@ static void cmd_wake(int argc, char *argv[])return bt_shell_noninteractive_quit (EXIT_FAILURE ); } +static void cmd_bearer (int argc,char *argv[]) +{ +GDBusProxy *proxy; +char *str; + + proxy =find_device (argc, argv); +if (!proxy) +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + +if (argc <=2 ) { +print_property (proxy,"PreferredBearer" ); +return ; + } + + str =strdup (argv[2 ]); + +if (g_dbus_proxy_set_property_basic (proxy,"PreferredBearer" , +DBUS_TYPE_STRING , &str, + generic_callback, str, free)) +return ; + +return bt_shell_noninteractive_quit (EXIT_FAILURE ); +} +static void cmd_list_attributes (int argc,char *argv[]) {GDBusProxy *proxy;@@ -3247,6 +3272,8 @@ static const struct bt_shell_menu main_menu = { dev_generator }, {"wake" ,"[dev] [on/off]" , cmd_wake,"Get/Set wake support" , dev_generator }, + { "bearer", "<dev> [last-seen/bredr/le]", cmd_bearer, + "Get/Set preferred bearer", dev_generator }, { } }, }; --Quoted 1 line
2.48.1
So I went ahead and implemented the idea of having PreferredBearer, this works great when setting bredr it really stops from connecting to LE, the said the other way around when setting to le seems to confuse some headsets like EarFun and it ends up connecting both bearers:
[EarFun Air Pro 3]> transport.show
Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd1UUID: Sink PAC (00002bc9-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 16 Khz (0x03) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000001 Configuration.Location: Front Left (0x00000001) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 30 (0x001e) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0 QoS.CIG: 0x00 (0) QoS.CIS: 0x00 (0) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x0008 (8) QoS.SDU: 0x001e (30) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x02 (2) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd3 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd2 UUID: Sink PAC (00002bc9-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 16 Khz (0x03) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000002 Configuration.Location: Front Right (0x00000002) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 30 (0x001e) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0 QoS.CIG: 0x00 (0) QoS.CIS: 0x01 (1) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x0008 (8) QoS.SDU: 0x001e (30) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x02 (2) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd4 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd3 UUID: Source PAC (00002bcb-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 48 Khz (0x08) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000001 Configuration.Location: Front Left (0x00000001) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 90 (0x005a) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0 QoS.CIG: 0x00 (0) QoS.CIS: 0x00 (0) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x000f (15) QoS.SDU: 0x005a (90) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x05 (5) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd1 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0/fd4 UUID: Source PAC (00002bcb-0000-1000-8000-00805f9b34fb) Codec: 0x06 (6) Configuration.#0: len 0x02 type 0x01 Configuration.Sampling Frequency: 48 Khz (0x08) Configuration.#1: len 0x02 type 0x02 Configuration.Frame Duration: 7.5 ms (0x00) Configuration.#2: len 0x05 type 0x03 Configuration.Location: 0x00000002 Configuration.Location: Front Right (0x00000002) Configuration.#3: len 0x03 type 0x04 Configuration.Frame Length: 90 (0x005a) Configuration.#4: len 0x02 type 0x05 Configuration.Frame Blocks per SDU: 1 (0x01) Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Volume: 0x00c8 (200) Endpoint: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_sink0 QoS.CIG: 0x00 (0) QoS.CIS: 0x01 (1) QoS.Framing: 0x00 (0) QoS.PresentationDelay: 0x00009c40 (40000) QoS.Interval: 0x00001d4c (7500) QoS.Latency: 0x000f (15) QoS.SDU: 0x005a (90) QoS.PHY: 0x02 (2) QoS.Retransmissions: 0x05 (5) Location: 0x00000003 (3) Links: /org/bluez/hci0/dev_70_5A_6F_63_B6_41/pac_source0/fd2 Transport /org/bluez/hci0/dev_70_5A_6F_63_B6_41/fd5 UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb) Codec: 0x02 (2) Media Codec: MPEG24 Object Types: MPEG-4 AAC LCQuoted 8 lines
Frequencies: 48kHz Channels: 2 Bitrate: 320000 VBR: Yes Device: /org/bluez/hci0/dev_70_5A_6F_63_B6_41 State: idle Delay: 0x0960 (2400) Volume: 0x0064 (100)Forgot to mention, but with the above transports it seems to confuse the gnome audio output selection, it doesn't seem to be able to mix A2DP and BAP transports for some reason, so when I select the device it enables BAP but A2DP is not shown as an option.
Quoted 7 lines
Quoted 4 lines
I'll have to see if I can reproduce that on current PW master branch.
The visibility of profiles in theory should only cares about whether the UUIDs appear in both device properties and transport.
I think I will merge these changes since the property is marked as experimental; we can always change it or revert later.
Since the default value retains previous behavior, I think that's a good idea as it makes it easier to iterate on this.
Signature · 1 line
Pauli Virtanen
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=937740
---Test result---
Test Summary:
CheckPatch PENDING 0.38 seconds GitLint PENDING 0.31 seconds BuildEll PASS 20.45 seconds BluezMake FAIL 86.37 seconds MakeCheck FAIL 1944.05 seconds MakeDistcheck PASS 159.44 seconds CheckValgrind FAIL 62.84 seconds CheckSmatch FAIL 152.00 seconds bluezmakeextell FAIL 69.03 seconds IncrementalBuild PENDING 0.35 seconds ScanBuild PASS 872.45 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: BluezMake - FAIL
Desc: Build BlueZ
Output:
tools/mgmt-tester.c: In function ‘main’:tools/mgmt-tester.c:12893:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without 12893 | int main(int argc, char *argv[])
| ^~~~
src/device.c: In function ‘dev_property_prefer_bearer_exists’:
src/device.c:3420:68: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
3420 | if ((device->bredr_state.connected || device->bredr_state.bonded) &&
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
3421 | device->le_state.connected || device->le_state.bonded)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors
make[1]: *** [Makefile:11137: src/bluetoothd-device.o] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4682: all] Error 2
##############################
Test: MakeCheck - FAIL
Desc: Run Bluez Make Check
Output:
unit/test-avdtp.c: In function ‘main’:unit/test-avdtp.c:766:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
766 | int main(int argc, char *argv[])
| ^~~~
unit/test-avrcp.c: In function ‘main’:
unit/test-avrcp.c:989:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
989 | int main(int argc, char *argv[])
| ^~~~
src/device.c: In function ‘dev_property_prefer_bearer_exists’:
src/device.c:3420:68: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
3420 | if ((device->bredr_state.connected || device->bredr_state.bonded) &&
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
3421 | device->le_state.connected || device->le_state.bonded)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors
make[1]: *** [Makefile:11137: src/bluetoothd-device.o] Error 1
make: *** [Makefile:12320: check] Error 2
##############################
Test: CheckValgrind - FAIL
Desc: Run Bluez Make Check with Valgrind
Output:
tools/mgmt-tester.c: In function ‘main’:tools/mgmt-tester.c:12893:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without 12893 | int main(int argc, char *argv[])
| ^~~~
src/device.c: In function ‘dev_property_prefer_bearer_exists’:
src/device.c:3420:68: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
3420 | if ((device->bredr_state.connected || device->bredr_state.bonded) &&
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
3421 | device->le_state.connected || device->le_state.bonded)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors
make[1]: *** [Makefile:11137: src/bluetoothd-device.o] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:12320: check] Error 2
##############################
Test: CheckSmatch - FAIL
Desc: Run smatch tool with source
Output:
src/shared/crypto.c:271:21: warning: Variable length array is used. src/shared/crypto.c:272:23: warning: Variable length array is used. src/shared/gatt-helpers.c:768:31: warning: Variable length array is used. src/shared/gatt-helpers.c:830:31: warning: Variable length array is used. src/shared/gatt-helpers.c:1323:31: warning: Variable length array is used. src/shared/gatt-helpers.c:1354:23: warning: Variable length array is used. src/shared/gatt-server.c:278:25: warning: Variable length array is used. src/shared/gatt-server.c:618:25: warning: Variable length array is used. src/shared/gatt-server.c:716:25: warning: Variable length array is used. src/shared/bap.c:296:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):/usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function declaration of function 'Function' /usr/include/readline/rltypedefs.h:36:25: warning: non-ANSI function declaration of function 'VFunction' /usr/include/readline/rltypedefs.h:37:27: warning: non-ANSI function declaration of function 'CPFunction' /usr/include/readline/rltypedefs.h:38:29: warning: non-ANSI function declaration of function 'CPPFunction' src/shared/crypto.c:271:21: warning: Variable length array is used. src/shared/crypto.c:272:23: warning: Variable length array is used. src/shared/gatt-helpers.c:768:31: warning: Variable length array is used. src/shared/gatt-helpers.c:830:31: warning: Variable length array is used. src/shared/gatt-helpers.c:1323:31: warning: Variable length array is used. src/shared/gatt-helpers.c:1354:23: warning: Variable length array is used. src/shared/gatt-server.c:278:25: warning: Variable length array is used. src/shared/gatt-server.c:618:25: warning: Variable length array is used. src/shared/gatt-server.c:716:25: warning: Variable length array is used. src/shared/bap.c:296:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):/usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function declaration of function 'Function' /usr/include/readline/rltypedefs.h:36:25: warning: non-ANSI function declaration of function 'VFunction' /usr/include/readline/rltypedefs.h:37:27: warning: non-ANSI function declaration of function 'CPFunction' /usr/include/readline/rltypedefs.h:38:29: warning: non-ANSI function declaration of function 'CPPFunction' tools/mesh-cfgtest.c:1453:17: warning: unknown escape sequence: '\%'tools/sco-tester.c: note: in included file:./lib/bluetooth.h:232:15: warning: array of flexible structures./lib/bluetooth.h:237:31: warning: array of flexible structurestools/bneptest.c:634:39: warning: unknown escape sequence: '\%'tools/seq2bseq.c:57:26: warning: Variable length array is used.tools/obex-client-tool.c: note: in included file (through /usr/include/readline/readline.h):/usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function declaration of function 'Function' /usr/include/readline/rltypedefs.h:36:25: warning: non-ANSI function declaration of function 'VFunction' /usr/include/readline/rltypedefs.h:37:27: warning: non-ANSI function declaration of function 'CPFunction' /usr/include/readline/rltypedefs.h:38:29: warning: non-ANSI function declaration of function 'CPPFunction' android/avctp.c:505:34: warning: Variable length array is used.android/avctp.c:556:34: warning: Variable length array is used.unit/test-avrcp.c:373:26: warning: Variable length array is used. unit/test-avrcp.c:398:26: warning: Variable length array is used. unit/test-avrcp.c:414:24: warning: Variable length array is used. android/avrcp-lib.c:1085:34: warning: Variable length array is used. android/avrcp-lib.c:1583:34: warning: Variable length array is used. android/avrcp-lib.c:1612:34: warning: Variable length array is used. android/avrcp-lib.c:1638:34: warning: Variable length array is used.src/device.c: In function ‘dev_property_prefer_bearer_exists’:src/device.c:3420:68: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
3420 | if ((device->bredr_state.connected || device->bredr_state.bonded) &&
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
3421 | device->le_state.connected || device->le_state.bonded)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors
make[1]: *** [Makefile:11137: src/bluetoothd-device.o] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4682: all] Error 2
##############################
Test: bluezmakeextell - FAIL
Desc: Build Bluez with External ELL
Output:
src/device.c: In function ‘dev_property_prefer_bearer_exists’:src/device.c:3420:68: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
3420 | if ((device->bredr_state.connected || device->bredr_state.bonded) &&
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
3421 | device->le_state.connected || device->le_state.bonded)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors
make[1]: *** [Makefile:11137: src/bluetoothd-device.o] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4682: all] Error 2
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth