Solution: BLE HID Selfie¶
1 功能概述¶
此项目演示模拟蓝牙自拍杆功能。
2 环境要求¶
board: pan1080a_afld_evb
uart (option): 显示串口shell
测试硬件:智能手机
PC工具: 软件shell工具(支持串口,波特率921600)
3 编译和烧录¶
项目位置:zephyr\samples_panchip\solutions\ble_hid_selfie
统一的配置、编译、下载工具正在开发中,当前可以使用脚本进行编译和下载。
脚本位置:quick_build_samples\solutions\ble_hid_selfie.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 演示说明¶
将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
智能手机蓝牙设置中找到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
然后我们就可以通过支持的test命令来模拟蓝牙自拍杆的相关动作
5 支持的模拟测试命令¶
测试命令 |
功能描述 |
---|---|
|
模拟 |
|
模拟 |
|
模拟 |
|
模拟 |
相应命令支持的函数可以参考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);