当前文档版本为 v0.6.0,您可以访问当前页面的 开发中 版本以获取最近可能的更新。

Bluetooth: Central / Health Thermometer sensor

1 功能概述

此项目演示蓝牙主机功能,不同的是这个应用程序专门寻找健康温度计传感器,并在连接建立后上报模具温度读数。

2 环境要求

  • board: 支持 BLE 的蓝牙设备

  • uart(option): 用来显示串口log

  • 测试软件: nRF Connect

3 编译和烧录

例程位置:zephyr\samples_panchip\bluetooth\central_ht

使用 ZAL 工具可以对其进行编译、烧录、打开 VS Code 调试等操作。关于 ZAL 工具的详细介绍请参考:Zephyr APP Launcher 工具介绍

4 演示说明

  1. 准备2块板卡,1块烧录peripheral_ht(见peripheral_ht例程),一块烧录central_ht

  2. 开启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
    
  3. 打开peripheral_ht,显示被central_ht设备扫描,串口数据打印connected,并显示上报的温度信息

    Connected

    temperature is 21C

    Indication success Indication complete

    temperature is 22C

    Indication success Indication complete

  4. 在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.
    

5 RAM/Flash资源使用情况

Memory region         Used Size  Region Size  %age Used
FLASH:      115744 B       256 KB     44.15%
SRAM:       29564 B        50 KB     57.74%