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

Solution: BLE HID Selfie

1 功能概述

此项目演示模拟蓝牙自拍杆功能。

2 环境要求

  • board: pan108xxb5_evb

  • uart (option): 显示串口shell

  • 测试硬件:智能手机

  • PC工具: 软件shell工具(支持串口,波特率921600)

3 编译和烧录

例程位置:zephyr\samples_panchip\solutions\ble_hid_selfie

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

4 演示说明

  1. 将ble_hid_selfie烧录至EVB板后,使用shell工具连接上EVB开发板(波特率921600),会显示如下log。通过连续双击tab可以显示出当前可用的命令。

Bluetooth initialized
Advertising successfully started


[00:00:00.029,000] <inf> fs_nvs: 8 Sectors of 4096 bytes
[00:00:00.029,000] <inf> fs_nvs: alloc wra: 0, fe8
[00:00:00.029,000] <inf> fs_nvs: data wra: 0, 0
[00:00:00.129,000] <inf> bt_hci_core: No ID address. App must call settings_load()
[00:00:00.139,000] <inf> bt_hci_core: Identity: EC:5F:48:F6:62:BD (random)
[00:00:00.139,000] <inf> bt_hci_core: HCI: version 5.1 (0x0a) revision 0x0003, manufacturer 0x07d1
[00:00:00.139,000] <inf> bt_hci_core: LMP: version 5.1 (0x0a) subver 0x0000
[00:00:00.154,000] <inf> bt_settings: Saving ID
uart:~$
  clear    date     device   devmem   flash    help     history  kernel
  log      resize   sensor   shell    test
uart:~$ test
  photos    ac_home   vol_up    vol_down  raw_hex
  1. 智能手机蓝牙设置中找到Pan Selfie设备,选中连接并输入shell产生的随机数Passkey进行配对。

uart:~$ Connected 75:19:99:D2:BE:BA (random)
Passkey for 75:19:99:D2:BE:BA (random): 905570
Security changed: 75:19:99:D2:BE:BA (random) level 4
ccc 0001
ccc consumer 0001
image

手机配对界面

  1. 然后我们就可以通过支持的test命令来模拟蓝牙自拍杆的相关动作

5 支持的模拟测试命令

测试命令

功能描述

test photos

模拟拍照按键

test ac_home

模拟Home

test vol_up

模拟音量+

test vol_down

模拟音量-

相应命令支持的函数可以参考shell命令实现:

SHELL_STATIC_SUBCMD_SET_CREATE(sub_test,
			       SHELL_CMD(photos,       NULL,   "Take Photos command",  cmd_test_photos),
			       SHELL_CMD(ac_home,      NULL,   "AC Home command",      cmd_test_ac_home),
			       SHELL_CMD(vol_up,       NULL,   "Volume up command",    cmd_test_vol_up),
			       SHELL_CMD(vol_down,     NULL,   "Volume down command",  cmd_test_vol_down),
			       SHELL_CMD(raw_hex,      NULL,   "RAW Hexgroup command", cmd_test_raw_hex),
			       SHELL_SUBCMD_SET_END /* Array terminated. */
			       );
SHELL_CMD_REGISTER(test, &sub_test, "HID Over GATT Test commands", NULL);

6 RAM/Flash资源使用情况

Memory region         Used Size  Region Size  %age Used
FLASH:      140536 B       384 KB     35.74%
SRAM:       42300 B        50 KB     82.62%