Skip to content

Commit fb12616

Browse files
lylezhu2012Hardevsinh-Palaniya
authored andcommitted
Bluetooth: classic: shell: Add command query_calls for HFP HF
Add the command `query_calls` to query the current calls list. The received current calls list will be printed in callback `hf_query_call()`. Signed-off-by: Lyle Zhu <[email protected]>
1 parent f2d2060 commit fb12616

File tree

1 file changed

+33
-0
lines changed
  • subsys/bluetooth/host/classic/shell

1 file changed

+33
-0
lines changed

subsys/bluetooth/host/classic/shell/hfp.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,19 @@ void hf_subscriber_number(struct bt_hfp_hf *hf, const char *number, uint8_t type
299299
bt_shell_print("Subscriber number %s, type %d, service %d", number, type, service);
300300
}
301301

302+
#if defined(CONFIG_BT_HFP_HF_ECS)
303+
void hf_query_call(struct bt_hfp_hf *hf, struct bt_hfp_hf_current_call *call)
304+
{
305+
if (call == NULL) {
306+
return;
307+
}
308+
309+
bt_shell_print("CLCC idx %d dir %d status %d mode %d mpty %d number %s type %d",
310+
call->index, call->dir, call->status, call->mode, call->multiparty,
311+
call->number != NULL ? call->number : "UNKNOWN", call->type);
312+
}
313+
#endif /* CONFIG_BT_HFP_HF_ECS */
314+
302315
static struct bt_hfp_hf_cb hf_cb = {
303316
.connected = hf_connected,
304317
.disconnected = hf_disconnected,
@@ -348,6 +361,9 @@ static struct bt_hfp_hf_cb hf_cb = {
348361
#endif /* CONFIG_BT_HFP_HF_VOICE_RECG */
349362
.request_phone_number = hf_request_phone_number,
350363
.subscriber_number = hf_subscriber_number,
364+
#if defined(CONFIG_BT_HFP_HF_ECS)
365+
.query_call = hf_query_call,
366+
#endif /* CONFIG_BT_HFP_HF_ECS */
351367
};
352368

353369
static int cmd_reg_enable(const struct shell *sh, size_t argc, char **argv)
@@ -952,6 +968,20 @@ static int cmd_battery(const struct shell *sh, size_t argc, char **argv)
952968
}
953969
#endif /* CONFIG_BT_HFP_HF_HF_INDICATOR_BATTERY */
954970

971+
#if defined(CONFIG_BT_HFP_HF_ECS)
972+
static int cmd_query_calls(const struct shell *sh, size_t argc, char **argv)
973+
{
974+
int err;
975+
976+
err = bt_hfp_hf_query_list_of_current_calls(hfp_hf);
977+
if (err != 0) {
978+
shell_error(sh, "Failed to query list of current calls: %d", err);
979+
}
980+
981+
return err;
982+
}
983+
#endif /* CONFIG_BT_HFP_HF_ECS */
984+
955985
SHELL_STATIC_SUBCMD_SET_CREATE(hf_cmds,
956986
SHELL_CMD_ARG(reg, NULL, HELP_NONE, cmd_reg_enable, 1, 0),
957987
SHELL_CMD_ARG(connect, NULL, "<channel>", cmd_connect, 2, 0),
@@ -1017,6 +1047,9 @@ SHELL_STATIC_SUBCMD_SET_CREATE(hf_cmds,
10171047
#if defined(CONFIG_BT_HFP_HF_HF_INDICATOR_BATTERY)
10181048
SHELL_CMD_ARG(battery, NULL, "<level>", cmd_battery, 2, 0),
10191049
#endif /* CONFIG_BT_HFP_HF_HF_INDICATOR_BATTERY */
1050+
#if defined(CONFIG_BT_HFP_HF_ECS)
1051+
SHELL_CMD_ARG(query_calls, NULL, HELP_NONE, cmd_query_calls, 1, 0),
1052+
#endif /* */
10201053
SHELL_SUBCMD_SET_END
10211054
);
10221055
#endif /* CONFIG_BT_HFP_HF */

0 commit comments

Comments
 (0)