Skip to content

Commit fcedda6

Browse files
lylezhu2012kartben
authored andcommitted
Sample: Bluetooth: HFP_AG: Update the sample
Due to the interface of AG is updated, update AG sample accordingly. Signed-off-by: Lyle Zhu <[email protected]>
1 parent 67e01df commit fcedda6

File tree

1 file changed

+14
-10
lines changed
  • samples/bluetooth/handsfree_ag/src

1 file changed

+14
-10
lines changed

samples/bluetooth/handsfree_ag/src/main.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525

2626
static struct bt_conn *default_conn;
2727
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;
3029

3130
static struct bt_br_discovery_param br_discover;
3231
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_
4342

4443
static void ag_connected(struct bt_hfp_ag *ag)
4544
{
45+
if (!hfp_ag) {
46+
hfp_ag = ag;
47+
}
4648
printk("HFP AG connected!\n");
4749
k_work_schedule(&call_connect_work, K_MSEC(CONFIG_BT_HFP_AG_START_CALL_DELAY_TIME));
4850
}
@@ -62,38 +64,40 @@ static void ag_sco_disconnected(struct bt_hfp_ag *ag)
6264
printk("HFP AG SCO disconnected!\n");
6365
}
6466

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)
6668
{
6769
printk("Ringing (in bond? %s)\n", in_band ? "Yes" : "No");
6870
}
6971

70-
static void ag_accept(struct bt_hfp_ag *ag)
72+
static void ag_accept(struct bt_hfp_ag_call *call)
7173
{
7274
printk("Call Accepted\n");
7375
k_work_schedule(&call_disconnect_work, K_SECONDS(10));
7476
}
7577

76-
static void ag_reject(struct bt_hfp_ag *ag)
78+
static void ag_reject(struct bt_hfp_ag_call *call)
7779
{
7880
printk("Call Rejected\n");
7981
k_work_schedule(&call_disconnect_work, K_SECONDS(1));
8082
}
8183

82-
static void ag_terminate(struct bt_hfp_ag *ag)
84+
static void ag_terminate(struct bt_hfp_ag_call *call)
8385
{
8486
printk("Call terminated\n");
8587
k_work_schedule(&call_disconnect_work, K_SECONDS(1));
8688
}
8789

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)
8991
{
92+
hfp_ag_call = call;
9093
printk("Call outgoing, remote number %s\n", number);
9194
k_work_cancel_delayable(&call_connect_work);
9295
k_work_schedule(&call_remote_ringing_work, K_SECONDS(1));
9396
}
9497

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)
9699
{
100+
hfp_ag_call = call;
97101
printk("Incoming call, remote number %s\n", number);
98102
k_work_cancel_delayable(&call_connect_work);
99103
}
@@ -329,7 +333,7 @@ static void call_remote_ringing_work_handler(struct k_work *work)
329333

330334
printk("Remote starts ringing\n");
331335

332-
err = bt_hfp_ag_remote_ringing(hfp_ag);
336+
err = bt_hfp_ag_remote_ringing(hfp_ag_call);
333337

334338
if (err != 0) {
335339
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)
344348

345349
printk("Remote accepts the call\n");
346350

347-
err = bt_hfp_ag_remote_accept(hfp_ag);
351+
err = bt_hfp_ag_remote_accept(hfp_ag_call);
348352

349353
if (err != 0) {
350354
printk("Fail to notify hfp unit that the remote accepts call (err %d)\n", err);

0 commit comments

Comments
 (0)