Skip to content

在 ESP-IDF 中,蓝牙配置是一个复杂的过程,涉及到多个模块和选项。以下是对您提供的配置选项的详细解释,按功能模块划分,帮助您更好地理解每个选项的作用和意义。


1. Bluetooth 主配置

Bluetooth Host

  • NimBLE - BLE only 选择 NimBLE 作为蓝牙协议栈,仅支持低功耗蓝牙(BLE)功能。
    • Controller:启用控制器功能,用于处理蓝牙的物理层和链路层操作。
    • Enabled:启用 NimBLE 功能。
    • NimBLE Options:NimBLE 的高级配置选项。

Memory allocation strategy

  • Internal memory:选择使用内部内存进行资源分配。

NimBLE Host log verbosity

  • Info logs:设置日志级别为信息级别,用于调试和监控。

Maximum number of concurrent connections

  • 3:最多支持 3 个并发连接。

Maximum number of bonds to save across reboots

  • 3:最多保存 3 个配对记录,即使在设备重启后仍然有效。

Maximum number of CCC descriptors to save across reboots

  • 8:最多保存 8 个 CCC(Client Characteristic Configuration)描述符,用于通知和指示功能。

Maximum number of connection oriented channels

  • 0:不支持连接导向型通道(L2CAP)。

The CPU core on which NimBLE host will run

  • Core 0 (PRO CPU):指定 NimBLE 主机运行在 PRO CPU 核心。

NimBLE Host task stack size

  • 4096:为 NimBLE 主机任务分配 4096 字节的堆栈空间。

2. BLE 角色和功能

Enable BLE Central role

  • 启用 BLE 中央设备角色,用于连接和控制外围设备。

Enable BLE Peripheral role

  • 启用 BLE 外围设备角色,用于被中央设备连接。

Enable BLE Broadcaster role

  • 启用广播者角色,用于发送广播数据,但不接受连接。

Enable BLE Observer role

  • 启用观察者角色,用于扫描广播数据,但不发起连接。

Persist the BLE Bonding keys in NVS

  • 在 NVS(非易失性存储)中保存配对密钥,即使设备重启后仍然保留配对信息。

Reset device identity when all bonding records are deleted

  • 当所有配对记录被删除时,重置设备身份。

Enable BLE SM feature

  • 启用安全管理模式,支持配对和加密功能。

Security manager legacy pairing

  • 启用传统配对模式(Bluetooth 4.0)。

Security manager secure connections (4.2)

  • 启用安全连接模式(Bluetooth 4.2)。

Use predefined public-private key pair

  • 使用预定义的公钥和私钥对。

Enable LE encryption

  • 启用低功耗蓝牙加密功能。

Security level

  • 0:设置安全级别为 0(无加密)。

3. BLE GAP 和 GATT 配置

BLE GAP default device name

  • nimble:默认设备名称为 "nimble"。

Maximum length of BLE device name in octets

  • 31:设备名称的最大长度为 31 字节。

Preferred MTU size in octets

  • 256:首选的 MTU(最大传输单元)大小为 256 字节。

External appearance of the device

  • 0:设备外观设置为 0(无特定外观)。

Maximum number of GATT client procedures

  • 4:最多支持 4 个 GATT 客户端操作。

Enable GATT caching

  • 启用 GATT 缓存功能,用于优化性能。

BLE white list size

  • 12:白名单大小为 12 个设备。

Enable BLE 5 feature

  • 启用 Bluetooth 5.0 特性,如 2M PHY 和 Coded PHY。

Enable 2M Phy

  • 启用 2M PHY,提高传输速率。

Enable coded Phy

  • 启用 Coded PHY,用于长距离通信。

Enable extended advertising

  • 启用扩展广播功能。

Enable extended scanning

  • 启用扩展扫描功能。

Enable periodic sync

  • 启用周期性同步功能。

Maximum number of periodic advertising syncs

  • 0:不支持周期性广播同步。

4. BLE 安全和加密

Enable BLE SM feature

  • 启用安全管理模式,支持配对和加密。

Security level

  • 0:设置安全级别为 0(无加密)。

Enable LE encryption

  • 启用低功耗蓝牙加密功能。

Security manager legacy pairing

  • 启用传统配对模式。

Security manager secure connections (4.2)

  • 启用安全连接模式(Bluetooth 4.2)。

5. BLE 性能和调试

Enable extra runtime asserts and host debugging

  • 启用额外的运行时断言和主机调试功能,用于开发和调试。

Enable dynamic services

  • 启用动态服务功能,允许动态添加和删除 GATT 服务。

Enable connection reattempts on connection establishment error

  • 在连接建立失败时,尝试重新建立连接。

Maximum number connection reattempts

  • 3:最多尝试 3 次重新连接。

RPA timeout in seconds

  • 900:RPA(随机私有地址)超时时间为 900 秒。

BLE host stop timeout in msec

  • 2000:BLE 主机停止超时时间为 2000 毫秒。

6. BLE Mesh 和其他高级功能

Enable BLE mesh functionality

  • 启用 BLE Mesh 功能,用于构建低功耗蓝牙网格网络。

Override TinyCrypt with mbedTLS for crypto computations

  • 使用 mbedTLS 替代 TinyCrypt 进行加密计算。

Enable blufi functionality

  • 启用 blufi 功能,用于通过 BLE 进行设备配置和固件更新。

Enable Esp Timer for Nimble

  • 启用 ESP Timer 功能,用于 NimBLE 的定时操作。

7. BLE 控制器配置

The cpu core which bluetooth controller run

  • Core 0 (PRO CPU):指定蓝牙控制器运行在 PRO CPU 核心。

HCI mode

  • VHCI:使用虚拟 HCI 模式,通过主机接口与控制器通信。

BLE Max Instances

  • 6:最多支持 6 个 BLE 实例。

BLE static ACL TX buffer numbers

  • 0:不使用静态 ACL TX 缓冲区。

BLE default Tx power level

  • +9dBm:默认发射功率为 +9dBm。

BLE adv report flow control supported

  • 启用广播报告流控制功能。

BLE adv report flow control number

  • 100:广播报告流控制的数量为 100。

BLE adv lost event threshold value

  • 20:广播丢失事件的阈值为 20。

8. BLE 扫描和过滤

BLE Scan Duplicate Options

  • Scan Duplicate Type:扫描重复类型设置为按设备地址过滤。
  • Maximum number of devices in scan duplicate filter:扫描重复过滤器中最多支持 100 个设备。
  • Duplicate scan list refresh period (seconds):重复扫描列表刷新周期为 0 秒(不刷新)。

Special duplicate scan mechanism for BLE Mesh scan

  • 为 BLE Mesh 扫描启用特殊重复扫描机制。

9. BLE 资源和内存配置

Memory Settings

  • MSYS_1 Block Count:MSYS_1 块数量为 12。
  • MSYS_1 Block Size:MSYS_1 块大小为 256 字节。
  • MSYS_2 Block Count:MSYS_2 块数量为 24。
  • MSYS_2 Block Size:MSYS_2 块大小为 320 字节。
  • ACL Buffer count:ACL 缓冲区数量为 24。
  • Transport ACL Buffer size:传输 ACL 缓冲区大小为 255 字节。
  • Transport Event Buffer size:传输事件缓冲区大小为 70 字节。
  • Transport Event Buffer count:传输事件缓冲区数量为 30。
  • Discardable Transport Event Buffer count:可丢弃的传输事件缓冲区数量为 8。

10. BLE 传输和调试

Host-controller Transport

  • Uart Flow Control:禁用 UART 流控制。
  • UART Rts Pin:UART RTS 引脚为 GPIO 19。
  • UART Cts Pin:UART CTS 引脚为 GPIO 23。

Enable Bluetooth HCI debug mode

  • 启用 Bluetooth HCI 调试模式,用于开发和调试。

Maximum number of Bluetooth alarms

  • 50:最多支持 50 个蓝牙定时器。

11. BLE GAP 和 GATT 高级配置

GAP Service

  • GAP Appearance write permissions:允许写入 GAP 外观属性。
  • GAP Characteristic - Central Address Resolution:不支持中央地址解析功能。
  • GAP device name write permissions:允许写入设备名称。

PPCP Connection Interval Max (Unit: 1.25 ms)

  • 最大连接间隔为 0(默认值)。

PPCP Connection Interval Min (Unit: 1.25 ms)

  • 最小连接间隔为 0(默认值)。

PPCP Slave Latency

  • 从机延迟为 0(默认值)。

PPCP Supervision Timeout (Uint: 10 ms)

  • 监督超时时间为 0(默认值)。

12. BLE Mesh 和其他高级功能

ESP BLE Mesh Support

  • 启用 ESP BLE Mesh 支持,用于构建低功耗蓝牙网格网络。

Enable support for VSC and VSE

  • 启用对 VSC(供应商特定命令)和 VSE(供应商特定事件)的支持。

Encrypted Advertising Data

  • 启用加密广播数据功能。

Enable BLE high duty advertising interval feature

  • 启用高占空比广播功能。

Allow Connections with scanning in progress

  • 允许在扫描过程中接受连接。

BLE queue congestion check

  • 启用 BLE 队列拥塞检查功能。

13. BLE 控制器高级选项

Controller Options

  • BLE Max Instances:最多支持 6 个 BLE 实例。
  • BLE static ACL TX buffer numbers:不使用静态 ACL TX 缓冲区。
  • The cpu core which bluetooth controller run:控制器运行在 PRO CPU 核心。
  • HCI mode:使用虚拟 HCI 模式。

The maximum number of 5.0 extend duplicate scan filter

  • 30:最多支持 30 个扩展重复扫描过滤器。

BLE CCA mode

  • NONE:不启用 CCA(信道冲突避免)模式。

CCA threshold value

  • 20:CCA 阈值为 20。

Connection event length determination method

  • ORIGINAL:使用原始方法确定连接事件长度。

default Tx antenna used

  • Antenna 0:默认使用天线 0 进行发射。

default Rx antenna used

  • Antenna 0:默认使用天线 0 进行接收。

BLE default Tx power level

  • +9dBm:默认发射功率为 +9dBm。

BLE adv report flow control supported

  • 启用广播报告流控制功能。

BLE adv report flow control number

  • 100:广播报告流控制的数量为 100。

BLE adv lost event threshold value

  • 20:广播丢失事件的阈值为 20。

14. BLE 共存和调试

Coexistence: limit on MAX Tx/Rx time for coded-PHY connection

  • Force Disable:强制禁用对编码 PHY 连接的最大收发时间限制。

MODEM SLEEP Options

  • Bluetooth modem sleep:启用蓝牙调制解调器睡眠模式,以节省功耗。
  • Enable HW AGC recorrect:启用硬件自动增益控制校正。
  • Disable active scan backoff:禁用主动扫描退避。
  • Enable aux packet when ext adv data length is zero:在扩展广播数据长度为零时启用辅助数据包。
  • Enable channel assessment:启用信道评估功能。
  • Enable LE Ping procedure:启用低功耗蓝牙 Ping 程序。
  • BLE disconnect when instant passed:在即时值超过时断开连接。
  • BLE ACL connection update procedure:启用 ACL 连接更新程序。
  • BLE ACL channel map update procedure:启用 ACL 信道图更新程序。
  • BLE ACL PHY update procedure:启用 ACL PHY 更新程序。
  • Put all BLE Controller code in flash:将所有 BLE 控制器代码存储在闪存中。

15. BLE 调试和日志

Enable Bluetooth HCI debug mode

  • 启用 Bluetooth HCI 调试模式,用于开发和调试。

Maximum number of Bluetooth alarms

  • 50:最多支持 50 个蓝牙定时器。

Released under the GPL License.