资源介绍
ESP32 蓝牙开发资料,用于了解ESP32内部的蓝牙实现。
本⼿册为 ESP32 的蓝⽛架构简介,主要分三个章节介绍了蓝⽛、经典蓝⽛和蓝⽛低功耗
⽅⾯的整体架构。注意,本⼿册仅针对 ESP-IDF V2.1 及以下版本。
⽬录
1. 蓝⽛ 1 .........................................................................................................................................
1.1. 概述 ............................................................................................................................................1
1.1.1. 蓝⽛应⽤结构 ................................................................................................................1
1.1.2. HCI 接⼝选择 ................................................................................................................2
1.1.3. 蓝⽛运⾏环境 ................................................................................................................3
1.2. 框架 ............................................................................................................................................4
1.2.1. 控制器 ...........................................................................................................................4
1.2.2. BLUEDROID .................................................................................................................4
1.2.2.1. 主机架构 ................................................................................................................4
1.2.2.2. OS 相关适配..........................................................................................................6
1.2.3. 蓝⽛⽬录........................................................................................................................6
2. 经典蓝⽛ 9 .................................................................................................................................
2.1. 概述 ............................................................................................................................................9
2.2. 协议和规范 ...............................................................................................................................10
2.2.1. L2CAP.........................................................................................................................10
2.2.2. SDP.............................................................................................................................10
2.2.3. GAP.............................................................................................................................10
2.2.4. A2DP 和 AVRCP .........................................................................................................11
3. 蓝⽛低功耗 14 ............................................................................................................................
3.1. GAP..........................................................................................................................................14
3.1.1. 概述.............................................................................................................................14
3.1.2. BLE 设备⻆⾊转换状态图............................................................................................15
3.1.3. BLE ⼴播流程..............................................................................................................16
3.1.3.1. 使⽤ public 地址进⾏⼴播...................................................................................16
3.1.3.2. 使⽤可解析地址进⾏⼴播....................................................................................17
3.1.3.3. 使⽤静态随机地址进⾏⼴播 ................................................................................18
3.1.4. BLE ⼴播类型介绍.......................................................................................................19
3.1.4.1. 可连接可扫描⾮定向⼴播....................................................................................19
3.1.4.2. ⾼占空⽐定向⼴播和可连接低占空⽐定向⼴播 ...................................................19
3.1.4.3. 可扫描⾮定向⼴播...............................................................................................20
3.1.4.4. 不可连接⾮定向⼴播 ...........................................................................................20
3.1.5. BLE ⼴播过滤策略介绍 ...............................................................................................20
3.1.6. BLE 扫描流程..............................................................................................................21
3.1.7. BLE GAP 实现机制 .....................................................................................................21
3.2. GATT ........................................................................................................................................21
3.2.1. ATT 属性协议 .............................................................................................................21
3.2.2. GATT 规范...................................................................................................................23
3.2.3. 基于 ESP32 IDF 建⽴ GATT 服务(GATT 服务器) ....................................................25
3.2.4. 基于 ESP32 IDF 发现对⽅设备的服务信息(GATT 客户端)......................................26
3.3. SMP .........................................................................................................................................27
3.3.1. 概述.............................................................................................................................27
3.3.2. BLE 安全管理控制器...................................................................................................27
3.3.2.1.BLE 加密流程 .......................................................................................................27
3.3.2.2.BLE 绑定流程 .......................................................................................................30
3.3.3. BLE 安全管理实现机制 .............................