openwrt蓝牙文件传输

openwrt支持:

USB Supprot-------------------------------

kmod-usb-ohci

kmod-usb-uhci

kmod-usb-storage-extras

kmod-usb2

 

Utilities-------------------------------

bluez-utils

bluez-daemon

 

Utilities-------------------------------

openobex

openobex-apps

 

工具说明:

bluez-utils依赖bluez-libs,dbus

生成工具:bccmd,bluemoon,btattach,btmon,btmgmt,ciptool,hciattach,hciconfig,hcidump,hcitool,hex2hcd,l2ping,l2test,mpris-proxy,rctest,rfcomm,sdptool,gatttool

 

bluez-libs依赖kmod-bluetooth蓝牙hci驱动

bluez-daemon生成工具:bluetoothd,bluetoothctl,obexd

openobex-apps生成工具:obex_test

 

kmod-bluetooth驱动

openwrt蓝牙驱动ko参考:kmod-bluetooth

        $(LINUX_DIR)/net/bluetooth/bluetooth.ko \

        $(LINUX_DIR)/net/bluetooth/rfcomm/rfcomm.ko \

        $(LINUX_DIR)/net/bluetooth/bnep/bnep.ko \

        $(LINUX_DIR)/net/bluetooth/hidp/hidp.ko \

        $(LINUX_DIR)/drivers/bluetooth/hci_uart.ko \

        $(LINUX_DIR)/drivers/bluetooth/btusb.ko

 

工具使用:

bluetoothd完成蓝牙hci层的统一管理服务端

bluetoothctl 蓝牙服务控制,通过dbus与bluetoothd通信

obexd蓝牙文件传输协议接收服务端,通过dbus与bluetoothd通信

hciconfig,hcitool 蓝牙hci层控制工具

obex_test蓝牙文件传输客户端,支持点对点蓝牙的文件发送与接收

sdptool 蓝牙从设备profile服务扫描工具

 

# 建立串口和蓝牙hci协议层的数据连接通道,usb方式不用

hciattach /dev/ttyAMA0 bcm43xx 921600 noflow -

hciconfig hci0 up

hcitool scan

hciconfig hci0 sspmode disable #关闭简易配对模式,有这个模式的被配对方就不用点击确认

# 查找目标mac蓝牙服务,文件传输服务为"OBEX Object Push" (0x1105),找出服务所在信道

sdptool brower F4:63:1F:D8:E0:89

# 蓝牙应用层使用工具

 

bluetoothctl

power on -- 启动蓝牙模块

agent on -- 蓝牙模块agent 打开

scan on -- 扫描周边设备,得到手机MAC:DC:09:4C:62:B3:CA

trust DC:09:4C:62:B3:CA -- trust该手机

pairable on -- 配对使能

discoverable on -- 开放检测

show -- 查看蓝牙配置信息

 

echo "power on" | bluetoothctl

echo "agent on" | bluetoothctl

echo "pairable on" | bluetoothctl

echo "discoverable on" | bluetoothctl

echo "show" | bluetoothctl

 

# obex_test发送文件

obex_test -b F4:63:1F:D8:E0:89 5

 

# obexd开启obex服务,接收文件

export DBUS_SESSION_BUS_ADDRESS="unix:path=/var/run/dbus/system_bus_socket"

obexd -a -r /tmp/ -n

 

 

obexd的dbus启动配置文件编写:

========================================

root@OpenWrt:~# cat /etc/dbus-1/system.d/obex-dbus.conf

<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"

 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">

<busconfig>

 

  <!-- ../system.conf have denied everything, so we just punch some holes -->

 

  <policy user="root">

    <allow own="org.bluez.obex"/>

    <allow send_destination="org.bluez.obex"/>

  </policy>

 

  <policy at_console="true">

    <allow send_destination="org.bluez.obex"/>

  </policy>

 

  <policy group="lp">

    <allow send_destination="org.bluez.obex"/>

  </policy>

 

  <policy context="default">

    <deny send_destination="org.bluez.obex"/>

  </policy>

 

</busconfig>

 

上一篇:如何在Android中发送基于BT免提配置文件的AT命令?


下一篇:android – 如何通过蓝牙获取InputStream并放入Textview?