调用 RegisterProfile 时出现 org.freedesktop.DBus.Error.UnknownMethod 错误

Getting org.freedesktop.DBus.Error.UnknownMethod error on calling RegisterProfile

我正在尝试使用 bluetoothctl (bluez5.42) 注册配置文件。 我 运行 bluetoothctl 如下:

bluez-5.42/dev/client# ./bluetoothctl 
[NEW] Controller 00:50:43:22:29:D9 pe-lt571-0 [default]
[bluetooth]# register-profile 00000017-0000-1000-8000-00805f9
Failed to register profile: org.freedesktop.DBus.Error.UnknownMethod

补充一下,我使用的是 Linux 内核 4.4。 在我开始 bluetoothctl 之前,我有 运行 bluetoothd。 另外,我检查了使用 d-feet 做同样的事情,我得到了同样的错误。

为什么我会收到未知方法错误?是设置问题吗?

我在 dbus 监视器上得到以下信息

method call sender=:1.89 -> dest=org.bluez serial=20 path=/org/bluez/hci0; interface=org.bluez.GattManager1; member=RegisterProfile
   object path "/org/bluez/profile"
   array [
      string "00000100-0000-1000-8000-00805f9"
   ]
   array [
   ]

org.bluez.GattManager1 DBus 接口上没有名为 RegisterProfile 的方法。它是 bluez-5.42 的 bluetoothctl 代码中的一个错误,已在 bluez-5.46 中修复。 RegisterProfile 方法在 org.bluez.ProfileManager1 接口上。

从 bluez-5.46 开始,不存在带有 bluetoothctl 的注册配置文件。如果您想注册蓝牙配置文件,请查看 bluez 源目录中的 test/test-hfp python 脚本。它展示了如何在 org.bluez.ProfileManager1 上使用 RegisterProfile 方法。另请参阅 doc/profile-api.txt 以了解此界面上可用的方法。

或者,如果您想注册 GATT 服务,请参阅 test/test-gatt-profile python 脚本和 bluez 源中的 doc/gatt-api.txt。