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.h and hardware/libhardware/include/hardware/bt_*.h files.
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 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.

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-vendor module. See the vendor/broadcom/libbt-vendor 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 the external/bluetooth/hci directory for an example.

http://source.android.com/devices/bluetooth.html

Bluetooth的更多相关文章

  1. 蓝牙Bluetooth技术小知识

    蓝牙Bluetooth技术以及广泛的应用于各种设备,并将继续在物联网IoT领域担任重要角色.下面搜集整理了一些关于蓝牙技术的小知识,以备参考. 蓝牙Bluetooth技术始创于1994年,其名字来源于 ...

  2. 浅谈Bluetooth蓝牙开发

    前言:项目用到蓝牙开发,具体蓝牙获取硬件传感器中的数据. 因为没有蓝牙开发的相关经验,决定先了解一些蓝牙开发的知识,再去看之前同事写的蓝牙相关代码. ------------------------- ...

  3. Bluetooth Low Energy 嗅探

    Bluetooth Low Energy 嗅探 路人甲 · 2015/10/16 10:52 0x00 前言 如果你打开这篇文章时期望看到一些新的东西,那么很抱歉这篇文章不是你在找的那篇文章.因为严格 ...

  4. 例子:Bluetooth app to device sample

    本例子演示了: 判断蓝牙是否打开,是通过一个HRsult值为0x8007048F的异常来判断的 catch (Exception ex) { if ((uint)ex.HResult == 0x800 ...

  5. core Bluetooth(蓝牙4.0)

    蓝牙4.0以低功耗著称,一般也叫BLE(Bluetooth Low Energy). 目前主要应用的场景有:智能家居.运动手环和室内导航等. 利用core Bluetooth框架可以实现苹果设备与第三 ...

  6. Find out files transfered via Bluetooth

    The case was about business secret and forensic guy did a physical acquisition from a smart phone. H ...

  7. 蓝牙(Bluetooth) IEEE 802.15.1 协议学习

    catalogue . 蓝牙概念 . 配对和连接 . 机密安全性 . 蓝牙协议分类 . 蓝牙协议栈 1. 蓝牙概念 蓝牙(Bluetooth)是一种无线技术标准,可实现固定设备.移动设备和楼宇个人域网 ...

  8. 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 ...

  9. bluetooth service uuid

    转自:https://www.bluetooth.com/specifications/assigned-numbers/service-discovery service discovery ​​​ ...

  10. bluetooth 蓝牙协议和标准,配置

    Bluetooth 配置文件表达了一般行为,Bluetooth 设备可以通过这些行为与其它设备进行通信.Bluetooth 技术定义了广泛的配置文件,描述了许多不同类型的使用案例.为了使用 Bluet ...

随机推荐

  1. 使用Xcode5开发时的icon取消高光效果

    .在General中App Icons 使用Source--> AppIcon .在Images.xcassets 中依次添加对应尺寸的icon. .选中AppIcon ,在右侧第三个按钮下,勾 ...

  2. 数理方程:Laplace变换 & 留数(更新中)

    更新:25 APR 2016 Laplace变换 设函数\(f(t)\)在\(t>0\)时有定义,积分 \(F(s)=\int_0^{+\infty}f(t)e^{-st}dt \qquad ( ...

  3. MySQL分区表的使用

    MySQL使用分区表的好处: 1,可以把一些归类的数据放在一个分区中,可以减少服务器检查数据的数量加快查询. 2,方便维护,通过删除分区来删除老的数据. 3,分区数据可以被分布到不同的物理位置,可以做 ...

  4. JavaScript--基本包装类型(13)

    // JS为了便于操作基本类型,提供了3个特殊的引用类型:Boolean/Number和String; 一 基本包装类型概述 // 实际上,每当读取一个基本类型值的时候,后台就会创建一个对应的基本包装 ...

  5. 一.CSS工作原理

    CSS全称层叠样式表,它是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言.是能够真正做到网页表现与内容分离的一种样式设计语言,能够对网页 ...

  6. VMware Workstation CentOS-6.4-x86_64-minimal 配置网络以及安装JDK和tomcat

    1.配置网络(能够联网)转自:http://blog.sina.com.cn/s/blog_75ad10100101ma4c.html 1)vmware的网卡连接方式选择为桥接(bridged)不要用 ...

  7. Cocos2d-x 3.x的Windows Phone 8工程

    Cocos2d-x 3.x中我们使用的Cocos2d-x 3.2,它提供了Windows Phone 8平台的支持.下面我们介绍一下在Cocos2d-x 3.2中如何生成Cocos2d-x的Windo ...

  8. Objective-C排序算法实现

    算法作为程序猿的一种基本技能,对我来说却一直是一个硬伤.毕竟平时的工作接触算法的地方很少,大部分时间都是在搭建UI,写业务逻辑,写网络请求.然而在面试当中,算法往往又是考察的重点. 也许你会说这些平时 ...

  9. dropdownlist值改变时调用js

    DropDownList的OnSelectedIndexChanged方法是服务器端方法如要用需要设置AutoPostBack选项为true,并且在服务器后台写方法 要调用js方法需要onchange ...

  10. ES6新增Promise

    1.promise概念 ES6 原生提供了 Promise 对象. 所谓 Promise,就是一个对象,用来传递异步操作的消息.它代表了某个未来才会知道结果的事件(通常是一个异步操作),并且这个事件提 ...