我正在尝试从运行Ubuntu Linux的Beaglebone Black与汽车OBDII蓝牙设备配对,但并不成功。最初,我能够使用bluez-simple-agent设置hci0,尽管它从未要求我输入PIN码。该设备的PIN码应为“1234”。现在,当我运行bluez-simple-agent时,会出现以下情况:
任何帮助都将不胜感激,因为我已经没有更多的想法了。
参考资料:
- rfcomm - 手动使用蓝牙 RFCOMM - 如何设置蓝牙 通过蓝牙进行串行连接 - 设备
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
如果它能正常工作就好了,但是当我尝试使用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";
}
运行"rfcomm bind 0"会成功地在/dev/rfcomm0创建一个设备:
rfcomm0: 00:0D:18:A0:4E:35 channel 16 clean
然而,尝试从 /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$
之后,rfcomm 返回如下结果:
ubuntu@ubuntu-armhf:/etc/bluetooth$ rfcomm
rfcomm0: 00:0D:18:A0:4E:35 channel 16 closed
根据"sdptool records"的结果,我认为我正在使用正确的通道(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
任何帮助都将不胜感激,因为我已经没有更多的想法了。
参考资料:
- rfcomm - 手动使用蓝牙 RFCOMM - 如何设置蓝牙 通过蓝牙进行串行连接 - 设备