Skip to content

Improve pair_two

When pair_two is run multiple times in a row, BlueZ may fail to correctly remove the previous pairing if a signal occurs between the RemoveDevice call and its reply:

‣ Type=method_call  Endian=l  Flags=0  Version=1 Cookie=4
  Sender=:1.569  Destination=org.bluez  Path=/org/bluez/hci0  Interface=org.bluez.Adapter1  Member=RemoveDevice
  UniqueName=:1.569
  MESSAGE "o" {
          OBJECT_PATH "/org/bluez/hci0/dev_5C_F3_70_02_35_F9";
  };

‣ Type=signal  Endian=l  Flags=1  Version=1 Cookie=4722
  Sender=:1.18  Path=/org/bluez/hci0/dev_5C_F3_70_02_35_F9  Interface=org.freedesktop.DBus.Properties  Member=PropertiesChanged
  UniqueName=:1.18
  MESSAGE "sa{sv}as" {
          STRING "org.bluez.Device1";
          ARRAY "{sv}" {
                  DICT_ENTRY "sv" {
                          STRING "ServicesResolved";
                          VARIANT "b" {
                                  BOOLEAN false;
                          };
                  };
          };
          ARRAY "s" {
          };
  };

‣ Type=method_return  Endian=l  Flags=1  Version=1 Cookie=4723  ReplyCookie=4
  Sender=:1.18  Destination=:1.569
  UniqueName=:1.18
  MESSAGE "" {
  };

instead of:

‣ Type=method_call  Endian=l  Flags=0  Version=1 Cookie=14
  Sender=:1.569  Destination=org.bluez  Path=/org/bluez/hci0  Interface=org.bluez.Adapter1  Member=RemoveDevice
  UniqueName=:1.569
  MESSAGE "o" {
          OBJECT_PATH "/org/bluez/hci0/dev_5C_F3_70_02_35_F9";
  };

‣ Type=signal  Endian=l  Flags=1  Version=1 Cookie=4740
  Sender=:1.18  Path=/  Interface=org.freedesktop.DBus.ObjectManager  Member=InterfacesRemoved
  UniqueName=:1.18
  MESSAGE "oas" {
          OBJECT_PATH "/org/bluez/hci0/dev_5C_F3_70_02_35_F9";
          ARRAY "s" {
                  STRING "org.freedesktop.DBus.Properties";
                  STRING "org.freedesktop.DBus.Introspectable";
                  STRING "org.bluez.Device1";
                  STRING "org.bluez.MediaControl1";
          };
  };

‣ Type=method_return  Endian=l  Flags=1  Version=1 Cookie=4741  ReplyCookie=14
  Sender=:1.18  Destination=:1.569
  UniqueName=:1.18
  MESSAGE "" {
  };

In this case pair_two never receives the InterfacesAdded for the slave_device.

Luckily, pair_two still receives PropertiesChanged signals for the slave_device and it can force removal of this device so there's a chance to get the InterfacesAdded signal and trigger the pairing.

Signed-off-by: Frédéric Danis frederic.danis@collabora.com

Merge request reports

Loading