> ## 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 客户端功能

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

## 前提条件

开始之前，请<a href="verify-hfp-functions#set-up-the-device-for-hfp-functions" target="_self">设置您的设备</a>并<a href="verify-hfp-functions#configure-the-dut-for-hfp-client-functions" target="_self">为 HFP 客户端功能配置 DUT</a>。

## 连接远程设备

要连接远程设备，请在 `bluetoothctl` 菜单中运行以下命令：

```text theme={null}
connect <bt_address>
```

**参数**

`<bt_address>` 是远程设备的蓝牙地址。

**示例**

要连接 `<bt_address>` 为 `F8:7D:76:9D:9B:6B` 的已配对远程设备，请运行以下命令：

```text theme={null}
connect F8:7D:76:9D:9B:6B
```

**示例输出**

```text theme={null}
[bluetooth]# connect F8:7D:76:9D:9B:6B
Attempting to connect to F8:7D:76:9D:9B:6B
(CHG) Device F8:7D:76:9D:9B:6B Connected: yes
[NEW] Endpoint /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/sep3
[NEW] Endpoint /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/sep4
[NEW] Endpoint /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/sep5
[NEW] Endpoint /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/sep6
(NEW) Endpoint /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/sep1
(NEW) Endpoint /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/sep2
[NEW] Transport /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/sep1/fd0
Connection successful
[NEW] Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 [default]
[NEW] Item /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0/Filesystem /Filesystem
[NEW) Item /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0/NowPlaying /NowPlaying
[CHG) Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Type: Audio
[CHG] Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Subtype: None
[CHG] Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Status: stopped
[CHG] Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Browsable: yes
[CHG] Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Searchable: yes
[CHG) Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Playlist: /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0/NowPlaying
(CHG) Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Name: Music
[CHG] Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Repeat: off
[CHG] Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Shuffle: off
[NEW] Folder /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0
[CHG] Device F8:7D:76:9D:9B:6B ServicesResolved: yes
(CHG) Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Duration: 0x00000000 (0)
(CHG) Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Genre:
[CHG] Player /org/blwez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Title:
[CHG] Player /org/blwez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Item: /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player@/NowPlaying/item18446749073709551615
[CHG] Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 TrackNumber: 0x00000000 (0)
[CHG] Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Artist:
(CHG) Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 NumberOfTracks: 0x00000000 (0)
[CHG) Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Album:
[NEW] Item /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0/NowPlaying/item18446744073709551615 <unknown>
[CHG] Player /org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/player0 Position: 0x00000000 (0)
[MyDeviceA]#
```

## 拨打电话号码

要拨打电话号码，请在 `ofono/test` 菜单中运行以下命令：

```text theme={null}
./dial-number <phone_number>
```

**参数**

`<phone_number>` 是您要拨打的电话号码。

**示例输出**

```text theme={null}
sh-5.1# ./dial-number 7123456789
Using modem /hfp/org/bluez/hci0/dev_F8_7D_76_9D_9B_6B
/hfp/org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/voicecall01
sh-5.1#
```

## 接听来电

要接听来电，请在 `ofono/test` 菜单中运行以下命令：

```text theme={null}
./answer-calls
```

**示例输出**

```text theme={null}
sh-5.1# ./answer-calls
[ /hfp/org/bluez/hci0/dev_F8_7D_76_9D_9B_6B ]
[ /hfp/org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/voicecall01 ] incoming
sh-5.1# |
```

<Note>
  在通话中会听到回声。这是使用 BlueZ 协议栈的软件中的已知行为。
</Note>

## 列出活动通话

要列出活动通话，请在 `ofono/test` 菜单中运行以下命令：

```text theme={null}
./list-calls
```

**示例输出**

```text theme={null}
sh-5.1# ./list-calls
[ /hfp/org/bluez/hci0/dev_F8_7D_76_9D_9B_6B ]
[ /hfp/org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/voicecall01 ]
      State = incoming
      LineIdentification = +917123456789
      Name =
      Multiparty = 0
      RemoteHeld = 0
      RemoteMultiparty = 0
      Emergency = 0
```

## 拒接或挂断通话

要拒接或挂断通话，请在 `ofono/test` 菜单中运行以下命令：

```text theme={null}
./hangup-call <call_path>
```

**参数**

`<call_path>` 是活动通话的通话路径。

**示例**

要挂断路径为 `/hfp/org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/voicecall01` 的通话，请运行以下命令：

```text theme={null}
./hangup-call /hfp/org/bluez/hci0/dev_F8_7D_76_9D_9B_6B/voicecall01
```

## 断开远程设备

要断开远程设备，请在 `bluetoothctl` 菜单中运行以下命令：

```text theme={null}
disconnect <bt_address>
```

**参数**

`<bt_address>` 是远程设备的蓝牙地址。

**示例**

要断开 `<bt_address>` 为 `F8:7D:76:9D:9B:6B` 的已配对远程设备，请运行以下命令：

```text theme={null}
disconnect F8:7D:76:9D:9B:6B
```

**示例输出**

```text theme={null}
[MyDeviceA]# disconnect
Attempting to disconnect from F8:7D:76:9D:9B:6B
[CHG] Device F8:7D:76:9D:9B:6B ServicesResolved: no
Successful disconnected
[CHG] Device F8:7D:76:9D:9B:6B Connected: no
[bluetooth]#
```
