【问题标题】:BlueZ5: Event when inbound pairing is completeBlueZ5:入站配对完成时的事件
【发布时间】:2019-10-04 19:04:34
【问题描述】:

我正在编写一个 C++ 应用程序,用于管理嵌入式设备的蓝牙连接。我在 Linux 下通过 D-Bus 与 BlueZ5 对话。

作为实现入站配对的第一步,我执行了以下操作:

  • 通过 AgentManager1 接口注册“NoInputNoOutput”代理
  • 通过 Adapter1 接口设置可配对开启和可配对超时以及可发现开启和可发现超时

现在我需要一个事件来告诉我新设备已配对,这样我就可以信任它并接受 SPP 连接。但我在规范中找不到这样的事件 (https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc)。

有这样的活动吗?似乎 bluetoothctl 发出类似

的消息

[新] 设备 44:55:66:11:22:33 Foo Bar

设备配对后...

谁能告诉我必须听哪个事件?

或者我必须投票吗?我认为 bluetoothctl 不会投票,因为它的反应非常快。

【问题讨论】:

    标签: c++ linux bluetooth dbus bluez


    【解决方案1】:

    来自here

    布尔连接[只读]

    指示远程设备当前是否已连接。 PropertiesChanged 信号指示此状态的更改。

    添加新设备时,InterfaceAdded 信号会在 interface=org.freedesktop.DBus.ObjectManager 上广播。请参阅使用 dbus-monitor 捕获的以下信号。检查属性 Connected。

    signal time=1558128293.155096 sender=:1.2 -> destination=(null destination) serial=65 path=/; interface=org.freedesktop.DBus.ObjectManager; member=InterfacesAdded
       object path "/org/bluez/hci0/dev_F0_D7_AA_AA_0C_41"
       array [
          dict entry(
             string "org.freedesktop.DBus.Introspectable"
             array [
             ]
          )
          dict entry(
             string "org.bluez.Device1"
             array [
                dict entry(
                   string "Address"
                   variant                   string "F0:D7:AA:AA:0C:41"
                )
                dict entry(
                   string "Name"
                   variant                   string "Moto"
                )
                dict entry(
                   string "Alias"
                   variant                   string "Moto"
                )
                dict entry(
                   string "Class"
                   variant                   uint32 5898764
                )
                dict entry(
                   string "Icon"
                   variant                   string "phone"
                )
                dict entry(
                   string "Paired"
                   variant                   boolean false
                )
                dict entry(
                   string "Trusted"
                   variant                   boolean false
                )
                dict entry(
                   string "Blocked"
                   variant                   boolean false
                )
                dict entry(
                   string "LegacyPairing"
                   variant                   boolean false
                )
                dict entry(
                   string "Connected"
                   variant                   boolean true
                )
                dict entry(
                   string "UUIDs"
                   variant                   array [
                      ]
                )
                dict entry(
                   string "Adapter"
                   variant                   object path "/org/bluez/hci0"
                )
             ]
          )
          dict entry(
             string "org.freedesktop.DBus.Properties"
             array [
             ]
          )
       ]
    

    如果设备已添加,则您会在 interface=org.freedesktop.DBus.Properties 上获得 PropertiesChanged 信号。请参阅下面的捕获,它是一个登录断开连接,但上面的捕获可以帮助您在设备连接时接收信号。

    signal time=1558128303.204016 sender=:1.2 -> destination=(null destination) serial=71 path=/org/bluez/hci0/dev_F0_D7_AA_AA_0C_41; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
       string "org.bluez.Device1"
       array [
          dict entry(
             string "Connected"
             variant             boolean false
          )
       ]
       array [
       ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-12
      • 1970-01-01
      • 2014-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-25
      • 2020-09-12
      相关资源
      最近更新 更多