Android Bluetooth How To(Based on Android L Bluedroid)

持续更新中…

1、How to enable btsnoop log?

  a) UI Settings-->

  b) Developer Options-->

  c) reboot Tablet, then snoop log will locate in /sdcard/btsnoop_hci.log(this path can be configured in /etc/bluetooth/bt_stack.conf)

2、If developer options default not enabled, you can use following steps to enable it

  a) Settings-->

  b) About Tablet-->

  c) Click 4 or 5 times or more in Build Number-->

  d)then, Develop options will comeout-->

Pls also be noted that how to enable Developer Options might depend on system and Android Versions

3、bluedroid useful config files

  a) bt_stack.conf

    i. 此文件保存在/etc/bluetooth/目录下,用于配置抓取bluedroid协议栈log的方式和log的级别

  b) bt_config.xml

i.此文件在/data/misc/bluedroid/目录下,保存了当前BT设备、扫描到的BT设备以及配对过的BT设备的信息,包括device name、BD_ADDR、link key、Report Descriptor(HID)等等

  c) bt_did.conf,/etc/Bluetooth/

i. Device ID (DID) configuration file,未被使用

  d) auto_pair_devlist.conf,/etc/Bluetooth/

i. 保存blacklist和whitelist

4、How to enable & adjust bluedroid debug log level?

  a) this should customized in /etc/bluetooth/bt_stack.conf

  b) enable btsnoop log -->

i.set BtSnoopLogOutput to true

          BtSnoopLogOutput=true

ii. set BtSnoopFileName to path you want to save btsnoop log

          BtSnoopFileName=/sdcard/btsnoop_hci.log

  c) adjust trace & debug level

i. set TraceConf to true

        TraceConf=true

ii. 根据需要设置debug level,默认是2,通常debug的时候,都是将level默认设置为5来抓log,这样可以打出更多的信息(logcat)

        TRC_BTM=5

        TRC_HCI=5

        TRC_L2CAP=5

        TRC_RFCOMM=5

        TRC_OBEX=5

        TRC_AVCT=5

        TRC_AVDT=5

        TRC_AVRC=5

        TRC_AVDT_SCB=5

        TRC_AVDT_CCB=5

        TRC_A2D=5

        TRC_SDP=5

        TRC_GATT=5

        TRC_SMP=5

        TRC_BTAPP=5

        TRC_BTIF=5

5、Android Bluetooth相关code路径

  a) bluedroid协议栈

i. <Android Root>/external/bluetooth/bluedroid/

  b) Bluetooth.apk

i. <Android Root>/packages/apps/Bluetooth/

  c) Settings.apk

i. <Android Root>/packages/apps/Settings/src/com/android/settings/bluetooth

  d) hal头文件

i. <Android Root>/hardware/libhardware/include/hardware/bluetooth.h

         ii. <Android Root>/hardware/libhardware/include/hardware/bt_*.h

  e) framework相关

i. <Android Root>/frameworks/base/core/java/android/bluetooth

ii. <Android Root>/frameworks/base/services/core/java/com/android/server/ BluetoothManagerService.java

6、bluedroid build出来的binary

  a) bluetooth.default.so

i. 这个协议栈的profile、stack所编译出来的,是bluedroid的精华所在

i. 由如下库文件组成,static lib (参考:bluedroid/main/Android.mk)

      1. libbt-brcm_bta \ -> bluedroid/bta/Android.mk
      2. libbt-brcm_gki \ -> bluedroid/gki/Android.mk
      3. libbt-brcm_stack \ -> bluedroid/stack/Android.mk
      4. libbt-hci \ -> bluedroid/hci/Android.mk
      5. libbt-utils \ -> bluedroid/hci/Android.mk
      6. libbt-qcom_sbc_decoder \ -> bluedroid\embdrv\sbc\decoder\Android.mk
      7. libosi \ -> bluedroid/osi/Android.mk
      8. libtinyxml2 \

  b) audio.a2dp.default.so

i. 这个是a2dp和audio的hal接口,-> bluedroid\audio_a2dp_hw\Android.mk

  c) libbt-vendor.so

i. vendor自己实现的,用于将bluedroid协议栈铜特定的芯片driver接起来

7、 Android BT基本架构

更多相关文章

  1. Android解决禁止使用http协议的方案
  2. 在LinearLayout中嵌套RelativeLayout来设置Button的位置(xml文件)
  3. android studio ndk 编译自定义MK文件
  4. Android Studio-Gradle项目中添加JNI生成文件(.so文件)

随机推荐

  1. android 更换皮肤项目
  2. android4.0创建AVD后,打开虚拟机黑屏问题
  3. android ndk安装是使用
  4. Android(安卓)强制设置横屏或竖屏
  5. 2011.09.26(4)——— android sample之Note
  6. Android播放器框架分析之AwesomePlayer
  7. and 使用以及添加一个自己的mime type在C
  8. Android构建报错:Android(安卓)resource l
  9. android的单元测试摘要
  10. Android和JAVA面试题相关资料