@@ -974,6 +974,10 @@ struct bt_hfp_ag *hfp_ag;
974974struct bt_conn * hfp_ag_sco_conn ;
975975static struct bt_hfp_ag_call * hfp_ag_call [CONFIG_BT_HFP_AG_MAX_CALLS ];
976976
977+ static struct bt_hfp_ag_existing_call ag_existing_call_info [CONFIG_BT_HFP_AG_MAX_CALLS ];
978+
979+ static size_t ag_existing_calls ;
980+
977981static void ag_add_a_call (struct bt_hfp_ag_call * call )
978982{
979983 for (size_t index = 0 ; index < ARRAY_SIZE (hfp_ag_call ); index ++ ) {
@@ -1032,6 +1036,30 @@ static void ag_sco_disconnected(struct bt_conn *sco_conn, uint8_t reason)
10321036 }
10331037}
10341038
1039+ static int ag_get_existing_call (struct bt_hfp_ag * ag , struct bt_hfp_ag_existing_call * call )
1040+ {
1041+ static int call_index ;
1042+
1043+ if ((ag_existing_calls < 1 ) || (call == NULL )) {
1044+ return - EINVAL ;
1045+ }
1046+
1047+ if (ag_existing_calls > ARRAY_SIZE (ag_existing_call_info )) {
1048+ ag_existing_calls = ARRAY_SIZE (ag_existing_call_info );
1049+ }
1050+
1051+ if (call_index >= ag_existing_calls ) {
1052+ call_index = 0 ;
1053+ ag_existing_calls = 0 ;
1054+ return - EINVAL ;
1055+ }
1056+
1057+ memcpy (call , & ag_existing_call_info [call_index ], sizeof (* call ));
1058+ call_index ++ ;
1059+
1060+ return 0 ;
1061+ }
1062+
10351063static int ag_memory_dial (struct bt_hfp_ag * ag , const char * location , char * * number )
10361064{
10371065 static char * phone = "123456789" ;
@@ -1229,6 +1257,7 @@ static struct bt_hfp_ag_cb ag_cb = {
12291257 .disconnected = ag_disconnected ,
12301258 .sco_connected = ag_sco_connected ,
12311259 .sco_disconnected = ag_sco_disconnected ,
1260+ .get_existing_call = ag_get_existing_call ,
12321261 .memory_dial = ag_memory_dial ,
12331262 .number_call = ag_number_call ,
12341263 .outgoing = ag_outgoing ,
@@ -1317,6 +1346,28 @@ static int cmd_ag_sco_disconnect(const struct shell *sh, size_t argc, char **arg
13171346 return err ;
13181347}
13191348
1349+ static int cmd_ag_existing_call (const struct shell * sh , size_t argc , char * * argv )
1350+ {
1351+ size_t max_calls ;
1352+
1353+ max_calls = MIN (CONFIG_BT_HFP_AG_MAX_CALLS , ARRAY_SIZE (ag_existing_call_info ));
1354+ if (ag_existing_calls >= max_calls ) {
1355+ shell_error (sh , "Supported max call count %d" , max_calls );
1356+ return - EINVAL ;
1357+ }
1358+
1359+ memset (ag_existing_call_info [ag_existing_calls ].number , 0 ,
1360+ sizeof (ag_existing_call_info [ag_existing_calls ].number ));
1361+ memcpy (ag_existing_call_info [ag_existing_calls ].number , argv [1 ],
1362+ MIN (strlen (argv [1 ]), sizeof (ag_existing_call_info [ag_existing_calls ].number ) - 1 ));
1363+ ag_existing_call_info [ag_existing_calls ].type = (uint8_t )atoi (argv [2 ]);
1364+ ag_existing_call_info [ag_existing_calls ].status = (enum bt_hfp_ag_call_status )atoi (argv [3 ]);
1365+ ag_existing_call_info [ag_existing_calls ].dir = atoi (argv [4 ]) > 0 ? true : false;
1366+
1367+ ag_existing_calls ++ ;
1368+ return 0 ;
1369+ }
1370+
13201371static int cmd_ag_remote_incoming (const struct shell * sh , size_t argc , char * * argv )
13211372{
13221373 int err ;
@@ -1857,6 +1908,8 @@ SHELL_STATIC_SUBCMD_SET_CREATE(ag_cmds,
18571908 SHELL_CMD_ARG (connect , NULL , "<channel>" , cmd_ag_connect , 2 , 0 ),
18581909 SHELL_CMD_ARG (disconnect , NULL , HELP_NONE , cmd_ag_disconnect , 1 , 0 ),
18591910 SHELL_CMD_ARG (sco_disconnect , NULL , HELP_NONE , cmd_ag_sco_disconnect , 1 , 0 ),
1911+ SHELL_CMD_ARG (existing_calls , NULL , "<number> <type> <status> <dir>" ,
1912+ cmd_ag_existing_call , 5 , 0 ),
18601913 SHELL_CMD_ARG (remote_incoming , NULL , "<number>" , cmd_ag_remote_incoming , 2 , 0 ),
18611914 SHELL_CMD_ARG (hold_incoming , NULL , "<number>" , cmd_ag_hold_incoming , 2 , 0 ),
18621915 SHELL_CMD_ARG (remote_reject , NULL , "<call index>" , cmd_ag_remote_reject , 2 , 0 ),
0 commit comments