Android Bluetooth 移植(上)

原文链接地址:http://source.android.com/porting/bluetooth.html#androidBluetoothPorting

本文涵盖以下方面

·         移植

·         编译

·         疑难解答

·         工具

·         支持特性

 

Android 的蓝牙协议栈使用BlueZ实现来对GAP, SDP以及RFCOMM等应用规范的支持,并获得了SIG认证。由于Bluez使用GPL授权, 所以Android 框架通过D-BUS IPC来与bluez的用户空间代码交互以避免使用未经授权的代码。

Android 在应用框架framework中实现HSPHFP(v1.5)规范,并且与电话应用(Phone App)配合紧密。

下图展示了蓝牙软件栈面向库的视图,在它下面是面向进程的视图。

1 面向库的视图

图中使用实线的块是在android中实现的,而虚线的部分则由合作伙伴具体定制。

2 面向进程的视图(基于1.0版本)

移植

BlueZ兼容bluetooth 2.1, 支持任意基于蓝牙2.1的芯片组, 并且后向兼容早期的版本。移植中有两个与芯片的结合点:

·         UART 驱动

·         蓝牙电源开关

UART 驱动

BlueZ内核子系统通过守护进程hciattach 与特定硬件的UART驱动进行绑定。

MSM7201A为例,参考drivers/serial/msm_serial.c。你可能还需要编辑init.rc hciattach 的命令行选项。

蓝牙电源开关

Android V1.0与之前的版本采用不同的方式控制蓝牙芯片的电源开关。

1.0: Android 框架向/sys/modules/board_[PLATFORM]/parameters/bluetooth_power_on 01.

Post 1.0: Android 框架使用 linux rfkill API

可以参考 arch/arm/mach-msm/board-trout-rfkill.c

编译

为了使能Android的蓝牙功能,在编译时需要在 BoardConfig.mk中加入

BOARD_HAVE_BLUETOOTH := true

 

疑难解答

调试

在开始时,可以通过读log (adb logcat)并寻找蓝牙相关的 ERRROR WARNING 信息来调试你的蓝牙实现, Bluez中也包含了一些十分有用的调试工具。下面按照推荐顺序提供了一些例子。

hciconfig -a                 # print BT chipset address and features. Useful to check if you can communicate with your BT chipset.

hcidump -XVt                 # print live HCI UART traffic.

hcitool scan                 # scan for local devices. Useful to check if RX/TX works.

l2ping ADDRESS         # ping another BT device. Useful to check if RX/TX works.

sdptool records ADDRESS # request the SDP records of another BT device.

后台进程的Log

后台进程hcid (STDOUT)  hciattach (STDERR)log默认输出到/dev/null。可以编辑 init.rc  init.PLATFORM.rc 来使这些进程在 logwrapper下运行,从而将输出重定向到logcat.

hciconfig -a hcitool

当使用你自己编译的system.img, 如果 hciconfig -a 可以正常工作但hcitool 却不能正确扫描, 可以尝试为蓝牙芯片组安装固件。目前的开源代码库中并不提供该固件, 但是你可以通过使用 adb pull 然后 adb push从早期的T-Mobile G1中获取 (位于 /etc/firmware/brf6300.bin).

工具

BlueZ 提供了一套丰富的基于命令行的工具用于调试与并与蓝牙子系统进行交互,其中包括:

·         hciconfig

·         hcitool

·         hcidump

·         sdptool

·         dbus-send

·         dbus-monitor

 

 

  • 1
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
########################BT FM ########################## Download the image using command: 1 # Flash Image Put the board in Flashing mode. Refer below Appendix - 1 cd <your path>/Nvidia_Demo/android_gb_cardhu_os_image sudo ./nvflash --bct flash.bct --setbct --odmdata 0x40080105 --configfile flash.cfg --create --bl bootloader.bin --go #################################################################################################################################################################################################### Appendix - 1 Nvidia Board in Flashing Mode #################################################################################################################################################################################################### 1. Connect the Debug board to Cardhu board. 2. Connect the power supply and Micro USB to Cardhu 3. On the Debug Board Press S12 (FRC RCV), Keeping this pressed Press and release S7 (RESET), Now Release S12. 4. Now Device is in Flashing mode, We can start nvflash command now. #################################################################################################################################################################################################### Appendix - 2 Nvidia Board Keys (On Debug Board) #################################################################################################################################################################################################### 1. S7 (RESET) --> is the RESET button. 2. S5 (ROW1) --> is the BACK button. 2. S10 (ROW2) --> is the Home button. 4. S6 (ON KEY) --> is Wake up button. #################################################################################################################################################################################################### Appendix - 3 Nvidia Board unavailable Keys workaround #################################################################################################################################################################################################### 1.To execute teh specific keys, provide the key inputs from adb shell. Provide the keyevent for the desired key.Refer teh key list below. Eg: for MENU key run adb shell #input keyevent 82 { "STAR", 17 }, { "POUND", 18 }, { "DPAD_UP", 19 }, { "DPAD_DOWN", 20 }, { "DPAD_LEFT", 21 }, { "DPAD_RIGHT", 22 }, { "DPAD_CENTER", 23 }, { "VOLUME_UP", 24 }, { "VOLUME_DOWN", 25 }, { "POWER", 26 }, { "CAMERA", 27 }, { "CLEAR", 28 }, { "HEADSETHOOK", 79 }, { "FOCUS", 80 }, { "PLUS", 81 }, { "MENU", 82 }, { "NOTIFICATION", 83 }, { "SEARCH", 84 }, { "MEDIA_PLAY_PAUSE", 85 }, { "MEDIA_STOP", 86 }, { "MEDIA_NEXT", 87 },

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值