在 Ubuntu 上与蓝牙 OBDII 设备配对时遇到困难

tom*_*sic 5 ubuntu bluetooth bluez beagleboneblack elm327

我正在尝试与运行 Ubuntu Linux 的 Beaglebone Black 上的汽车 OBDII 蓝牙设备配对,但运气不佳。

最初我能够使用 bluez-simple-agent 设置 hci0,尽管它从未要求我提供 PIN。该设备的 PIN 应该是“1234”。现在,当我运行 bluez-simple-agent 时,我得到以下信息:

ubuntu@ubuntu-armhf:/etc/bluetooth$ sudo bluez-simple-agent hci0 00:0D:18:A0:4E:35
Creating device failed: org.bluez.Error.AlreadyExists: Already Exists
Run Code Online (Sandbox Code Playgroud)

如果它工作正常,那就太好了,但是当我尝试使用 rfcomm 绑定时,我反复收到“无法连接 RFCOMM 套接字:无效交换”(重新启动设备后第一次),然后“无法连接 RFCOMM 套接字:此后每次都出现“连接被拒绝”的情况。

这是我的 /etc/bluetooth/rfcomm.conf 文件:

rfcomm0 {
    # Automatically bind the device at startup
    bind no;

    # Bluetooth address of the device
    device 00:0D:18:A0:4E:35;

    # RFCOMM channel for the connection
    channel 16;

    # Description of the connection
    comment "OBDII";
}
Run Code Online (Sandbox Code Playgroud)

运行“rfcomm bind 0”确实在 /dev/rfcomm0 成功创建了一个设备:

rfcomm0: 00:0D:18:A0:4E:35 channel 16 clean 
Run Code Online (Sandbox Code Playgroud)

然而,尝试从 /dev/rfcomm0 读取,给了我这个:

ubuntu@ubuntu-armhf:/etc/bluetooth$ sudo cat /dev/rfcomm0
cat: /dev/rfcomm0: Invalid exchange
ubuntu@ubuntu-armhf:/etc/bluetooth$ sudo cat /dev/rfcomm0
cat: /dev/rfcomm0: Connection refused
ubuntu@ubuntu-armhf:/etc/bluetooth$ 
Run Code Online (Sandbox Code Playgroud)

此后,rfcomm 返回:

ubuntu@ubuntu-armhf:/etc/bluetooth$ rfcomm
rfcomm0: 00:0D:18:A0:4E:35 channel 16 closed 
Run Code Online (Sandbox Code Playgroud)

我认为我根据“sdptool记录”的结果使用了正确的通道(16)

ubuntu@ubuntu-armhf:/etc/bluetooth$ sudo sdptool records 00:0D:18:A0:4E:35 
...
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 16
Profile Descriptor List:
  "Serial Port" (0x1101)
    Version: 0x0100
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激,因为我现在完全没有想法。

参考文献:

Jos*_*mas 4

从蓝牙设置中删除已配对的设备并重新添加