> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 验证 BlueZ 协议栈的功能

<a id="verify-bluetooth-functionality-of-bluez-stack" />

Qualcomm Linux 蓝牙解决方案包括 BlueZ 协议栈和示例测试应用程序。这些应用程序与 BlueZ 协议栈的蓝牙守护进程交互，以运行不同的蓝牙功能。可使用它们来验证 BlueZ 协议栈的功能。

Qualcomm Linux 支持以下演示蓝牙配置文件用例和测试过程的示例应用程序。每个应用程序都通过菜单驱动的选项提供特定配置文件的功能。

| 示例应用程序       | 配置文件             |
| ------------ | ---------------- |
| bluetoothctl | GAP、GATT、A2DP    |
| evtool       | HOGP             |
| obexctl      | OPP、FTP、PBAP、MAP |
| ofono        | HFP              |

以下工作流程展示了如何开始使用示例应用程序验证蓝牙功能。

<img src="https://mintcdn.com/qualcomm-prod/PyJ823JBh-_RDtS4/Technologies/Bluetooth/media/qli-bt/get-started-workflow.png?fit=max&auto=format&n=PyJ823JBh-_RDtS4&q=85&s=b650575f6a293a428fda4e191f6de2c2" alt="" width="1307" height="197" data-path="Technologies/Bluetooth/media/qli-bt/get-started-workflow.png" />

完成工作流程的顺序如下：

1. 按照<a href="https://dragonwingdocs.qualcomm.com/Key-Documents/Yocto-Guide/build-qualcomm-linux" target="_self"><em>使用 Yocto 构建 Qualcomm Linux</em></a>中所述设置您的基础设施。

2. 设置设备并运行某个配置文件的示例应用程序。

3. 验证蓝牙配置文件的功能。

4. 如果出现任何问题，请按照<a href="debug-bluetooth-issues" target="_self">调试蓝牙问题</a>中所述记录和调试问题。

## 设置蓝牙 MAC 地址

默认情况下，出厂时会将蓝牙 MAC 地址设置在一次性可编程存储器中。如果您想手动设置蓝牙 MAC 地址，请完成以下过程。

<Note>
  手动设置的蓝牙 MAC 地址在设备重启后不会保留。
</Note>

**前提条件**

* 启用 SSH 以访问您的主机设备。有关说明，请参阅<a href="https://dragonwingdocs.qualcomm.com/Key-Documents/Flash-Guide/how-to-sign-in-with-ssh" target="_self">使用 SSH 登录</a>。

* <a href="perform-bluetooth-gap-functions#disable-bluetooth" target="_self">关闭设备上的蓝牙。</a>

**步骤**

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

   ```text theme={null}
   ssh root@<device_IP_address>
   ```

   **示例**

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

   ```text theme={null}
   ssh root@10.92.160.222
   ```

2. 输入以下密码以连接到 SSH：

   ```text theme={null}
   oelinux123
   ```

3. 打开蓝牙管理工具并运行以下命令设置蓝牙地址：

   ```text theme={null}
   btmgmt public-addr <bt_address>
   ```

   例如，要将设备的蓝牙地址设置为 `22:22:9B:2C:79:1E`，运行以下命令：

   ```text theme={null}
   btmgmt public-addr 22:22:9B:2C:79:1E
   ```

   **示例输出**

   ```text theme={null}
   sh-5.1# btmgmt public-addr 22:22:9B:2C:79:1E
   hci0 Set Public Address complete, options:
   sh-5.1# hciconfig
   hci0:     Type: Primary Bus: UART    
            BD Address: 22:22:9B:2C:79:1E ACL MTU: 1024:7 SCO MTU: 240:8
            DOWN
            RX bytes: 7763 acl:0 sco:0 events:364 errors:0
            TX bytes: 938685 acl:0 sco:0 commands:4004 errors:0
   ```

## 源代码位置

下表列出了蓝牙组件（如协议栈、示例测试应用程序和驱动程序）的源代码位置。

<table>
  <thead>
    <tr><th>组件</th><th>源代码位置</th></tr>
  </thead>

  <tbody>
    <tr><td>bluetoothctl</td><td>[https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/tools](https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/tools)</td></tr>
    <tr><td>obexctl</td><td>[https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/tools](https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/tools)</td></tr>
    <tr><td>ofono</td><td>[https://git.kernel.org/pub/scm/network/ofono/ofono.git](https://git.kernel.org/pub/scm/network/ofono/ofono.git)</td></tr>
    <tr><td>BlueZ 协议栈</td><td><ul><li>BlueZ 的 git 仓库位于：[https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/](https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/)</li><li>您可以在以下地址下载该协议栈：[https://mirrors.edge.kernel.org/pub/linux/bluetooth/bluez-5.65.tar.gz](https://mirrors.edge.kernel.org/pub/linux/bluetooth/bluez-5.65.tar.gz)</li><li>蓝牙内核子系统的 git 仓库位于：<ul><li>[https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git/tree/](https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git/tree/)</li><li>[https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/](https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/)</li></ul></li></ul></td></tr>
    <tr><td>蓝牙驱动程序</td><td>您可以从以下位置下载蓝牙驱动程序：<ul><li>[https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/drivers/bluetooth/hci\_qca.c](https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/drivers/bluetooth/hci_qca.c) (UART)</li><li>[https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/drivers/bluetooth/btqca.c](https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/drivers/bluetooth/btqca.c) (UART)</li><li>[https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/drivers/bluetooth/btusb.c](https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/drivers/bluetooth/btusb.c) (USB)</li></ul></td></tr>
  </tbody>
</table>

## 后续步骤

* 要设置设备并验证 GAP 功能，请参阅<a href="verify-gap-functions" target="_self">验证 GAP 功能</a>。

* 要设置设备并验证 GATT 功能，请参阅<a href="verify-gatt-functions" target="_self">验证 GATT 功能</a>。

* 要设置设备并验证 HOGP 功能，请参阅<a href="verify-hogp-functions" target="_self">验证 HOGP 功能</a>。

* 要设置设备并验证 A2DP 功能，请参阅<a href="verify-a2-dp-functions" target="_self">验证 A2DP 功能</a>。

* 要设置设备并验证 HFP 功能，请参阅<a href="verify-hfp-functions" target="_self">验证 HFP 功能</a>。

* 要设置设备并验证 OPP 功能，请参阅<a href="verify-opp-functions" target="_self">验证 OPP 功能</a>。

* 要设置设备并验证 FTP 功能，请参阅<a href="verify-ftp-functions" target="_self">验证 FTP 功能</a>。

* 要设置设备并验证 PBAP 功能，请参阅<a href="verify-pbap-functions" target="_self">验证 PBAP 功能</a>。

* 要设置设备并验证 MAP 功能，请参阅<a href="verify-map-functions" target="_self">验证 MAP 功能</a>。
