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)
-
-
- libbt-brcm_bta \ -> bluedroid/bta/Android.mk
- libbt-brcm_gki \ -> bluedroid/gki/Android.mk
- libbt-brcm_stack \ -> bluedroid/stack/Android.mk
- libbt-hci \ -> bluedroid/hci/Android.mk
- libbt-utils \ -> bluedroid/hci/Android.mk
- libbt-qcom_sbc_decoder \ -> bluedroid\embdrv\sbc\decoder\Android.mk
- libosi \ -> bluedroid/osi/Android.mk
- 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基本架構