折騰了半天終於搞定了,開心 用的是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