@@ -39,24 +39,33 @@ static struct bt_hfp_hf_call *hfp_hf_call[CONFIG_BT_HFP_HF_MAX_CALLS];
39
39
40
40
static void hf_add_a_call (struct bt_hfp_hf_call * call )
41
41
{
42
- for ( size_t index = 0 ; index < ARRAY_SIZE ( hfp_hf_call ); index ++ ) {
43
- if (!hfp_hf_call [index ]) {
44
- hfp_hf_call [index ] = call ;
42
+ ARRAY_FOR_EACH ( hfp_hf_call , i ) {
43
+ if (!hfp_hf_call [i ]) {
44
+ hfp_hf_call [i ] = call ;
45
45
return ;
46
46
}
47
47
}
48
48
}
49
49
50
50
static void hf_remove_a_call (struct bt_hfp_hf_call * call )
51
51
{
52
- for ( size_t index = 0 ; index < ARRAY_SIZE ( hfp_hf_call ); index ++ ) {
53
- if (call == hfp_hf_call [index ]) {
54
- hfp_hf_call [index ] = NULL ;
52
+ ARRAY_FOR_EACH ( hfp_hf_call , i ) {
53
+ if (call == hfp_hf_call [i ]) {
54
+ hfp_hf_call [i ] = NULL ;
55
55
return ;
56
56
}
57
57
}
58
58
}
59
59
60
+ static void hf_remove_calls (void )
61
+ {
62
+ ARRAY_FOR_EACH (hfp_hf_call , i ) {
63
+ if (hfp_hf_call [i ] != NULL ) {
64
+ hfp_hf_call [i ] = NULL ;
65
+ }
66
+ }
67
+ }
68
+
60
69
static void hf_connected (struct bt_conn * conn , struct bt_hfp_hf * hf )
61
70
{
62
71
hf_conn = conn ;
@@ -68,6 +77,7 @@ static void hf_disconnected(struct bt_hfp_hf *hf)
68
77
{
69
78
hf_conn = NULL ;
70
79
hfp_hf = NULL ;
80
+ hf_remove_calls ();
71
81
bt_shell_print ("HF disconnected" );
72
82
}
73
83
@@ -976,24 +986,33 @@ static struct bt_hfp_ag_call *hfp_ag_call[CONFIG_BT_HFP_AG_MAX_CALLS];
976
986
977
987
static void ag_add_a_call (struct bt_hfp_ag_call * call )
978
988
{
979
- for ( size_t index = 0 ; index < ARRAY_SIZE ( hfp_ag_call ); index ++ ) {
980
- if (!hfp_ag_call [index ]) {
981
- hfp_ag_call [index ] = call ;
989
+ ARRAY_FOR_EACH ( hfp_ag_call , i ) {
990
+ if (!hfp_ag_call [i ]) {
991
+ hfp_ag_call [i ] = call ;
982
992
return ;
983
993
}
984
994
}
985
995
}
986
996
987
997
static void ag_remove_a_call (struct bt_hfp_ag_call * call )
988
998
{
989
- for ( size_t index = 0 ; index < ARRAY_SIZE ( hfp_ag_call ); index ++ ) {
990
- if (call == hfp_ag_call [index ]) {
991
- hfp_ag_call [index ] = NULL ;
999
+ ARRAY_FOR_EACH ( hfp_ag_call , i ) {
1000
+ if (call == hfp_ag_call [i ]) {
1001
+ hfp_ag_call [i ] = NULL ;
992
1002
return ;
993
1003
}
994
1004
}
995
1005
}
996
1006
1007
+ static void ag_remove_calls (void )
1008
+ {
1009
+ ARRAY_FOR_EACH (hfp_ag_call , i ) {
1010
+ if (hfp_ag_call [i ] != NULL ) {
1011
+ hfp_ag_call [i ] = NULL ;
1012
+ }
1013
+ }
1014
+ }
1015
+
997
1016
static void ag_connected (struct bt_conn * conn , struct bt_hfp_ag * ag )
998
1017
{
999
1018
if (conn != default_conn ) {
@@ -1005,6 +1024,7 @@ static void ag_connected(struct bt_conn *conn, struct bt_hfp_ag *ag)
1005
1024
1006
1025
static void ag_disconnected (struct bt_hfp_ag * ag )
1007
1026
{
1027
+ ag_remove_calls ();
1008
1028
bt_shell_print ("AG disconnected" );
1009
1029
}
1010
1030
0 commit comments