Linux下Bluetooth的使用__Linux

來源:互聯網
上載者:User
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. 



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.