Bluez5:入口配对完成时的事件

BlueZ5: Event when inbound pairing is complete

本文关键字:完成时 事件 入口 Bluez5      更新时间:2023-10-16

我正在编写一个C 的应用程序,该应用程序管理嵌入式设备的蓝牙连接。我通过Linux下的D-Bus与Bluez5交谈。

作为实施入站配对的第一步,我做了以下操作:

  • 通过AgentManager1接口注册" NoinputNoOutput"代理
  • 通过Adapter1接口在和可发现和可发现的超时及时设置对超时以及可发现的时间

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

有这样的事件吗?看来它是 bluetoothctl 发出的消息,例如

[新的]设备44:55:66:11:22:33 foo bar

一旦设备配对...

有人可以告诉我我必须听哪个事件吗?

还是我必须进行调查?我认为 bluetoothctl 民意调查的反应很快。

从这里

布尔连接[readonly]

指示远程设备当前是否已连接。 属性变的信号表示此状态的变化。

添加了新设备后,将互动信号在接口= org.freedesktop.dbus.objectManager上广播。请参阅下面使用DBU-Monitor捕获的信号。检查已连接的属性。

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 [
         ]
      )
   ]

如果已经添加了设备,则您在接口= org.freedesktop.dbus.properties上获得属性变的信号。请参阅下面的捕获,其登录与断开连接,但上面可以帮助您在连接设备时接收信号。

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 [
   ]