Add Connectable property to org.bluez.Device
v2 cover Add Connectable property to org.bluez.Device
bluetoothd records whether each advertising report was connectable, from the Device Found event's Not Connectable flag, and uses it internally, for example to pick the bearer to connect and to drop temporary non-connectable devices when discovery stops. Applications cannot read it over D-Bus, so they have to guess, e.g. from whether the device has a name, which is wrong for named beacons and for unnamed peripherals.
This series exposes it as a read-only Connectable property on org.bluez.Device1 and on the org.bluez.Bearer.LE1 and org.bluez.Bearer.BREDR1 interfaces, emitted when it first becomes known and whenever it changes. bluetoothctl prints it in info, and prints devices that are discoverable but not connectable in red.
Tested with an nRF52840 switching between ADV_IND, ADV_SCAN_IND and ADV_NONCONN_IND advertising: Device1 and Bearer.LE1 follow each change, including PropertiesChanged in both directions on a device kept by continuous discovery, and the non-connectable profiles, which keep the discoverable flags, are printed in red.
Changes in v2:
- Add Connectable to org.bluez.Bearer.LE1 and org.bluez.Bearer.BREDR1, so the LE value is visible for dual-mode devices (Luiz)
- Print discoverable broadcasters in red in bluetoothctl (Luiz)
- Print LE.Connectable and BREDR.Connectable in info
- Document the property type as boolean, like most of org.bluez.Device
- Rebase on master
Kevin Dewald (6):
org.bluez.Device: Add Connectable property
org.bluez.Bearer: Add Connectable property
device: Add Connectable property
bearer: Add Connectable property
client: Print Connectable in info
client: Print discoverable broadcasters in red
client/main.c | 32 ++++++++++++++++++++ doc/org.bluez.Bearer.BREDR.rst | 6 ++++ doc/org.bluez.Bearer.LE.rst | 12 ++++++++ doc/org.bluez.Device.rst | 11 +++++++ src/bearer.c | 38 ++++++++++++++++++++++++ src/bearer.h | 1 + src/device.c | 54 ++++++++++++++++++++++++++++++++++ src/device.h | 2 ++ 8 files changed, 156 insertions(+)
Signature · 1 line
2.54.0 (Apple Git-157)
PATCH v2 1/6 org.bluez.Device: Add Connectable property
This adds Connectable property which indicates whether the remote device accepts connections, as reported by its last advertising report or inquiry result.
bluetoothd already tracks this per bearer from the Device Found event, but it is not exposed over D-Bus, so applications cannot tell connectable advertisers such as peripherals from non-connectable ones such as beacons without attempting a connection.
--- doc/org.bluez.Device.rst | 11 +++++++++++ 1 file changed, 11 insertions(+)
doc/org.bluez.Device.rst +11 -0
@@ -395,6 +395,17 @@ int16 TxPower [readonly, optional] Advertised transmitted power level (inquiry or advertising). +boolean Connectable [readonly, optional] +```````````````````````````````````````` + +Indicates whether the remote device accepts connections, based on the most +recent advertising report or inquiry result. For LE this is false when the +last advertising report was non-connectable, e.g. ADV_NONCONN_IND or +ADV_SCAN_IND. + +BR/EDR devices are always considered connectable. LE devices only have this +property once they have been discovered or connected. + dict ManufacturerData [readonly, optional] ``````````````````````````````````````````
Signature · 1 line
2.54.0 (Apple Git-157)
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/series/1178077/
---Test result---
Test Summary:
CheckPatch PASS 2.34 seconds GitLint PASS 1.58 seconds BuildEll PASS 17.22 seconds BluezMake PASS 305.01 seconds MakeCheck PASS 13.85 seconds MakeDistcheck PASS 129.73 seconds CheckValgrind PASS 213.03 seconds CheckSmatch PASS 223.50 seconds bluezmakeextell PASS 84.08 seconds TestFunctional PASS 976.56 seconds IncrementalBuild PASS 397.38 seconds ScanBuild PASS 886.61 seconds
https://github.com/bluez/bluez/pull/2622
---
Regards,
Linux Bluetooth
PATCH v2 2/6 org.bluez.Bearer: Add Connectable property
In reply to Kevin DewaldThis adds Connectable property to org.bluez.Bearer.LE1 and org.bluez.Bearer.BREDR1, so it is possible to tell which bearer of a dual-mode device accepts connections, since Device1.Connectable is always true for them as BREDR is always considered connectable.
--- doc/org.bluez.Bearer.BREDR.rst | 6 ++++++ doc/org.bluez.Bearer.LE.rst | 12 ++++++++++++ 2 files changed, 18 insertions(+)
doc/org.bluez.Bearer.BREDR.rst +6 -0
@@ -141,3 +141,9 @@ boolean Connected [readonly, experimental] Indicates if the remote device is currently connected to BREDR bearer. A PropertiesChanged signal indicate changes to this status. + +boolean Connectable [readonly, experimental] +```````````````````````````````````````````` + +Indicates if the remote device accepts connections on BREDR bearer. BREDR +devices are always considered connectable.
doc/org.bluez.Bearer.LE.rst +12 -0
@@ -141,3 +141,15 @@ boolean Connected [readonly, experimental] Indicates if the remote device is currently connected to LE bearer. A PropertiesChanged signal indicate changes to this status. + +boolean Connectable [readonly, optional, experimental] +`````````````````````````````````````````````````````` + +Indicates if the remote device accepts connections on LE bearer, based on the +most recent advertising report. It is false when the last advertising report +was non-connectable, e.g. ADV_NONCONN_IND or ADV_SCAN_IND. + +The property is only present once the device has been discovered or connected +over LE bearer. + +A PropertiesChanged signal indicate changes to this status.
Signature · 1 line
2.54.0 (Apple Git-157)
PATCH v2 3/6 device: Add Connectable property
In reply to Kevin DewaldThis implements Connectable property using device_is_connectable, which reports whether the last advertising report on the device's bearer was connectable, and emits PropertiesChanged from device_update_last_seen when the value changes or first becomes known.
--- src/device.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
src/device.c +36 -0
@@ -327,6 +327,14 @@ static struct bearer_state *get_state(struct btd_device *dev,return &dev->le_state; } +static bool device_connectable_known (struct btd_device *dev) +{ +if (dev->bredr) +return true; + +return get_state (dev, dev->bdaddr_type)->last_seen !=0 ; +} +bool btd_device_is_initiator (struct btd_device *dev) {if (dev->le_state.connected)
@@ -1281,6 +1289,25 @@ static gboolean dev_property_exists_tx_power(const GDBusPropertyTable *property,return TRUE; } +static gboolean +dev_property_get_connectable (const GDBusPropertyTable *property, +DBusMessageIter *iter,void *data) +{ +struct btd_device *dev = data; +dbus_bool_t val =device_is_connectable (dev); + +dbus_message_iter_append_basic (iter,DBUS_TYPE_BOOLEAN , &val); + +return TRUE; +} + +static gboolean +dev_property_exists_connectable (const GDBusPropertyTable *property, +void *data) +{ +return device_connectable_known (data); +} +static gboolean dev_property_get_svc_resolved (const GDBusPropertyTable *property,DBusMessageIter *iter,void *data)
@@ -3756,6 +3783,8 @@ static const GDBusPropertyTable device_properties[] = { NULL, dev_property_service_data_exist }, {"TxPower" ,"n" , dev_property_get_tx_power,NULL , dev_property_exists_tx_power }, + { "Connectable", "b", dev_property_get_connectable, NULL, + dev_property_exists_connectable }, { "ServicesResolved", "b", dev_property_get_svc_resolved, NULL, NULL }, { "AdvertisingFlags", "ay", dev_property_get_flags, NULL, dev_property_flags_exist },
@@ -5341,12 +5370,19 @@ void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type, bool connectable) {struct bearer_state *state; +bool known =device_connectable_known (device); +bool was_connectable =device_is_connectable (device); state =get_state (device, bdaddr_type); state->last_seen =time (NULL ); state->connectable = connectable; +if (known !=device_connectable_known (device) || + was_connectable !=device_is_connectable (device)) +g_dbus_emit_property_changed (dbus_conn, device->path, +DEVICE_INTERFACE ,"Connectable" ); +if (!device_is_temporary (device))return ;
Signature · 1 line
2.54.0 (Apple Git-157)
PATCH v2 4/6 bearer: Add Connectable property
In reply to Kevin DewaldThis implements Connectable property for both bearers. For LE it reflects whether the last advertising report was connectable, and PropertiesChanged is emitted from device_update_last_seen when it changes or first becomes known. BREDR always reports it as true.
--- src/bearer.c | 38 ++++++++++++++++++++++++++++++++++++++ src/bearer.h | 1 + src/device.c | 18 ++++++++++++++++++ src/device.h | 2 ++ 4 files changed, 59 insertions(+)
src/bearer.c +38 -0
@@ -249,6 +249,31 @@ static gboolean bearer_get_connected(const GDBusPropertyTable *property,return TRUE; } +static gboolean bearer_get_connectable (const GDBusPropertyTable *property, +DBusMessageIter *iter,void *data) +{ +struct btd_bearer *bearer = data; +dbus_bool_t connectable; + + connectable =btd_device_bdaddr_type_connectable (bearer->device, + bearer->type); + +dbus_message_iter_append_basic (iter,DBUS_TYPE_BOOLEAN , &connectable); + +return TRUE; +} + +static gboolean bearer_connectable_exists (const GDBusPropertyTable *property, +void *data) +{ +struct btd_bearer *bearer = data; + +if (bearer->type ==BDADDR_BREDR ) +return TRUE; + +return btd_device_bdaddr_type_seen (bearer->device, bearer->type); +} +static const GDBusSignalTable bearer_signals[] = { {GDBUS_SIGNAL ("Disconnected" , GDBUS_ARGS({ "name", "s" }, { "message", "s" })) },
@@ -264,6 +289,9 @@ static const GDBusPropertyTable bearer_properties[] = { G_DBUS_PROPERTY_FLAG_EXPERIMENTAL }, {"Connected" ,"b" , bearer_get_connected,NULL ,NULL , G_DBUS_PROPERTY_FLAG_EXPERIMENTAL }, + { "Connectable", "b", bearer_get_connectable, NULL, + bearer_connectable_exists, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL }, {} };
@@ -354,6 +382,16 @@ void btd_bearer_bonded(struct btd_bearer *bearer) "Bonded"); } +void btd_bearer_connectable (struct btd_bearer *bearer) +{ +if (!bearer || !bearer->path) +return ; + +g_dbus_emit_property_changed (btd_get_dbus_connection (), bearer->path, +bearer_interface (bearer->type), +"Connectable" ); +} +void btd_bearer_connected (struct btd_bearer *bearer,int err) {DBusMessage *reply;
src/bearer.h +1 -0
@@ -18,5 +18,6 @@ void btd_bearer_destroy(struct btd_bearer *bearer);void btd_bearer_paired (struct btd_bearer *bearer);void btd_bearer_bonded (struct btd_bearer *bearer); +void btd_bearer_connectable (struct btd_bearer *bearer);void btd_bearer_connected (struct btd_bearer *bearer,int err);void btd_bearer_disconnected (struct btd_bearer *bearer,uint8_t reason);
src/device.c +18 -0
@@ -3829,6 +3829,19 @@ bool btd_device_bdaddr_type_connected(struct btd_device *dev, uint8_t type)return dev->le_state.connected; } +bool btd_device_bdaddr_type_connectable (struct btd_device *dev,uint8_t type) +{ +if (type ==BDADDR_BREDR ) +return true; + +return dev->le_state.connectable; +} + +bool btd_device_bdaddr_type_seen (struct btd_device *dev,uint8_t type) +{ +return get_state (dev, type)->last_seen !=0 ; +} +static void clear_temporary_timer (struct btd_device *dev) {if (dev->temporary_timer) {
@@ -5372,8 +5385,10 @@ void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type,struct bearer_state *state;bool known =device_connectable_known (device);bool was_connectable =device_is_connectable (device); +bool changed; state =get_state (device, bdaddr_type); + changed = !state->last_seen || state->connectable != connectable; state->last_seen =time (NULL ); state->connectable = connectable;
@@ -5383,6 +5398,9 @@ void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type,g_dbus_emit_property_changed (dbus_conn, device->path,DEVICE_INTERFACE ,"Connectable" ); +if (changed && bdaddr_type !=BDADDR_BREDR ) +btd_bearer_connectable (device->le); +if (!device_is_temporary (device))return ;
src/device.h +2 -0
@@ -127,6 +127,8 @@ void device_set_flags(struct btd_device *device, uint8_t flags);bool btd_device_is_connected (struct btd_device *dev);bool btd_device_bearer_is_connected (struct btd_device *dev);bool btd_device_bdaddr_type_connected (struct btd_device *dev,uint8_t type); +bool btd_device_bdaddr_type_connectable (struct btd_device *dev,uint8_t type); +bool btd_device_bdaddr_type_seen (struct btd_device *dev,uint8_t type);uint8_t btd_device_get_bdaddr_type (struct btd_device *dev);bool device_is_retrying (struct btd_device *device); void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type,
Signature · 1 line
2.54.0 (Apple Git-157)
PATCH v2 5/6 client: Print Connectable in info
In reply to Kevin DewaldThis prints the Connectable property of the device and its bearers with the likes of info command:
bluetoothctl> info <addr>
...
Connectable: yes
...
LE.Connectable: yes
--- client/main.c | 5 +++++ 1 file changed, 5 insertions(+)
client/main.c +5 -0
@@ -2026,6 +2026,7 @@ static void cmd_info(int argc, char *argv[])print_property (proxy,"ServiceData" );print_property (proxy,"RSSI" );print_property (proxy,"TxPower" ); +print_property (proxy,"Connectable" );print_property (proxy,"AdvertisingFlags" );print_property (proxy,"AdvertisingData" );print_property (proxy,"Sets" );
@@ -2054,6 +2055,8 @@ static void cmd_info(int argc, char *argv[])print_property_with_label (bearer,"Bonded" ,"BREDR.Bonded" );print_property_with_label (bearer,"Connected" ,"BREDR.Connected" ); +print_property_with_label (bearer,"Connectable" , +"BREDR.Connectable" ); } bearer = find_proxies_by_iface(default_ctrl->bearers,
@@ -2063,6 +2066,8 @@ static void cmd_info(int argc, char *argv[])print_property_with_label (bearer,"Paired" ,"LE.Paired" );print_property_with_label (bearer,"Bonded" ,"LE.Bonded" );print_property_with_label (bearer,"Connected" ,"LE.Connected" ); +print_property_with_label (bearer,"Connectable" , +"LE.Connectable" ); }return bt_shell_noninteractive_quit (EXIT_SUCCESS );
Signature · 1 line
2.54.0 (Apple Git-157)
PATCH v2 6/6 client: Print discoverable broadcasters in red
In reply to Kevin DewaldThis prints devices in red when they set the discoverable flags but are not connectable, to warn the user they cannot be connected to despite being discoverable.
--- client/main.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
client/main.c +27 -0
@@ -183,6 +183,19 @@ static struct set_discovery_filter_args { .set = true, }; +static bool device_is_broadcaster (GDBusProxy *proxy) +{ +DBusMessageIter iter; +dbus_bool_t connectable; + +if (!g_dbus_proxy_get_property (proxy,"Connectable" , &iter)) +return false; + +dbus_message_iter_get_basic (&iter, &connectable); + +return !connectable; +} +static void print_device (GDBusProxy *proxy,const char *description) {DBusMessageIter iter;
@@ -227,6 +240,20 @@ static void print_device(GDBusProxy *proxy, const char *description)return ; } +/* Print discoverable broadcasters in red to warn the user they cannot +* be connected to despite being discoverable. +*/ +if (device_is_broadcaster (proxy)) { +bt_shell_printf ("%s%s%s" COLOR_RED "Device %s %s" +COLOR_OFF "\n" , + description ?"[" :"" , + description ? :"" , + description ?"] " :"" , + address, name); + +return ; + } + done: bt_shell_printf("%s%s%sDevice %s %s\n", description ? "[" : "",
Signature · 1 line
2.54.0 (Apple Git-157)
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 9 lines · On Thu, 1 Oct 2026 22:46:11 -0700 you wrote:
bluetoothd records whether each advertising report was connectable, from the Device Found event's Not Connectable flag, and uses it internally, for example to pick the bearer to connect and to drop temporary non-connectable devices when discovery stops. Applications cannot read it over D-Bus, so they have to guess, e.g. from whether the device has a name, which is wrong for named beacons and for unnamed peripherals.
[...]
Here is the summary with links:
- [BlueZ,v2,1/6] org.bluez.Device: Add Connectable property
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=75a778e17f49 - [BlueZ,v2,2/6] org.bluez.Bearer: Add Connectable property https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f890d4b660c6 - [BlueZ,v2,3/6] device: Add Connectable property https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=6afb6e729270 - [BlueZ,v2,4/6] bearer: Add Connectable property https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=ab50d5e88fb6 - [BlueZ,v2,5/6] client: Print Connectable in info https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=82f671c83429 - [BlueZ,v2,6/6] client: Print discoverable broadcasters in red https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=4dc15be8ee3f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html