# 验证 GATT 功能

GATT 是一个服务框架，它使用 ATT 来发现服务，并在对等设备上读取和写入特征值。

要执行低功耗蓝牙 GATT 服务器或客户端功能，必须首先完成以下过程中的步骤。

## 前提条件

- 启用 SSH 以访问您的主机设备。有关说明，请参阅[使用 SSH 登录](https://docs.qualcomm.com/bundle/publicresource/topics/80-70022-254/how_to.html#use-ssh)。
- 将 DUT 和远程设备放置在蓝牙附近。

## 设置设备以使用蓝牙低功耗 GATT 功能

1. 在命令提示符下使用以下命令运行 SSH：

ssh root@<device_IP_address>
        Copy to clipboard

    **示例**

    如果设备的 IP 地址为 `10.92.160.222`，则运行以下命令：

ssh root@10.92.160.222
        Copy to clipboard
2. 输入以下密码来连接 SSH：

oelinux123
        Copy to clipboard
3. 通过运行以下命令打开蓝牙测试应用程序：

bluetoothctl
        Copy to clipboard

    您可以通过 bluetoothctl 的主菜单选项执行一些 GATT 功能，例如连接和扫描。

    **示例输出**

sh-5.1# bluetoothctl
        Agent registered        uetoothd...
        [CHG] Controller 22:22:F1:C1:99:C0 Pairable: yes
        Copy to clipboard
4. 运行以下命令，启用蓝牙：

power on
        Copy to clipboard

    **示例输出**

[bluetooth]# power on
        [CHG] Controller 22:22:F1:C1:99:C0 Class: 0x007c0000
        Changing power on succeeded
        [CHG] Controller 22:22:F1:C1:99:C0 Powered: yes
        Copy to clipboard
5. 通过运行以下命令转到 **GATT 子菜单**：

menu gatt
        Copy to clipboard

    **示例输出**

[bluetooth]# menu gatt
        Menu gatt:
        Available commands:
        -------------------
        list-attributes [dev/local]                       List attributes
        select-attribute <attribute/UUID/local> [attribute/UUID] Select attribute
        attribute-info [attribute/UUID]                   Select attribute
        read [offset]                                     Read attribute value
        write <data=xx xx ...> [offset] [type]            Write attribute value
        acquire-write                                     Acquire Write file descriptor
        release-write                                     Release Write file descriptor
        acquire-notify                                    Acquire Notify file descriptor
        release-notify                                    Release Notify file descriptor
        notify <on/off>                                   Notify attribute value
        clone [dev/attribute/UUID]                        Clone a device or attribute
        register-application [UUID ...]                   Register profile to connect
        unregister-application                            Unregister profile
        register-service <UUID> [handle]                  Register application service.
        unregister-service <UUID/object>                  Unregister application service
        register-includes <UUID> [handle]                 Register as Included service in.
        unregister-includes <Service-UUID> <Inc-UUID>     Unregister Included service.
        register-characteristic <UUID> <Flags=read,write,notify...> [handle] Register application characteristic
        unregister-characteristic <UUID/object>           Unregister application characteristic
        register-descriptor <UUID> <Flags=read,write...> [handle] Register application descriptor
        unregister-descriptor <UUID/object>               Unregister application descriptor
        back                                              Return to main menu
        version                                           Display version
        quit                                              Quit program
        exit                                              Quit program
        help                                              Display help about this program
        export                                            Print environment variables
        Copy to clipboard

    - 对于 GATT 服务器功能，请参阅[执行低功耗蓝牙 GATT 服务器功能](https://docs.qualcomm.com/doc/80-70022-13SC/topic/bluez-perform-bluetooth-low-energy-gatt-server-functions.html#bluez-perform-bluetooth-low-energy-gatt-server-functions)。
    - 对于 GATT 客户端功能，请参阅[执行低功耗蓝牙 GATT 客户端功能](https://docs.qualcomm.com/doc/80-70022-13SC/topic/bluez-perform-bluetooth-low-energy-gatt-client-functions.html#bluez-perform-bluetooth-low-energy-gatt-client-functions)。

## 后续步骤

- [执行低功耗蓝牙 GATT 服务器功能](https://docs.qualcomm.com/doc/80-70022-13SC/topic/bluez-perform-bluetooth-low-energy-gatt-server-functions.html)
您可以使用 **GATT 子菜单**选项和 `bluetoothctl` 命令执行低功耗蓝牙 GATT 服务器功能。
- [执行低功耗蓝牙 GATT 客户端功能](https://docs.qualcomm.com/doc/80-70022-13SC/topic/bluez-perform-bluetooth-low-energy-gatt-client-functions.html)
您可以使用 **GATT 子菜单**选项和 `bluetoothctl` 命令执行低功耗蓝牙 GATT 客户端功能。

Last Published: Nov 03, 2025

[Previous Topic
执行蓝牙 GAP 功能](https://docs.qualcomm.com/bundle/publicresource/80-70022-13SC/topics/bluez-perform-bluetooth-gap-functions.md) [Next Topic
执行低功耗蓝牙 GATT 服务器功能](https://docs.qualcomm.com/bundle/publicresource/80-70022-13SC/topics/bluez-perform-bluetooth-low-energy-gatt-server-functions.md)