xref: /btstack/src/classic/hfp_hf.h (revision ce263fc8087b85d5dc9a00ecb73252242caf68b5)
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 //
403deb3ec6SMatthias Ringwald //  Minimal setup for HFP Hands-Free (HF) unit (!! UNDER DEVELOPMENT !!)
413deb3ec6SMatthias Ringwald //
423deb3ec6SMatthias Ringwald // *****************************************************************************
433deb3ec6SMatthias Ringwald 
443deb3ec6SMatthias Ringwald 
453deb3ec6SMatthias Ringwald #ifndef btstack_hfp_hf_h
463deb3ec6SMatthias 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 /**
603deb3ec6SMatthias Ringwald  * @brief Create HFP Hands-Free (HF) SDP service record.
613deb3ec6SMatthias Ringwald  */
629b1c3b4dSMatthias 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);
633deb3ec6SMatthias Ringwald 
643deb3ec6SMatthias Ringwald /**
653deb3ec6SMatthias Ringwald  * @brief Intialize HFP Hands-Free (HF) device.
663deb3ec6SMatthias Ringwald  * TODO:  move optional params into setters
673deb3ec6SMatthias Ringwald  */
683deb3ec6SMatthias Ringwald void hfp_hf_init(uint16_t rfcomm_channel_nr, uint32_t supported_features, uint16_t * indicators, int indicators_nr, uint32_t indicators_status);
693deb3ec6SMatthias Ringwald void hfp_hf_set_codecs(uint8_t * codecs, int codecs_nr);
703deb3ec6SMatthias Ringwald 
713deb3ec6SMatthias Ringwald /**
723deb3ec6SMatthias Ringwald  * @brief Register callback for the HFP Hands-Free (HF) client.
733deb3ec6SMatthias Ringwald  */
743deb3ec6SMatthias Ringwald void hfp_hf_register_packet_handler(hfp_callback_t callback);
753deb3ec6SMatthias Ringwald 
763deb3ec6SMatthias Ringwald /**
773deb3ec6SMatthias Ringwald  * @brief Establish RFCOMM connection, and perform service level connection agreement:
783deb3ec6SMatthias Ringwald  * - exchange of supported features
793deb3ec6SMatthias Ringwald  * - retrieve Audio Gateway (AG) indicators and their status
803deb3ec6SMatthias Ringwald  * - enable indicator status update in the AG
813deb3ec6SMatthias Ringwald  * - notify the AG about its own available codecs, if possible
823deb3ec6SMatthias Ringwald  * - retrieve the AG information describing the call hold and multiparty services, if possible
833deb3ec6SMatthias Ringwald  * - retrieve which HF indicators are enabled on the AG, if possible
843deb3ec6SMatthias Ringwald  */
853deb3ec6SMatthias Ringwald void hfp_hf_establish_service_level_connection(bd_addr_t bd_addr);
863deb3ec6SMatthias Ringwald 
873deb3ec6SMatthias Ringwald /**
883deb3ec6SMatthias Ringwald  * @brief Release the RFCOMM channel and the audio connection between the HF and the AG.
893deb3ec6SMatthias Ringwald  * TODO: trigger release of the audio connection
903deb3ec6SMatthias Ringwald  */
913deb3ec6SMatthias Ringwald void hfp_hf_release_service_level_connection(bd_addr_t bd_addr);
923deb3ec6SMatthias Ringwald 
933deb3ec6SMatthias Ringwald /**
943deb3ec6SMatthias Ringwald  * @brief Deactivate/reactivate status update for all indicators in the AG.
953deb3ec6SMatthias Ringwald  */
96*ce263fc8SMatthias Ringwald void hfp_hf_enable_status_update_for_all_ag_indicators(bd_addr_t bd_addr);
97*ce263fc8SMatthias Ringwald void hfp_hf_disable_status_update_for_all_ag_indicators(bd_addr_t bd_addr);
983deb3ec6SMatthias Ringwald 
993deb3ec6SMatthias Ringwald /**
1003deb3ec6SMatthias Ringwald  * @brief Deactivate/reactivate status update for the individual indicators in the AG using bitmap.
1013deb3ec6SMatthias Ringwald  */
102*ce263fc8SMatthias Ringwald void hfp_hf_set_status_update_for_individual_ag_indicators(bd_addr_t bd_addr, uint32_t indicators_status_bitmap);
1033deb3ec6SMatthias Ringwald 
1043deb3ec6SMatthias Ringwald 
1053deb3ec6SMatthias Ringwald /**
1063deb3ec6SMatthias Ringwald  * @brief Find out the name of the currently selected Network operator by AG.
1073deb3ec6SMatthias Ringwald  * The name is restricted to max 16 characters.
1083deb3ec6SMatthias Ringwald  */
1093deb3ec6SMatthias Ringwald void hfp_hf_query_operator_selection(bd_addr_t bd_addr);
1103deb3ec6SMatthias Ringwald 
1113deb3ec6SMatthias Ringwald /**
1123deb3ec6SMatthias Ringwald  * @brief Enable/disable Extended Audio Gateway Error result codes in the AG.
1133deb3ec6SMatthias Ringwald  * Whenever there is an error relating to the functionality of the AG as a
1143deb3ec6SMatthias Ringwald  * result of AT command, the AG shall send +CME ERROR:
1153deb3ec6SMatthias Ringwald  * - +CME ERROR: 0  - AG failure
1163deb3ec6SMatthias Ringwald  * - +CME ERROR: 1  - no connection to phone
1173deb3ec6SMatthias Ringwald  * - +CME ERROR: 3  - operation not allowed
1183deb3ec6SMatthias Ringwald  * - +CME ERROR: 4  - operation not supported
1193deb3ec6SMatthias Ringwald  * - +CME ERROR: 5  - PH-SIM PIN required
1203deb3ec6SMatthias Ringwald  * - +CME ERROR: 10 - SIM not inserted
1213deb3ec6SMatthias Ringwald  * - +CME ERROR: 11 - SIM PIN required
1223deb3ec6SMatthias Ringwald  * - +CME ERROR: 12 - SIM PUK required
1233deb3ec6SMatthias Ringwald  * - +CME ERROR: 13 - SIM failure
1243deb3ec6SMatthias Ringwald  * - +CME ERROR: 14 - SIM busy
1253deb3ec6SMatthias Ringwald  * - +CME ERROR: 16 - incorrect password
1263deb3ec6SMatthias Ringwald  * - +CME ERROR: 17 - SIM PIN2 required
1273deb3ec6SMatthias Ringwald  * - +CME ERROR: 18 - SIM PUK2 required
1283deb3ec6SMatthias Ringwald  * - +CME ERROR: 20 - memory full
1293deb3ec6SMatthias Ringwald  * - +CME ERROR: 21 - invalid index
1303deb3ec6SMatthias Ringwald  * - +CME ERROR: 23 - memory failure
1313deb3ec6SMatthias Ringwald  * - +CME ERROR: 24 - text string too long
1323deb3ec6SMatthias Ringwald  * - +CME ERROR: 25 - invalid characters in text string
1333deb3ec6SMatthias Ringwald  * - +CME ERROR: 26 - dial string too long
1343deb3ec6SMatthias Ringwald  * - +CME ERROR: 27 - invalid characters in dial string
1353deb3ec6SMatthias Ringwald  * - +CME ERROR: 30 - no network service
1363deb3ec6SMatthias Ringwald  * - +CME ERROR: 31 - network Timeout.
1373deb3ec6SMatthias Ringwald  * - +CME ERROR: 32 - network not allowed – Emergency calls only
1383deb3ec6SMatthias Ringwald  */
139*ce263fc8SMatthias Ringwald void hfp_hf_enable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr);
140*ce263fc8SMatthias Ringwald void hfp_hf_disable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr);
1413deb3ec6SMatthias Ringwald 
1423deb3ec6SMatthias Ringwald /**
1433deb3ec6SMatthias Ringwald  * @brief
1443deb3ec6SMatthias Ringwald  */
1453deb3ec6SMatthias Ringwald void hfp_hf_establish_audio_connection(bd_addr_t bd_addr);
1463deb3ec6SMatthias Ringwald 
1473deb3ec6SMatthias Ringwald /**
1483deb3ec6SMatthias Ringwald  * @brief
1493deb3ec6SMatthias Ringwald  */
1503deb3ec6SMatthias Ringwald void hfp_hf_release_audio_connection(bd_addr_t bd_addr);
1513deb3ec6SMatthias Ringwald 
152*ce263fc8SMatthias Ringwald /**
153*ce263fc8SMatthias Ringwald  * @brief
154*ce263fc8SMatthias Ringwald  */
155*ce263fc8SMatthias Ringwald void hfp_hf_answer_incoming_call(bd_addr_t bd_addr);
156*ce263fc8SMatthias Ringwald 
157*ce263fc8SMatthias Ringwald /**
158*ce263fc8SMatthias Ringwald  * @brief
159*ce263fc8SMatthias Ringwald  */
160*ce263fc8SMatthias Ringwald void hfp_hf_reject_call(bd_addr_t bd_addr);
161*ce263fc8SMatthias Ringwald 
162*ce263fc8SMatthias Ringwald /**
163*ce263fc8SMatthias Ringwald  * @brief
164*ce263fc8SMatthias Ringwald  */
165*ce263fc8SMatthias Ringwald void hfp_hf_user_busy(bd_addr_t addr);
166*ce263fc8SMatthias Ringwald 
167*ce263fc8SMatthias Ringwald /**
168*ce263fc8SMatthias Ringwald  * @brief
169*ce263fc8SMatthias Ringwald  */
170*ce263fc8SMatthias Ringwald void hfp_hf_end_active_and_accept_other(bd_addr_t addr);
171*ce263fc8SMatthias Ringwald 
172*ce263fc8SMatthias Ringwald /**
173*ce263fc8SMatthias Ringwald  * @brief
174*ce263fc8SMatthias Ringwald  */
175*ce263fc8SMatthias Ringwald void hfp_hf_swap_calls(bd_addr_t addr);
176*ce263fc8SMatthias Ringwald 
177*ce263fc8SMatthias Ringwald /**
178*ce263fc8SMatthias Ringwald  * @brief
179*ce263fc8SMatthias Ringwald  */
180*ce263fc8SMatthias Ringwald void hfp_hf_join_held_call(bd_addr_t addr);
181*ce263fc8SMatthias Ringwald 
182*ce263fc8SMatthias Ringwald /**
183*ce263fc8SMatthias Ringwald  * @brief
184*ce263fc8SMatthias Ringwald  */
185*ce263fc8SMatthias Ringwald void hfp_hf_connect_calls(bd_addr_t addr);
186*ce263fc8SMatthias Ringwald 
187*ce263fc8SMatthias Ringwald /**
188*ce263fc8SMatthias Ringwald  * @brief
189*ce263fc8SMatthias Ringwald  */
190*ce263fc8SMatthias Ringwald void hfp_hf_terminate_call(bd_addr_t bd_addr);
191*ce263fc8SMatthias Ringwald 
192*ce263fc8SMatthias Ringwald /**
193*ce263fc8SMatthias Ringwald  * @brief
194*ce263fc8SMatthias Ringwald  */
195*ce263fc8SMatthias Ringwald void hfp_hf_dial_number(bd_addr_t bd_addr, char * number);
196*ce263fc8SMatthias Ringwald 
197*ce263fc8SMatthias Ringwald /**
198*ce263fc8SMatthias Ringwald  * @brief
199*ce263fc8SMatthias Ringwald  */
200*ce263fc8SMatthias Ringwald void hfp_hf_dial_memory(bd_addr_t bd_addr, char * number);
201*ce263fc8SMatthias Ringwald 
202*ce263fc8SMatthias Ringwald /**
203*ce263fc8SMatthias Ringwald  * @brief
204*ce263fc8SMatthias Ringwald  */
205*ce263fc8SMatthias Ringwald void hfp_hf_redial_last_number(bd_addr_t bd_addr);
206*ce263fc8SMatthias Ringwald 
207*ce263fc8SMatthias Ringwald /*
208*ce263fc8SMatthias Ringwald  * @brief
209*ce263fc8SMatthias Ringwald  */
210*ce263fc8SMatthias Ringwald void hfp_hf_activate_call_waiting_notification(bd_addr_t bd_addr);
211*ce263fc8SMatthias Ringwald 
212*ce263fc8SMatthias Ringwald /*
213*ce263fc8SMatthias Ringwald  * @brief
214*ce263fc8SMatthias Ringwald  */
215*ce263fc8SMatthias Ringwald void hfp_hf_deactivate_call_waiting_notification(bd_addr_t bd_addr);
216*ce263fc8SMatthias Ringwald 
217*ce263fc8SMatthias Ringwald /*
218*ce263fc8SMatthias Ringwald  * @brief
219*ce263fc8SMatthias Ringwald  */
220*ce263fc8SMatthias Ringwald void hfp_hf_activate_calling_line_notification(bd_addr_t bd_addr);
221*ce263fc8SMatthias Ringwald 
222*ce263fc8SMatthias Ringwald /*
223*ce263fc8SMatthias Ringwald  * @brief
224*ce263fc8SMatthias Ringwald  */
225*ce263fc8SMatthias Ringwald void hfp_hf_deactivate_calling_line_notification(bd_addr_t bd_addr);
226*ce263fc8SMatthias Ringwald 
227*ce263fc8SMatthias Ringwald 
228*ce263fc8SMatthias Ringwald /*
229*ce263fc8SMatthias Ringwald  * @brief
230*ce263fc8SMatthias Ringwald  */
231*ce263fc8SMatthias Ringwald void hfp_hf_activate_echo_canceling_and_noise_reduction(bd_addr_t bd_addr);
232*ce263fc8SMatthias Ringwald 
233*ce263fc8SMatthias Ringwald /*
234*ce263fc8SMatthias Ringwald  * @brief
235*ce263fc8SMatthias Ringwald  */
236*ce263fc8SMatthias Ringwald void hfp_hf_deactivate_echo_canceling_and_noise_reduction(bd_addr_t bd_addr);
237*ce263fc8SMatthias Ringwald 
238*ce263fc8SMatthias Ringwald /*
239*ce263fc8SMatthias Ringwald  * @brief
240*ce263fc8SMatthias Ringwald  */
241*ce263fc8SMatthias Ringwald void hfp_hf_activate_voice_recognition_notification(bd_addr_t bd_addr);
242*ce263fc8SMatthias Ringwald 
243*ce263fc8SMatthias Ringwald /*
244*ce263fc8SMatthias Ringwald  * @brief
245*ce263fc8SMatthias Ringwald  */
246*ce263fc8SMatthias Ringwald void hfp_hf_deactivate_voice_recognition_notification(bd_addr_t bd_addr);
247*ce263fc8SMatthias Ringwald 
248*ce263fc8SMatthias Ringwald /*
249*ce263fc8SMatthias Ringwald  * @brief
250*ce263fc8SMatthias Ringwald  */
251*ce263fc8SMatthias Ringwald void hfp_hf_set_microphone_gain(bd_addr_t bd_addr, int gain);
252*ce263fc8SMatthias Ringwald 
253*ce263fc8SMatthias Ringwald /*
254*ce263fc8SMatthias Ringwald  * @brief
255*ce263fc8SMatthias Ringwald  */
256*ce263fc8SMatthias Ringwald void hfp_hf_set_speaker_gain(bd_addr_t bd_addr, int gain);
257*ce263fc8SMatthias Ringwald 
258*ce263fc8SMatthias Ringwald /*
259*ce263fc8SMatthias Ringwald  * @brief
260*ce263fc8SMatthias Ringwald  */
261*ce263fc8SMatthias Ringwald void hfp_hf_send_dtmf_code(bd_addr_t bd_addr, char code);
262*ce263fc8SMatthias Ringwald 
263*ce263fc8SMatthias Ringwald /*
264*ce263fc8SMatthias Ringwald  * @brief
265*ce263fc8SMatthias Ringwald  */
266*ce263fc8SMatthias Ringwald void hfp_hf_request_phone_number_for_voice_tag(bd_addr_t addr);
2673deb3ec6SMatthias Ringwald 
2683deb3ec6SMatthias Ringwald /* API_END */
2693deb3ec6SMatthias Ringwald 
2703deb3ec6SMatthias Ringwald #if defined __cplusplus
2713deb3ec6SMatthias Ringwald }
2723deb3ec6SMatthias Ringwald #endif
2733deb3ec6SMatthias Ringwald 
2743deb3ec6SMatthias Ringwald #endif