# 通用属性配置文件

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

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

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

## 为低功耗蓝牙 GATT 功能设置设备

**前提条件**

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

**步骤**

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

        ssh root@<device_IP_address>Copy to clipboard

    **示例**

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

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

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

        bluetoothctlCopy to clipboard

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

    **示例输出**

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

        power onCopy 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: yesCopy to clipboard
5. 运行以下命令转至 GATT submenu： 

        menu gattCopy 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 variablesCopy to clipboard

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

- **[执行低功耗蓝牙 GATT 服务器功能](https://docs.qualcomm.com/doc/80-70017-13SC/topic/bluez-perform-bluetooth-low-energy-gatt-server-functions.html)**  

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

您可以使用 GATT             submenu 选项和 `bluetoothctl` 命令执行低功耗蓝牙 GATT 客户端功能。

**上一级主题：** [验证 BlueZ 堆栈的功能](https://docs.qualcomm.com/doc/80-70017-13SC/topic/verify-bluetooth-functionality-of-bluez-stack.html)

Last Published: Jan 23, 2025

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