# 通用访问 Profile (General Access Profile)

蓝牙低功耗 GAP 是对现有 BR/EDR GAP 的扩展。

要执行蓝牙 GAP 功能，您必须首先完成以下过程中的步骤。

## 为蓝牙 GAP 功能设置设备

**前提条件**

- 启用 SSH 以访问您的主机设备。有关说明，请参阅[使用 SSH 登录](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-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.222
        Copy to clipboard
2. 输入以下密码来连接 SSH：

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

bluetoothctl
        Copy to clipboard

    **示例输出**

sh-5.1# bluetoothctl
        Agent registered        uetoothd...
        [CHG] Controller 22:22:F1:C1:99:C0 Pairable: yes
        Copy to clipboard

    - 要查看 GAP 功能，请运行以下命令：

help
            Copy to clipboard

        该命令提供 **bluetoothctl** 的主菜单。主菜单包括子菜单和 GAP 功能。要执行 GAP 功能，请参阅[执行蓝牙 GAP 功能](https://docs.qualcomm.com/doc/80-70020-13SC/topic/bluez-perform-bluetooth-gap-functions.html#bluez-perform-bluetooth-gap-functions)。

        **示例输出**

[bluetooth]# help
            Menu main:
            Available commands:
            -------------------
            advertise                                         Advertise Options Submenu
            monitor                                           Advertisement Monitor Options Submenu
            scan                                              Scan Options Submenu
            gatt                                              Generic Attribute Submenu
            admin                                             Admin Policy Submenu
            player                                            Media Player Submenu
            endpoint                                          Media Endpoint Submenu
            transport                                         Media Transport Submenu
            list                                              List available controllers
            show [ctrl]                                       Controller information
            select <ctrl>                                     Select default controller
            devices [Paired/Bonded/Trusted/Connected]         List available devices, with an optional property as the filter
            system-alias <name>                               Set controller alias
            reset-alias                                       Reset controller alias
            power <on/off>                                    Set controller power
            pairable <on/off>                                 Set controller pairable mode
            discoverable <on/off>                             Set controller discoverable mode
            discoverable-timeout [value]                      Set discoverable timeout
            agent <on/off/capability>                         Enable/disable agent with given capability
            default-agent                                     Set agent as the default one
            advertise <on/off/type>                           Enable/disable advertising with given type
            set-alias <alias>                                 Set device alias
            scan <on/off/bredr/le>                            Scan for devices
            info [dev]                                        Device information
            pair [dev]                                        Pair with device
            cancel-pairing [dev]                              Cancel pairing with device
            trust [dev]                                       Trust device
            untrust [dev]                                     Untrust device
            block [dev]                                       Block device
            unblock [dev]                                     Unblock device
            remove <dev>                                      Remove device
            connect <dev>                                     Connect device
            disconnect [dev]                                  Disconnect device
            menu <name>                                       Select submenu
            version                                           Display version
            quit                                              Quit program
            exit                                              Quit program
            help                                              Display help about this program
            export                                            Print environment variables
            Copy to clipboard
    - 要验证设备上的蓝牙状态，请运行以下命令：

show
            Copy to clipboard

        **示例输出**

[bluetooth]# show
            Controller 8C:FD:F0:21:84:23 (public)
                     Name: qcs9100-ride-sx
                     Alias: qcs9100-ride-sx
                     Class: 0x00000000
                     Powered: no
                     Discoverable: no
                     DiscoverableTimeout: 0x000000b4
                     Pairable: yes
                     UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
                     UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
                     UUID: Message Access Server     (00001132-0000-1000-8000-00805f9b34fb)
                     UUID: Message Notification Se.. (00001133-0000-1000-8000-00805f9b34fb)
                     UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
                     UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
                     UUID: Phonebook Access Server   (0000112f-0000-1000-8000-00805f9b34fb)
                     UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
                     UUID: OBEX File Transfer        (00001106-0000-1000-8000-00805f9b34fb)
                     UUID: Device Information        (0000180a-0000-1000-8000-00805f9b34fb)
                     UUID: IrMC Sync                 (00001104-0000-1000-8000-00805f9b34fb)
                     UUID: Handsfree                 (0000111e-0000-1000-8000-00805f9b34fb)
                     UUID: OBEX Object Push          (00001105-0000-1000-8000-00805f9b34fb)
                     Modalias: usb:v1D6Bp0246d0541
                     Discovering: no
                     Roles: central
                     Roles: peripheral
            Advertising Features:
                     ActiveInstances: 0x00 (0)
                     SupportedInstances: 0x10 (16)
                     SupportedIncludes: tx-power
                     SupportedIncludes: appearance
                     SupportedIncludes: local-name
                     SupportedSecondaryChannels: 1M
                     SupportedSecondaryChannels: 2M
                     SupportedSecondaryChannels: Coded
            Copy to clipboard

## 后续步骤

- [执行蓝牙 GAP 功能](https://docs.qualcomm.com/doc/80-70020-13SC/topic/bluez-perform-bluetooth-gap-functions.html)
可以使用 `bluetoothctl` 主菜单中提供的命令执行各种蓝牙 GAP 功能。

Last Published: Jul 22, 2025

[Previous Topic
验证 BlueZ 协议栈的功能](https://docs.qualcomm.com/bundle/publicresource/80-70020-13SC/topics/verify-bluetooth-functionality-of-bluez-stack.md) [Next Topic
执行蓝牙 GAP 功能](https://docs.qualcomm.com/bundle/publicresource/80-70020-13SC/topics/bluez-perform-bluetooth-gap-functions.md)