Skip to content

Commit 68d2526

Browse files
lylezhu2012kartben
authored andcommitted
Sample: Bluetooth: HFP_HF: Update the sample
Due to the interface of HF is updated, update HF sample accordingly. Signed-off-by: Lyle Zhu <[email protected]>
1 parent eb327af commit 68d2526

File tree

1 file changed

+60
-24
lines changed
  • samples/bluetooth/handsfree/src

1 file changed

+60
-24
lines changed

samples/bluetooth/handsfree/src/main.c

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,67 +19,103 @@
1919
#include <zephyr/bluetooth/classic/hfp_hf.h>
2020
#include <zephyr/settings/settings.h>
2121

22-
static void connected(struct bt_conn *conn)
22+
static void hf_connected(struct bt_conn *conn, struct bt_hfp_hf *hf)
2323
{
2424
printk("HFP HF Connected!\n");
2525
}
2626

27-
static void disconnected(struct bt_conn *conn)
27+
static void hf_disconnected(struct bt_hfp_hf *hf)
2828
{
2929
printk("HFP HF Disconnected!\n");
3030
}
3131

32-
static void service(struct bt_conn *conn, uint32_t value)
32+
static void hf_sco_connected(struct bt_hfp_hf *hf, struct bt_conn *sco_conn)
33+
{
34+
printk("HF SCO connected\n");
35+
}
36+
37+
static void hf_sco_disconnected(struct bt_conn *sco_conn, uint8_t reason)
38+
{
39+
printk("HF SCO disconnected\n");
40+
}
41+
42+
static void hf_service(struct bt_hfp_hf *hf, uint32_t value)
3343
{
3444
printk("Service indicator value: %u\n", value);
3545
}
3646

37-
static void call(struct bt_conn *conn, uint32_t value)
47+
static void hf_outgoing(struct bt_hfp_hf *hf, struct bt_hfp_hf_call *call)
48+
{
49+
printk("HF call %p outgoing\n", call);
50+
}
51+
52+
static void hf_remote_ringing(struct bt_hfp_hf_call *call)
53+
{
54+
printk("HF remote call %p start ringing\n", call);
55+
}
56+
57+
static void hf_incoming(struct bt_hfp_hf *hf, struct bt_hfp_hf_call *call)
58+
{
59+
printk("HF call %p incoming\n", call);
60+
}
61+
62+
static void hf_incoming_held(struct bt_hfp_hf_call *call)
63+
{
64+
printk("HF call %p is held\n", call);
65+
}
66+
67+
static void hf_accept(struct bt_hfp_hf_call *call)
3868
{
39-
printk("Call indicator value: %u\n", value);
69+
printk("HF call %p accepted\n", call);
4070
}
4171

42-
static void call_setup(struct bt_conn *conn, uint32_t value)
72+
static void hf_reject(struct bt_hfp_hf_call *call)
4373
{
44-
printk("Call Setup indicator value: %u\n", value);
74+
printk("HF call %p rejected\n", call);
4575
}
4676

47-
static void call_held(struct bt_conn *conn, uint32_t value)
77+
static void hf_terminate(struct bt_hfp_hf_call *call)
4878
{
49-
printk("Call Held indicator value: %u\n", value);
79+
printk("HF call %p terminated\n", call);
5080
}
5181

52-
static void signal(struct bt_conn *conn, uint32_t value)
82+
static void hf_signal(struct bt_hfp_hf *hf, uint32_t value)
5383
{
5484
printk("Signal indicator value: %u\n", value);
5585
}
5686

57-
static void roam(struct bt_conn *conn, uint32_t value)
87+
static void hf_roam(struct bt_hfp_hf *hf, uint32_t value)
5888
{
5989
printk("Roaming indicator value: %u\n", value);
6090
}
6191

62-
static void battery(struct bt_conn *conn, uint32_t value)
92+
static void hf_battery(struct bt_hfp_hf *hf, uint32_t value)
6393
{
6494
printk("Battery indicator value: %u\n", value);
6595
}
6696

67-
static void ring_cb(struct bt_conn *conn)
97+
static void hf_ring_indication(struct bt_hfp_hf_call *call)
6898
{
69-
printk("Incoming Call...\n");
99+
printk("HF call %p ring\n", call);
70100
}
71101

72102
static struct bt_hfp_hf_cb hf_cb = {
73-
.connected = connected,
74-
.disconnected = disconnected,
75-
.service = service,
76-
.call = call,
77-
.call_setup = call_setup,
78-
.call_held = call_held,
79-
.signal = signal,
80-
.roam = roam,
81-
.battery = battery,
82-
.ring_indication = ring_cb,
103+
.connected = hf_connected,
104+
.disconnected = hf_disconnected,
105+
.sco_connected = hf_sco_connected,
106+
.sco_disconnected = hf_sco_disconnected,
107+
.service = hf_service,
108+
.outgoing = hf_outgoing,
109+
.remote_ringing = hf_remote_ringing,
110+
.incoming = hf_incoming,
111+
.incoming_held = hf_incoming_held,
112+
.accept = hf_accept,
113+
.reject = hf_reject,
114+
.terminate = hf_terminate,
115+
.signal = hf_signal,
116+
.roam = hf_roam,
117+
.battery = hf_battery,
118+
.ring_indication = hf_ring_indication,
83119
};
84120

85121
static void bt_ready(int err)

0 commit comments

Comments
 (0)