1

According to the Bluez API documentation (Device API) the return of the Connect() method indicates a successful connection of one or more profiles:

void Connect()

(skipped)

If at least one profile was connected successfully this method will indicate success.

At the same time there is a Connected property, which is described as:

boolean Connected [readonly]

Indicates if the remote device is currently connected. A PropertiesChanged signal indicate changes to this status.

In practice it appears that the return of the Connect() method and the arrival of the PropertiesChanged signal notifying about Connected property being set to true happen few seconds apart.

When running bluetoothctl:

[bluetooth]# connect XX:XX:XX:XX:XX:XX
Attempting to connect to XX:XX:XX:XX:XX:XX
[CHG] Device XX:XX:XX:XX:XX:XX Connected: yes
Connection successful

Following messages were captured on the D-Bus:

method call time=1646854334.904791 sender=:1.521 -> destination=org.bluez serial=50 path=/org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX; interface=org.bluez.Device1; member=Connect
signal time=1646854336.902736 sender=:1.128 -> destination=(null destination) serial=10521 path=/org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.bluez.Device1"
   array [
      dict entry(
         string "Connected"
         variant             boolean true
      )
   ]
   array [
   ]

method return time=1646854339.349113 sender=:1.128 -> destination=:1.521 serial=10522 reply_serial=50

Which tells us that:

  • The [CHG] Device XX:XX:XX:XX:XX:XX Connected: yes appears on the screen when the Connected property changes to true as reported by the signal (time=1646854336.902736).
  • The Connection successful message appears when the Connect() method returns (time=1646854339.349113).
  • These events occur 2.4 seconds apart.

The question is what the difference between these two events and which one actually signifies that the Bluetooth device was connected?

(When disconnecting the device, the Disconnect() method return and the arrival of the signal occur 0.003 seconds apart).


Environment: Linux kernel: 5.4-179, Bluez: 5.62-r3, Systemd: 249.9.

1 Answer 1

0

The arrival of the Connected signal indicates the establishment of the low level link (ACL).

The return of the Connect() method indicates that at least one profile was connected successfully (higher level connection).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .