android source bluetooth
2016-04-26 13:50
417 查看
https://source.android.com/devices/bluetooth.html
Android provides a default Bluetooth stack that is divided into two layers: The Bluetooth Embedded System (BTE),which implements the core Bluetooth functionality, and the Bluetooth Application Layer (BTA), whichcommunicates with Android framework applications.
To fully leverage the
Bluetooth Low Energy APIsadded in Android 5.0, you should implement the
Android 6.0 Bluetooth HCI Requirements.That document initially was provided as the
Android 5.0 Bluetooth HCI Requirements.
the Bluetooth stack:
Figure 1. Bluetooth architecture
Application frameworkAt the application framework level is application code, which utilizes the
android.bluetooth APIs to interact with the Bluetooth hardware. Internally, this code calls the Bluetooth process through the Binder IPC mechanism.Bluetooth system serviceThe Bluetooth system service, located in
android.bluetooth is located in
android.bluetooth APIs and Bluetooth process call into and that you must implement to have your Bluetooth hardware function correctly. The header file for the Bluetooth HAL is
Vendor extensionsTo add custom extensions and an HCI layer for tracing, you can create a libbt-vendor module and specify these components.
Profile-specific files are located in the same directory. For details, see the
HAL File Reference.
The following is a partial list of the profile-related files. For the
complete set, see the
Keep in mind that your Bluetooth implementation is not constrained to the featuresand profiles exposed in the HAL. You can find the default implementation locatedin the Bluetooth stack in the
Custom Bluetooth profiles - If you want to add Bluetooth profiles that do not haveHAL interfaces provided by Android, you must supply an SDK add-on download to make the profile available to app developers, make the APIs available in the Bluetooth system
process app (
Custom vendor extensions and configuration changes - You can add things such as extra AT commands or device-specific configuration changesby creating a
Host Controller Interface (HCI) - You can provide your own HCI by creating a
Bluetooth
In this document
Android provides a default Bluetooth stack that is divided into two layers: The Bluetooth Embedded System (BTE),which implements the core Bluetooth functionality, and the Bluetooth Application Layer (BTA), whichcommunicates with Android framework applications.
To fully leverage the
Bluetooth Low Energy APIsadded in Android 5.0, you should implement the
Android 6.0 Bluetooth HCI Requirements.That document initially was provided as the
Android 5.0 Bluetooth HCI Requirements.
Architecture
A Bluetooth system service communicates with the Bluetooth stack through JNI and with applications through Binder IPC. The system service provides developers with access to various Bluetooth profiles. The following diagram shows the general structure ofthe Bluetooth stack:
Figure 1. Bluetooth architecture
Application frameworkAt the application framework level is application code, which utilizes the
android.bluetooth APIs to interact with the Bluetooth hardware. Internally, this code calls the Bluetooth process through the Binder IPC mechanism.Bluetooth system serviceThe Bluetooth system service, located in
packages/apps/Bluetooth, is packaged as an Android app and implements the Bluetooth service and profiles at the Android framework layer. This app calls into the HAL layer via JNI.JNIThe JNI code associated with
android.bluetooth is located in
packages/apps/Bluetooth/jni. The JNI code calls into the HAL layer and receives callbacks from the HAL when certain Bluetooth operations occur, such as when devices are discovered.HALThe hardware abstraction layer defines the standard interface that the
android.bluetooth APIs and Bluetooth process call into and that you must implement to have your Bluetooth hardware function correctly. The header file for the Bluetooth HAL is
hardware/libhardware/include/hardware/bluetooth.h. Additionally, please review all of the
hardware/libhardware/include/hardware/bt_*.hfiles. Bluetooth stackThe default Bluetooth stack is provided for you and is located in
system/bt. The stack implements the generic Bluetooth HAL and customizes it with extensions and configuration changes.
Vendor extensionsTo add custom extensions and an HCI layer for tracing, you can create a libbt-vendor module and specify these components.
Implementing the HAL
The Bluetooth HAL is located in/hardware/libhardware/include/hardware/bluetooth.h. Thus, the
bluetooth.hfile contains the basic interface for the Bluetooth stack, and you must implement its functions.
Profile-specific files are located in the same directory. For details, see the
HAL File Reference.
The following is a partial list of the profile-related files. For the
complete set, see the
/hardware/libhardware/include/hardware/directory:
bt_av.h: Includes the interface definition for the A2DP profile.
bt_gatt.h,
bt_gatt_client.h, and
bt_gatt_server.h: These include the interface definition for the GATT profile.
bt_hf.h: Includes the interface definition for the HFP profile.
bt_hh.h: Includes the interface definition for the HID host profile.
bt_hl.h: Includes the interface definition for the HDP profile.
bt_mce.h: Includes the interface definition for the MAP profile.
bt_pan.h: Includes the interface definition for the PAN profile.
bt_rc.h: Includes the interface definition for the AVRCP profile.
bt_sock.h: Includes the interface definition for RFCOMM sockets.
Keep in mind that your Bluetooth implementation is not constrained to the featuresand profiles exposed in the HAL. You can find the default implementation locatedin the Bluetooth stack in the
system/btdirectory,which implements the default HAL and also extra features and customizations.
Customizing the Native Bluetooth Stack
If you are using the default Bluetooth stack, but want to make a few customizations, you cando the following:Custom Bluetooth profiles - If you want to add Bluetooth profiles that do not haveHAL interfaces provided by Android, you must supply an SDK add-on download to make the profile available to app developers, make the APIs available in the Bluetooth system
process app (
packages/apps/Bluetooth), and add them to the default stack (
system/bt).
Custom vendor extensions and configuration changes - You can add things such as extra AT commands or device-specific configuration changesby creating a
libbt-vendormodule. See the
/hardware/broadcom/libbtdirectoryfor an example.
Host Controller Interface (HCI) - You can provide your own HCI by creating a
libbt-hcimodule, whichis mainly used for debug tracing. See the
external/bluetooth/hcidirectory for an example.
相关文章推荐
- How to retrieve the Device Unique ID from android device
- UI设计师的Photoshop配置技巧
- concurrent之BlockingQueue
- UITableView总结
- 【leetcode】128. Longest Consecutive Sequence
- duilib---响应windows原生消息和自定义消息
- 给UICollectionView添加表头
- 【Vue】 -(6) 条件渲染和列表渲染
- Jenkins中使用过的Msbuild编译bat
- duilib入门问题
- IOS中十六进制的颜色转换为UIColor
- Android属性动画(二):深入valueAnimator和objecAnimator
- UIToolBar的使用
- Android异步更新UI的几种方法
- 2013年山东省第四届ACM大学生程序设计竞赛 Problem A Rescue The Princess 向量法 水题
- 控制器跳转和视图切换之NavigationController,UITabBarController,模态
- 40-变量的value和type存储
- 利用C#队列集合(Queue)写的一个算法
- Flink DataStream API Programming Guide
- imbue