Bluetooth: Central / Heart-rate Monitor¶
1 功能概述¶
此项目演示蓝牙主机功能,不同的是这个应用程序专门查找心率监视器,并在连接后报告心率读数。
2 环境要求¶
board: 支持 BLE 的蓝牙设备
uart(option): 用来显示串口log
测试软件: nRF Connect
3 编译和烧录¶
例程位置:zephyr\samples_panchip\bluetooth\central_hr
使用 ZAL 工具可以对其进行编译、烧录、打开 VS Code 调试等操作。关于 ZAL 工具的详细介绍请参考:Zephyr APP Launcher 工具介绍。
4 演示说明¶
准备2个设备,分别烧录peripheral_hr(见peripheral_hr例程),烧录centrl_hr例程
开启central设备,此时central设备可以看到扫描数据
Scanning successfully started [DEVICE]: 1D:0C:35:49:40:DC (random), AD evt type 3, AD data len 31, RSSI -43 [DEVICE]: 1D:0C:35:49:40:DC (random), AD evt type 3, AD data len 31, RSSI -42 [DEVICE]: 59:70:28:64:72:07 (random), AD evt type 3, AD data len 31, RSSI -71 [DEVICE]: 59:70:28:64:72:07 (random), AD evt type 3, AD data len 31, RSSI -72 [DEVICE]: DF:BC:88:D2:0C:B9 (random), AD evt type 0, AD data len 11, RSSI -42 [AD]: 1 data_len 1 [AD]: 3 data_len 6
打开peripheral_hr,显示被central_hr设备扫描,串口数据打印connected
Connected <inf> hrs: HRS notifications enabled
在central_hr串口上会显示connect,收到上报的心率信息
Connected: DF:BC:88:D2:0C:B9 (random) [ATTRIBUTE] handle 25 [ATTRIBUTE] handle 28 [SUBSCRIBED] [NOTIFICATION] data 0x20009f6c length 2 [NOTIFICATION] data 0x20009f6c length 2 [NOTIFICATION] data 0x20009f6c length 2 [NOTIFICATION] data 0x20009f6c length 2
5 RAM/Flash资源使用情况¶
Memory region Used Size Region Size %age Used
FLASH: 108260 B 256 KB 41.30%
SRAM: 30696 B 50 KB 59.95%