> ## 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.

# 验证 HFP 功能

> HFP 定义了音频网关设备如何连接到免提设备，以实现远程控制和音频连接等功能。

<a id="bluez-hfp" />

要执行 HFP 客户端或音频网关功能，您必须先完成以下过程中的步骤。

## 前提条件

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

* 将 DUT 和远程设备置于蓝牙有效范围内。

## 为 HFP 功能设置设备

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. 根据需要为 HFP <a href="#configure-the-dut-for-hfp-client-functions" target="_self">客户端</a>或<a href="#configure-the-dut-for-hfp-audio-gateway-functions" target="_self">音频网关</a>功能配置 DUT。

## 为 HFP 客户端功能配置 DUT

在完成 HFP 功能的<a href="#set-up-the-device-for-hfp-functions" target="_self">初始设备设置</a>后，请为 HFP 客户端执行以下操作：

1. 在 SSH 中运行以下命令验证 ofono 服务的状态：

   ```text theme={null}
   systemctl status ofono
   ```

2. 从 <a href="https://github.com/PipeWire/wireplumber/blob/0.5.1/src/config/wireplumber.conf.d.examples/" target="_self">GitHub PipeWire 页面</a>下载蓝牙配置文件 `bluetooth.conf`。

3. 将 `bluetooth.conf` 文件推送到设备的 `/usr/share/wireplumber/wireplumber.conf.d` 目录。

4. 在文本编辑器中打开 `bluetooth.conf` 文件。

5. 取消注释 `bluez5.hfphsp-backend = "native"` 属性。将其值从 `"native"` 更改为 `"ofono"`。

   文件应如下所示：

   ```text theme={null}
   # bluez5.enable-hw-volume = true

   ## HFP/HSP backend (default: native).
   ## Available values: any, none, hsphfpd, ofono, native
   bluez5.hfphsp-backend = "ofono"

   ## HFP/HSP native backend modem (default: none).
   ```

6. 保存文件。

7. 运行以下命令重新加载守护进程：

   ```text theme={null}
   systemctl daemon-reload
   ```

8. 运行以下命令重启 WirePlumber 服务：

   ```text theme={null}
   systemctl restart wireplumber
   ```

   在重新加载守护进程并重启 WirePlumber 服务后，`bluetooth.conf` 配置文件中的更改将反映到系统中。PipeWire 使用 DBUS 与 ofono 建立连接。

9. 在 SSH 中运行以下命令启动 `bluetoothctl`：

   ```text theme={null}
   bluetoothctl
   ```

10. 在 `bluetoothctl` 菜单中运行以下命令，验证免提客户端设备的 UUID 是否出现在列表中：

    ```text theme={null}
    show
    ```

**示例输出**

```text theme={null}
[bluetooth]# show
Controller 22:22:9B:2C:79:1E (public)
   Name: qcm6490
   Alias: qcm6490
   Class: 0x002c0000
   Powered: yes
   Discoverable: no
   DiscoverableTimeout: 0x000000b4
   Pairable: yes
   UUID: A/V Remote Control        (e000110e-0000-1000-8000-00805f9b34fb)
   UUID: PnP Information           (e0001200-0000-1000-8000-00805f9b34fb)
   UUID: Audio Source              (e000110a-0000-1000-8000-00805f9b34fb)
   UUID: Audio Sink                (e000110b-0000-1000-8000-00805f9b34fb)
   UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
   UUID: Generic Access Profile    (e0001800-0000-1000-8000-00805f9b34fb)
   UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
   UUID: Device Information        (0000180a-0000-1000-8000-00805f9b34fb)
   UUID: Handsfree                 (e000111e-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
[bluetooth]#
```

<Note>
  列表中不会列出免提音频网关和耳机的 UUID。仅显示通过 PipeWire 配置的免提客户端 UUID。
</Note>

11. 在 SSH 中运行以下命令打开 `ofono/test` 菜单：

    ```text theme={null}
    ls -rt /usr/lib/ofono/test
    ```

    <Note>
      请在您的设备上构建并安装 `ofono-tests` 软件包，以使用 `ofono/test` 应用程序。
    </Note>

**示例输出**

```text theme={null}
sh-5.1# ls -rt /usr/lib/ofono/test
unlock-pin                 set-ddr                     hangup-call
test-stk-menu              set-context-property        hangup-all
test-ss-control-cs         set-cbs-topics              hangup-active
test-ss-control-cf         set-call-forwarding         get-tech-preference
test-ss-control-cb         send-vcard                  get-serving-cell-info
test-ss                    send-vcal                   get-operators
test-sms                   send-ussd                   get-icon
test-smart-messaging       send-sms                    enter-pin
test-serving-cell-info     scan-for-operators          enable-throttling
test-push-notification     reset-pin                   enable-modem
test-phonebook             remove-contexts             enable-gprs
test-network-registration  release-and-swap            enable-cbs
test-modem                 release-and-answer          display-icon
test-message-waiting       reject-calls                disable-throttling
test-gnss                  register-operator           disable-modem
test-cbs                   register-auto               disable-gprs
test-call-settings         receive-sms                 disable-call-forwarding
test-call-forwarding       process-context-settings    dial-number
test-call-barring          private-chat                deactivate-context
test-advice-of-charge      online-modem                deactivate-all
swap-calls                 offline-modem               create-multiparty
set-use-sms-reports        monitor-ofono               create-mms-context
set-umts-band              lockdown-modem              create-internet-context
set-tty                    lock-pin                    change-pin
set-tech-preference        list-operators              cdma-set-credentials
set-speaker-volume         list-modems                 cdma-list-call
set-sms-smsc               list-messages               cdma-hangup
set-sms-bearer             list-contexts               cdma-dial-number
set-sms-alphabet           list-calls                  cdma-connman-enable
set-roaming-allowed        list-applications           cdma-connman-disable
set-msisdn                 list-allowed-access-points  cancel-ussd
set-mms-details            initiate-ussd               cancel-sms
set-mic-volume             ims-unregister              backtrace
set-lte-property           ims-register                answer-calls
set-gsm-band               hold-and-answer             activate-context
set-fast-dormancy          hangup-multiparty
```

有关 HFP 客户端功能，请参阅 <a href="perform-bluetooth-hfp-client-functions" target="_self">执行蓝牙 HFP 客户端功能</a>。

## 为 HFP 音频网关功能配置 DUT

在完成 HFP 功能的<a href="#set-up-the-device-for-hfp-functions" target="_self">初始设备设置</a>后，请为 HFP 音频网关执行以下操作：

1. 在 SSH 中运行以下命令启动 `bluetoothctl`：

   ```text theme={null}
   bluetoothctl
   ```

2. 在 `bluetoothctl` 菜单中运行以下命令，验证免提音频网关和耳机的 UUID 是否出现在列表中：

   ```text theme={null}
   show
   ```

   **示例输出**

   ```text theme={null}
   [bluetooth]# show
   Controller 22:22:9B:2C:79:1E (public)
      Name: qcm6490
      Alias: qcm6490
      Class: 0x006c0000
      Powered: yes
      Discoverable: no
      DiscoverableTimeout: 0x000000b4
      Pairable: yes
      UUID: A/V Remote Control        (0000110a-0000-1000-8000-00805f9b34fb)
      UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
      UUID: Handsfree Audio Gateway   (0000111f-0000-1000-8000-00805f9b34fb)
      UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
      UUID: Headset                   (00001108-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: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
      UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
      UUID: Device Information        (0000180a-0000-1000-8000-00805f9b34fb)
      UUID: Handsfree                 (0000111e-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
   [bluetooth]# |
   ```

3. 按如下方式将改进型子带编码（mSBC）编解码器启用为 HFP 音频网关连接的默认编解码器：

   a. 在设备上使用文本编辑器打开 `bluetooth.conf` 文件。

   b. 取消注释 bluetooth.conf 文件中的 `bluez5.enable-msbc = true` 行。

   c. 保存 `bluetooth.conf` 文件。

4. 运行以下命令重新加载 Bluetooth 守护进程：

   ```text theme={null}
   systemctl daemon-reload
   ```

5. 运行以下命令重启 WirePlumber 服务：

   ```text theme={null}
   systemctl restart wireplumber
   ```

   `bluetooth.conf` 配置文件中的更改即在设备上生效。

有关 HFP 音频网关功能，请参阅 <a href="perform-bluetooth-hfp-audio-gateway-functions" target="_self">执行蓝牙 HFP 音频网关功能</a>。

## 后续步骤

### <a href="perform-bluetooth-hfp-client-functions" target="_self">执行蓝牙 HFP 客户端功能</a>

您可以使用 **bluetoothctl** 菜单和 **ofono/test** 工具执行 HFP 客户端功能。蓝牙 HFP 客户端功能包括连接或断开远程设备以及通过蓝牙管理电话呼叫。您可以使用 HFP 客户端功能拨打电话号码、接听或拒接来电以及列出活动通话。

### <a href="perform-bluetooth-hfp-audio-gateway-functions" target="_self">执行蓝牙 HFP 音频网关功能</a>

您可以使用 **bluetoothctl** 菜单和 **paplay** 命令执行 HFP 音频网关功能。蓝牙 HFP 音频网关功能允许您连接或断开远程设备，并验证音频网关功能以确保免提操作正常。
