1 /** @file
2  *  @brief Handsfree Profile handling.
3  */
4 
5 /*
6  * Copyright (c) 2015-2016 Intel Corporation
7  *
8  * SPDX-License-Identifier: Apache-2.0
9  */
10 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_HFP_HF_H_
11 #define ZEPHYR_INCLUDE_BLUETOOTH_HFP_HF_H_
12 
13 /**
14  * @brief Hands Free Profile (HFP)
15  * @defgroup bt_hfp Hands Free Profile (HFP)
16  * @ingroup bluetooth
17  * @{
18  */
19 
20 #include <bluetooth/bluetooth.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /* AT Commands */
27 enum bt_hfp_hf_at_cmd {
28 	BT_HFP_HF_ATA,
29 	BT_HFP_HF_AT_CHUP,
30 };
31 
32 /*
33  * Command complete types for the application
34  */
35 #define HFP_HF_CMD_OK             0
36 #define HFP_HF_CMD_ERROR          1
37 #define HFP_HF_CMD_CME_ERROR      2
38 #define HFP_HF_CMD_UNKNOWN_ERROR  4
39 
40 /** @brief HFP HF Command completion field */
41 struct bt_hfp_hf_cmd_complete {
42 	/* Command complete status */
43 	uint8_t type;
44 	/* CME error number to be added */
45 	uint8_t cme;
46 };
47 
48 /** @brief HFP profile application callback */
49 struct bt_hfp_hf_cb {
50 	/** HF connected callback to application
51 	 *
52 	 *  If this callback is provided it will be called whenever the
53 	 *  connection completes.
54 	 *
55 	 *  @param conn Connection object.
56 	 */
57 	void (*connected)(struct bt_conn *conn);
58 	/** HF disconnected callback to application
59 	 *
60 	 *  If this callback is provided it will be called whenever the
61 	 *  connection gets disconnected, including when a connection gets
62 	 *  rejected or cancelled or any error in SLC establisment.
63 	 *
64 	 *  @param conn Connection object.
65 	 */
66 	void (*disconnected)(struct bt_conn *conn);
67 	/** HF indicator Callback
68 	 *
69 	 *  This callback provides service indicator value to the application
70 	 *
71 	 *  @param conn Connection object.
72 	 *  @param value service indicator value received from the AG.
73 	 */
74 	void (*service)(struct bt_conn *conn, uint32_t value);
75 	/** HF indicator Callback
76 	 *
77 	 *  This callback provides call indicator value to the application
78 	 *
79 	 *  @param conn Connection object.
80 	 *  @param value call indicator value received from the AG.
81 	 */
82 	void (*call)(struct bt_conn *conn, uint32_t value);
83 	/** HF indicator Callback
84 	 *
85 	 *  This callback provides call setup indicator value to the application
86 	 *
87 	 *  @param conn Connection object.
88 	 *  @param value call setup indicator value received from the AG.
89 	 */
90 	void (*call_setup)(struct bt_conn *conn, uint32_t value);
91 	/** HF indicator Callback
92 	 *
93 	 *  This callback provides call held indicator value to the application
94 	 *
95 	 *  @param conn Connection object.
96 	 *  @param value call held indicator value received from the AG.
97 	 */
98 	void (*call_held)(struct bt_conn *conn, uint32_t value);
99 	/** HF indicator Callback
100 	 *
101 	 *  This callback provides signal indicator value to the application
102 	 *
103 	 *  @param conn Connection object.
104 	 *  @param value signal indicator value received from the AG.
105 	 */
106 	void (*signal)(struct bt_conn *conn, uint32_t value);
107 	/** HF indicator Callback
108 	 *
109 	 *  This callback provides roaming indicator value to the application
110 	 *
111 	 *  @param conn Connection object.
112 	 *  @param value roaming indicator value received from the AG.
113 	 */
114 	void (*roam)(struct bt_conn *conn, uint32_t value);
115 	/** HF indicator Callback
116 	 *
117 	 *  This callback battery service indicator value to the application
118 	 *
119 	 *  @param conn Connection object.
120 	 *  @param value battery indicator value received from the AG.
121 	 */
122 	void (*battery)(struct bt_conn *conn, uint32_t value);
123 	/** HF incoming call Ring indication callback to application
124 	 *
125 	 *  If this callback is provided it will be called whenever there
126 	 *  is an incoming call.
127 	 *
128 	 *  @param conn Connection object.
129 	 */
130 	void (*ring_indication)(struct bt_conn *conn);
131 	/** HF notify command completed callback to application
132 	 *
133 	 *  The command sent from the application is notified about its status
134 	 *
135 	 *  @param conn Connection object.
136 	 *  @param cmd structure contains status of the command including cme.
137 	 */
138 	void (*cmd_complete_cb)(struct bt_conn *conn,
139 			      struct bt_hfp_hf_cmd_complete *cmd);
140 };
141 
142 /** @brief Register HFP HF profile
143  *
144  *  Register Handsfree profile callbacks to monitor the state and get the
145  *  required HFP details to display.
146  *
147  *  @param cb callback structure.
148  *
149  *  @return 0 in case of success or negative value in case of error.
150  */
151 int bt_hfp_hf_register(struct bt_hfp_hf_cb *cb);
152 
153 /** @brief Handsfree client Send AT
154  *
155  *  Send specific AT commands to handsfree client profile.
156  *
157  *  @param conn Connection object.
158  *  @param cmd AT command to be sent.
159  *
160  *  @return 0 in case of success or negative value in case of error.
161  */
162 int bt_hfp_hf_send_cmd(struct bt_conn *conn, enum bt_hfp_hf_at_cmd cmd);
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 /**
169  * @}
170  */
171 
172 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_HFP_HF_H_ */
173