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

Bluetooth: Central HID

1 功能概述

此项目演示蓝牙主机HID功能,连接HID设备可以读取HID设备发来的键值等信息。

  • 支持BLE ACT32K时钟演示(高精度32K时钟,不需要外部XTL32K,但是不支持低功耗)

  • 支持BLE XTL32K低功耗(外部XTL32K,支持低功耗)

  • 支持BLE RCL32K低功耗(内部RCL32K,不需要外部XTL32K, 支持低功耗,功耗和连接稳定性次于XTL32K)

2 环境要求

  • board: 支持 BLE 的蓝牙设备

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

3 编译和烧录

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

根据需要选择clock_act,clock_xtl,clock_rcl 文件夹, 分别对应ACT32K, XTL32K以及RCL32K。

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

4 演示说明

  1. 准备1个EVB设备,烧录centrl_hids例程, 其中另外一个设备暂时为”iDance JX-1”

  2. 开启central设备,此时central设备可以看到扫描数据

    *** Booting Zephyr OS build zephyr-v2.7.0-1072-ge521019f6dd4  ***
    *** llcontroller-v1.0.0-08bf4252 ***
    Starting Bluetooth Central HIDS example
    goon disable
    controller initializing....
    Bluetooth initialized
    [00:00:00.024,000] [0m<inf> fs_nvs: 8 Sectors of 4096 bytes[0m
    [00:00:00.024,000] [0m<inf> fs_nvs: alloc wra: 0, fa0[0m
    [00:00:00.024,000] [0m<inf> fs_nvs: data wra: 0, 58[0m
    [00:00:00.119,000] [0m<inf> bt_hci_core: No ID address. App must call settings_load()[0m
    [00:00:00.121,000] [0m<inf> bt_hci_core: Identity: E7:0F:58:16:17:19 (random)[0m
    [00:00:00.121,000] [0m<inf> bt_hci_core: HCI: version 5.1 (0x0a) revision 0x0003, manufacturer 0x07d1[0m
    [00:00:00.121,000] [0m<inf> bt_hci_core: LMP: version 5.1 (0x0a) subver 0x0000[0m
    Scanning successfully started
    Filters matched Address: 78:9C:E7:7B:69:01 (public) connectable: yes
    Connected: 78:9C:E7:7B:69:01 (public)
    Security changed: 78:9C:E7:7B:69:01 (public) level 2
    Pairing completed: 78:9C:E7:7B:69:01 (public), bonded: 1
    The discovery procedure succeeded
    HIDS is ready to work
    Subscribe to report id: 2
    Subscribe to report id: 1
    Subscribe to boot keyboard report
    Notification, id: 1, size: 8, data: 0x0 0x0 0x53 0x0 0x0 0x0 0x0 0x0
    Notification, id: 1, size: 8, data: 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
    Notification, id: 1, size: 8, data: 0x0 0x0 0x53 0x0 0x0 0x0 0x0 0x0
    Notification, id: 1, size: 8, data: 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
    
    
  3. 如果过滤其他设备名称,则在prj.conf中重新设置CONFIG_FILTER_DEV_NAME_STR="iDance JX-1"对应的名称。

    过滤的广播中必须是complete local name中包含该名称,设备名称不能仅仅在scan response中。

5 低功耗说明

目前clock_xtlclock_rcl 是支持低功耗,其中clock_rcl 相对连接功耗和稳定相对于clock_xtl应该略差,其中clock_rcl 为了稳定性考虑,特意增加了看门狗,可以通过CONFIG_APP_WDT_ENABLE宏开关来进行控制。

clock_rcl 初步测试连接1小时左右(办公室环境),也有测试连接时长较长的情况(10+小时),可能与RC本身一致性有关,待进一步测试。

6 RAM/Flash资源使用情况

xtl:

Memory region         Used Size  Region Size  %age Used
FLASH:       118004 B       384 KB     30.01%
SRAM:         42026 B        50 KB     82.08%

rcl:

Memory region         Used Size  Region Size  %age Used
FLASH:       118644 B       384 KB      30.17%
SRAM:         42034 B        50 KB      82.10%