洞下沙滩门票:Bluetooth driver

来源:百度文库 编辑:中财网 时间:2024/05/06 10:31:28

软件开发文档
一:蓝牙的编译
1.编译蓝牙固件
在下载的wlan包里面修改编译脚本wl1271_bt_build.sh的KERNEL_PATH和
TOOLCHAIN_PATH路径,指向你的KERNEL包和编译工具包的路径。执行编译脚本./wl1271_bt_build.sh build,编译的ti-bluetooth.tar.bz2结果在wlan/wl1271/source/build/image目录下。解压此包在firmware下有TIInit_7.2.31.bts此二进制的固件包.
2.编译kernel
在kernel中首选通过make menuconfig选择编译选项
Networking support -> Bluetooth subsystem support
<*> L2CAP protocol support
<*> SCO links support
<*> RFCOMM protocol support
[*] RFCOMM TTY support
<*> BNEP protocol support
[*] Multicast filter support
[*] Protocol filter support
<*> HIDP protocol support
Networking support -> Bluetooth subsystem support ->

Bluetooth device drivers

<*> HCI UART driver
[*] UART (H4) protocol support
[*] BCSP protocol suppor
[*] HCILL protocol support
[*] WL1271 Bluetooth driver support
Device Drivers -> Misc devices

[*] Android pmem allocator
<*> Bluetooth power control driver for TI wl127x

勾上以上选项,编译KERNEL生成 uImage。
二:android文件系统部分加载
1.1.$ cd $YOUR_PATH/android/

1.2. 修改BoardConfig.mk
BOARD_HAVE_BLUETOOTH := true

1.3.拷贝How to integrated Android BT&FM1:使能android对blutooth的支持包里hcitool.c和hciattach_ti.c文件到android包里
cp source/hciattach.c $ANDROID_SRC/external/bluetooth/bluez/tools

cp source/hciattach_ti.c $ANDROID_SRC/external/bluetooth/bluez/tools

把board-omap3beagle.c文件关于bluetooth部分加到board-omap3evm.c
1.4建立固件分位
在/system/lib目录下建立firmware
文件夹,把TIInit_7.2.31.bts复制到这个文件夹中,把ti-bluetooth的sbin中的wl1271bt_enable复制到android下的system/bin.
1.5修改android中的init.rc关于蓝牙部分的地方
■ export BT_FW_PATH /system/lib/firmware

■ mkdir /data/misc/hcid 0770 bluetooth bluetooth

■ chmod 0660 /dev/ttyS0

■ chown bluetooth bluetooth /dev/ttyS0

■ chmod 0660 sys/class/rfkill/rfkill0/state

■ chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state

■ write sys/class/rfkill/rfkill0/state 0

■ service hciattach /system/bin/hciattach -n /dev/ttyS0 texas 115200

user root

group bluetooth net_bt_admin misc

disabled

oneshot

1.6编译整个文件系统等到最终的文件系统,之后烧入.

三:蓝牙命令调试流程
1:wl1271bt_enable /dev/ttyS1 & 上电
2.hciattach /dev/ttyS1 texas 3000000 &
3:hciconfig hci0 up 激活蓝牙模块
4:hcitool dev 查看蓝牙模块信息
5:hcitool scan 查询周围蓝牙设备
6: 建立虚拟串口设备
# mknod /dev/rfcomm0 c 216 1
# chmod 666 /dev/rfcomm0
需要设置minicom
Serial Device      : /dev/rfcomm0
7:修改rfcomm.conf
# vi /etc/bluetooth/rfcomm.conf   
rfcomm0{
    bind    no;
    device -00:1B:35:00:12:34;
    channel 1;
    comment "HCI003"
}
说明:
    bind no 是设置是否自动绑定设备;
    device -是设置绑定设备的地址;
    channel 是设置设备的通道;
    comment 是对设备的描述。
注意:这个device的地址是本地蓝牙设备的地址。
8: 添加sdp协议通道
# 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
说明:后面的参数不一定全部支持,简单起见默认将服务全部打开。
9: 使用虚拟串口与外界蓝牙设备绑定
# rfcomm bind /dev/rfcomm0 1蓝牙设备地址         通道
# rfcomm bind /dev/rfcomm0 00:08:AC:03:58:A6 -
蓝牙设备地址: 远端蓝牙设备地址(DTK001)
如果需要解除绑定
# rfcomm unbind /dev/rfcomm0 BD_ADDR channel
10:hcitool cc 00:08:AC:03:58:A6连接

11:hcitool conn查看连接