xref: /btstack/src/classic/hfp_hf.h (revision 16ece13520cb8efcf94cb63eab58a3eda87f40a2)
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 void hfp_hf_set_supported_features(uint32_t supported_features);
87 
88 /**
89  * @brief Release the RFCOMM channel and the audio connection between the HF and the AG.
90  * TODO: trigger release of the audio connection
91  */
92 void hfp_hf_release_service_level_connection(bd_addr_t bd_addr);
93 
94 /**
95  * @brief Deactivate/reactivate status update for all indicators in the AG.
96  */
97 void hfp_hf_enable_status_update_for_all_ag_indicators(bd_addr_t bd_addr);
98 void hfp_hf_disable_status_update_for_all_ag_indicators(bd_addr_t bd_addr);
99 
100 /**
101  * @brief Deactivate/reactivate status update for the individual indicators in the AG using bitmap.
102  */
103 void hfp_hf_set_status_update_for_individual_ag_indicators(bd_addr_t bd_addr, uint32_t indicators_status_bitmap);
104 
105 
106 /**
107  * @brief Find out the name of the currently selected Network operator by AG.
108  * The name is restricted to max 16 characters.
109  */
110 void hfp_hf_query_operator_selection(bd_addr_t bd_addr);
111 
112 /**
113  * @brief Enable/disable Extended Audio Gateway Error result codes in the AG.
114  * Whenever there is an error relating to the functionality of the AG as a
115  * result of AT command, the AG shall send +CME ERROR:
116  * - +CME ERROR: 0  - AG failure
117  * - +CME ERROR: 1  - no connection to phone
118  * - +CME ERROR: 3  - operation not allowed
119  * - +CME ERROR: 4  - operation not supported
120  * - +CME ERROR: 5  - PH-SIM PIN required
121  * - +CME ERROR: 10 - SIM not inserted
122  * - +CME ERROR: 11 - SIM PIN required
123  * - +CME ERROR: 12 - SIM PUK required
124  * - +CME ERROR: 13 - SIM failure
125  * - +CME ERROR: 14 - SIM busy
126  * - +CME ERROR: 16 - incorrect password
127  * - +CME ERROR: 17 - SIM PIN2 required
128  * - +CME ERROR: 18 - SIM PUK2 required
129  * - +CME ERROR: 20 - memory full
130  * - +CME ERROR: 21 - invalid index
131  * - +CME ERROR: 23 - memory failure
132  * - +CME ERROR: 24 - text string too long
133  * - +CME ERROR: 25 - invalid characters in text string
134  * - +CME ERROR: 26 - dial string too long
135  * - +CME ERROR: 27 - invalid characters in dial string
136  * - +CME ERROR: 30 - no network service
137  * - +CME ERROR: 31 - network Timeout.
138  * - +CME ERROR: 32 - network not allowed – Emergency calls only
139  */
140 void hfp_hf_enable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr);
141 void hfp_hf_disable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr);
142 
143 /**
144  * @brief
145  */
146 void hfp_hf_establish_audio_connection(bd_addr_t bd_addr);
147 
148 /**
149  * @brief
150  */
151 void hfp_hf_release_audio_connection(bd_addr_t bd_addr);
152 
153 /**
154  * @brief
155  */
156 void hfp_hf_answer_incoming_call(bd_addr_t bd_addr);
157 
158 /**
159  * @brief
160  */
161 void hfp_hf_reject_call(bd_addr_t bd_addr);
162 
163 /**
164  * @brief
165  */
166 void hfp_hf_user_busy(bd_addr_t addr);
167 
168 /**
169  * @brief
170  */
171 void hfp_hf_end_active_and_accept_other(bd_addr_t addr);
172 
173 /**
174  * @brief
175  */
176 void hfp_hf_swap_calls(bd_addr_t addr);
177 
178 /**
179  * @brief
180  */
181 void hfp_hf_join_held_call(bd_addr_t addr);
182 
183 /**
184  * @brief
185  */
186 void hfp_hf_connect_calls(bd_addr_t addr);
187 
188 /**
189  * @brief
190  */
191 void hfp_hf_terminate_call(bd_addr_t bd_addr);
192 
193 /**
194  * @brief
195  */
196 void hfp_hf_dial_number(bd_addr_t bd_addr, char * number);
197 
198 /**
199  * @brief
200  */
201 void hfp_hf_dial_memory(bd_addr_t bd_addr, char * number);
202 
203 /**
204  * @brief
205  */
206 void hfp_hf_redial_last_number(bd_addr_t bd_addr);
207 
208 /*
209  * @brief
210  */
211 void hfp_hf_activate_call_waiting_notification(bd_addr_t bd_addr);
212 
213 /*
214  * @brief
215  */
216 void hfp_hf_deactivate_call_waiting_notification(bd_addr_t bd_addr);
217 
218 /*
219  * @brief
220  */
221 void hfp_hf_activate_calling_line_notification(bd_addr_t bd_addr);
222 
223 /*
224  * @brief
225  */
226 void hfp_hf_deactivate_calling_line_notification(bd_addr_t bd_addr);
227 
228 
229 /*
230  * @brief
231  */
232 void hfp_hf_activate_echo_canceling_and_noise_reduction(bd_addr_t bd_addr);
233 
234 /*
235  * @brief
236  */
237 void hfp_hf_deactivate_echo_canceling_and_noise_reduction(bd_addr_t bd_addr);
238 
239 /*
240  * @brief
241  */
242 void hfp_hf_activate_voice_recognition_notification(bd_addr_t bd_addr);
243 
244 /*
245  * @brief
246  */
247 void hfp_hf_deactivate_voice_recognition_notification(bd_addr_t bd_addr);
248 
249 /*
250  * @brief
251  */
252 void hfp_hf_set_microphone_gain(bd_addr_t bd_addr, int gain);
253 
254 /*
255  * @brief
256  */
257 void hfp_hf_set_speaker_gain(bd_addr_t bd_addr, int gain);
258 
259 /*
260  * @brief
261  */
262 void hfp_hf_send_dtmf_code(bd_addr_t bd_addr, char code);
263 
264 /*
265  * @brief
266  */
267 void hfp_hf_request_phone_number_for_voice_tag(bd_addr_t addr);
268 
269 /*
270  * @brief
271  */
272 void hfp_hf_query_current_call_status(bd_addr_t addr);
273 
274 /*
275  * @brief
276  */
277 void hfp_hf_release_call_with_index(bd_addr_t addr, int index);
278 
279 /*
280  * @brief
281  */
282 void hfp_hf_private_consultation_with_call(bd_addr_t addr, int index);
283 
284 /*
285  * @brief
286  */
287 void hfp_hf_rrh_query_status(bd_addr_t addr);
288 
289 /*
290  * @brief
291  */
292 void hfp_hf_rrh_hold_call(bd_addr_t addr);
293 
294 /*
295  * @brief
296  */
297 void hfp_hf_rrh_accept_held_call(bd_addr_t addr);
298 
299 /*
300  * @brief
301  */
302 void hfp_hf_rrh_reject_held_call(bd_addr_t addr);
303 
304 /*
305  * @brief
306  */
307 void hfp_hf_query_subscriber_number(bd_addr_t addr);
308 
309 /*
310  * @brief
311  */
312 void hfp_hf_set_hf_indicator(bd_addr_t addr, int assigned_number, int value);
313 
314 /* API_END */
315 
316 #if defined __cplusplus
317 }
318 #endif
319 
320 #endif