蓝牙核心框架 | bluetooth

Bluetooth core system architecture

蓝牙核心系统由一个 Host,一个Primary Controller 和0个或多个Secondary Controllers组成。

image

Link Manager, Link Controller and BR/EDR Radio blocks comprise a BR/EDR Controller.
An AMP PAL, AMP MAC, and AMP PHY comprise an AMP Controller.
Link Manager, Link Controller and LE Radio blocks comprise an LE Controller.
L2CAP, SDP and GAP blocks comprise a BR/EDR Host.
L2CAP, SMP, Attribute protocol, GAP and Generic Attribute Profile (GATT) blocks comprise an LE Host.
A BR/EDR/LE Host combines the set of blocks from each respective Host.

蓝牙核心协议有:
* Radio (PHY) protocol
* Link Control (LC) and Link Manager (LM) protocol or Link Layer (LL) protocol
* AMP PAL
* Logical Link Control and Adaptation protocol (L2CAP)
* AMP Manager Protocol

另外,Service Discovery Protocol (SDP)和Attribute Protocol (ATT)是应用层协议。

core architectural blocks

这里介绍核心体系结构的组成部分。

Host Architectural Blocks

BR/EDR and LE 体系有一部分是共用,有一部分是各自实现。

  • Channel Manager
  • L2CAP Resource Manager
  • Security Manager Protocol
  • Attribute Protocol
  • AMP Manager Protocol
  • Generic Attribute Profile
    GATT is used on LE devices for LE profile service discovery.
  • Generic Access Profile

BR/EDR/LE Controller Architectural Blocks

BR/EDR and LE 体系有一部分是共用,有一部分是各自实现。

  • Device Manager
  • Link Manager
    Link Manager Protocol (LMP) in BR/EDR and the Link Layer Protocol (LL) in LE
  • Baseband Resource Manager
  • Link Controller
  • PHY

AMP Controller architectural blocks

  • AMP HCI
  • AMP PAL
  • AMP MAC
  • AMP PHY

更多

更多内容参考:蓝牙学习汇总

BluetoothKit是一款功能强大的Android蓝牙通信框架,支持经典蓝牙和低功耗蓝牙设备混合扫描,提供了一系列简单易用的接口用于低功耗蓝牙设备的连接,数据读写,通知等。 特点 一、支持经典蓝牙和BLE蓝牙混合扫描,支持自定义扫描策略  作为智能家居平台,接入的设备包括经典蓝牙和BLE,因此扫描设备时需要两者混合进行,而设备扫描场景不同,扫描策略也会不一样,因此需要支持扫描策略可配置。 二、充分解决了Android中BLE兼容性和稳定性问题  Android系统对蓝牙4.0支持得并不完善,有许多bug, BluetoothKit很好地解决了其中大部分已知的问题。  三、简单易用,接口简洁明了  BluetoothKit采用异步串行化策略处理所有设备操作,并支持任务超时及出错重试。  技术 一、实现了一个完整的跨进程异步任务队列,支持任务超时、出错重试及防御队列溢出 二、拦截并Hook系统层蓝牙Binder,实现对所有蓝牙设备通信的监控,当同时连接设备数过多时会自动断掉活跃度最低的设备 三、整个框架封装在一个service中,可灵活指定service所在进程。通过client与service通信,client可源于多个不同进程,因此适用于多进程架构的app 四、屏蔽了接口异步回调可能持有调用端Activity引用导致的内存泄露 五、利用动态代理自动将所有操作封闭在工作线程,所以整个框架无锁 使用 // 首先,需要按如下方式初始化BluetoothClient: BluetoothClient mClient = BluetoothClient.getInstance(context); // 扫描设备:支持经典蓝牙和BLE设备混合扫描,可自由定制扫描策略如下: SearchRequest request = new SearchRequest.Builder() .searchBluetoothLeDevice(3000, 3) .searchBluetoothClassicDevice(5000) .searchBluetoothLeDevice(2000) .build(); mClient.search(request, new SearchResponse() { @Override public void onSearchStarted() { } @Override public void onDeviceFounded(SearchResult device) { } @Override public void onSearchStopped() { } @Override public void onSearchCanceled() { } }); // 停止蓝牙扫描 mClient.stopSearch(); // BLE设备连接 mClient.connect(MAC, new BleConnectResponse() { @Override public void onResponse(int code, Bundle data) { if (code == REQUEST_SUCCESS) { } } }); // BLE设备断开连接 mClient.disconnect(MAC); // 读取BLE设备 mClient.read(MAC, serviceUUID, characterUUID, new BleReadResponse() { @Override public void onResponse(int code, byte[] data) { if (code == REQUEST_SUCCESS) { } } }); // 写BLE设备 mClient.write(MAC, serviceUUID, characterUUID, bytes, new BleWriteResponse() { @Override public void onResponse(int code) { if (code == REQUEST_SUCCESS) { } } }); // 打开设备通知 mClient.notify(MAC, serviceUUID, characterUUID, new BleNotifyResponse() { @Override public void onNotify(UUID service, UUID character, byte[] value) { } @Override public void onResponse(int code) { if (code == REQUEST_SUCCESS) { } } }); // 关闭设备通知 mClient.unnotify(MAC, serviceUUID, characterUUID, new BleUnnotifyResponse() { @Override public void onResponse(int code) { if (code == REQUEST_SUCCESS) { } } }); // 读取rssi mClient.readRssi(MAC, new BleReadRssiResponse() { @Override public void onResponse(int code, Integer rssi) { if (code == REQUEST_SUCCESS) { } } }); 标签:BluetoothKit
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值