开发排错指南

常见问题与解决方案

问题 可能原因 解决方案
设备无法被发现 未开启广播/距离过远 检查广播参数/缩短距离
连接经常断开 参数不当/信号弱 调整 interval/latency
数据发送失败 MTU 不匹配/特征值属性 协商 MTU/检查属性
配对失败 IO 能力不匹配 检查配对参数

调试工具

Android

  • nRF Connect
  • BLE Scanner
  • HCI Log

iOS

  • LightBlue
  • BlueCarbon

PC

  • nRF Connect Desktop
  • Wireshark (BTVS)

调试日志示例

// BLE 连接日志分析
[D] GAP: Start advertising
[D] GAP: Connected (handle=0)
[D] GATT: MTU exchanged (517)
[D] GATT: Service discovered
[D] ATT: Write Request (handle=0x0003)
[D] ATT: Write Response
[D] GAP: Connection parameters updated