本文主要是介绍在Linux下蓝牙进行rfcomm连接,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在Linux下蓝牙进行rfcomm连接
折腾了半天终于搞定了,开心 用的是bluez3.36,大概说一下流程 :
1. 配置/etc/bluetooth/rfcomm.conf
rfcomm0 {
# # Automatically bind the device at startup
bind no;
#
# # Bluetooth address of the device
device XX:XX:XX:XX:XX:XX;
#
# # RFCOMM channel for the connection
channel 1;
#
# # Description of the connection
comment "Example Bluetooth device";
}
2. 关闭本地pin验证
hciconfig hci0 noauth ; # 关闭本地的pin验证
3. 设置连接pin码
编辑/var/lib/bluetooth/XX:XX:XX:XX:XX:XX/pincodes (XX:XX:XX:XX:XX:XX为本地设备地址) 文件格式为: XX:XX:XX:XX:XX:XX 1234 (XX:XX:XX:XX:XX:XX为目标设备地址)
4. 运行
mknod /dev/rfcomm0 c 216 0
chmod 666 /dev/rfcomm0
rfcomm connect 0;
5. 输出字符到蓝牙串口
echo y>/dev/rfcomm0
这篇关于在Linux下蓝牙进行rfcomm连接的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!