# 执行蓝牙 HOGP 功能

Source: [https://docs.qualcomm.com/doc/80-70017-13SC/topic/bluez-perform-bluetooth-hogp-functions.html](https://docs.qualcomm.com/doc/80-70017-13SC/topic/bluez-perform-bluetooth-hogp-functions.html)

可以使用 `bluetoothctl` 选项和 evtest 工具执行 HOGP 功能。

开始之前，请按照[设置 HOGP 功能的设备](https://docs.qualcomm.com/doc/80-70017-13SC/topic/bluez-hogp.html#bluez-hogp__section_g4p_4rv_mcc_navyanka_08-25-24-1354-32-878)中的说明设置您的设备。

## 连接远程设备

要连接远程设备，请从 `bluetoothctl` 菜单运行以下命令：

    connect <bt_address>Copy to clipboard

**参数**

`<bt_address>` 是远程设备的蓝牙地址。

**示例**

要使用 `<bt_address>` `30:73:00:41:22:49` 连接到已配对的远程设备，请运行以下命令：

    connect 30:73:00:41:22:49Copy to clipboard

**示例输出**

[bluetooth]# connect 30:73:00:41:22:49
    Attempting to connect to 30:73:00:41:22:49
    [CHG] Device 30:73:00:41:22:49 Connected: yes
    [CHG] Device 30:73:00:41:22:49 Modalias: usb:v04E8p7021d0001
    [CHG] Device 30:73:00:41:22:49 UUIDs: 00001000-0000-1000-8000-00805f9b34fb
    [CHG] Device 30:73:00:41:22:49 UUIDs: 00001124-0000-1000-8000-00805f9b34fb
    [CHG] Device 30:73:00:41:22:49 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
    [CHG] Device 30:73:00:41:22:49 ServicesResolved: yes
    [CHG] Device 30:73:00:41:22:49 WakeAllowed: yes
    Connection successfulCopy to clipboard

## 验证 HOGP 功能

evtest 工具是一个用于验证 HOGP 功能的开源工具。它监视和查询输入设备（例如鼠标或键盘）的设备事件。

注释： evtest 工具在用户编译时不可用。要验证 HOGP 功能，请从开源编译该工具并将其推送到 DUT。

**示例**

要验证蓝牙无线鼠标的功能，请执行以下操作：

1. 打开蓝牙无线鼠标。
2. 在蓝牙无线鼠标的 DUT 上运行[低能耗扫描](https://docs.qualcomm.com/doc/80-70017-13SC/topic/bluez-perform-bluetooth-low-energy-gatt-client-functions.html#bluez-perform-bluetooth-low-energy-gatt-client-functions__section_oyf_kts_lcc_navyanka_08-21-24-1425-50-130) 。
3. [将 DUT 连接](https://docs.qualcomm.com/doc/80-70017-13SC/topic/bluez-perform-bluetooth-hogp-functions.html#bluez-perform-bluetooth-hogp-functions__section_wtd_4x5_mcc_navyanka_08-25-24-1122-5-392)至蓝牙无线鼠标。
4. 在 SSH 中运行 evtest 工具。
5. 从屏幕上显示的已连接输入设备列表中选择蓝牙无线鼠标。
6. 使用鼠标执行不同的操作，例如单击、滚动、拖动和移动。
7. 验证屏幕上打印的每个操作的事件。

## 断开对端设备的连接

要断开远程设备的连接，请从 `bluetoothctl` 菜单运行以下命令：

    disconnect <bt_address>Copy to clipboard

**参数**

`<bt_address>` 是远程设备的蓝牙地址。

**示例**

要断开与 `<bt_address>` `30:73:00:41:22:49` 配对的远程设备，请运行以下命令：

    disconnect 30:73:00:41:22:49Copy to clipboard

**示例输出**

[MyBTkeyboard]# disconnect 30:73:00:41:22:49
    Attempting to disconnect from 30:73:00:41:22:49
    [CHG] Device 30:73:00:41:22:49 ServicesResolved: no
    Successful disconnected
    [CHG] Device 30:73:00:41:22:49 Connected: noCopy to clipboard

**上一级主题：** [基于 GATT 配置文件的 Human Interface Device](https://docs.qualcomm.com/doc/80-70017-13SC/topic/bluez-hogp.html)

Last Published: Jan 23, 2025

[Previous Topic
基于 GATT 配置文件的 Human Interface Device](https://docs.qualcomm.com/bundle/publicresource/80-70017-13SC/topics/bluez-hogp.md) [Next Topic
高级音频分发配置文件](https://docs.qualcomm.com/bundle/publicresource/80-70017-13SC/topics/bluez-a2dp.md)