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), which communicates 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 of the Bluetooth stack:
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.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.hardware/libhardware/include/hardware/bluetooth.h
. Additionally, please review all of the hardware/libhardware/include/hardware/bt_*.h
files.system/bt
. The stack implements the generic Bluetooth HAL and customizes it with extensions and configuration changes.Implementing the HAL
The Bluetooth HAL is located in /hardware/libhardware/include/hardware/bluetooth.h
. Thus, the bluetooth.h
file 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
, andbt_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 features and profiles exposed in the HAL. You can find the default implementation located in the Bluetooth stack in the system/bt
directory, 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 can do the following:
- Custom Bluetooth profiles - If you want to add Bluetooth profiles that do not have HAL 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 changes by creating a
libbt-vendor
module. See the/hardware/broadcom/libbt
directory for an example. - Host Controller Interface (HCI) - You can provide your own HCI by creating a
libbt-hci
module, which is mainly used for debug tracing. See theexternal/bluetooth/hci
directory for an example.
相关推荐
- **Android Bluetooth框架层**:位于Java层,包含`android.bluetooth`包中的各种类,如`BluetoothAdapter`, `BluetoothDevice`, `BluetoothGatt`等,提供了开发者友好的API。 - **蓝牙应用程序**:使用Android蓝牙...
Android Bluetooth Framework 应用层分析 AndroidBluetooth Framework 是 Android 操作系统中的蓝牙协议栈,负责管理蓝牙设备的连接、数据传输和蓝牙 Profile 的管理。整个蓝牙系统可以分为四个层次:蓝牙嵌入式...
Bluetooth HAL 是 Android 4.2 中引入的,定义了 Bluetooth 设备的标准接口,担任 Android Framework 和 Bluetooth 设备之间的桥梁。Bluedroid 是 Android Bluetooth 框架的关键组件,负责扫描、连接和数据传输等...
Android 6.0 (API Level 23) 进一步扩展了Android的功能,最重要的变化之一是引入了运行时权限管理。在Marshmallow之前,应用在安装时需要获取所有所需的权限,而在API 23之后,用户可以在运行时决定是否授予某个...
This is an android application framework for bluetooth4.0 communication. This app will support the help on making android bluetooth4.0 application.
Framework使用BinderIPC机制来使用蓝牙服务,其代码路径是android\frameworks\base\core\java\android\bluetooth。Bluedroid协议栈是Android官方提供的实现,代码路径位于android\external\bluetooth\bluedroid。 ...
Android Print Framework提供了一些内置的支持,但可能需要额外的定制工作来满足特定需求。 此外,对于不支持蓝牙的打印机,可以利用Wi-Fi Direct或云打印服务作为替代方案。Wi-Fi Direct允许设备之间直接建立无线...
在Android P(9)系统中,蓝牙(Bluetooth)框架是一个至关重要的组件,它负责设备间的无线通信。本文将深入探讨BT Framework的架构、初始化流程、状态机操作以及启用和禁用蓝牙的过程。对于开发者而言,理解这些...
BluetoothKit---Android Bluetooth Framework 这个库用于Android蓝牙BLE设备通信,支持设备扫描,连接,读写,通知。 这套框架存在的意义 一、统一解决Android蓝牙通信过程中的兼容性问题 二、提供尽可能简单易用的...
LiteBle: Android Bluetooth Framework Extremely simple! Based on callback. Communication with BluetoothLE(BLE) device as easy as HTTP communication. One Device, One connection, One LiteBluetooth ...
在Android中,蓝牙功能主要由蓝牙框架(Bluetooth Framework)和相关类来支持。 首先,我们需要了解蓝牙通信的基础概念,例如RFCOMM协议。RFCOMM是一种基于欧洲电信标准协会(ETSI)07.10规程的串行线性仿真协议,它...
A sample application that demonstrates Android's search framework, including how to provide search suggestions for Quick Search Box. Snake An implementation of the classic game "Snake." Soft ...
首先,Android 4.3是Android操作系统的版本之一,它引入了许多新特性和改进。通过查看源码,开发者可以学习到如何实现这些特性,例如OpenGL ES 3.0的支持,这为游戏和图形密集型应用提供了更强大的图形处理能力。...
3. **Bluetooth Smart (BLE) 支持**:Android 4.3开始支持蓝牙低功耗(Bluetooth Smart),使得设备能与智能健康和健身设备等物联网产品无缝连接。 4. **Wi-Fi Direct打印**:新增了对Wi-Fi Direct打印的支持,用户...
首先,我们要理解Android的蓝牙API是构建在Android Bluetooth Framework之上的,它提供了一套丰富的接口和类,允许开发者轻松地进行蓝牙设备的搜索、配对、连接以及数据传输。主要涉及的类有BluetoothAdapter、...
DrawerLayout实现抽屉式布局,自定义RecyclerView实现照片墙,支持下拉刷新,上拉加载更多。Realm数据库使用以及搭建项目框架。简单封装RxJava2+Retrofit2+OkHttp...https://github.com/Aphrodite123/FrameWorkDemo.git
该版本的Android和ios控制程序支持三种控制通道。 Bluetooth channel(蓝牙通道) 该通道支持与以前CSRmesh2.0版本相同的功能。使用此通道,用户可以控制支持上述模型的CSRmesh设备。 Gateway channel(网关通道)...
2. **Android Framework**:这是Android系统的核心组件,包括各种服务、类库和接口,如Activity Manager、Content Providers、Broadcast Receivers、Intent等,开发者可以通过这些接口与系统进行交互。 3. **Java ...
Android蓝牙 上层(java-framework)层打开使能流程图,将Android 源码使用流程图的形式画了出来,使Android 蓝牙开发者更清楚数据收发走向,代码流程更加形象生动,能够很快的熟悉Android 蓝牙源码,利于后面问题...
- **Android Example4 Bluetooth.zip**: 包含蓝牙打印的示例代码,展示了如何发现和连接蓝牙打印机,以及如何发送打印数据。 - **Android Example4 USB.rar**: 提供USB打印的代码,包括请求权限、识别和连接USB...