1. 激活設備
首先要有一個藍牙適配器,這個不用說,一般都是USB接口類型。
lsusb 查看系統中連接的藍牙設備
hciconfig 查看設備的詳細信息
hciconfig hci0 up 將設備激活
2. 配置bluez
配置文件位於目錄/etc/bluetooth
3. bluetooth服務
/etc/rc.d/init.d/bluetooth stop
/etc/rc.d/init.d/bluetooth start
4. 掃描設備
hcitool scan
通過以上命令可以查找周圍的Bluetooth設備5. 綁定設備
有兩種方式來綁定目的藍牙設備
@1 修改/etc/bluetooth/rfcomm.conf
@2 rfcomm bind /dev/rfcomm0 XX:XX:XX:XX:XX:XX
解除綁定方法是
# rfcomm unbind /dev/rfcomm0 BD_ADDR channel
tip: 如果沒有虛擬串口設備(rfcomm0),則需要手動創建(rfcomm_create_dev?)
# mknod /dev/rfcomm0 c 216 1
# chmod 666 /dev/rfcomm0
6. 添加通道
sdptool add --channel=1 DID SP DUN LAN FAX OPUSH FTP HS HF SAP NAP GN PANU HID CIP CTP A2SRC A2SNK SYNCML NOKID PCSUITE SR1
後面的參數表示系統支持的全部服務
7. 連接設備
hcitool cc XX:XX:XX:XX:XX:XX
8. 發送文件
obex-send *.*
9. bluez tools
bccmd: used to issue BlueCore commands to Cambridge Silicon Radio devices.
bluetoothd: the Bluetooth daemon.
ciptool: used to set up, maintain, and inspect the CIP configuration of the Bluetooth subsystem in the Linux kernel.
hciattach: used to attach a serial UART to the Bluetooth stack as HCI transport interface.
hciconfig: used to configure Bluetooth devices.
hcitool: used to configure Bluetooth connections and send some special command to Bluetooth devices.
hid2hci: used to set up switch supported Bluetooth devices into the HCI mode and back.
l2ping: used to send a L2CAP echo request to the Bluetooth MAC address given in dotted hex notation.
rctest: used to test RFCOMM communications on the Bluetooth stack.
rfcomm: used to set up, maintain, and inspect the RFCOMM configuration of the Bluetooth subsystem in the Linux kernel.
sdptool: used to perform SDP queries on Bluetooth devices.
libbluetooth.so: contains the BlueZ 4 API functions.