xref: /btstack/src/classic/hfp_hf.h (revision 66a048ab906a04706fe3948e52f9291ec7110b9c)
13deb3ec6SMatthias Ringwald /*
23deb3ec6SMatthias Ringwald  * Copyright (C) 2014 BlueKitchen GmbH
33deb3ec6SMatthias Ringwald  *
43deb3ec6SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
53deb3ec6SMatthias Ringwald  * modification, are permitted provided that the following conditions
63deb3ec6SMatthias Ringwald  * are met:
73deb3ec6SMatthias Ringwald  *
83deb3ec6SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
93deb3ec6SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
103deb3ec6SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
113deb3ec6SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
123deb3ec6SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
133deb3ec6SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
143deb3ec6SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
153deb3ec6SMatthias Ringwald  *    from this software without specific prior written permission.
163deb3ec6SMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
173deb3ec6SMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
183deb3ec6SMatthias Ringwald  *    monetary gain.
193deb3ec6SMatthias Ringwald  *
203deb3ec6SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
213deb3ec6SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
223deb3ec6SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
233deb3ec6SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
243deb3ec6SMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
253deb3ec6SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
263deb3ec6SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
273deb3ec6SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
283deb3ec6SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
293deb3ec6SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
303deb3ec6SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
313deb3ec6SMatthias Ringwald  * SUCH DAMAGE.
323deb3ec6SMatthias Ringwald  *
333deb3ec6SMatthias Ringwald  * Please inquire about commercial licensing options at
343deb3ec6SMatthias Ringwald  * [email protected]
353deb3ec6SMatthias Ringwald  *
363deb3ec6SMatthias Ringwald  */
373deb3ec6SMatthias Ringwald 
383deb3ec6SMatthias Ringwald // *****************************************************************************
393deb3ec6SMatthias Ringwald //
40*66a048abSMatthias Ringwald //  HFP Hands-Free (HF) unit
413deb3ec6SMatthias Ringwald //
423deb3ec6SMatthias Ringwald // *****************************************************************************
433deb3ec6SMatthias Ringwald 
443deb3ec6SMatthias Ringwald 
45*66a048abSMatthias Ringwald #ifndef __BTSTACK_HFP_HF_H
46*66a048abSMatthias Ringwald #define __BTSTACK_HFP_HF_H
473deb3ec6SMatthias Ringwald 
483deb3ec6SMatthias Ringwald #include "hci.h"
493edc84c5SMatthias Ringwald #include "classic/sdp_query_rfcomm.h"
503edc84c5SMatthias Ringwald #include "classic/hfp.h"
513deb3ec6SMatthias Ringwald 
523deb3ec6SMatthias Ringwald #if defined __cplusplus
533deb3ec6SMatthias Ringwald extern "C" {
543deb3ec6SMatthias Ringwald #endif
553deb3ec6SMatthias Ringwald 
563deb3ec6SMatthias Ringwald /* API_START */
573deb3ec6SMatthias Ringwald 
583deb3ec6SMatthias Ringwald /**
593deb3ec6SMatthias Ringwald  * @brief Create HFP Hands-Free (HF) SDP service record.
603deb3ec6SMatthias Ringwald  */
619b1c3b4dSMatthias Ringwald 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);
623deb3ec6SMatthias Ringwald 
633deb3ec6SMatthias Ringwald /**
643deb3ec6SMatthias Ringwald  * @brief Intialize HFP Hands-Free (HF) device.
653deb3ec6SMatthias Ringwald  * TODO:  move optional params into setters
663deb3ec6SMatthias Ringwald  */
673deb3ec6SMatthias Ringwald void hfp_hf_init(uint16_t rfcomm_channel_nr, uint32_t supported_features, uint16_t * indicators, int indicators_nr, uint32_t indicators_status);
68*66a048abSMatthias Ringwald 
693deb3ec6SMatthias Ringwald void hfp_hf_set_codecs(uint8_t * codecs, int codecs_nr);
703deb3ec6SMatthias Ringwald 
71*66a048abSMatthias Ringwald void hfp_hf_set_supported_features(uint32_t supported_features);
72*66a048abSMatthias Ringwald 
733deb3ec6SMatthias Ringwald /**
743deb3ec6SMatthias Ringwald  * @brief Register callback for the HFP Hands-Free (HF) client.
753deb3ec6SMatthias Ringwald  */
763deb3ec6SMatthias Ringwald void hfp_hf_register_packet_handler(hfp_callback_t callback);
773deb3ec6SMatthias Ringwald 
783deb3ec6SMatthias Ringwald /**
793deb3ec6SMatthias Ringwald  * @brief Establish RFCOMM connection, and perform service level connection agreement:
803deb3ec6SMatthias Ringwald  * - exchange of supported features
813deb3ec6SMatthias Ringwald  * - retrieve Audio Gateway (AG) indicators and their status
823deb3ec6SMatthias Ringwald  * - enable indicator status update in the AG
833deb3ec6SMatthias Ringwald  * - notify the AG about its own available codecs, if possible
843deb3ec6SMatthias Ringwald  * - retrieve the AG information describing the call hold and multiparty services, if possible
853deb3ec6SMatthias Ringwald  * - retrieve which HF indicators are enabled on the AG, if possible
863deb3ec6SMatthias Ringwald  */
873deb3ec6SMatthias Ringwald void hfp_hf_establish_service_level_connection(bd_addr_t bd_addr);
883deb3ec6SMatthias Ringwald 
893deb3ec6SMatthias Ringwald /**
903deb3ec6SMatthias Ringwald  * @brief Release the RFCOMM channel and the audio connection between the HF and the AG.
913deb3ec6SMatthias Ringwald  * TODO: trigger release of the audio connection
923deb3ec6SMatthias Ringwald  */
933deb3ec6SMatthias Ringwald void hfp_hf_release_service_level_connection(bd_addr_t bd_addr);
943deb3ec6SMatthias Ringwald 
953deb3ec6SMatthias Ringwald /**
963deb3ec6SMatthias Ringwald  * @brief Deactivate/reactivate status update for all indicators in the AG.
973deb3ec6SMatthias Ringwald  */
98ce263fc8SMatthias Ringwald void hfp_hf_enable_status_update_for_all_ag_indicators(bd_addr_t bd_addr);
99*66a048abSMatthias Ringwald 
100ce263fc8SMatthias Ringwald void hfp_hf_disable_status_update_for_all_ag_indicators(bd_addr_t bd_addr);
1013deb3ec6SMatthias Ringwald 
1023deb3ec6SMatthias Ringwald /**
1033deb3ec6SMatthias Ringwald  * @brief Deactivate/reactivate status update for the individual indicators in the AG using bitmap.
1043deb3ec6SMatthias Ringwald  */
105ce263fc8SMatthias Ringwald void hfp_hf_set_status_update_for_individual_ag_indicators(bd_addr_t bd_addr, uint32_t indicators_status_bitmap);
1063deb3ec6SMatthias Ringwald 
1073deb3ec6SMatthias Ringwald 
1083deb3ec6SMatthias Ringwald /**
1093deb3ec6SMatthias Ringwald  * @brief Find out the name of the currently selected Network operator by AG.
1103deb3ec6SMatthias Ringwald  * The name is restricted to max 16 characters.
111*66a048abSMatthias Ringwald  *
112*66a048abSMatthias Ringwald  * TODO: what is the result of this?
1133deb3ec6SMatthias Ringwald  */
1143deb3ec6SMatthias Ringwald void hfp_hf_query_operator_selection(bd_addr_t bd_addr);
1153deb3ec6SMatthias Ringwald 
1163deb3ec6SMatthias Ringwald /**
1173deb3ec6SMatthias Ringwald  * @brief Enable/disable Extended Audio Gateway Error result codes in the AG.
1183deb3ec6SMatthias Ringwald  * Whenever there is an error relating to the functionality of the AG as a
1193deb3ec6SMatthias Ringwald  * result of AT command, the AG shall send +CME ERROR:
1203deb3ec6SMatthias Ringwald  * - +CME ERROR: 0  - AG failure
1213deb3ec6SMatthias Ringwald  * - +CME ERROR: 1  - no connection to phone
1223deb3ec6SMatthias Ringwald  * - +CME ERROR: 3  - operation not allowed
1233deb3ec6SMatthias Ringwald  * - +CME ERROR: 4  - operation not supported
1243deb3ec6SMatthias Ringwald  * - +CME ERROR: 5  - PH-SIM PIN required
1253deb3ec6SMatthias Ringwald  * - +CME ERROR: 10 - SIM not inserted
1263deb3ec6SMatthias Ringwald  * - +CME ERROR: 11 - SIM PIN required
1273deb3ec6SMatthias Ringwald  * - +CME ERROR: 12 - SIM PUK required
1283deb3ec6SMatthias Ringwald  * - +CME ERROR: 13 - SIM failure
1293deb3ec6SMatthias Ringwald  * - +CME ERROR: 14 - SIM busy
1303deb3ec6SMatthias Ringwald  * - +CME ERROR: 16 - incorrect password
1313deb3ec6SMatthias Ringwald  * - +CME ERROR: 17 - SIM PIN2 required
1323deb3ec6SMatthias Ringwald  * - +CME ERROR: 18 - SIM PUK2 required
1333deb3ec6SMatthias Ringwald  * - +CME ERROR: 20 - memory full
1343deb3ec6SMatthias Ringwald  * - +CME ERROR: 21 - invalid index
1353deb3ec6SMatthias Ringwald  * - +CME ERROR: 23 - memory failure
1363deb3ec6SMatthias Ringwald  * - +CME ERROR: 24 - text string too long
1373deb3ec6SMatthias Ringwald  * - +CME ERROR: 25 - invalid characters in text string
1383deb3ec6SMatthias Ringwald  * - +CME ERROR: 26 - dial string too long
1393deb3ec6SMatthias Ringwald  * - +CME ERROR: 27 - invalid characters in dial string
1403deb3ec6SMatthias Ringwald  * - +CME ERROR: 30 - no network service
1413deb3ec6SMatthias Ringwald  * - +CME ERROR: 31 - network Timeout.
1423deb3ec6SMatthias Ringwald  * - +CME ERROR: 32 - network not allowed – Emergency calls only
1433deb3ec6SMatthias Ringwald  */
144ce263fc8SMatthias Ringwald void hfp_hf_enable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr);
145ce263fc8SMatthias Ringwald void hfp_hf_disable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr);
1463deb3ec6SMatthias Ringwald 
1473deb3ec6SMatthias Ringwald /**
1483deb3ec6SMatthias Ringwald  * @brief
1493deb3ec6SMatthias Ringwald  */
1503deb3ec6SMatthias Ringwald void hfp_hf_establish_audio_connection(bd_addr_t bd_addr);
1513deb3ec6SMatthias Ringwald 
1523deb3ec6SMatthias Ringwald /**
1533deb3ec6SMatthias Ringwald  * @brief
1543deb3ec6SMatthias Ringwald  */
1553deb3ec6SMatthias Ringwald void hfp_hf_release_audio_connection(bd_addr_t bd_addr);
1563deb3ec6SMatthias Ringwald 
157ce263fc8SMatthias Ringwald /**
158ce263fc8SMatthias Ringwald  * @brief
159ce263fc8SMatthias Ringwald  */
160ce263fc8SMatthias Ringwald void hfp_hf_answer_incoming_call(bd_addr_t bd_addr);
161ce263fc8SMatthias Ringwald 
162ce263fc8SMatthias Ringwald /**
163ce263fc8SMatthias Ringwald  * @brief
164ce263fc8SMatthias Ringwald  */
165ce263fc8SMatthias Ringwald void hfp_hf_reject_call(bd_addr_t bd_addr);
166ce263fc8SMatthias Ringwald 
167ce263fc8SMatthias Ringwald /**
168ce263fc8SMatthias Ringwald  * @brief
169ce263fc8SMatthias Ringwald  */
170ce263fc8SMatthias Ringwald void hfp_hf_user_busy(bd_addr_t addr);
171ce263fc8SMatthias Ringwald 
172ce263fc8SMatthias Ringwald /**
173ce263fc8SMatthias Ringwald  * @brief
174ce263fc8SMatthias Ringwald  */
175ce263fc8SMatthias Ringwald void hfp_hf_end_active_and_accept_other(bd_addr_t addr);
176ce263fc8SMatthias Ringwald 
177ce263fc8SMatthias Ringwald /**
178ce263fc8SMatthias Ringwald  * @brief
179ce263fc8SMatthias Ringwald  */
180ce263fc8SMatthias Ringwald void hfp_hf_swap_calls(bd_addr_t addr);
181ce263fc8SMatthias Ringwald 
182ce263fc8SMatthias Ringwald /**
183ce263fc8SMatthias Ringwald  * @brief
184ce263fc8SMatthias Ringwald  */
185ce263fc8SMatthias Ringwald void hfp_hf_join_held_call(bd_addr_t addr);
186ce263fc8SMatthias Ringwald 
187ce263fc8SMatthias Ringwald /**
188ce263fc8SMatthias Ringwald  * @brief
189ce263fc8SMatthias Ringwald  */
190ce263fc8SMatthias Ringwald void hfp_hf_connect_calls(bd_addr_t addr);
191ce263fc8SMatthias Ringwald 
192ce263fc8SMatthias Ringwald /**
193ce263fc8SMatthias Ringwald  * @brief
194ce263fc8SMatthias Ringwald  */
195ce263fc8SMatthias Ringwald void hfp_hf_terminate_call(bd_addr_t bd_addr);
196ce263fc8SMatthias Ringwald 
197ce263fc8SMatthias Ringwald /**
198ce263fc8SMatthias Ringwald  * @brief
199ce263fc8SMatthias Ringwald  */
200ce263fc8SMatthias Ringwald void hfp_hf_dial_number(bd_addr_t bd_addr, char * number);
201ce263fc8SMatthias Ringwald 
202ce263fc8SMatthias Ringwald /**
203ce263fc8SMatthias Ringwald  * @brief
204*66a048abSMatthias Ringwald  * TODO: use int for number instead of string?
205ce263fc8SMatthias Ringwald  */
206ce263fc8SMatthias Ringwald void hfp_hf_dial_memory(bd_addr_t bd_addr, char * number);
207ce263fc8SMatthias Ringwald 
208ce263fc8SMatthias Ringwald /**
209ce263fc8SMatthias Ringwald  * @brief
210ce263fc8SMatthias Ringwald  */
211ce263fc8SMatthias Ringwald void hfp_hf_redial_last_number(bd_addr_t bd_addr);
212ce263fc8SMatthias Ringwald 
213ce263fc8SMatthias Ringwald /*
214ce263fc8SMatthias Ringwald  * @brief
215ce263fc8SMatthias Ringwald  */
216ce263fc8SMatthias Ringwald void hfp_hf_activate_call_waiting_notification(bd_addr_t bd_addr);
217ce263fc8SMatthias Ringwald 
218ce263fc8SMatthias Ringwald /*
219ce263fc8SMatthias Ringwald  * @brief
220ce263fc8SMatthias Ringwald  */
221ce263fc8SMatthias Ringwald void hfp_hf_deactivate_call_waiting_notification(bd_addr_t bd_addr);
222ce263fc8SMatthias Ringwald 
223ce263fc8SMatthias Ringwald /*
224ce263fc8SMatthias Ringwald  * @brief
225ce263fc8SMatthias Ringwald  */
226ce263fc8SMatthias Ringwald void hfp_hf_activate_calling_line_notification(bd_addr_t bd_addr);
227ce263fc8SMatthias Ringwald 
228ce263fc8SMatthias Ringwald /*
229ce263fc8SMatthias Ringwald  * @brief
230ce263fc8SMatthias Ringwald  */
231ce263fc8SMatthias Ringwald void hfp_hf_deactivate_calling_line_notification(bd_addr_t bd_addr);
232ce263fc8SMatthias Ringwald 
233ce263fc8SMatthias Ringwald 
234ce263fc8SMatthias Ringwald /*
235ce263fc8SMatthias Ringwald  * @brief
236ce263fc8SMatthias Ringwald  */
237ce263fc8SMatthias Ringwald void hfp_hf_activate_echo_canceling_and_noise_reduction(bd_addr_t bd_addr);
238ce263fc8SMatthias Ringwald 
239ce263fc8SMatthias Ringwald /*
240ce263fc8SMatthias Ringwald  * @brief
241ce263fc8SMatthias Ringwald  */
242ce263fc8SMatthias Ringwald void hfp_hf_deactivate_echo_canceling_and_noise_reduction(bd_addr_t bd_addr);
243ce263fc8SMatthias Ringwald 
244ce263fc8SMatthias Ringwald /*
245ce263fc8SMatthias Ringwald  * @brief
246ce263fc8SMatthias Ringwald  */
247ce263fc8SMatthias Ringwald void hfp_hf_activate_voice_recognition_notification(bd_addr_t bd_addr);
248ce263fc8SMatthias Ringwald 
249ce263fc8SMatthias Ringwald /*
250ce263fc8SMatthias Ringwald  * @brief
251ce263fc8SMatthias Ringwald  */
252ce263fc8SMatthias Ringwald void hfp_hf_deactivate_voice_recognition_notification(bd_addr_t bd_addr);
253ce263fc8SMatthias Ringwald 
254ce263fc8SMatthias Ringwald /*
255ce263fc8SMatthias Ringwald  * @brief
256ce263fc8SMatthias Ringwald  */
257ce263fc8SMatthias Ringwald void hfp_hf_set_microphone_gain(bd_addr_t bd_addr, int gain);
258ce263fc8SMatthias Ringwald 
259ce263fc8SMatthias Ringwald /*
260ce263fc8SMatthias Ringwald  * @brief
261ce263fc8SMatthias Ringwald  */
262ce263fc8SMatthias Ringwald void hfp_hf_set_speaker_gain(bd_addr_t bd_addr, int gain);
263ce263fc8SMatthias Ringwald 
264ce263fc8SMatthias Ringwald /*
265ce263fc8SMatthias Ringwald  * @brief
266ce263fc8SMatthias Ringwald  */
267ce263fc8SMatthias Ringwald void hfp_hf_send_dtmf_code(bd_addr_t bd_addr, char code);
268ce263fc8SMatthias Ringwald 
269ce263fc8SMatthias Ringwald /*
270ce263fc8SMatthias Ringwald  * @brief
271ce263fc8SMatthias Ringwald  */
272ce263fc8SMatthias Ringwald void hfp_hf_request_phone_number_for_voice_tag(bd_addr_t addr);
2733deb3ec6SMatthias Ringwald 
274667ec068SMatthias Ringwald /*
275667ec068SMatthias Ringwald  * @brief
276667ec068SMatthias Ringwald  */
277667ec068SMatthias Ringwald void hfp_hf_query_current_call_status(bd_addr_t addr);
278667ec068SMatthias Ringwald 
279667ec068SMatthias Ringwald /*
280667ec068SMatthias Ringwald  * @brief
281667ec068SMatthias Ringwald  */
282667ec068SMatthias Ringwald void hfp_hf_release_call_with_index(bd_addr_t addr, int index);
283667ec068SMatthias Ringwald 
284667ec068SMatthias Ringwald /*
285667ec068SMatthias Ringwald  * @brief
286667ec068SMatthias Ringwald  */
287667ec068SMatthias Ringwald void hfp_hf_private_consultation_with_call(bd_addr_t addr, int index);
288667ec068SMatthias Ringwald 
289667ec068SMatthias Ringwald /*
290667ec068SMatthias Ringwald  * @brief
291667ec068SMatthias Ringwald  */
292667ec068SMatthias Ringwald void hfp_hf_rrh_query_status(bd_addr_t addr);
293667ec068SMatthias Ringwald 
294667ec068SMatthias Ringwald /*
295667ec068SMatthias Ringwald  * @brief
296667ec068SMatthias Ringwald  */
297667ec068SMatthias Ringwald void hfp_hf_rrh_hold_call(bd_addr_t addr);
298667ec068SMatthias Ringwald 
299667ec068SMatthias Ringwald /*
300667ec068SMatthias Ringwald  * @brief
301667ec068SMatthias Ringwald  */
302667ec068SMatthias Ringwald void hfp_hf_rrh_accept_held_call(bd_addr_t addr);
303667ec068SMatthias Ringwald 
304667ec068SMatthias Ringwald /*
305667ec068SMatthias Ringwald  * @brief
306667ec068SMatthias Ringwald  */
307667ec068SMatthias Ringwald void hfp_hf_rrh_reject_held_call(bd_addr_t addr);
308667ec068SMatthias Ringwald 
309667ec068SMatthias Ringwald /*
310667ec068SMatthias Ringwald  * @brief
311667ec068SMatthias Ringwald  */
312667ec068SMatthias Ringwald void hfp_hf_query_subscriber_number(bd_addr_t addr);
313667ec068SMatthias Ringwald 
314667ec068SMatthias Ringwald /*
315667ec068SMatthias Ringwald  * @brief
316667ec068SMatthias Ringwald  */
317667ec068SMatthias Ringwald void hfp_hf_set_hf_indicator(bd_addr_t addr, int assigned_number, int value);
318667ec068SMatthias Ringwald 
3193deb3ec6SMatthias Ringwald /* API_END */
3203deb3ec6SMatthias Ringwald 
3213deb3ec6SMatthias Ringwald #if defined __cplusplus
3223deb3ec6SMatthias Ringwald }
3233deb3ec6SMatthias Ringwald #endif
3243deb3ec6SMatthias Ringwald 
325*66a048abSMatthias Ringwald #endif // __BTSTACK_HFP_HF_H