在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验证 1)
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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM