首页 > 解决方案 > 使用bluez通过蓝牙连接两个树莓派

问题描述

我正在尝试使用此 API:https ://www.linumiz.com/bluetooth-connectdevice-without-scanning/在两个 Raspberry PI 之间建立连接。我像服务器一样使用这个程序,例如:

pi@raspberrypi:~/bluetoothC $ sudo ./bin/bluez_adapter_connect

适配器电源“打开”

然后,在客户端:

pi@raspberrypi:~/bluetoothC $ sudo ./bin/bluez_adapter_connect B8:27:EB:9F:91:A7

适配器“打开”电源无法获得结果:GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod:接口“org.bluez.Adapter1”上带有签名“a{sv}”的方法“ConnectDevice”不存在

但我不明白这个错误。我这样做正确吗?如果没有,我该怎么办?

标签: bluetoothraspberry-pibluezrfcomm

解决方案


正如文章中提到的,ConnectDevice 是 BlueZ 5.49 中引入的新适配器 API。有关更多详细信息,请参阅此处的发行说明。

这个 API 仍然被标记为实验性的,所以你需要在实验模式下运行 bluetoothd 守护进程,即在启动 bluetoothd 时传递“-E”作为额外参数。

所以你需要,

  1. BlueZ 5.49 或更高版本
  2. 使用“-E”选项运行蓝牙守护程序

推荐阅读