xref: /btstack/src/classic/hfp_ag.h (revision edc46354e2a5878102b1b5d34f592cdf85c38112)
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
232fca4dadSMilanka Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
242fca4dadSMilanka Ringwald  * GMBH 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 
38fe5a6c4eSMilanka Ringwald /**
39fe5a6c4eSMilanka Ringwald  * @title HFP Audio Gateway (AG)
40fe5a6c4eSMilanka Ringwald  *
41fe5a6c4eSMilanka Ringwald  */
423deb3ec6SMatthias Ringwald 
4350b9afa4SMilanka Ringwald #ifndef BTSTACK_HFP_AG_H
4450b9afa4SMilanka Ringwald #define BTSTACK_HFP_AG_H
453deb3ec6SMatthias Ringwald 
463deb3ec6SMatthias Ringwald #include "hci.h"
47efda0b48SMatthias Ringwald #include "classic/sdp_client_rfcomm.h"
483edc84c5SMatthias Ringwald #include "classic/hfp.h"
4974386ee0SMatthias Ringwald #include "classic/hfp_gsm_model.h"
503deb3ec6SMatthias Ringwald 
513deb3ec6SMatthias Ringwald #if defined __cplusplus
523deb3ec6SMatthias Ringwald extern "C" {
533deb3ec6SMatthias Ringwald #endif
543deb3ec6SMatthias Ringwald 
553deb3ec6SMatthias Ringwald /* API_START */
56ce263fc8SMatthias Ringwald typedef struct {
57ce263fc8SMatthias Ringwald     uint8_t type;
58ce263fc8SMatthias Ringwald     const char * number;
59ce263fc8SMatthias Ringwald } hfp_phone_number_t;
603deb3ec6SMatthias Ringwald 
613deb3ec6SMatthias Ringwald /**
623deb3ec6SMatthias Ringwald  * @brief Create HFP Audio Gateway (AG) SDP service record.
63a0ffb263SMatthias Ringwald  * @param service
64a0ffb263SMatthias Ringwald  * @param rfcomm_channel_nr
65ada240cdSMatthias Ringwald  * @param name or NULL for default value. Provide "" (empty string) to skip attribute
66a0ffb263SMatthias Ringwald  * @param ability_to_reject_call
67aa10b9cbSMatthias Ringwald  * @param supported_features 32-bit bitmap, see HFP_AGSF_* values in hfp.h
68aa10b9cbSMatthias Ringwald  * @param codecs_nr
69aa10b9cbSMatthias Ringwald  * @param codecs
703deb3ec6SMatthias Ringwald  */
71aa10b9cbSMatthias Ringwald void hfp_ag_create_sdp_record_with_codecs(uint8_t * service, uint32_t service_record_handle, int rfcomm_channel_nr,
72aa10b9cbSMatthias Ringwald                                           const char * name, uint8_t ability_to_reject_call, uint16_t supported_features,
73aa10b9cbSMatthias Ringwald                                           uint8_t codecs_nr, const uint8_t * codecs);
743deb3ec6SMatthias Ringwald 
753deb3ec6SMatthias Ringwald /**
76a0ffb263SMatthias Ringwald  * @brief Set up HFP Audio Gateway (AG) device without additional supported features.
77a0ffb263SMatthias Ringwald  * @param rfcomm_channel_nr
783deb3ec6SMatthias Ringwald  */
79ab2445a0SMatthias Ringwald void hfp_ag_init(uint8_t rfcomm_channel_nr);
80a0ffb263SMatthias Ringwald 
81a0ffb263SMatthias Ringwald /**
82a0ffb263SMatthias Ringwald  * @brief Set codecs.
83a0ffb263SMatthias Ringwald  * @param codecs_nr
84a0ffb263SMatthias Ringwald  * @param codecs
85a0ffb263SMatthias Ringwald  */
86aa10b9cbSMatthias Ringwald void hfp_ag_init_codecs(uint8_t codecs_nr, const uint8_t * codecs);
87a0ffb263SMatthias Ringwald 
88a0ffb263SMatthias Ringwald /**
89a0ffb263SMatthias Ringwald  * @brief Set supported features.
90a0ffb263SMatthias Ringwald  * @param supported_features 32-bit bitmap, see HFP_AGSF_* values in hfp.h
91a0ffb263SMatthias Ringwald  */
92a0ffb263SMatthias Ringwald void hfp_ag_init_supported_features(uint32_t supported_features);
93a0ffb263SMatthias Ringwald 
94a0ffb263SMatthias Ringwald /**
95a0ffb263SMatthias Ringwald  * @brief Set AG indicators.
96a0ffb263SMatthias Ringwald  * @param indicators_nr
97a0ffb263SMatthias Ringwald  * @param indicators
98a0ffb263SMatthias Ringwald  */
997ca89cabSMatthias Ringwald void hfp_ag_init_ag_indicators(int ag_indicators_nr, const hfp_ag_indicator_t * ag_indicators);
100a0ffb263SMatthias Ringwald 
101a0ffb263SMatthias Ringwald /**
102a0ffb263SMatthias Ringwald  * @brief Set HF indicators.
103a0ffb263SMatthias Ringwald  * @param indicators_nr
104a0ffb263SMatthias Ringwald  * @param indicators
105a0ffb263SMatthias Ringwald  */
1067ca89cabSMatthias Ringwald void hfp_ag_init_hf_indicators(int hf_indicators_nr, const hfp_generic_status_indicator_t * hf_indicators);
107a0ffb263SMatthias Ringwald 
108a0ffb263SMatthias Ringwald /**
109a0ffb263SMatthias Ringwald  * @brief Set Call Hold services.
110a0ffb263SMatthias Ringwald  * @param indicators_nr
111a0ffb263SMatthias Ringwald  * @param indicators
112a0ffb263SMatthias Ringwald  */
113a0ffb263SMatthias Ringwald void hfp_ag_init_call_hold_services(int call_hold_services_nr, const char * call_hold_services[]);
114a0ffb263SMatthias Ringwald 
115*edc46354SMatthias Ringwald /**
116*edc46354SMatthias Ringwald  * @brief Provide Apple Device information upon AT+XAPL
117*edc46354SMatthias Ringwald  * @param device
118*edc46354SMatthias Ringwald  * @param features
119*edc46354SMatthias Ringwald  */
120*edc46354SMatthias Ringwald void hfp_ag_init_apple_identification(const char * device, uint8_t features);
121*edc46354SMatthias Ringwald 
1223deb3ec6SMatthias Ringwald 
1233deb3ec6SMatthias Ringwald /**
1243deb3ec6SMatthias Ringwald  * @brief Register callback for the HFP Audio Gateway (AG) client.
125a0ffb263SMatthias Ringwald  * @param callback
1263deb3ec6SMatthias Ringwald  */
12713839019SMatthias Ringwald void hfp_ag_register_packet_handler(btstack_packet_handler_t callback);
1283deb3ec6SMatthias Ringwald 
1293deb3ec6SMatthias Ringwald /**
130471dea41SMatthias Ringwald  * @brief Register custom AT command.
131471dea41SMatthias Ringwald  * @param hfp_custom_at_command (with 'AT+' prefix)
132471dea41SMatthias Ringwald  */
133471dea41SMatthias Ringwald void hfp_ag_register_custom_at_command(hfp_custom_at_command_t * custom_at_command);
134471dea41SMatthias Ringwald 
135471dea41SMatthias Ringwald /**
136c5fa3c94SMilanka Ringwald  * @brief Enable/Disable in-band ring tone.
137c5fa3c94SMilanka Ringwald  *
138a0ffb263SMatthias Ringwald  * @param use_in_band_ring_tone
13966a048abSMatthias Ringwald  */
140d7d354cbSMilanka Ringwald void hfp_ag_set_use_in_band_ring_tone(int use_in_band_ring_tone);
14166a048abSMatthias Ringwald 
14266a048abSMatthias Ringwald 
14366a048abSMatthias Ringwald // actions used by local device / user
14466a048abSMatthias Ringwald 
14566a048abSMatthias Ringwald /**
1463deb3ec6SMatthias Ringwald  * @brief Establish RFCOMM connection, and perform service level connection agreement:
1473deb3ec6SMatthias Ringwald  * - exchange of supported features
1483deb3ec6SMatthias Ringwald  * - report Audio Gateway (AG) indicators and their status
1493deb3ec6SMatthias Ringwald  * - enable indicator status update in the AG
1503deb3ec6SMatthias Ringwald  * - accept the information about available codecs in the Hands-Free (HF), if sent
1513deb3ec6SMatthias Ringwald  * - report own information describing the call hold and multiparty services, if possible
1523deb3ec6SMatthias Ringwald  * - report which HF indicators are enabled on the AG, if possible
153a0ffb263SMatthias Ringwald  * The status of SLC connection establishment is reported via
154a0ffb263SMatthias Ringwald  * HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED.
155a0ffb263SMatthias Ringwald  *
156c5fa3c94SMilanka Ringwald  * @param  bd_addr of HF
1574eb3f1d8SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
1584eb3f1d8SMilanka Ringwald  *                  - ERROR_CODE_COMMAND_DISALLOWED if connection already exists or connection in wrong state, or
1594eb3f1d8SMilanka Ringwald  *                  - BTSTACK_MEMORY_ALLOC_FAILED
1604eb3f1d8SMilanka Ringwald  *
1613deb3ec6SMatthias Ringwald  */
1624eb3f1d8SMilanka Ringwald uint8_t hfp_ag_establish_service_level_connection(bd_addr_t bd_addr);
1633deb3ec6SMatthias Ringwald 
1643deb3ec6SMatthias Ringwald /**
1653deb3ec6SMatthias Ringwald  * @brief Release the RFCOMM channel and the audio connection between the HF and the AG.
166a0ffb263SMatthias Ringwald  * If the audio connection exists, it will be released.
167a0ffb263SMatthias Ringwald  * The status of releasing the SLC connection is reported via
168a0ffb263SMatthias Ringwald  * HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED.
169a0ffb263SMatthias Ringwald  *
170c5fa3c94SMilanka Ringwald  * @param acl_handle
171657bc59fSMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist
1723deb3ec6SMatthias Ringwald  */
173657bc59fSMilanka Ringwald uint8_t hfp_ag_release_service_level_connection(hci_con_handle_t acl_handle);
1743deb3ec6SMatthias Ringwald 
1753deb3ec6SMatthias Ringwald /**
176a0ffb263SMatthias Ringwald  * @brief Establish audio connection.
1771c7aea60SMilanka Ringwald  * The status of Audio connection establishment is reported via HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE.
178c5fa3c94SMilanka Ringwald  *
179c5fa3c94SMilanka Ringwald  * @param acl_handle
180c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist
181aa4dd815SMatthias Ringwald  */
182c5fa3c94SMilanka Ringwald uint8_t hfp_ag_establish_audio_connection(hci_con_handle_t acl_handle);
1833deb3ec6SMatthias Ringwald 
1843deb3ec6SMatthias Ringwald /**
185a0ffb263SMatthias Ringwald  * @brief Release audio connection.
1861c7aea60SMilanka Ringwald  * The status of releasing the Audio connection is reported via HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE.
187c5fa3c94SMilanka Ringwald  *
188c5fa3c94SMilanka Ringwald  * @param acl_handle
189c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist
1903deb3ec6SMatthias Ringwald  */
191c5fa3c94SMilanka Ringwald uint8_t hfp_ag_release_audio_connection(hci_con_handle_t acl_handle);
1923deb3ec6SMatthias Ringwald 
19366a048abSMatthias Ringwald /**
194a0ffb263SMatthias Ringwald  * @brief Put the current call on hold, if it exists, and accept incoming call.
19566a048abSMatthias Ringwald  */
19666a048abSMatthias Ringwald void hfp_ag_answer_incoming_call(void);
1973deb3ec6SMatthias Ringwald 
198aa4dd815SMatthias Ringwald /**
199a0ffb263SMatthias Ringwald  * @brief Join held call with active call.
200aa4dd815SMatthias Ringwald  */
20166a048abSMatthias Ringwald void hfp_ag_join_held_call(void);
20266a048abSMatthias Ringwald 
20366a048abSMatthias Ringwald /**
204a0ffb263SMatthias Ringwald  * @brief Reject incoming call, if exists, or terminate active call.
20566a048abSMatthias Ringwald  */
20666a048abSMatthias Ringwald void hfp_ag_terminate_call(void);
20766a048abSMatthias Ringwald 
208154628ccSMatthias Ringwald /**
209a0ffb263SMatthias Ringwald  * @brief Put incoming call on hold.
21066a048abSMatthias Ringwald  */
21166a048abSMatthias Ringwald void hfp_ag_hold_incoming_call(void);
21266a048abSMatthias Ringwald 
213154628ccSMatthias Ringwald /**
214a0ffb263SMatthias Ringwald  * @brief Accept the held incoming call.
21566a048abSMatthias Ringwald  */
21666a048abSMatthias Ringwald void hfp_ag_accept_held_incoming_call(void);
21766a048abSMatthias Ringwald 
218154628ccSMatthias Ringwald /**
219a0ffb263SMatthias Ringwald  * @brief Reject the held incoming call.
22066a048abSMatthias Ringwald  */
22166a048abSMatthias Ringwald void hfp_ag_reject_held_incoming_call(void);
22266a048abSMatthias Ringwald 
223154628ccSMatthias Ringwald /**
224a0ffb263SMatthias Ringwald  * @brief Set microphone gain.
225c5fa3c94SMilanka Ringwald  *
226c5fa3c94SMilanka Ringwald  * @param acl_handle
227a0ffb263SMatthias Ringwald  * @param gain Valid range: [0,15]
228c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
229c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
230c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if invalid gain range
23166a048abSMatthias Ringwald  */
232c5fa3c94SMilanka Ringwald uint8_t hfp_ag_set_microphone_gain(hci_con_handle_t acl_handle, int gain);
23366a048abSMatthias Ringwald 
234154628ccSMatthias Ringwald /**
235a0ffb263SMatthias Ringwald  * @brief Set speaker gain.
236c5fa3c94SMilanka Ringwald  *
237c5fa3c94SMilanka Ringwald  * @param acl_handle
238a0ffb263SMatthias Ringwald  * @param gain Valid range: [0,15]
239c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
240c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
241c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if invalid gain range
24266a048abSMatthias Ringwald  */
243c5fa3c94SMilanka Ringwald uint8_t hfp_ag_set_speaker_gain(hci_con_handle_t acl_handle, int gain);
24466a048abSMatthias Ringwald 
245154628ccSMatthias Ringwald /**
246a0ffb263SMatthias Ringwald  * @brief Set battery level.
247c5fa3c94SMilanka Ringwald  *
248c5fa3c94SMilanka Ringwald  * @param battery_level Valid range: [0,5]
249c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
250c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
251c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if invalid battery level range
25266a048abSMatthias Ringwald  */
253c5fa3c94SMilanka Ringwald uint8_t hfp_ag_set_battery_level(int battery_level);
25466a048abSMatthias Ringwald 
255154628ccSMatthias Ringwald /**
256a0ffb263SMatthias Ringwald  * @brief Clear last dialed number.
25766a048abSMatthias Ringwald  */
25866a048abSMatthias Ringwald void hfp_ag_clear_last_dialed_number(void);
25966a048abSMatthias Ringwald 
260154628ccSMatthias Ringwald /**
2619de679b7SMilanka Ringwald  * @brief Set last dialed number.
2629de679b7SMilanka Ringwald  */
2639de679b7SMilanka Ringwald void hfp_ag_set_last_dialed_number(const char * number);
2649de679b7SMilanka Ringwald 
265154628ccSMatthias Ringwald /**
266a0ffb263SMatthias Ringwald  * @brief Notify the HF that an incoming call is waiting
267a0ffb263SMatthias Ringwald  * during an ongoing call. The notification will be sent only if the HF has
268a0ffb263SMatthias Ringwald  * has previously enabled the "Call Waiting notification" in the AG.
269c5fa3c94SMilanka Ringwald  *
270c5fa3c94SMilanka Ringwald  * @param acl_handle
271c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
272c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
273c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if call waiting notification is not enabled
274a0ffb263SMatthias Ringwald  */
275c5fa3c94SMilanka Ringwald uint8_t hfp_ag_notify_incoming_call_waiting(hci_con_handle_t acl_handle);
27666a048abSMatthias Ringwald 
27766a048abSMatthias Ringwald // Voice Recognition
27866a048abSMatthias Ringwald 
279154628ccSMatthias Ringwald /**
280b321b609SMilanka Ringwald  * @brief Activate voice recognition and emit HFP_SUBEVENT_VOICE_RECOGNITION_ACTIVATED event with status ERROR_CODE_SUCCESS
281b321b609SMilanka Ringwald  * if successful. Prerequisite is established SLC.
282c5fa3c94SMilanka Ringwald  *
283c5fa3c94SMilanka Ringwald  * @param acl_handle
284c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
285c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
2866ba83b5eSMilanka Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_VOICE_RECOGNITION_FUNCTION is not supported by HF and AG, or already activated
28766a048abSMatthias Ringwald  */
288d84719b1SMilanka Ringwald uint8_t hfp_ag_activate_voice_recognition(hci_con_handle_t acl_handle);
289d84719b1SMilanka Ringwald 
290154628ccSMatthias Ringwald /**
291b321b609SMilanka Ringwald  * @brief Deactivate voice recognition and emit HFP_SUBEVENT_VOICE_RECOGNITION_DEACTIVATED event with status ERROR_CODE_SUCCESS
292b321b609SMilanka Ringwald  * if successful. Prerequisite is established SLC.
293d84719b1SMilanka Ringwald  *
294d84719b1SMilanka Ringwald  * @param acl_handle
295d84719b1SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
296d84719b1SMilanka Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
2976ba83b5eSMilanka Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_VOICE_RECOGNITION_FUNCTION is not supported by HF and AG, or already deactivated
298d84719b1SMilanka Ringwald  */
299d84719b1SMilanka Ringwald uint8_t hfp_ag_deactivate_voice_recognition(hci_con_handle_t acl_handle);
30066a048abSMatthias Ringwald 
301154628ccSMatthias Ringwald /**
302e8e72901SMilanka Ringwald  * @brief Notify HF that sound will be played and HFP_SUBEVENT_ENHANCED_VOICE_RECOGNITION_AG_IS_STARTING_SOUND event with status ERROR_CODE_SUCCESS
303e8e72901SMilanka Ringwald  * if successful, otherwise ERROR_CODE_COMMAND_DISALLOWED.
304c5fa3c94SMilanka Ringwald  *
305c5fa3c94SMilanka Ringwald  * @param acl_handle
306c5fa3c94SMilanka Ringwald  * @param activate
307c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
308c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
3096ba83b5eSMilanka Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_ENHANCED_VOICE_RECOGNITION_STATUS is not supported by HF and AG
310c5fa3c94SMilanka Ringwald  */
311f0c27a95SMilanka Ringwald uint8_t hfp_ag_enhanced_voice_recognition_report_sending_audio(hci_con_handle_t acl_handle);
312c5fa3c94SMilanka Ringwald 
313154628ccSMatthias Ringwald /**
314e8e72901SMilanka Ringwald  * @brief Notify HF that AG is ready for input and emit HFP_SUBEVENT_ENHANCED_VOICE_RECOGNITION_AG_READY_TO_ACCEPT_AUDIO_INPUT event with status ERROR_CODE_SUCCESS
315e8e72901SMilanka Ringwald  * if successful, otherwise ERROR_CODE_COMMAND_DISALLOWED.
316c5fa3c94SMilanka Ringwald  *
317c5fa3c94SMilanka Ringwald  * @param acl_handle
318c5fa3c94SMilanka Ringwald  * @param activate
319c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
320c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
3216ba83b5eSMilanka Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_ENHANCED_VOICE_RECOGNITION_STATUS is not supported by HF and AG
322c5fa3c94SMilanka Ringwald  */
323f0c27a95SMilanka Ringwald uint8_t hfp_ag_enhanced_voice_recognition_report_ready_for_audio(hci_con_handle_t acl_handle);
324c5fa3c94SMilanka Ringwald 
325154628ccSMatthias Ringwald /**
326e8e72901SMilanka Ringwald  * @brief Notify that AG is processing input and emit HFP_SUBEVENT_ENHANCED_VOICE_RECOGNITION_AG_IS_PROCESSING_AUDIO_INPUT event with status ERROR_CODE_SUCCESS
327e8e72901SMilanka Ringwald  * if successful, otherwise ERROR_CODE_COMMAND_DISALLOWED.
328c5fa3c94SMilanka Ringwald  *
329c5fa3c94SMilanka Ringwald  * @param acl_handle
330c5fa3c94SMilanka Ringwald  * @param activate
331c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
332c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
3336ba83b5eSMilanka Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if feature HFP_(HF/AG)SF_ENHANCED_VOICE_RECOGNITION_STATUS is not supported by HF and AG
334c5fa3c94SMilanka Ringwald  */
335cf75be85SMilanka Ringwald uint8_t hfp_ag_enhanced_voice_recognition_report_processing_input(hci_con_handle_t acl_handle);
336c5fa3c94SMilanka Ringwald 
337154628ccSMatthias Ringwald /**
338e8e72901SMilanka Ringwald  * @brief Send enhanced audio recognition message and HFP_SUBEVENT_ENHANCED_VOICE_RECOGNITION_AG_MESSAGE_SENT event with status ERROR_CODE_SUCCESS
339e8e72901SMilanka Ringwald  * if successful, otherwise ERROR_CODE_COMMAND_DISALLOWED.
340c5fa3c94SMilanka Ringwald  *
341c5fa3c94SMilanka Ringwald  * @param acl_handle
342c5fa3c94SMilanka Ringwald  * @param activate
343c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
3446504a03aSMilanka Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist,
345fe96b3b0SMilanka Ringwald                 - ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if the message size exceeds the HFP_MAX_VR_TEXT_SIZE, or the command does not fit into a single packet frame,
3466ba83b5eSMilanka Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if HF and AG do not support features: HFP_(HF/AG)SF_ENHANCED_VOICE_RECOGNITION_STATUS and HFP_(HF/AG)SF_VOICE_RECOGNITION_TEXT
347c5fa3c94SMilanka Ringwald  */
348b95cac54SMilanka Ringwald uint8_t hfp_ag_enhanced_voice_recognition_send_message(hci_con_handle_t acl_handle, hfp_voice_recognition_state_t state, hfp_voice_recognition_message_t msg);
349c5fa3c94SMilanka Ringwald 
350154628ccSMatthias Ringwald /**
351a0ffb263SMatthias Ringwald  * @brief Send a phone number back to the HF.
352c5fa3c94SMilanka Ringwald  *
353c5fa3c94SMilanka Ringwald  * @param acl_handle
354a0ffb263SMatthias Ringwald  * @param phone_number
355c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist
35666a048abSMatthias Ringwald  */
357c5fa3c94SMilanka Ringwald uint8_t hfp_ag_send_phone_number_for_voice_tag(hci_con_handle_t acl_handle, const char * phone_number);
35866a048abSMatthias Ringwald 
359154628ccSMatthias Ringwald /**
360a0ffb263SMatthias Ringwald  * @brief Reject sending a phone number to the HF.
361c5fa3c94SMilanka Ringwald  *
362c5fa3c94SMilanka Ringwald  * @param acl_handle
363c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist
36466a048abSMatthias Ringwald  */
365c5fa3c94SMilanka Ringwald uint8_t hfp_ag_reject_phone_number_for_voice_tag(hci_con_handle_t acl_handle);
36666a048abSMatthias Ringwald 
367a0ffb263SMatthias Ringwald /**
368a0ffb263SMatthias Ringwald  * @brief Store phone number with initiated call.
369a0ffb263SMatthias Ringwald  * @param type
370a0ffb263SMatthias Ringwald  * @param number
371a0ffb263SMatthias Ringwald  */
372a0ffb263SMatthias Ringwald void hfp_ag_set_clip(uint8_t type, const char * number);
373a0ffb263SMatthias Ringwald 
37466a048abSMatthias Ringwald 
37566a048abSMatthias Ringwald // Cellular Actions
376aa4dd815SMatthias Ringwald 
377aa4dd815SMatthias Ringwald /**
378a0ffb263SMatthias Ringwald  * @brief Pass the accept incoming call event to the AG.
379aa4dd815SMatthias Ringwald  */
380aa4dd815SMatthias Ringwald void hfp_ag_incoming_call(void);
381aa4dd815SMatthias Ringwald 
382aa4dd815SMatthias Ringwald /**
383fe899794SMatthias Ringwald  * @brief Outgoing call initiated
384fe899794SMatthias Ringwald  */
3850f1da533SMatthias Ringwald void hfp_ag_outgoing_call_initiated(void);
386fe899794SMatthias Ringwald 
387fe899794SMatthias Ringwald /**
388a0ffb263SMatthias Ringwald  * @brief Pass the reject outgoing call event to the AG.
389aa4dd815SMatthias Ringwald  */
390aa4dd815SMatthias Ringwald void hfp_ag_outgoing_call_rejected(void);
391aa4dd815SMatthias Ringwald 
392aa4dd815SMatthias Ringwald /**
393a0ffb263SMatthias Ringwald  * @brief Pass the accept outgoing call event to the AG.
394aa4dd815SMatthias Ringwald  */
395aa4dd815SMatthias Ringwald void hfp_ag_outgoing_call_accepted(void);
396aa4dd815SMatthias Ringwald 
397aa4dd815SMatthias Ringwald /**
398a0ffb263SMatthias Ringwald  * @brief Pass the outgoing call ringing event to the AG.
399aa4dd815SMatthias Ringwald  */
400aa4dd815SMatthias Ringwald void hfp_ag_outgoing_call_ringing(void);
401aa4dd815SMatthias Ringwald 
402aa4dd815SMatthias Ringwald /**
403a0ffb263SMatthias Ringwald  * @brief Pass the outgoing call established event to the AG.
404aa4dd815SMatthias Ringwald  */
405aa4dd815SMatthias Ringwald void hfp_ag_outgoing_call_established(void);
406aa4dd815SMatthias Ringwald 
407aa4dd815SMatthias Ringwald /**
408674ebed5SMilanka Ringwald  * @brief Pass the call dropped event to the AG.
409aa4dd815SMatthias Ringwald  */
410aa4dd815SMatthias Ringwald void hfp_ag_call_dropped(void);
411a0ffb263SMatthias Ringwald 
412154628ccSMatthias Ringwald /**
413a0ffb263SMatthias Ringwald  * @brief Set network registration status.
414a0ffb263SMatthias Ringwald  * @param status 0 - not registered, 1 - registered
415c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
416c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
417c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if invalid registration status
418aa4dd815SMatthias Ringwald  */
419c5fa3c94SMilanka Ringwald uint8_t hfp_ag_set_registration_status(int registration_status);
420aa4dd815SMatthias Ringwald 
421154628ccSMatthias Ringwald /**
422a0ffb263SMatthias Ringwald  * @brief Set network signal strength.
423c5fa3c94SMilanka Ringwald  *
424c5fa3c94SMilanka Ringwald  * @param signal_strength [0-5]
425c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
426c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
427c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if invalid signal strength range
428aa4dd815SMatthias Ringwald  */
429c5fa3c94SMilanka Ringwald uint8_t hfp_ag_set_signal_strength(int signal_strength);
430aa4dd815SMatthias Ringwald 
431154628ccSMatthias Ringwald /**
432a0ffb263SMatthias Ringwald  * @brief Set roaming status.
433c5fa3c94SMilanka Ringwald  *
434c5fa3c94SMilanka Ringwald  * @param roaming_status 0 - no roaming, 1 - roaming active
435c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
436c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
437c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if invalid roaming status
438aa4dd815SMatthias Ringwald  */
439c5fa3c94SMilanka Ringwald uint8_t hfp_ag_set_roaming_status(int roaming_status);
440aa4dd815SMatthias Ringwald 
441154628ccSMatthias Ringwald /**
442a0ffb263SMatthias Ringwald  * @brief Set subcriber number information, e.g. the phone number
443a0ffb263SMatthias Ringwald  * @param numbers
444a0ffb263SMatthias Ringwald  * @param numbers_count
445aa4dd815SMatthias Ringwald  */
446ce263fc8SMatthias Ringwald void hfp_ag_set_subcriber_number_information(hfp_phone_number_t * numbers, int numbers_count);
447ce263fc8SMatthias Ringwald 
448154628ccSMatthias Ringwald /**
449a0ffb263SMatthias Ringwald  * @brief Called by cellular unit after a DTMF code was transmitted, so that the next one can be emitted.
450c5fa3c94SMilanka Ringwald  *
451c5fa3c94SMilanka Ringwald  * @param acl_handle
452c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist
453ce263fc8SMatthias Ringwald  */
454c5fa3c94SMilanka Ringwald uint8_t hfp_ag_send_dtmf_code_done(hci_con_handle_t acl_handle);
455ce263fc8SMatthias Ringwald 
45666a048abSMatthias Ringwald /**
45766a048abSMatthias Ringwald  * @brief Report Extended Audio Gateway Error result codes in the AG.
45866a048abSMatthias Ringwald  * Whenever there is an error relating to the functionality of the AG as a
45966a048abSMatthias Ringwald  * result of AT command, the AG shall send +CME ERROR:
46066a048abSMatthias Ringwald  * - +CME ERROR: 0  - AG failure
46166a048abSMatthias Ringwald  * - +CME ERROR: 1  - no connection to phone
46266a048abSMatthias Ringwald  * - +CME ERROR: 3  - operation not allowed
46366a048abSMatthias Ringwald  * - +CME ERROR: 4  - operation not supported
46466a048abSMatthias Ringwald  * - +CME ERROR: 5  - PH-SIM PIN required
46566a048abSMatthias Ringwald  * - +CME ERROR: 10 - SIM not inserted
46666a048abSMatthias Ringwald  * - +CME ERROR: 11 - SIM PIN required
46766a048abSMatthias Ringwald  * - +CME ERROR: 12 - SIM PUK required
46866a048abSMatthias Ringwald  * - +CME ERROR: 13 - SIM failure
46966a048abSMatthias Ringwald  * - +CME ERROR: 14 - SIM busy
47066a048abSMatthias Ringwald  * - +CME ERROR: 16 - incorrect password
47166a048abSMatthias Ringwald  * - +CME ERROR: 17 - SIM PIN2 required
47266a048abSMatthias Ringwald  * - +CME ERROR: 18 - SIM PUK2 required
47366a048abSMatthias Ringwald  * - +CME ERROR: 20 - memory full
47466a048abSMatthias Ringwald  * - +CME ERROR: 21 - invalid index
47566a048abSMatthias Ringwald  * - +CME ERROR: 23 - memory failure
47666a048abSMatthias Ringwald  * - +CME ERROR: 24 - text string too long
47766a048abSMatthias Ringwald  * - +CME ERROR: 25 - invalid characters in text string
47866a048abSMatthias Ringwald  * - +CME ERROR: 26 - dial string too long
47966a048abSMatthias Ringwald  * - +CME ERROR: 27 - invalid characters in dial string
48066a048abSMatthias Ringwald  * - +CME ERROR: 30 - no network service
48166a048abSMatthias Ringwald  * - +CME ERROR: 31 - network Timeout.
48266a048abSMatthias Ringwald  * - +CME ERROR: 32 - network not allowed – Emergency calls only
483a0ffb263SMatthias Ringwald  *
484c5fa3c94SMilanka Ringwald  * @param acl_handle
485a0ffb263SMatthias Ringwald  * @param error
486c5fa3c94SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
487c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
488c5fa3c94SMilanka Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if extended audio gateway error report is disabled
489ce263fc8SMatthias Ringwald  */
490c5fa3c94SMilanka Ringwald uint8_t hfp_ag_report_extended_audio_gateway_error_result_code(hci_con_handle_t acl_handle, hfp_cme_error_t error);
4919cae807eSMatthias Ringwald 
49220b2edb6SMatthias Ringwald /**
4935be6b47aSMatthias Ringwald  * @brief Send unsolicited result code (most likely a response to a vendor-specific command not part of standard HFP).
4947f8f1191SMatthias Ringwald  * @note  Emits HFP_SUBEVENT_CUSTOM_AT_MESSAGE_SENT when result code was sent
4955be6b47aSMatthias Ringwald  *
4965be6b47aSMatthias Ringwald  * @param unsolicited_result_code to send
4975be6b47aSMatthias Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
4985be6b47aSMatthias Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
4995be6b47aSMatthias Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if extended audio gateway error report is disabled
5005be6b47aSMatthias Ringwald  */
5015be6b47aSMatthias Ringwald uint8_t hfp_ag_send_unsolicited_result_code(hci_con_handle_t acl_handle, const char * unsolicited_result_code);
5025be6b47aSMatthias Ringwald 
5035be6b47aSMatthias Ringwald /**
504471dea41SMatthias Ringwald  * @brief Send result code for AT command received via HFP_SUBEVENT_CUSTOM_AT_COMMAND
505471dea41SMatthias Ringwald  * @note  Emits HFP_SUBEVENT_COMPLETE when result code was sent
506471dea41SMatthias Ringwald  *
507471dea41SMatthias Ringwald  * @param ok for OK, or ERROR
508471dea41SMatthias Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
509471dea41SMatthias Ringwald  *              - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
510471dea41SMatthias Ringwald  *              - ERROR_CODE_COMMAND_DISALLOWED if extended audio gateway error report is disabled
511471dea41SMatthias Ringwald  */
512471dea41SMatthias Ringwald uint8_t hfp_ag_send_command_result_code(hci_con_handle_t acl_handle, bool ok);
513471dea41SMatthias Ringwald 
514471dea41SMatthias Ringwald /**
51520b2edb6SMatthias Ringwald  * @brief De-Init HFP AG
51620b2edb6SMatthias Ringwald  */
51720b2edb6SMatthias Ringwald void hfp_ag_deinit(void);
51820b2edb6SMatthias Ringwald 
519aa10b9cbSMatthias Ringwald /**
520aa10b9cbSMatthias Ringwald  * @brief Create HFP Audio Gateway (AG) SDP service record.
521aa10b9cbSMatthias Ringwald  * @deprecated Use hfp_ag_create_sdp_record_with_codecs instead
522aa10b9cbSMatthias Ringwald  * @param service
523aa10b9cbSMatthias Ringwald  * @param rfcomm_channel_nr
524aa10b9cbSMatthias Ringwald  * @param name
525aa10b9cbSMatthias Ringwald  * @param ability_to_reject_call
526aa10b9cbSMatthias Ringwald  * @param suported_features 32-bit bitmap, see HFP_AGSF_* values in hfp.h
527aa10b9cbSMatthias Ringwald  * @param wide_band_speech supported
528aa10b9cbSMatthias Ringwald  */
529aa10b9cbSMatthias 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, int wide_band_speech);
530aa10b9cbSMatthias Ringwald 
5313deb3ec6SMatthias Ringwald /* API_END */
5323deb3ec6SMatthias Ringwald 
533bc06f5acSMatthias Ringwald // testing
534bc06f5acSMatthias Ringwald hfp_ag_indicator_t * hfp_ag_get_ag_indicators(hfp_connection_t * hfp_connection);
53566a048abSMatthias Ringwald 
53681e25d0aSMatthias Ringwald // @return true to process even as normal, false to cause HFP AG to ignore event
53781e25d0aSMatthias Ringwald void hfp_ag_register_custom_call_sm_handler(bool (*handler)(hfp_ag_call_event_t event));
53881e25d0aSMatthias Ringwald 
5393deb3ec6SMatthias Ringwald #if defined __cplusplus
5403deb3ec6SMatthias Ringwald }
5413deb3ec6SMatthias Ringwald #endif
5423deb3ec6SMatthias Ringwald 
5433deb3ec6SMatthias Ringwald #endif
544