Bluetooth
Android provides a default Bluetooth stack, BlueDroid, 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. A Bluetooth system service communicates with the Bluetooth stack through JNI and with applications through Binder IPC. The system service provides developers access to various Bluetooth profiles. The following diagram shows the general structure of the Bluetooth stack:

- Application framework
- At the application framework level is the app's 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 service
- The 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. - JNI
- The 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. - HAL
- The hardware abstraction layer defines the standard interface that the android.bluetooth APIs and Bluetooth process calls into and that you must implement to have your bluetooth hardware function correctly. The header files for the Bluetooth HAL is located in the
hardware/libhardware/include/hardware/bluetooth.handhardware/libhardware/include/hardware/bt_*.hfiles. - Bluetooth stack
- The default Bluetooth stack is provided for you and is located in
external/bluetooth/bluedroid. The stack implements the generic Bluetooth HAL as well as customizes it with extensions and configuration changes. - Vendor extensions
- To 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 the hardware/libhardware/include/hardware/ directory and consists of the following header files:
bluetooth.h: Contains the HAL for the Bluetooth hardware on the devicebt_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 profilebt_hl.h: Contains the HAL for the health profilebt_pan.h: Contains the HAL for the pan profilebt_sock.h: Contains the HAL for the socket profile.
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 BlueDroid Bluetooth stack in the external/bluetooth/bluedroid directory, which implements the default HAL and also extra features and customizations.
Customizing the BlueDroid Stack
If you are using the default BlueDroid stack, but want to make a few customizations, you can do the following things:
- 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 BlueDroid stack (external/bluetooth/bluedroid). - Custom vendor extensions and configuration changes - You can add things such as extra AT commands or device-specific configuration changes by creating a
libbt-vendormodule. See thevendor/broadcom/libbt-vendordirectory for an example. - Host Controller Interface (HCI) - You can provide your own HCI by creating a
libbt-hcimodule, which is mainly used for debug tracing. See theexternal/bluetooth/hcidirectory for an example.
http://source.android.com/devices/bluetooth.html
Bluetooth的更多相关文章
- 蓝牙Bluetooth技术小知识
蓝牙Bluetooth技术以及广泛的应用于各种设备,并将继续在物联网IoT领域担任重要角色.下面搜集整理了一些关于蓝牙技术的小知识,以备参考. 蓝牙Bluetooth技术始创于1994年,其名字来源于 ...
- 浅谈Bluetooth蓝牙开发
前言:项目用到蓝牙开发,具体蓝牙获取硬件传感器中的数据. 因为没有蓝牙开发的相关经验,决定先了解一些蓝牙开发的知识,再去看之前同事写的蓝牙相关代码. ------------------------- ...
- Bluetooth Low Energy 嗅探
Bluetooth Low Energy 嗅探 路人甲 · 2015/10/16 10:52 0x00 前言 如果你打开这篇文章时期望看到一些新的东西,那么很抱歉这篇文章不是你在找的那篇文章.因为严格 ...
- 例子:Bluetooth app to device sample
本例子演示了: 判断蓝牙是否打开,是通过一个HRsult值为0x8007048F的异常来判断的 catch (Exception ex) { if ((uint)ex.HResult == 0x800 ...
- core Bluetooth(蓝牙4.0)
蓝牙4.0以低功耗著称,一般也叫BLE(Bluetooth Low Energy). 目前主要应用的场景有:智能家居.运动手环和室内导航等. 利用core Bluetooth框架可以实现苹果设备与第三 ...
- Find out files transfered via Bluetooth
The case was about business secret and forensic guy did a physical acquisition from a smart phone. H ...
- 蓝牙(Bluetooth) IEEE 802.15.1 协议学习
catalogue . 蓝牙概念 . 配对和连接 . 机密安全性 . 蓝牙协议分类 . 蓝牙协议栈 1. 蓝牙概念 蓝牙(Bluetooth)是一种无线技术标准,可实现固定设备.移动设备和楼宇个人域网 ...
- Overview and Evaluation of Bluetooth Low Energy: An Emerging Low-Power Wireless Technology
转自:http://www.mdpi.com/1424-8220/12/9/11734/htm Sensors 2012, 12(9), 11734-11753; doi:10.3390/s12091 ...
- bluetooth service uuid
转自:https://www.bluetooth.com/specifications/assigned-numbers/service-discovery service discovery ...
- bluetooth 蓝牙协议和标准,配置
Bluetooth 配置文件表达了一般行为,Bluetooth 设备可以通过这些行为与其它设备进行通信.Bluetooth 技术定义了广泛的配置文件,描述了许多不同类型的使用案例.为了使用 Bluet ...
随机推荐
- Macbook之设置Finder显示文件完整路径
终端里输入:defaults write com.apple.finder _FXShowPosixPathInTitle -bool TRUE;killall Finder 回复输入:default ...
- 【php基础】XML,DTD实例
要求一:能看懂别人写的DTD文件,自己能写更好.例如products.dtd: <!ENTITY AUTHOR "John Doe"> <!ENTITY COMP ...
- 获取动态SQL的返回结果
1. 介绍说明 有时候在执行存储过程后,需要获取存储过程返回的列表,然后进行相应操作的情况,或者执行动态语句,获取返回结果的情况,通过EXEC ,sp_executesql可以实现该功能. 网上也有很 ...
- 零基础Android学习笔记-01 安卓开发环境搭建
安卓开发环境搭建. 1.首先准备JDK,从官网找到JDK下载地址,原来做.NET不熟悉JAVA,干脆用最新的,下载了JDK 1.7的版本.原来装过1.5还要配置环境变量什么的.但1.7好像很给力,装好 ...
- Spring中Quartz的配置
Quartz是一个强大的企业级任务调度框架,Spring中继承并简化了Quartz,下面就看看在Spring中怎样配置Quartz: 首先,来写一个测试被调度的类:(QuartzHelloWorldJ ...
- PowerDesigner数据库建模工具一缆
转自:http://blog.csdn.net/shanliwa/archive/2007/10/20/1834117.aspx Sybase PowerDesigner - 一个高端数据建模工具.你 ...
- 学习 AngularJS 第一天
AngularJS 高级程序设计 遇到问题:安装web服务器 var connect = require("connect"); connect.createServer( con ...
- [javascript|基本概念]学习笔记
1/语法 a.区分大小写 b.标识符(首字符必须是字母/"_"/"$",其他可为字母/"_"/"$"/数字,不能用关键字 ...
- 方法:一个简单的读取配置文件.properties的工具类 JAVA
import java.util.ResourceBundle; public class ConfigHelper { private static ConfigHelper instance; p ...
- 存储过程及Comm.cs类的创建
2013-09-25 13:08:59 一.准备工作 首先创建一个数据库,如创建“试用期公务员管理”数据库:再创建一个Comm.cs类,添加代码如下: using System;using Syste ...