25
25
26
26
static struct bt_conn * default_conn ;
27
27
struct bt_hfp_ag * hfp_ag ;
28
-
29
- static struct bt_br_discovery_param br_discover ;
28
+ struct bt_hfp_ag_call * hfp_ag_call ;
30
29
31
30
static struct bt_br_discovery_param br_discover ;
32
31
static struct bt_br_discovery_result scan_result [CONFIG_BT_HFP_AG_DISCOVER_RESULT_COUNT ];
@@ -43,6 +42,9 @@ NET_BUF_POOL_DEFINE(sdp_discover_pool, 10, BT_L2CAP_BUF_SIZE(CONFIG_BT_L2CAP_TX_
43
42
44
43
static void ag_connected (struct bt_hfp_ag * ag )
45
44
{
45
+ if (!hfp_ag ) {
46
+ hfp_ag = ag ;
47
+ }
46
48
printk ("HFP AG connected!\n" );
47
49
k_work_schedule (& call_connect_work , K_MSEC (CONFIG_BT_HFP_AG_START_CALL_DELAY_TIME ));
48
50
}
@@ -62,38 +64,40 @@ static void ag_sco_disconnected(struct bt_hfp_ag *ag)
62
64
printk ("HFP AG SCO disconnected!\n" );
63
65
}
64
66
65
- static void ag_ringing (struct bt_hfp_ag * ag , bool in_band )
67
+ static void ag_ringing (struct bt_hfp_ag_call * call , bool in_band )
66
68
{
67
69
printk ("Ringing (in bond? %s)\n" , in_band ? "Yes" : "No" );
68
70
}
69
71
70
- static void ag_accept (struct bt_hfp_ag * ag )
72
+ static void ag_accept (struct bt_hfp_ag_call * call )
71
73
{
72
74
printk ("Call Accepted\n" );
73
75
k_work_schedule (& call_disconnect_work , K_SECONDS (10 ));
74
76
}
75
77
76
- static void ag_reject (struct bt_hfp_ag * ag )
78
+ static void ag_reject (struct bt_hfp_ag_call * call )
77
79
{
78
80
printk ("Call Rejected\n" );
79
81
k_work_schedule (& call_disconnect_work , K_SECONDS (1 ));
80
82
}
81
83
82
- static void ag_terminate (struct bt_hfp_ag * ag )
84
+ static void ag_terminate (struct bt_hfp_ag_call * call )
83
85
{
84
86
printk ("Call terminated\n" );
85
87
k_work_schedule (& call_disconnect_work , K_SECONDS (1 ));
86
88
}
87
89
88
- static void ag_outgoing (struct bt_hfp_ag * ag , const char * number )
90
+ static void ag_outgoing (struct bt_hfp_ag * ag , struct bt_hfp_ag_call * call , const char * number )
89
91
{
92
+ hfp_ag_call = call ;
90
93
printk ("Call outgoing, remote number %s\n" , number );
91
94
k_work_cancel_delayable (& call_connect_work );
92
95
k_work_schedule (& call_remote_ringing_work , K_SECONDS (1 ));
93
96
}
94
97
95
- static void ag_incoming (struct bt_hfp_ag * ag , const char * number )
98
+ static void ag_incoming (struct bt_hfp_ag * ag , struct bt_hfp_ag_call * call , const char * number )
96
99
{
100
+ hfp_ag_call = call ;
97
101
printk ("Incoming call, remote number %s\n" , number );
98
102
k_work_cancel_delayable (& call_connect_work );
99
103
}
@@ -329,7 +333,7 @@ static void call_remote_ringing_work_handler(struct k_work *work)
329
333
330
334
printk ("Remote starts ringing\n" );
331
335
332
- err = bt_hfp_ag_remote_ringing (hfp_ag );
336
+ err = bt_hfp_ag_remote_ringing (hfp_ag_call );
333
337
334
338
if (err != 0 ) {
335
339
printk ("Fail to notify hfp unit that the remote starts ringing (err %d)\n" , err );
@@ -344,7 +348,7 @@ static void call_remote_accept_work_handler(struct k_work *work)
344
348
345
349
printk ("Remote accepts the call\n" );
346
350
347
- err = bt_hfp_ag_remote_accept (hfp_ag );
351
+ err = bt_hfp_ag_remote_accept (hfp_ag_call );
348
352
349
353
if (err != 0 ) {
350
354
printk ("Fail to notify hfp unit that the remote accepts call (err %d)\n" , err );
0 commit comments