蓝牙概述

蓝牙基础架构

蓝牙分为 BT Host、HCI (Host Controller Interface) 和 BT Controller 三部分:

模块

描述

BT Host

Application

包含蓝牙 APIs,以及由此实现的 Peripheral、Central、Scatternet、Mesh、A2DP、LE Audio 等应用

Framework

包含以下 lib:

  • LE audio lib:\component\bluetooth\rtk_stack\platform\amebaxxx\lib\(km4\kr4\ca32)\leaudio.a

  • BLE mgr lib:\component\bluetooth\rtk_stack\platform\amebaxxx\lib\(km4\kr4\ca32)\ble_mgr.a

  • BT mgr lib:\component\bluetooth\rtk_stack\platform\amebaxxx\lib\(km4\kr4\ca32)\bt_mgr.a

  • system lib:\component\bluetooth\rtk_stack\platform\amebaxxx\lib\(km4\kr4\ca32)\sysm.a

各 lib 的作用:

  • LE audio lib & BLE mgr lib:实现了 BAP 和 CAP,以及 LE audio 依赖的 BLE profile

  • BT mgr lib:实现了 BR/EDR profile

  • system lib:提供一些系统相关的功能

Host stack

lib 路径:\component\bluetooth\rtk_stack\platform\amebaxxx\lib\(km4\kr4\ca32)\(ble_only\dual_mode)\btgap.a

实现了蓝牙上层协议栈的功能,包括 GAP、GATT、L2CAP、ATT 和 SMP 等

HCI

Controller 与 Host 唯一的通信接口,两者之间的所有数据交互都通过该接口完成

BT Controller

lib 路径:\component\bluetooth\driver\platform\amebaxxx\hci\bt_normal_patch.c

以二进制数组形式提供,实现了蓝牙下层协议栈的功能,包括 Link Layer 和 PHY

蓝牙的基础架构如下图所示:

../../_images/bt_architecture.svg

蓝牙功能支持列表

Item Feature Supported
Physical BR/EDR /
BLE
BLE 4.0 Advertiser
Scanner
Initiator
Master
Slave
Link Layer Encryption
BLE Max. Link (Theoretical value) 8 Master + 3 Slave
BLE 4.1 Low Duty Cycle Directed Advertising
MWS Coexistence /
LE Ping
LE Link Layer Topology
LE Scatternet
BLE 4.2 LE Data Length Extension
LE Secure Connection
Link Layer Privacy
Link Layer Extended Scanner Filter Policies
BLE 5.0 LE 2Mbps PHY
LE Long Range
LE Advertising Extensions
LE Channel Selection Algorithm #2
High Duty Cycle Non-Connectable Advertising
LE Periodic Advertising /

蓝牙功能配置

功能

配置文件

配置项

Link Layer Privacy

以 Peripheral 为例:

\component\bluetooth\example\ble_peripheral\peripheral.c

修改 privacy_enabletrue

LE Advertising Extensions

\component\bluetooth\api\include\bt_api_config.h

修改 RTK_BLE_5_0_AE_ADV_SUPPORTRTK_BLE_5_0_AE_SCAN_SUPPORT1

LE Periodic Advertising

\component\bluetooth\api\include\bt_api_config.h

修改相应 SoC 的 RTK_BLE_5_0_AE_ADV_SUPPORTRTK_BLE_5_0_AE_SCAN_SUPPORTRTK_BLE_5_0_PA_ADV_SUPPORTRTK_BLE_5_0_PA_SYNC_SUPPORT1

Periodic Advertising Sync Transfer (PAST)

\component\bluetooth\api\include\bt_api_config.h

修改相应 SoC 的 RTK_BLE_5_0_AE_ADV_SUPPORTRTK_BLE_5_0_AE_SCAN_SUPPORTRTK_BLE_5_0_PA_ADV_SUPPORTRTK_BLE_5_0_PA_SYNC_SUPPORT

RTK_BLE_5_1_PAST_SENDER_SUPPORTRTK_BLE_5_1_PAST_RECIPIENT_SUPPORT1

SMP OOB

\component\bluetooth\api\include\bt_api_config.h

默认开启,修改 RTK_BLE_SMP_OOB_SUPPORT0 关闭

LE Data Length Extension

\component\bluetooth\api\include\bt_api_config.h

默认开启,修改 RTK_BLE_4_2_DATA_LEN_EXT_SUPPORT0 关闭

SET PHYS

\component\bluetooth\api\include\bt_api_config.h

默认开启,修改 RTK_BLE_5_0_SET_PHYS_SUPPORT0 关闭

LE Power Control

\component\bluetooth\api\include\bt_api_config.h

修改 RTK_BLE_5_2_POWER_CONTROL_SUPPORT1

EATT

\component\bluetooth\api\include\bt_api_config.h

修改 RTK_BT_5_2_EATT_SUPPORT1