zoukankan      html  css  js  c++  java
  • 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

    sdptool search --bdaddr F4:63:1F:D8:E0:89 0x1105

    # 蓝牙应用层使用工具

    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发送文件,需要带上对方mac的obex文件传输服务所在信道,与sdptool结合使用

    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>

    测试蓝牙特性

    1.某些手机蓝牙要在蓝牙设置页面才能被其他蓝牙扫描到(华为畅享9)
    2.某些手机蓝牙接收不了无后缀或特殊文件(小米8)
    3.苹果IOS系统是绝对的封闭性,所以iPhone蓝牙只能用于连接外设不能传输文件
    4.蓝牙同时连接7个设备后,第8个设备使用sdptool查找服务不成功
    5.某些手机蓝牙连接时需要点击确认配对
    6.需要点击确认配对的某些手机拒绝多次后(>8次),接收链路会失败,需要重新连接配对
    7.蓝牙作为从模式,有连接传输文件时,主模式文件传输失败
    8.获取不到主模式设备的rssi,主模式可以再beacon和scan request获取到应用层上报的从模式rssi

  • 相关阅读:
    求两个字符串中相同的汉字及字母的个数
    将十进制转成十六进制
    综合模糊查询
    求第一个字符串中第二个串的个数
    去除字符串中连续的分割符
    去除字符串中的html标记及标记中的内容
    sql基础语句
    SQL Server2008函数大全(完整版)
    sql 数字转人民币大写函数(两种方法)
    数字转IP地址函数
  • 原文地址:https://www.cnblogs.com/cxt-janson/p/11457139.html
Copyright © 2011-2022 走看看