使用 bluez 通过蓝牙连接两个 raspberry pi

Connecting two raspberry pi through bluetooth with bluez

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

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

Adapter is Powered "on"

然后,在客户端:

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

Adapter is Powered "on" Unable to get result: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: Method "ConnectDevice" with signature "a{sv}" on interface "org.bluez.Adapter1" doesn't exist

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

如文章所述,ConnectDevice 是 BlueZ 5.49 中引入的新适配器 API。有关详细信息,请参阅发行说明 here

此 API 仍标记为实验性的,因此您需要 运行 实验模式下的 bluetoothd 守护程序,即在启动 bluetoothd 时将“-E”作为额外参数传递。

所以你需要,

  1. BlueZ 5.49 或更高版本
  2. 运行 带“-E”选项的蓝牙守护进程