xref: /btstack/src/classic/hfp_ag.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 Audio Gateway (AG) unit
413deb3ec6SMatthias Ringwald //
423deb3ec6SMatthias Ringwald // *****************************************************************************
433deb3ec6SMatthias Ringwald 
443deb3ec6SMatthias Ringwald 
453deb3ec6SMatthias Ringwald #ifndef btstack_hfp_ag_h
463deb3ec6SMatthias Ringwald #define btstack_hfp_ag_h
473deb3ec6SMatthias Ringwald 
483deb3ec6SMatthias Ringwald #include "hci.h"
493edc84c5SMatthias Ringwald #include "classic/sdp_query_rfcomm.h"
503edc84c5SMatthias Ringwald #include "classic/hfp.h"
5174386ee0SMatthias Ringwald #include "classic/hfp_gsm_model.h"
523deb3ec6SMatthias Ringwald 
533deb3ec6SMatthias Ringwald #if defined __cplusplus
543deb3ec6SMatthias Ringwald extern "C" {
553deb3ec6SMatthias Ringwald #endif
563deb3ec6SMatthias Ringwald 
573deb3ec6SMatthias Ringwald /* API_START */
58ce263fc8SMatthias Ringwald typedef struct {
59ce263fc8SMatthias Ringwald     uint8_t type;
60ce263fc8SMatthias Ringwald     const char * number;
61ce263fc8SMatthias Ringwald } hfp_phone_number_t;
623deb3ec6SMatthias Ringwald 
633deb3ec6SMatthias Ringwald /**
643deb3ec6SMatthias Ringwald  * @brief Create HFP Audio Gateway (AG) SDP service record.
653deb3ec6SMatthias Ringwald  */
669b1c3b4dSMatthias Ringwald void hfp_ag_create_sdp_record(uint8_t * service, uint32_t service_record_handle, int rfcomm_channel_nr, const char * name, uint8_t ability_to_reject_call, uint16_t supported_features);;
673deb3ec6SMatthias Ringwald 
683deb3ec6SMatthias Ringwald /**
693deb3ec6SMatthias Ringwald  * @brief Intialize HFP Audio Gateway (AG) device.
703deb3ec6SMatthias Ringwald  * TODO:  move optional params into setters
713deb3ec6SMatthias Ringwald  */
723deb3ec6SMatthias Ringwald void hfp_ag_init(uint16_t rfcomm_channel_nr, uint32_t supported_features,
733deb3ec6SMatthias Ringwald     uint8_t * codecs, int codecs_nr,
743deb3ec6SMatthias Ringwald     hfp_ag_indicator_t * ag_indicators, int ag_indicators_nr,
753deb3ec6SMatthias Ringwald     hfp_generic_status_indicator_t * hf_indicators, int hf_indicators_nr,
763deb3ec6SMatthias Ringwald     const char *call_hold_services[], int call_hold_services_nr);
773deb3ec6SMatthias Ringwald 
783deb3ec6SMatthias Ringwald /**
793deb3ec6SMatthias Ringwald  * @brief Register callback for the HFP Audio Gateway (AG) client.
803deb3ec6SMatthias Ringwald  */
813deb3ec6SMatthias Ringwald void hfp_ag_register_packet_handler(hfp_callback_t callback);
823deb3ec6SMatthias Ringwald 
833deb3ec6SMatthias Ringwald /**
84*66a048abSMatthias Ringwald  * @brief Enable in-band ring tone
85*66a048abSMatthias Ringwald  */
86*66a048abSMatthias Ringwald void hfp_ag_set_use_in_band_ring_tone(int use_in_band_ring_tone);
87*66a048abSMatthias Ringwald 
88*66a048abSMatthias Ringwald 
89*66a048abSMatthias Ringwald // actions used by local device / user
90*66a048abSMatthias Ringwald 
91*66a048abSMatthias Ringwald /**
923deb3ec6SMatthias Ringwald  * @brief Establish RFCOMM connection, and perform service level connection agreement:
933deb3ec6SMatthias Ringwald  * - exchange of supported features
943deb3ec6SMatthias Ringwald  * - report Audio Gateway (AG) indicators and their status
953deb3ec6SMatthias Ringwald  * - enable indicator status update in the AG
963deb3ec6SMatthias Ringwald  * - accept the information about available codecs in the Hands-Free (HF), if sent
973deb3ec6SMatthias Ringwald  * - report own information describing the call hold and multiparty services, if possible
983deb3ec6SMatthias Ringwald  * - report which HF indicators are enabled on the AG, if possible
993deb3ec6SMatthias Ringwald  */
1003deb3ec6SMatthias Ringwald void hfp_ag_establish_service_level_connection(bd_addr_t bd_addr);
1013deb3ec6SMatthias Ringwald 
1023deb3ec6SMatthias Ringwald /**
1033deb3ec6SMatthias Ringwald  * @brief Release the RFCOMM channel and the audio connection between the HF and the AG.
104*66a048abSMatthias Ringwald  * TODO: trigger release of the audio connection ??
1053deb3ec6SMatthias Ringwald  */
1063deb3ec6SMatthias Ringwald void hfp_ag_release_service_level_connection(bd_addr_t bd_addr);
1073deb3ec6SMatthias Ringwald 
1083deb3ec6SMatthias Ringwald /**
109aa4dd815SMatthias Ringwald  * @brief
110aa4dd815SMatthias Ringwald  */
1113deb3ec6SMatthias Ringwald void hfp_ag_establish_audio_connection(bd_addr_t bd_addr);
1123deb3ec6SMatthias Ringwald 
1133deb3ec6SMatthias Ringwald /**
1143deb3ec6SMatthias Ringwald  * @brief
1153deb3ec6SMatthias Ringwald  */
1163deb3ec6SMatthias Ringwald void hfp_ag_release_audio_connection(bd_addr_t bd_addr);
1173deb3ec6SMatthias Ringwald 
118*66a048abSMatthias Ringwald /**
119*66a048abSMatthias Ringwald  * @brief
120*66a048abSMatthias Ringwald  */
121*66a048abSMatthias Ringwald void hfp_ag_answer_incoming_call(void);
1223deb3ec6SMatthias Ringwald 
123aa4dd815SMatthias Ringwald /**
124*66a048abSMatthias Ringwald  * @brief
125aa4dd815SMatthias Ringwald  */
126*66a048abSMatthias Ringwald void hfp_ag_join_held_call(void);
127*66a048abSMatthias Ringwald 
128*66a048abSMatthias Ringwald /**
129*66a048abSMatthias Ringwald  * @brief
130*66a048abSMatthias Ringwald  */
131*66a048abSMatthias Ringwald void hfp_ag_terminate_call(void);
132*66a048abSMatthias Ringwald 
133*66a048abSMatthias Ringwald /*
134*66a048abSMatthias Ringwald  * @brief
135*66a048abSMatthias Ringwald  */
136*66a048abSMatthias Ringwald void hfp_ag_hold_incoming_call(void);
137*66a048abSMatthias Ringwald 
138*66a048abSMatthias Ringwald /*
139*66a048abSMatthias Ringwald  * @brief
140*66a048abSMatthias Ringwald  */
141*66a048abSMatthias Ringwald void hfp_ag_accept_held_incoming_call(void);
142*66a048abSMatthias Ringwald 
143*66a048abSMatthias Ringwald /*
144*66a048abSMatthias Ringwald  * @brief
145*66a048abSMatthias Ringwald  */
146*66a048abSMatthias Ringwald void hfp_ag_reject_held_incoming_call(void);
147*66a048abSMatthias Ringwald 
148*66a048abSMatthias Ringwald /*
149*66a048abSMatthias Ringwald  * @brief
150*66a048abSMatthias Ringwald  */
151*66a048abSMatthias Ringwald void hfp_ag_set_microphone_gain(bd_addr_t bd_addr, int gain);
152*66a048abSMatthias Ringwald 
153*66a048abSMatthias Ringwald /*
154*66a048abSMatthias Ringwald  * @brief
155*66a048abSMatthias Ringwald  */
156*66a048abSMatthias Ringwald void hfp_ag_set_speaker_gain(bd_addr_t bd_addr, int gain);
157*66a048abSMatthias Ringwald 
158*66a048abSMatthias Ringwald /*
159*66a048abSMatthias Ringwald  * @brief
160*66a048abSMatthias Ringwald  */
161*66a048abSMatthias Ringwald void hfp_ag_set_battery_level(int level);
162*66a048abSMatthias Ringwald 
163*66a048abSMatthias Ringwald /*
164*66a048abSMatthias Ringwald  * @brief
165*66a048abSMatthias Ringwald  */
166*66a048abSMatthias Ringwald void hfp_ag_clear_last_dialed_number(void);
167*66a048abSMatthias Ringwald 
168*66a048abSMatthias Ringwald 
169*66a048abSMatthias Ringwald // Voice Recognition
170*66a048abSMatthias Ringwald 
171*66a048abSMatthias Ringwald /*
172*66a048abSMatthias Ringwald  * @brief
173*66a048abSMatthias Ringwald  */
174*66a048abSMatthias Ringwald void hfp_ag_activate_voice_recognition(bd_addr_t bd_addr, int activate);
175*66a048abSMatthias Ringwald 
176*66a048abSMatthias Ringwald /*
177*66a048abSMatthias Ringwald  * @brief
178*66a048abSMatthias Ringwald  */
179*66a048abSMatthias Ringwald void hfp_ag_send_phone_number_for_voice_tag(bd_addr_t bd_addr, const char * number);
180*66a048abSMatthias Ringwald 
181*66a048abSMatthias Ringwald /*
182*66a048abSMatthias Ringwald  * @brief
183*66a048abSMatthias Ringwald  */
184*66a048abSMatthias Ringwald void hfp_ag_reject_phone_number_for_voice_tag(bd_addr_t bd_addr);
185*66a048abSMatthias Ringwald 
186*66a048abSMatthias Ringwald 
187*66a048abSMatthias Ringwald // Cellular Actions
188aa4dd815SMatthias Ringwald 
189aa4dd815SMatthias Ringwald /**
190aa4dd815SMatthias Ringwald  * @brief
191aa4dd815SMatthias Ringwald  */
192aa4dd815SMatthias Ringwald void hfp_ag_incoming_call(void);
193aa4dd815SMatthias Ringwald 
194aa4dd815SMatthias Ringwald /**
195aa4dd815SMatthias Ringwald  * @brief number is stored.
196aa4dd815SMatthias Ringwald  */
197aa4dd815SMatthias Ringwald void hfp_ag_set_clip(uint8_t type, const char * number);
198aa4dd815SMatthias Ringwald 
199aa4dd815SMatthias Ringwald /**
200aa4dd815SMatthias Ringwald  * @brief
201aa4dd815SMatthias Ringwald  */
202aa4dd815SMatthias Ringwald void hfp_ag_outgoing_call_rejected(void);
203aa4dd815SMatthias Ringwald 
204aa4dd815SMatthias Ringwald /**
205aa4dd815SMatthias Ringwald  * @brief
206aa4dd815SMatthias Ringwald  */
207aa4dd815SMatthias Ringwald void hfp_ag_outgoing_call_accepted(void);
208aa4dd815SMatthias Ringwald 
209aa4dd815SMatthias Ringwald /**
210aa4dd815SMatthias Ringwald  * @brief
211aa4dd815SMatthias Ringwald  */
212aa4dd815SMatthias Ringwald void hfp_ag_outgoing_call_ringing(void);
213aa4dd815SMatthias Ringwald 
214aa4dd815SMatthias Ringwald /**
215aa4dd815SMatthias Ringwald  * @brief
216aa4dd815SMatthias Ringwald  */
217aa4dd815SMatthias Ringwald void hfp_ag_outgoing_call_established(void);
218aa4dd815SMatthias Ringwald 
219aa4dd815SMatthias Ringwald /**
220aa4dd815SMatthias Ringwald  * @brief
221aa4dd815SMatthias Ringwald  */
222aa4dd815SMatthias Ringwald void hfp_ag_call_dropped(void);
223aa4dd815SMatthias Ringwald /*
224aa4dd815SMatthias Ringwald  * @brief
225aa4dd815SMatthias Ringwald  */
226aa4dd815SMatthias Ringwald void hfp_ag_set_registration_status(int status);
227aa4dd815SMatthias Ringwald 
228aa4dd815SMatthias Ringwald /*
229aa4dd815SMatthias Ringwald  * @brief
230aa4dd815SMatthias Ringwald  */
231aa4dd815SMatthias Ringwald void hfp_ag_set_signal_strength(int strength);
232aa4dd815SMatthias Ringwald 
233aa4dd815SMatthias Ringwald /*
234aa4dd815SMatthias Ringwald  * @brief
235aa4dd815SMatthias Ringwald  */
236aa4dd815SMatthias Ringwald void hfp_ag_set_roaming_status(int status);
237aa4dd815SMatthias Ringwald 
238aa4dd815SMatthias Ringwald /*
239aa4dd815SMatthias Ringwald  * @brief
240aa4dd815SMatthias Ringwald  */
241ce263fc8SMatthias Ringwald void hfp_ag_set_subcriber_number_information(hfp_phone_number_t * numbers, int numbers_count);
242ce263fc8SMatthias Ringwald 
243ce263fc8SMatthias Ringwald /*
244*66a048abSMatthias Ringwald  * @brief Called by cellular unit after a DTMF code was transmitted, so that the next one can be emitted
245ce263fc8SMatthias Ringwald  */
246*66a048abSMatthias Ringwald void hfp_ag_send_dtmf_code_done(bd_addr_t bd_addr);
247ce263fc8SMatthias Ringwald 
248*66a048abSMatthias Ringwald /**
249*66a048abSMatthias Ringwald  * @brief Report Extended Audio Gateway Error result codes in the AG.
250*66a048abSMatthias Ringwald  * Whenever there is an error relating to the functionality of the AG as a
251*66a048abSMatthias Ringwald  * result of AT command, the AG shall send +CME ERROR:
252*66a048abSMatthias Ringwald  * - +CME ERROR: 0  - AG failure
253*66a048abSMatthias Ringwald  * - +CME ERROR: 1  - no connection to phone
254*66a048abSMatthias Ringwald  * - +CME ERROR: 3  - operation not allowed
255*66a048abSMatthias Ringwald  * - +CME ERROR: 4  - operation not supported
256*66a048abSMatthias Ringwald  * - +CME ERROR: 5  - PH-SIM PIN required
257*66a048abSMatthias Ringwald  * - +CME ERROR: 10 - SIM not inserted
258*66a048abSMatthias Ringwald  * - +CME ERROR: 11 - SIM PIN required
259*66a048abSMatthias Ringwald  * - +CME ERROR: 12 - SIM PUK required
260*66a048abSMatthias Ringwald  * - +CME ERROR: 13 - SIM failure
261*66a048abSMatthias Ringwald  * - +CME ERROR: 14 - SIM busy
262*66a048abSMatthias Ringwald  * - +CME ERROR: 16 - incorrect password
263*66a048abSMatthias Ringwald  * - +CME ERROR: 17 - SIM PIN2 required
264*66a048abSMatthias Ringwald  * - +CME ERROR: 18 - SIM PUK2 required
265*66a048abSMatthias Ringwald  * - +CME ERROR: 20 - memory full
266*66a048abSMatthias Ringwald  * - +CME ERROR: 21 - invalid index
267*66a048abSMatthias Ringwald  * - +CME ERROR: 23 - memory failure
268*66a048abSMatthias Ringwald  * - +CME ERROR: 24 - text string too long
269*66a048abSMatthias Ringwald  * - +CME ERROR: 25 - invalid characters in text string
270*66a048abSMatthias Ringwald  * - +CME ERROR: 26 - dial string too long
271*66a048abSMatthias Ringwald  * - +CME ERROR: 27 - invalid characters in dial string
272*66a048abSMatthias Ringwald  * - +CME ERROR: 30 - no network service
273*66a048abSMatthias Ringwald  * - +CME ERROR: 31 - network Timeout.
274*66a048abSMatthias Ringwald  * - +CME ERROR: 32 - network not allowed – Emergency calls only
275ce263fc8SMatthias Ringwald  */
276*66a048abSMatthias Ringwald void hfp_ag_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr, hfp_cme_error_t error);
2779cae807eSMatthias Ringwald 
2783deb3ec6SMatthias Ringwald /* API_END */
2793deb3ec6SMatthias Ringwald 
280*66a048abSMatthias Ringwald 
2813deb3ec6SMatthias Ringwald #if defined __cplusplus
2823deb3ec6SMatthias Ringwald }
2833deb3ec6SMatthias Ringwald #endif
2843deb3ec6SMatthias Ringwald 
2853deb3ec6SMatthias Ringwald #endif