BlueDroid介紹

自從Android 4.2開始,Android開始使用自己的藍牙協議棧BlueDroid,而不是bluez

BlueDroid可分爲兩層:
- BTE: Bluetooth Embedded System
- BTA: Bluetooth Application Layer

BTE實現了核心的藍牙功能,BTA則與框架的應用程序進行通信

1. 基本結構

下圖顯示了協議棧的基本結構

bluedroid
 

Application framework
framework/base/core/java/android/bluetooth
這裏是app代碼,使用android.bluetooth APIs和藍牙設備交互
其實現原理是通過Binder IPC機制使用藍牙服務

Bluetooth system service
位於packages/app/Bluetooth,打包爲一個Android應用程序(通過JNI與藍牙協議棧交互)
它在Android框架層實現了藍牙的服務和Profiles

JNI
有關代碼位於packages/apps/Bluetooth/jni
當進行藍牙操作時,JNI的代碼會調用到HAL層以獲取回調

HAL
HAL層定義了android.bluetooth和Bluetooth process calls into的標準接口
其頭文件位於hardware/libhardware/include/hardware

bluetooth.h: Contains the HAL for the Bluetooth hardware on the device 
bt_av.h:     Contains the HAL for the advanced audio profile. 
bt_hf.h:     Contains the HAL for the handsfree profile. 
bt_hh.h:     Contains the HAL for the HID host profile 
bt_hl.h:     Contains the HAL for the health profile 
bt_pan.h:    Contains the HAL for the pan profile 
bt_sock.h:   Contains the HAL for the socket profile

Bluetooth stack
藍牙協議棧,位於external/bluetooth/bluedroid
實現了通用的藍牙HAL及可配置組件

Vendor extensions
廠商可通過創建libbt-vendor模塊來自定義擴展接口和HCI層來方便調試

2. 代碼區

如下網址可在線查看相關代碼
AndroidXref
external/bluetooth/bluedroid
packages/apps/Bluetooth
hardware/libhardware/include/hardware

github上可進行代碼的下載
external_bluetooth_bluedroid
packages_apps_Bluetooth
android_hardware_libhardware

也可以到Android官網去下載
android Git repositories

參考:
<Android BlueDroid>
<
BlueDroid的結構和代碼分佈>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章