当前页面为 开发中 版本,查看特定版本的文档,请在页面左下角的下拉菜单中进行选择。

Bluetooth: Peripheral / Health Thermometer sensor

1 功能概述

此项目演示了蓝牙从机的功能,该工程包含了 HT (Health Thermometer) 服务,可以采集温度并上报给主机。

在不支持温度采集的设备上,这些温度数据是虚拟的。

2 环境要求

  • board: 支持 BLE 的蓝牙设备

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

  • 测试软件: nRF Connect

3 编译和烧录

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

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

4 演示说明

  1. 烧录完成后,设备自动启动蓝牙广播,可以在手机或抓包工具上获取如下信息:

    • Service UUID: 0x1809, 0x180A, 0x180F

    • Device Name: Zephyr Health Thermometer

  2. 当手机或其它主设备与其建立连接后,串口log 会显示连接信息,如下:

    Connected
    
  3. 此时,如果使能了Temperature Measurement,主机将收到温度数据,如下:

    image

    Peripheral HT 手机端 nRF Connect Service界面

    image

    Peripheral HT 手机端 nRF Connect Log界面

    串口log也会显示当前温度和数据传输的信息:

    temperature is 20C
    Indication success
    Indication complete
    temperature is 21C
    Indication success
    Indication complete
    temperature is 22C
    Indication success
    Indication complete
    temperature is 23C
    Indication success
    Indication complete
    temperature is 24C
    Indication success
    Indication complete
    temperature is 25C
    Indication success
    Indication complete
    temperature is 26C
    Indication success
    Indication complete
    temperature is 27C
    Indication success
    Indication complete
    

5 RAM/Flash资源使用情况

Memory region         Used Size  Region Size  %age Used
FLASH:       94524 B       384 KB     24.04%
SRAM:       28018 B        50 KB     54.72%