Linux下Bluetooth的使用

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. 



  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值