Bluetooth: Central / Health Thermometer sensor¶
1 功能概述¶
此项目演示蓝牙主机功能,不同的是这个应用程序专门寻找健康温度计传感器,并在连接建立后上报模具温度读数。
2 环境要求¶
board: 支持 BLE 的蓝牙设备
uart(option): 用来显示串口log
测试软件: nRF Connect
3 编译和烧录¶
项目位置:zephyr\samples_panchip\bluetooth\central_ht
统一的配置、编译、下载工具正在开发中,当前可以使用脚本进行编译和下载。
脚本位置:quick_build_samples\bluetooth\central_ht.bat
。
打开脚本后默认会编译项目,编译完成时,可输入字符进行后续下载等操作:
Input the keyword to continue:
'b' build 编译项目
'r' make clean and rebuild 重新编译项目
'f' flash download 下载
'e' erase chip 擦除芯片
'o' open project by VS Code 打开 `VS Code`,可查看源码,执行编译下载等
others exit 退出
wait input:
4 演示说明¶
准备2块板卡,1块烧录peripheral_ht(见peripheral_ht例程),一块烧录central_ht
开启central设备,此时central设备可以看到扫描数据
Scanning successfully started [DEVICE]: 35:C2:56:72:32:6C (random), AD evt type 3, AD data len 31, RSSI -43 [DEVICE]: EB:46:FA:EA:98:2F (random), AD evt type 0, AD data len 11, RSSI -43 [AD]: 1 data_len 1 [AD]: 3 data_len 6 [DEVICE]: EB:46:FA:EA:98:2F (random), AD evt type 4, AD data len 25, RSSI -43 [DEVICE]: 35:C2:56:72:32:6C (random), AD evt type 3, AD data len 31, RSSI -43 [DEVICE]: 5C:7B:03:66:6F:39 (random), AD evt type 0, AD data len 17, RSSI -42 [AD]: 1 data_len 1 [AD]: 10 data_len 1 [AD]: 255 data_len 9 [DEVICE]: 5C:7B:03:66:6F:39 (random), AD evt type 4, AD data len 0, RSSI -42 [DEVICE]: EB:46:FA:EA:98:2F (random), AD evt type 0, AD data len 11, RSSI -43
打开peripheral_ht,显示被central_ht设备扫描,串口数据打印connected,并显示上报的温度信息
Connected
temperature is 21C
Indication success Indication complete
temperature is 22C
Indication success Indication complete
在central_ht串口上会显示connect,查看上报的温度信息
Connected: C0:69:E0:DD:2B:1B (random) [ATTRIBUTE] handle 25 [ATTRIBUTE] handle 26 [ATTRIBUTE] handle 28 [SUBSCRIBED] Temperature 21C. Temperature 22C.