Silicon Labs Bluetooth LE SDK v3.x 是一套完整的软件开发套件,基于先进的 Bluetooth 5-compliant 协议栈,支持多连接及并发的 Central、Peripheral、Broadcaster 和 Observer 角色。本文档为开发者提供 SDK 整体架构说明、三种部署模式的介绍,以及 SDK 内置 Demos 与示例应用的完整列表。Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dsyx/docs.silabs.com_zh/llms.txt
Use this file to discover all available pages before exploring further.
关于 Bluetooth Stack
v3.x Silicon Labs Bluetooth Stack 适用于 Silicon Labs EFR32 SoCs 和 Modules,为开发者提供多套 API 以访问 Bluetooth 功能。其核心特性涵盖 GAP、连接管理、Security Manager、GATT Client/Server,以及 DTM、PS Store、DFU 和 System 等辅助功能模块。当前文档版本适用于 Simplicity Studio 5 和 Bluetooth SDK v3.x(Gecko SDK v4.x)。如使用 Simplicity Studio 4,请参阅 v2.13 文档。
三种运行模式
Silicon Labs Bluetooth Stack 支持以下三种运行模式,开发者可根据硬件资源和应用需求灵活选择。- Standalone 模式
- NCP 模式
- RCP 模式
Bluetooth Stack 和应用程序均在 EFR32 SoC 或 Module 上运行。应用程序使用 C 语言开发,直接调用 BGAPI 函数与协议栈交互。适用场景:片上资源充足、无需外部 Host 的独立设备(如传感器节点、Beacon 设备)。特点:
- 单芯片方案,系统最简化
- 直接访问所有硬件外设
- 支持最低功耗睡眠模式(EM2)
BGAPI 串行协议
在 NCP 模式下,可通过 BGAPI 串行协议控制 Bluetooth Stack。该协议是一个轻量级二进制协议,将 BGAPI 命令从 Host 传输到 Stack,并将响应和事件从 Stack 传回 Host。| 字节位置 | Byte 0 | Byte 1 | Byte 2 | Byte 3 | Byte 4–255 |
|---|---|---|---|---|---|
| 说明 | 消息类型 | 最小载荷长度 | 消息类别 | 消息 ID | 载荷 |
| 命令 | 0x20 | 0x00–0xFF | 0x00–0xFF | 0x00–0xFF | 命令专用数据 |
| 响应 | 0x20 | 0x00–0xFF | 0x00–0xFF | 0x00–0xFF | 响应专用数据 |
| 事件 | 0xA0 | 0x00–0xFF | 0x00–0xFF | 0x00–0xFF | 事件专用数据 |
SDK 主要内容
库文件(Libraries)
库文件(Libraries)
以下库随 Bluetooth SDK 一起交付,必须包含在 C 应用程序项目中:
| 库文件 | 说明 | 是否必选 |
|---|---|---|
libbluetooth.a | Bluetooth Stack 主库 | 是 |
librail_efr32xgXX_gcc_release.a | 对应平台的 RAIL GCC 库 | 是(GCC 项目) |
librail_efr32xgXX_iar_release.a | 对应平台的 RAIL IAR 库 | 是(IAR 项目) |
libpsstore.a | PS Store 功能(Series 1) | Series 1 必选 |
libnvm3_CM33_gcc/iar.a | NVM3(Series 2) | Series 2 必选 |
binapploader.o | OTA AppLoader | 可选 |
libcoex.a | Wi-Fi 和 Bluetooth 共存 | 可选 |
平台组件(Platform Components)
平台组件(Platform Components)
| 目录 | 说明 |
|---|---|
bootloader | Gecko Bootloader 源码和项目文件 |
CMSIS | Silicon Labs CMSIS-CORE 设备头文件 |
emdrv | 基于 DMA 的高性能外设驱动 |
emlib | 统一的低层外设支持库 |
micrium_os | Micrium OS |
radio | Silicon Labs RAIL 库 |
service | Sleeptimer 驱动与配置文件 |
Demos 和 Examples
所显示的 Demos 和 Examples 取决于所选部件。可在 Simplicity Studio 启动器视图的 Example Projects & Demos 选项卡中访问。名称中带有 (*) 的示例具有对应的预构建 Demo。
Bluetooth SoC 示例
Bluetooth SoC 示例
- Bluetooth – SoC Blinky(*): 经典 Blinky 示例,通过 EFR Connect App 控制 LED,演示双向 GATT 数据交换。
- Bluetooth – SoC Empty: 最小项目结构,作为自定义 Bluetooth 应用的起点,包含最小 GATT 数据库。
- Bluetooth – SoC Thermometer(*): 实现 Health Thermometer Profile 的 GATT Server,从 Si7021 传感器读取温度数据。
- Bluetooth – SoC Thermometer Client: GATT Client,可发现并连接最多 4 个 Thermometer Server 设备。
- Bluetooth – SoC Thermometer FreeRTOS: 演示 FreeRTOS 与 Bluetooth 应用的集成。
- Bluetooth – SoC Thermometer Micrium OS: 演示 Micrium RTOS 与 Bluetooth 应用的集成。
- Bluetooth – SoC Throughput(*): 测试设备吞吐量,可与两个 EFR32 设备或智能手机进行测试。
- Bluetooth – SoC iBeacon(*): 发送不可连接的 iBeacon 格式广告包。
- Bluetooth – SoC DTM: 实现直接测试模式(DTM),用于无线电测试。
- Bluetooth – SoC AoA Asset Tag(*): CTE 发射器,用于 AoA 方向测定。
- Bluetooth – SoC Voice(*): 通过 BLE 发送音频数据(支持 Thunderboard Sense 2/EFR32BG22)。
Bluetooth NCP 示例
Bluetooth NCP 示例
- Bluetooth – NCP(*): NCP 目标应用,通过 UART 暴露完整 BGAPI,支持动态 GATT。
- Bluetooth – NCP Empty(*): NCP 目标应用,包含最小静态 GATT 数据库。
- Bluetooth – NCP Host: NCP Host 参考实现,使用动态 GATT 特性。
- Bluetooth – NCP AoA Locator(*): NCP 目标,扩展了 CTE Receiver 支持,用于 AoA 计算。
- Bluetooth – RCP: Radio Co-Processor 目标,仅运行 Link 层,通过 UART HCI 暴露。
动态多协议(DMP)示例
动态多协议(DMP)示例
- Bluetooth – SoC Empty RAIL DMP FreeRTOS/Micrium OS: Bluetooth + 专有协议 DMP 起始项目。
- Bluetooth – SoC Empty Standard DMP FreeRTOS/Micrium OS: Bluetooth + IEEE 802.15.4 标准协议 DMP 起始项目。
- Bluetooth – SoC Light RAIL DMP FreeRTOS(*): 演示灯泡可通过 Bluetooth 或专有协议切换的 DMP 参考应用。
- Bluetooth – SoC Light Standard DMP FreeRTOS(*): 演示灯泡可通过 Bluetooth 或标准协议切换的 DMP 参考应用。
NCP Host 示例(host 端)
NCP Host 示例(host 端)
位于
app/bluetooth/examples_host 目录:- empty: 最小 Host 端项目结构,与 NCP 固件配合使用。
- ota-dfu: 演示对 Silicon Labs Bluetooth 设备执行 OTA DFU。
- uart-dfu: 演示对运行 NCP 固件的设备执行 UART DFU。
- voice: 连接 SoC Voice 示例,接收音频并存储为文件。
- aoa_locator: 与 NCP AoA Locator 目标配合,接收 IQ 样本并估算 AoA。
- throughput: 在 NCP 模式下测试设备吞吐量。
快速跳转
BLE 基础
了解 BLE 技术架构、GAP 角色、GATT 协议、广播与连接参数,以及安全配对机制。
快速入门指南
使用 Simplicity Studio 5 和 SDK v3.x 快速创建第一个 Bluetooth 应用项目。
C 应用开发指南
深入了解 Bluetooth Stack 架构、事件处理、Stack 配置与资源消耗分析。
GATT Configurator
使用可视化工具构建 GATT 数据库,添加 Service 和 Characteristic。