蓝牙:经典:HFP Shell

本文档介绍如何运行蓝牙经典 HFP 功能。 hfp 命令提供蓝牙经典 HFP Shell 命令。

有两个子命令: hfp hf 和 hfp ag。

hfp hf 用于免提配置文件(HF)功能, hfp ag 用于音频网关(AG)功能。

命令

除 hfp hf reg 和 hfp ag reg 之外,所有命令都只能在建立 ACL 连接后使用。

hfp 命令:

uart:~$ hfp
hfp - Bluetooth HFP shell commands
Subcommands:
  hf  : HFP HF shell commands
  ag  : HFP AG shell commands

hfp hf 命令:

uart:~$ hfp hf
hf - HFP HF shell commands
Subcommands:
  reg                          : [none]
  connect                      : <channel>
  disconnect                   : [none]
  sco_disconnect               : [none]
  cli                          : <enable/disable>
  vgm                          : <gain>
  vgs                          : <gain>
  operator                     : [none]
  audio_connect                : [none]
  auto_select_codec            : <enable/disable>
  select_codec                 : Codec ID
  set_codecs                   : Codec ID Map
  accept                       : <call index>
  reject                       : <call index>
  terminate                    : <call index>
  hold_incoming                : <call index>
  query_respond_hold_status    : [none]
  number_call                  : <phone number>
  memory_dial                  : <memory location>
  redial                       : [none]
  turn_off_ecnr                : [none]
  call_waiting_notify          : <enable/disable>
  release_all_held             : [none]
  set_udub                     : [none]
  release_active_accept_other  : [none]
  hold_active_accept_other     : [none]
  join_conversation            : [none]
  explicit_call_transfer       : [none]
  release_specified_call       : <call index>
  private_consultation_mode    : <call index>
  voice_recognition            : <activate/deactivate>
  ready_to_accept_audio        : [none]
  request_phone_number         : [none]
  transmit_dtmf_code           : <call index> <code(set 0-9, #,*,A-D)>
  query_subscriber             : [none]
  indicator_status             : <Activate/deactivate AG indicators bitmap>
  enhanced_safety              : <enable/disable>
  battery                      : <level>

hfp ag 命令:

uart:~$ hfp ag
ag - HFP AG shell commands
Subcommands:
  reg                     : [none]
  connect                 : <channel>
  disconnect              : [none]
  sco_disconnect          : [none]
  ongoing_calls           : <yes or no>
  set_ongoing_calls       : <number> <type> <status> <dir> [all]
  remote_incoming         : <number>
  hold_incoming           : <number>
  remote_reject           : <call index>
  remote_accept           : <call index>
  remote_terminate        : <call index>
  remote_ringing          : <call index>
  outgoing                : <number>
  reject                  : <call index>
  accept                  : <call index>
  hold                    : <call index>
  retrieve                : <call index>
  terminate               : <call index>
  vgm                     : <gain>
  vgs                     : <gain>
  operator                : <mode> <operator>
  audio_connect           : <codec id>
  inband_ringtone         : <enable/disable>
  explicit_call_transfer  : [none]
  voice_recognition       : <activate/deactivate>
  vre_state               : <[R-ready][S-send][P-processing]>
  vre_text                : <[R-ready][S-send][P-processing]> <id> <type>
                            <operation> <text string>
  subscriber              : <empty/notempty>
  signal_strength         : <signal strength>
  roaming_status          : <roaming status>
  battery_level           : <battery level>
  service_availability    : <yes/no>
  hf_indicator            : <indicator> <enable/disable>

HFP AG SLC

hfp ag 子命令提供蓝牙经典中 HFP AG 的功能。

  1. 注册 HFP AG:

uart:~$ hfp ag reg
  1. 连接到 HFP HF:

uart:~$ hfp ag connect 1
  1. 已与 HF 设备建立连接:

Security changed: XX:XX:XX:XX:XX:XX level 2
AG received codec id bit map 2
AG connected
AG received vgm 0
AG received vgs 0
  1. 断开与 HFP HF 的连接:

uart:~$ hfp ag disconnect
  1. 连接已断开:

AG disconnected

HFP HF SLC

hfp hf 子命令提供蓝牙经典中 HFP HF 的功能。

  1. 注册 HFP HF:

uart:~$ hfp hf reg
  1. 连接到 HFP AG:

uart:~$ hfp hf connect 2
  1. 已与 AG 设备建立连接:

Security changed: XX:XX:XX:XX:XX:XX level 2
HF service 0
HF signal 0
HF roam 0
HF battery 0
HF ring: in-band
HF connected
  1. 断开与 HFP HF 的连接:

uart:~$ hfp hf disconnect
  1. 连接已断开:

HF disconnected

去电

使用 AG 提供的电话号码拨打电话:

uart:~$ hfp ag outgoing 123456
AG outgoing call 0x20007690, number 123456
AG SCO connected 0x20005248
AG SCO info:
  SCO handle 0x0008
  SCO air mode 2
  SCO link type 2
uart:~$ hfp ag remote_ringing 0
AG call 0x20007690 start ringing mode 1
uart:~$ hfp ag remote_accept 0
AG call 0x20007690 accept

使用 HF 提供的电话号码拨打电话:

uart:~$
AG number call
AG outgoing call 0x20007690, number 123456789
AG SCO connected 0x20005248
AG SCO info:
  SCO handle 0x0008
  SCO air mode 2
  SCO link type 2
uart:~$ hfp ag remote_ringing 0
AG call 0x20007690 start ringing mode 1
uart:~$ hfp ag remote_accept 0
AG call 0x20007690 accept

来电

从 AG 接听来电:

uart:~$ hfp ag remote_incoming 123456
AG incoming call 0x20007690, number 123456
AG call 0x20007690 start ringing mode 1
AG SCO connected 0x20005248
AG SCO info:
  SCO handle 0x0008
  SCO air mode 2
  SCO link type 2
uart:~$ hfp ag accept 0
AG call 0x20007690 accept

从 HF 接听来电:

uart:~$ hfp ag remote_incoming 123456
AG incoming call 0x20007690, number 123456
AG codec negotiation result 0
AG call 0x20007690 start ringing mode 1
AG SCO connected 0x20005248
AG SCO info:
  SCO handle 0x0008
  SCO air mode 2
  SCO link type 2
AG call 0x20007690 accept

通话终止

去电或来电接通后,可以从 AG(音频网关)或 HF(免提)侧终止通话。

从 AG 终止通话过程:

uart:~$ hfp ag terminate 0
AG call 0x20007690 terminate
AG SCO disconnected 0x20005248 (reason 22)

从 HF 终止通话过程:

AG call 0x20007690 terminate
AG SCO disconnected 0x20005248 (reason 22)

从远端终止通话过程:

uart:~$ hfp ag remote_terminate 0
AG call 0x20007690 terminate
AG SCO disconnected 0x20005248 (reason 22)