xref: /btstack/src/classic/hfp_hf.h (revision a484130c09e8d2a02a11deb14ecadc15f0217953)
1 /*
2  * Copyright (C) 2014 BlueKitchen GmbH
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holders nor the names of
14  *    contributors may be used to endorse or promote products derived
15  *    from this software without specific prior written permission.
16  * 4. Any redistribution, use, or modification is done solely for
17  *    personal benefit and not for any commercial purpose or for
18  *    monetary gain.
19  *
20  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * Please inquire about commercial licensing options at
34  * [email protected]
35  *
36  */
37 
38 // *****************************************************************************
39 //
40 //  Minimal setup for HFP Hands-Free (HF) unit (!! UNDER DEVELOPMENT !!)
41 //
42 // *****************************************************************************
43 
44 
45 #ifndef btstack_hfp_hf_h
46 #define btstack_hfp_hf_h
47 
48 #include "hci.h"
49 #include "classic/sdp_query_rfcomm.h"
50 #include "classic/hfp.h"
51 
52 #if defined __cplusplus
53 extern "C" {
54 #endif
55 
56 /* API_START */
57 
58 
59 /**
60  * @brief Create HFP Hands-Free (HF) SDP service record.
61  */
62 void hfp_hf_create_sdp_record(uint8_t * service, uint32_t service_record_handle, int rfcomm_channel_nr, const char * name, uint16_t supported_features);
63 
64 /**
65  * @brief Intialize HFP Hands-Free (HF) device.
66  * TODO:  move optional params into setters
67  */
68 void hfp_hf_init(uint16_t rfcomm_channel_nr, uint32_t supported_features, uint16_t * indicators, int indicators_nr, uint32_t indicators_status);
69 void hfp_hf_set_codecs(uint8_t * codecs, int codecs_nr);
70 
71 /**
72  * @brief Register callback for the HFP Hands-Free (HF) client.
73  */
74 void hfp_hf_register_packet_handler(hfp_callback_t callback);
75 
76 /**
77  * @brief Establish RFCOMM connection, and perform service level connection agreement:
78  * - exchange of supported features
79  * - retrieve Audio Gateway (AG) indicators and their status
80  * - enable indicator status update in the AG
81  * - notify the AG about its own available codecs, if possible
82  * - retrieve the AG information describing the call hold and multiparty services, if possible
83  * - retrieve which HF indicators are enabled on the AG, if possible
84  */
85 void hfp_hf_establish_service_level_connection(bd_addr_t bd_addr);
86 
87 /**
88  * @brief Release the RFCOMM channel and the audio connection between the HF and the AG.
89  * TODO: trigger release of the audio connection
90  */
91 void hfp_hf_release_service_level_connection(bd_addr_t bd_addr);
92 
93 /**
94  * @brief Deactivate/reactivate status update for all indicators in the AG.
95  */
96 void hfp_hf_enable_status_update_for_all_ag_indicators(bd_addr_t bd_addr);
97 void hfp_hf_disable_status_update_for_all_ag_indicators(bd_addr_t bd_addr);
98 
99 /**
100  * @brief Deactivate/reactivate status update for the individual indicators in the AG using bitmap.
101  */
102 void hfp_hf_set_status_update_for_individual_ag_indicators(bd_addr_t bd_addr, uint32_t indicators_status_bitmap);
103 
104 
105 /**
106  * @brief Find out the name of the currently selected Network operator by AG.
107  * The name is restricted to max 16 characters.
108  */
109 void hfp_hf_query_operator_selection(bd_addr_t bd_addr);
110 
111 /**
112  * @brief Enable/disable Extended Audio Gateway Error result codes in the AG.
113  * Whenever there is an error relating to the functionality of the AG as a
114  * result of AT command, the AG shall send +CME ERROR:
115  * - +CME ERROR: 0  - AG failure
116  * - +CME ERROR: 1  - no connection to phone
117  * - +CME ERROR: 3  - operation not allowed
118  * - +CME ERROR: 4  - operation not supported
119  * - +CME ERROR: 5  - PH-SIM PIN required
120  * - +CME ERROR: 10 - SIM not inserted
121  * - +CME ERROR: 11 - SIM PIN required
122  * - +CME ERROR: 12 - SIM PUK required
123  * - +CME ERROR: 13 - SIM failure
124  * - +CME ERROR: 14 - SIM busy
125  * - +CME ERROR: 16 - incorrect password
126  * - +CME ERROR: 17 - SIM PIN2 required
127  * - +CME ERROR: 18 - SIM PUK2 required
128  * - +CME ERROR: 20 - memory full
129  * - +CME ERROR: 21 - invalid index
130  * - +CME ERROR: 23 - memory failure
131  * - +CME ERROR: 24 - text string too long
132  * - +CME ERROR: 25 - invalid characters in text string
133  * - +CME ERROR: 26 - dial string too long
134  * - +CME ERROR: 27 - invalid characters in dial string
135  * - +CME ERROR: 30 - no network service
136  * - +CME ERROR: 31 - network Timeout.
137  * - +CME ERROR: 32 - network not allowed – Emergency calls only
138  */
139 void hfp_hf_enable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr);
140 void hfp_hf_disable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr);
141 
142 /**
143  * @brief
144  */
145 void hfp_hf_establish_audio_connection(bd_addr_t bd_addr);
146 
147 /**
148  * @brief
149  */
150 void hfp_hf_release_audio_connection(bd_addr_t bd_addr);
151 
152 /**
153  * @brief
154  */
155 void hfp_hf_answer_incoming_call(bd_addr_t bd_addr);
156 
157 /**
158  * @brief
159  */
160 void hfp_hf_reject_call(bd_addr_t bd_addr);
161 
162 /**
163  * @brief
164  */
165 void hfp_hf_user_busy(bd_addr_t addr);
166 
167 /**
168  * @brief
169  */
170 void hfp_hf_end_active_and_accept_other(bd_addr_t addr);
171 
172 /**
173  * @brief
174  */
175 void hfp_hf_swap_calls(bd_addr_t addr);
176 
177 /**
178  * @brief
179  */
180 void hfp_hf_join_held_call(bd_addr_t addr);
181 
182 /**
183  * @brief
184  */
185 void hfp_hf_connect_calls(bd_addr_t addr);
186 
187 /**
188  * @brief
189  */
190 void hfp_hf_terminate_call(bd_addr_t bd_addr);
191 
192 /**
193  * @brief
194  */
195 void hfp_hf_dial_number(bd_addr_t bd_addr, char * number);
196 
197 /**
198  * @brief
199  */
200 void hfp_hf_dial_memory(bd_addr_t bd_addr, char * number);
201 
202 /**
203  * @brief
204  */
205 void hfp_hf_redial_last_number(bd_addr_t bd_addr);
206 
207 /*
208  * @brief
209  */
210 void hfp_hf_activate_call_waiting_notification(bd_addr_t bd_addr);
211 
212 /*
213  * @brief
214  */
215 void hfp_hf_deactivate_call_waiting_notification(bd_addr_t bd_addr);
216 
217 /*
218  * @brief
219  */
220 void hfp_hf_activate_calling_line_notification(bd_addr_t bd_addr);
221 
222 /*
223  * @brief
224  */
225 void hfp_hf_deactivate_calling_line_notification(bd_addr_t bd_addr);
226 
227 
228 /*
229  * @brief
230  */
231 void hfp_hf_activate_echo_canceling_and_noise_reduction(bd_addr_t bd_addr);
232 
233 /*
234  * @brief
235  */
236 void hfp_hf_deactivate_echo_canceling_and_noise_reduction(bd_addr_t bd_addr);
237 
238 /*
239  * @brief
240  */
241 void hfp_hf_activate_voice_recognition_notification(bd_addr_t bd_addr);
242 
243 /*
244  * @brief
245  */
246 void hfp_hf_deactivate_voice_recognition_notification(bd_addr_t bd_addr);
247 
248 /*
249  * @brief
250  */
251 void hfp_hf_set_microphone_gain(bd_addr_t bd_addr, int gain);
252 
253 /*
254  * @brief
255  */
256 void hfp_hf_set_speaker_gain(bd_addr_t bd_addr, int gain);
257 
258 /*
259  * @brief
260  */
261 void hfp_hf_send_dtmf_code(bd_addr_t bd_addr, char code);
262 
263 /*
264  * @brief
265  */
266 void hfp_hf_request_phone_number_for_voice_tag(bd_addr_t addr);
267 
268 /*
269  * @brief
270  */
271 void hfp_hf_query_current_call_status(bd_addr_t addr);
272 
273 /*
274  * @brief
275  */
276 void hfp_hf_release_call_with_index(bd_addr_t addr, int index);
277 
278 /*
279  * @brief
280  */
281 void hfp_hf_private_consultation_with_call(bd_addr_t addr, int index);
282 
283 /*
284  * @brief
285  */
286 void hfp_hf_rrh_query_status(bd_addr_t addr);
287 
288 /*
289  * @brief
290  */
291 void hfp_hf_rrh_hold_call(bd_addr_t addr);
292 
293 /*
294  * @brief
295  */
296 void hfp_hf_rrh_accept_held_call(bd_addr_t addr);
297 
298 /*
299  * @brief
300  */
301 void hfp_hf_rrh_reject_held_call(bd_addr_t addr);
302 
303 /*
304  * @brief
305  */
306 void hfp_hf_query_subscriber_number(bd_addr_t addr);
307 
308 /*
309  * @brief
310  */
311 void hfp_hf_set_hf_indicator(bd_addr_t addr, int assigned_number, int value);
312 
313 /* API_END */
314 
315 #if defined __cplusplus
316 }
317 #endif
318 
319 #endif