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
解除Binder 方法是
# 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.