xref: /btstack/src/classic/hfp.h (revision 6b3901f2f7d12ce28042d3f11dedd2ea564ff502)
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  * HFP Hands-Free (HF) unit and Audio Gateway Commons
40fe5a6c4eSMilanka Ringwald  *
41fe5a6c4eSMilanka Ringwald  */
423deb3ec6SMatthias Ringwald 
4380e33422SMatthias Ringwald #ifndef BTSTACK_HFP_H
4480e33422SMatthias Ringwald #define BTSTACK_HFP_H
453deb3ec6SMatthias Ringwald 
463deb3ec6SMatthias Ringwald #include "hci.h"
47efda0b48SMatthias Ringwald #include "classic/sdp_client_rfcomm.h"
483deb3ec6SMatthias Ringwald 
493deb3ec6SMatthias Ringwald #if defined __cplusplus
503deb3ec6SMatthias Ringwald extern "C" {
513deb3ec6SMatthias Ringwald #endif
523deb3ec6SMatthias Ringwald 
5350b9afa4SMilanka Ringwald // period AG will send RING messages
5450b9afa4SMilanka Ringwald #define HFP_RING_PERIOD_MS 2000
553deb3ec6SMatthias Ringwald 
563deb3ec6SMatthias Ringwald /* HF Supported Features:
573deb3ec6SMatthias Ringwald 0: EC and/or NR function
583deb3ec6SMatthias Ringwald 1: Three-way calling
593deb3ec6SMatthias Ringwald 2: CLI presentation capability
603deb3ec6SMatthias Ringwald 3: Voice recognition activation
613deb3ec6SMatthias Ringwald 4: Remote volume control
623deb3ec6SMatthias Ringwald 5: Enhanced call status
633deb3ec6SMatthias Ringwald 6: Enhanced call control
643deb3ec6SMatthias Ringwald 7: Codec negotiation
653deb3ec6SMatthias Ringwald 8: HF Indicators
663deb3ec6SMatthias Ringwald 9: eSCO S4 (and T2) Settings Supported
673deb3ec6SMatthias Ringwald 10-31: Reserved for future definition
683deb3ec6SMatthias Ringwald */
693deb3ec6SMatthias Ringwald #define HFP_HFSF_EC_NR_FUNCTION                          0
70aa4dd815SMatthias Ringwald #define HFP_HFSF_THREE_WAY_CALLING                       1
714f84bf36SMatthias Ringwald #define HFP_HFSF_CLI_PRESENTATION_CAPABILITY             2
72aa4dd815SMatthias Ringwald #define HFP_HFSF_VOICE_RECOGNITION_FUNCTION              3
734f84bf36SMatthias Ringwald #define HFP_HFSF_REMOTE_VOLUME_CONTROL                   4
744f84bf36SMatthias Ringwald #define HFP_HFSF_ENHANCED_CALL_STATUS                    5
754f84bf36SMatthias Ringwald #define HFP_HFSF_ENHANCED_CALL_CONTROL                   6
763deb3ec6SMatthias Ringwald #define HFP_HFSF_CODEC_NEGOTIATION                       7
773deb3ec6SMatthias Ringwald #define HFP_HFSF_HF_INDICATORS                           8
78ce263fc8SMatthias Ringwald #define HFP_HFSF_ESCO_S4                                 9
79ef3ae4ebSMilanka Ringwald #define HFP_HFSF_ENHANCED_VOICE_RECOGNITION_STATUS      10
80ef3ae4ebSMilanka Ringwald #define HFP_HFSF_VOICE_RECOGNITION_TEXT                 11
813deb3ec6SMatthias Ringwald 
823deb3ec6SMatthias Ringwald /* AG Supported Features:
833deb3ec6SMatthias Ringwald 0: Three-way calling
843deb3ec6SMatthias Ringwald 1: EC and/or NR function
853deb3ec6SMatthias Ringwald 2: Voice recognition function
863deb3ec6SMatthias Ringwald 3: In-band ring tone capability
873deb3ec6SMatthias Ringwald 4: Attach a number to a voice tag
883deb3ec6SMatthias Ringwald 5: Ability to reject a call
893deb3ec6SMatthias Ringwald 6: Enhanced call status
903deb3ec6SMatthias Ringwald 7: Enhanced call control
913deb3ec6SMatthias Ringwald 8: Extended Error Result Codes
923deb3ec6SMatthias Ringwald 9: Codec negotiation
933deb3ec6SMatthias Ringwald 10: HF Indicators
943deb3ec6SMatthias Ringwald 11: eSCO S4 (and T2) Settings Supported
953deb3ec6SMatthias Ringwald 12-31: Reserved for future definition
963deb3ec6SMatthias Ringwald */
973deb3ec6SMatthias Ringwald #define HFP_AGSF_THREE_WAY_CALLING                       0
983deb3ec6SMatthias Ringwald #define HFP_AGSF_EC_NR_FUNCTION                          1
99aa4dd815SMatthias Ringwald #define HFP_AGSF_VOICE_RECOGNITION_FUNCTION              2
100aa4dd815SMatthias Ringwald #define HFP_AGSF_IN_BAND_RING_TONE                       3
1014f84bf36SMatthias Ringwald #define HFP_AGSF_ATTACH_A_NUMBER_TO_A_VOICE_TAG          4
1024f84bf36SMatthias Ringwald #define HFP_AGSF_ABILITY_TO_REJECT_A_CALL                5
1034f84bf36SMatthias Ringwald #define HFP_AGSF_ENHANCED_CALL_STATUS                    6
1044f84bf36SMatthias Ringwald #define HFP_AGSF_ENHANCED_CALL_CONTROL                   7
1054f84bf36SMatthias Ringwald #define HFP_AGSF_EXTENDED_ERROR_RESULT_CODES             8
1063deb3ec6SMatthias Ringwald #define HFP_AGSF_CODEC_NEGOTIATION                       9
1073deb3ec6SMatthias Ringwald #define HFP_AGSF_HF_INDICATORS                          10
108ce263fc8SMatthias Ringwald #define HFP_AGSF_ESCO_S4                                11
109ef3ae4ebSMilanka Ringwald #define HFP_AGSF_ENHANCED_VOICE_RECOGNITION_STATUS      12
110ef3ae4ebSMilanka Ringwald #define HFP_AGSF_VOICE_RECOGNITION_TEXT                 13
1113deb3ec6SMatthias Ringwald 
1123deb3ec6SMatthias Ringwald #define HFP_DEFAULT_HF_SUPPORTED_FEATURES 0x0000
1133deb3ec6SMatthias Ringwald #define HFP_DEFAULT_AG_SUPPORTED_FEATURES 0x0009
1143deb3ec6SMatthias Ringwald 
11525789943SMilanka Ringwald #define HFP_MAX_NUM_INDICATORS                  10
11625789943SMilanka Ringwald #define HFP_MAX_NUM_CALL_SERVICES               20
11725789943SMilanka Ringwald #define HFP_CALL_SERVICE_SIZE                    3
11825789943SMilanka Ringwald #define HFP_MAX_NUM_CODECS                      10
119fc8835faSMilanka Ringwald #define HFP_BNEP_NUM_MAX_SIZE                   25
1203deb3ec6SMatthias Ringwald #define HFP_MAX_INDICATOR_DESC_SIZE             20
121db3cdbd4SMilanka Ringwald #define HFP_MAX_VR_TEXT_SIZE                   100
122a2e701c0SMilanka Ringwald #define HFP_VR_TEXT_HEADER_SIZE                 27      // bytes needed for sending +BVRA message including quotes but excluding string length:
123a2e701c0SMilanka Ringwald                                                         // \r\n+BVRA: <vrect>,<vrecstate>,<textID>,<textType>,<textOperation>,"<string>"\r\n
124a2e701c0SMilanka Ringwald 
12589425bfcSMilanka Ringwald #define HFP_MAX_NETWORK_OPERATOR_NAME_SIZE 17
12625789943SMilanka Ringwald 
127347d46c8SMilanka Ringwald #define HFP_HF_INDICATOR_UUID_ENHANCED_SAFETY   0x0001  // 0 - disabled, 1 - enabled
128347d46c8SMilanka Ringwald #define HFP_HF_INDICATOR_UUID_BATTERY_LEVEL     0X0002  // 0-100 remaining level of battery
1293deb3ec6SMatthias Ringwald 
1303deb3ec6SMatthias Ringwald #define HFP_SUPPORTED_FEATURES "+BRSF"
1313deb3ec6SMatthias Ringwald #define HFP_AVAILABLE_CODECS "+BAC"
1323deb3ec6SMatthias Ringwald #define HFP_INDICATOR "+CIND"
1333deb3ec6SMatthias Ringwald #define HFP_ENABLE_STATUS_UPDATE_FOR_AG_INDICATORS "+CMER"
134aa4dd815SMatthias Ringwald #define HFP_ENABLE_CLIP "+CLIP"
135aa4dd815SMatthias Ringwald #define HFP_ENABLE_CALL_WAITING_NOTIFICATION "+CCWA"
1363deb3ec6SMatthias Ringwald #define HFP_UPDATE_ENABLE_STATUS_FOR_INDIVIDUAL_AG_INDICATORS "+BIA" // +BIA:<enabled>,,<enabled>,,,<enabled>
1373deb3ec6SMatthias Ringwald #define HFP_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES "+CHLD"
1383deb3ec6SMatthias Ringwald #define HFP_GENERIC_STATUS_INDICATOR "+BIND"
1393deb3ec6SMatthias Ringwald #define HFP_TRANSFER_AG_INDICATOR_STATUS "+CIEV" // +CIEV: <index>,<value>
140ce263fc8SMatthias Ringwald #define HFP_TRANSFER_HF_INDICATOR_STATUS "+BIEV" // +BIEC: <index>,<value>
1413deb3ec6SMatthias Ringwald #define HFP_QUERY_OPERATOR_SELECTION "+COPS"     // +COPS: <mode>,0,<opearator>
1423deb3ec6SMatthias Ringwald #define HFP_ENABLE_EXTENDED_AUDIO_GATEWAY_ERROR "+CMEE"
1433deb3ec6SMatthias Ringwald #define HFP_EXTENDED_AUDIO_GATEWAY_ERROR "+CME ERROR"
1443deb3ec6SMatthias Ringwald #define HFP_TRIGGER_CODEC_CONNECTION_SETUP "+BCC"
1453deb3ec6SMatthias Ringwald #define HFP_CONFIRM_COMMON_CODEC "+BCS"
14697d2cadbSMatthias Ringwald #define HFP_ANSWER_CALL "ATA"
147aa4dd815SMatthias Ringwald #define HFP_HANG_UP_CALL "+CHUP"
148aa4dd815SMatthias Ringwald #define HFP_CHANGE_IN_BAND_RING_TONE_SETTING "+BSIR"
149aa4dd815SMatthias Ringwald #define HFP_CALL_PHONE_NUMBER "ATD"
150ce263fc8SMatthias Ringwald #define HFP_REDIAL_LAST_NUMBER "+BLDN"
151aa4dd815SMatthias Ringwald #define HFP_TURN_OFF_EC_AND_NR "+NREC" // EC (Echo CAnceling), NR (Noise Reduction)
152ef3ae4ebSMilanka Ringwald #define HFP_ACTIVATE_VOICE_RECOGNITION "+BVRA" // Voice Recognition
153aa4dd815SMatthias Ringwald #define HFP_SET_MICROPHONE_GAIN  "+VGM"
154aa4dd815SMatthias Ringwald #define HFP_SET_SPEAKER_GAIN     "+VGS"
155aa4dd815SMatthias Ringwald #define HFP_PHONE_NUMBER_FOR_VOICE_TAG "+BINP"
156aa4dd815SMatthias Ringwald #define HFP_TRANSMIT_DTMF_CODES  "+VTS"
157ce263fc8SMatthias Ringwald #define HFP_SUBSCRIBER_NUMBER_INFORMATION "+CNUM"
158ce263fc8SMatthias Ringwald #define HFP_LIST_CURRENT_CALLS "+CLCC"
159ce263fc8SMatthias Ringwald #define HFP_RESPONSE_AND_HOLD "+BTRH"
1603deb3ec6SMatthias Ringwald 
1613deb3ec6SMatthias Ringwald #define HFP_OK "OK"
1623deb3ec6SMatthias Ringwald #define HFP_ERROR "ERROR"
163ce263fc8SMatthias Ringwald #define HFP_RING "RING"
1643deb3ec6SMatthias Ringwald 
1653deb3ec6SMatthias Ringwald // Codecs
1663deb3ec6SMatthias Ringwald #define HFP_CODEC_CVSD    0x01
1673deb3ec6SMatthias Ringwald #define HFP_CODEC_MSBC    0x02
168fda8f1b4SMatthias Ringwald #define HFP_CODEC_LC3_SWB 0x03
1693deb3ec6SMatthias Ringwald 
1703deb3ec6SMatthias Ringwald typedef enum {
171520c92d5SMatthias Ringwald     HFP_ROLE_INVALID = 0,
172520c92d5SMatthias Ringwald     HFP_ROLE_AG,
173323d3000SMatthias Ringwald     HFP_ROLE_HF,
174323d3000SMatthias Ringwald } hfp_role_t;
175323d3000SMatthias Ringwald 
176323d3000SMatthias Ringwald typedef enum {
1773deb3ec6SMatthias Ringwald     HFP_CMD_NONE = 0,
1783deb3ec6SMatthias Ringwald     HFP_CMD_ERROR,
179aa4dd815SMatthias Ringwald     HFP_CMD_UNKNOWN,
1803deb3ec6SMatthias Ringwald     HFP_CMD_OK,
181ce263fc8SMatthias Ringwald     HFP_CMD_RING,
182245852b7SMilanka Ringwald     HFP_CMD_SUPPORTED_FEATURES,                             // 5
1833deb3ec6SMatthias Ringwald     HFP_CMD_AVAILABLE_CODECS,
18484a0c24eSMatthias Ringwald     HFP_CMD_RETRIEVE_AG_INDICATORS_GENERIC,
185aa4dd815SMatthias Ringwald     HFP_CMD_RETRIEVE_AG_INDICATORS,
186aa4dd815SMatthias Ringwald     HFP_CMD_RETRIEVE_AG_INDICATORS_STATUS,
187245852b7SMilanka Ringwald     HFP_CMD_ENABLE_INDICATOR_STATUS_UPDATE,                 // 10
1883deb3ec6SMatthias Ringwald     HFP_CMD_ENABLE_INDIVIDUAL_AG_INDICATOR_STATUS_UPDATE,
1893deb3ec6SMatthias Ringwald     HFP_CMD_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES,
190aa4dd815SMatthias Ringwald     HFP_CMD_ENABLE_CLIP,
191a0ffb263SMatthias Ringwald     HFP_CMD_AG_SENT_CLIP_INFORMATION,
192245852b7SMilanka Ringwald     HFP_CMD_ENABLE_CALL_WAITING_NOTIFICATION,               // 15
193a0ffb263SMatthias Ringwald     HFP_CMD_AG_SENT_CALL_WAITING_NOTIFICATION_UPDATE,
194aa4dd815SMatthias Ringwald     HFP_CMD_LIST_GENERIC_STATUS_INDICATORS,
195aa4dd815SMatthias Ringwald     HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS,
196aa4dd815SMatthias Ringwald     HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS_STATE,
197245852b7SMilanka Ringwald     HFP_CMD_SET_GENERIC_STATUS_INDICATOR_STATUS,            // 20
1983deb3ec6SMatthias Ringwald     HFP_CMD_TRANSFER_AG_INDICATOR_STATUS,
199aa4dd815SMatthias Ringwald     HFP_CMD_QUERY_OPERATOR_SELECTION_NAME,
200aa4dd815SMatthias Ringwald     HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT,
2013deb3ec6SMatthias Ringwald     HFP_CMD_ENABLE_EXTENDED_AUDIO_GATEWAY_ERROR,
202245852b7SMilanka Ringwald     HFP_CMD_EXTENDED_AUDIO_GATEWAY_ERROR,                   // 25
2033deb3ec6SMatthias Ringwald     HFP_CMD_TRIGGER_CODEC_CONNECTION_SETUP,
204aa4dd815SMatthias Ringwald     HFP_CMD_AG_SEND_COMMON_CODEC,
2053deb3ec6SMatthias Ringwald     HFP_CMD_AG_SUGGESTED_CODEC,
206aa4dd815SMatthias Ringwald     HFP_CMD_HF_CONFIRMED_CODEC,
207498a8121SMilanka Ringwald     HFP_CMD_CALL_ANSWERED,                                  // 30
208aa4dd815SMatthias Ringwald     HFP_CMD_CALL_HOLD,
209aa4dd815SMatthias Ringwald     HFP_CMD_HANG_UP_CALL,
210aa4dd815SMatthias Ringwald     HFP_CMD_CHANGE_IN_BAND_RING_TONE_SETTING,
211aa4dd815SMatthias Ringwald     HFP_CMD_CALL_PHONE_NUMBER,
212498a8121SMilanka Ringwald     HFP_CMD_REDIAL_LAST_NUMBER,                             // 35
213aa4dd815SMatthias Ringwald     HFP_CMD_TURN_OFF_EC_AND_NR,
214498a8121SMilanka Ringwald     HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION,                  // 37
215aa4dd815SMatthias Ringwald     HFP_CMD_HF_ACTIVATE_VOICE_RECOGNITION,
216aa4dd815SMatthias Ringwald     HFP_CMD_HF_REQUEST_PHONE_NUMBER,
217ce263fc8SMatthias Ringwald     HFP_CMD_AG_SENT_PHONE_NUMBER,
218aa4dd815SMatthias Ringwald     HFP_CMD_TRANSMIT_DTMF_CODES,
219aa4dd815SMatthias Ringwald     HFP_CMD_SET_MICROPHONE_GAIN,
220ce263fc8SMatthias Ringwald     HFP_CMD_SET_SPEAKER_GAIN,
221ce263fc8SMatthias Ringwald     HFP_CMD_GET_SUBSCRIBER_NUMBER_INFORMATION,
222ce263fc8SMatthias Ringwald     HFP_CMD_LIST_CURRENT_CALLS,
223ce263fc8SMatthias Ringwald     HFP_CMD_RESPONSE_AND_HOLD_QUERY,
224ce263fc8SMatthias Ringwald     HFP_CMD_RESPONSE_AND_HOLD_COMMAND,
225667ec068SMatthias Ringwald     HFP_CMD_RESPONSE_AND_HOLD_STATUS,
22651a2ebdeSMatthias Ringwald     HFP_CMD_HF_INDICATOR_STATUS,
22751a2ebdeSMatthias Ringwald     HFP_CMD_CUSTOM_MESSAGE
2283deb3ec6SMatthias Ringwald } hfp_command_t;
2293deb3ec6SMatthias Ringwald 
230aa4dd815SMatthias Ringwald 
2313deb3ec6SMatthias Ringwald typedef enum {
2323deb3ec6SMatthias Ringwald     HFP_CME_ERROR_AG_FAILURE = 0,
2333deb3ec6SMatthias Ringwald     HFP_CME_ERROR_NO_CONNECTION_TO_PHONE,
2343deb3ec6SMatthias Ringwald     HFP_CME_ERROR_2,
2353deb3ec6SMatthias Ringwald     HFP_CME_ERROR_OPERATION_NOT_ALLOWED,
2363deb3ec6SMatthias Ringwald     HFP_CME_ERROR_OPERATION_NOT_SUPPORTED,
2373deb3ec6SMatthias Ringwald     HFP_CME_ERROR_PH_SIM_PIN_REQUIRED,
2383deb3ec6SMatthias Ringwald     HFP_CME_ERROR_6,
2393deb3ec6SMatthias Ringwald     HFP_CME_ERROR_7,
2403deb3ec6SMatthias Ringwald     HFP_CME_ERROR_8,
2413deb3ec6SMatthias Ringwald     HFP_CME_ERROR_9,
2423deb3ec6SMatthias Ringwald     HFP_CME_ERROR_SIM_NOT_INSERTED,
2433deb3ec6SMatthias Ringwald     HFP_CME_ERROR_SIM_PIN_REQUIRED,
2443deb3ec6SMatthias Ringwald     HFP_CME_ERROR_SIM_PUK_REQUIRED,
2453deb3ec6SMatthias Ringwald     HFP_CME_ERROR_SIM_FAILURE,
2463deb3ec6SMatthias Ringwald     HFP_CME_ERROR_SIM_BUSY,
2473deb3ec6SMatthias Ringwald     HFP_CME_ERROR_15,
2483deb3ec6SMatthias Ringwald     HFP_CME_ERROR_INCORRECT_PASSWORD,
2493deb3ec6SMatthias Ringwald     HFP_CME_ERROR_SIM_PIN2_REQUIRED,
2503deb3ec6SMatthias Ringwald     HFP_CME_ERROR_SIM_PUK2_REQUIRED,
2513deb3ec6SMatthias Ringwald     HFP_CME_ERROR_19,
2523deb3ec6SMatthias Ringwald     HFP_CME_ERROR_MEMORY_FULL,
2533deb3ec6SMatthias Ringwald     HFP_CME_ERROR_INVALID_INDEX,
2543deb3ec6SMatthias Ringwald     HFP_CME_ERROR_22,
2553deb3ec6SMatthias Ringwald     HFP_CME_ERROR_MEMORY_FAILURE,
2563deb3ec6SMatthias Ringwald     HFP_CME_ERROR_TEXT_STRING_TOO_LONG,
2573deb3ec6SMatthias Ringwald     HFP_CME_ERROR_INVALID_CHARACTERS_IN_TEXT_STRING,
2583deb3ec6SMatthias Ringwald     HFP_CME_ERROR_DIAL_STRING_TOO_LONG,
2593deb3ec6SMatthias Ringwald     HFP_CME_ERROR_INVALID_CHARACTERS_IN_DIAL_STRING,
2603deb3ec6SMatthias Ringwald     HFP_CME_ERROR_28,
2613deb3ec6SMatthias Ringwald     HFP_CME_ERROR_29,
2623deb3ec6SMatthias Ringwald     HFP_CME_ERROR_NO_NETWORK_SERVICE,
2633deb3ec6SMatthias Ringwald     HFP_CME_ERROR_NETWORK_TIMEOUT,
2643deb3ec6SMatthias Ringwald     HFP_CME_ERROR_NETWORK_NOT_ALLOWED_EMERGENCY_CALLS_ONLY
2653deb3ec6SMatthias Ringwald } hfp_cme_error_t;
2663deb3ec6SMatthias Ringwald 
2673deb3ec6SMatthias Ringwald typedef enum {
2683deb3ec6SMatthias Ringwald     HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS = 0,
2693deb3ec6SMatthias Ringwald     HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT
2703deb3ec6SMatthias Ringwald } hfp_call_status_t;
2713deb3ec6SMatthias Ringwald 
2723deb3ec6SMatthias Ringwald typedef enum {
2733deb3ec6SMatthias Ringwald     HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS = 0,
2743deb3ec6SMatthias Ringwald     HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS,
2753deb3ec6SMatthias Ringwald     HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_DIALING_STATE,
2763deb3ec6SMatthias Ringwald     HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_ALERTING_STATE
2773deb3ec6SMatthias Ringwald } hfp_callsetup_status_t;
2783deb3ec6SMatthias Ringwald 
2793deb3ec6SMatthias Ringwald typedef enum {
280aa4dd815SMatthias Ringwald     HFP_CALLHELD_STATUS_NO_CALLS_HELD = 0,
281aa4dd815SMatthias Ringwald     HFP_CALLHELD_STATUS_CALL_ON_HOLD_OR_SWAPPED,
282aa4dd815SMatthias Ringwald     HFP_CALLHELD_STATUS_CALL_ON_HOLD_AND_NO_ACTIVE_CALLS
2833deb3ec6SMatthias Ringwald } hfp_callheld_status_t;
2843deb3ec6SMatthias Ringwald 
285d210d9c4SMatthias Ringwald 
2863deb3ec6SMatthias Ringwald typedef enum {
287aa4dd815SMatthias Ringwald     HFP_AG_INCOMING_CALL,
288aa4dd815SMatthias Ringwald     HFP_AG_INCOMING_CALL_ACCEPTED_BY_AG,
289aa4dd815SMatthias Ringwald     HFP_AG_INCOMING_CALL_ACCEPTED_BY_HF,
290aa4dd815SMatthias Ringwald     HFP_AG_AUDIO_CONNECTION_ESTABLISHED,
291fe899794SMatthias Ringwald     HFP_AG_OUTGOING_CALL_INITIATED_BY_AG,
2929ff73f41SMatthias Ringwald     HFP_AG_OUTGOING_CALL_INITIATED_BY_HF,
293aa4dd815SMatthias Ringwald     HFP_AG_OUTGOING_CALL_REJECTED,
294aa4dd815SMatthias Ringwald     HFP_AG_OUTGOING_CALL_ACCEPTED,
295aa4dd815SMatthias Ringwald     HFP_AG_OUTGOING_CALL_RINGING,
296aa4dd815SMatthias Ringwald     HFP_AG_OUTGOING_CALL_ESTABLISHED,
297aa4dd815SMatthias Ringwald     HFP_AG_OUTGOING_REDIAL_INITIATED,
298ce263fc8SMatthias Ringwald     HFP_AG_HELD_CALL_JOINED_BY_AG,
299aa4dd815SMatthias Ringwald     HFP_AG_TERMINATE_CALL_BY_AG,
300aa4dd815SMatthias Ringwald     HFP_AG_TERMINATE_CALL_BY_HF,
301aa4dd815SMatthias Ringwald     HFP_AG_CALL_DROPPED,
302ce263fc8SMatthias Ringwald     HFP_AG_RESPONSE_AND_HOLD_ACCEPT_INCOMING_CALL_BY_AG,
303ce263fc8SMatthias Ringwald     HFP_AG_RESPONSE_AND_HOLD_ACCEPT_HELD_CALL_BY_AG,
304ce263fc8SMatthias Ringwald     HFP_AG_RESPONSE_AND_HOLD_REJECT_HELD_CALL_BY_AG,
305ce263fc8SMatthias Ringwald     HFP_AG_RESPONSE_AND_HOLD_ACCEPT_INCOMING_CALL_BY_HF,
306ce263fc8SMatthias Ringwald     HFP_AG_RESPONSE_AND_HOLD_ACCEPT_HELD_CALL_BY_HF,
307d210d9c4SMatthias Ringwald     HFP_AG_RESPONSE_AND_HOLD_REJECT_HELD_CALL_BY_HF,
308d210d9c4SMatthias Ringwald     HFP_AG_CALL_HOLD_USER_BUSY,
309d210d9c4SMatthias Ringwald     HFP_AG_CALL_HOLD_RELEASE_ACTIVE_ACCEPT_HELD_OR_WAITING_CALL,
310d210d9c4SMatthias Ringwald     HFP_AG_CALL_HOLD_PARK_ACTIVE_ACCEPT_HELD_OR_WAITING_CALL,
311d210d9c4SMatthias Ringwald     HFP_AG_CALL_HOLD_ADD_HELD_CALL,
312d0c20769SMatthias Ringwald     HFP_AG_CALL_HOLD_EXIT_AND_JOIN_CALLS,
313d0c20769SMatthias Ringwald     HFP_AG_SET_CLIP
314aa4dd815SMatthias Ringwald } hfp_ag_call_event_t;
315aa4dd815SMatthias Ringwald 
316aa4dd815SMatthias Ringwald 
317aa4dd815SMatthias Ringwald typedef enum {
3183deb3ec6SMatthias Ringwald     HFP_PARSER_CMD_HEADER = 0,
3193deb3ec6SMatthias Ringwald     HFP_PARSER_CMD_SEQUENCE,
3203deb3ec6SMatthias Ringwald     HFP_PARSER_SECOND_ITEM,
321471dea41SMatthias Ringwald     HFP_PARSER_THIRD_ITEM,
322471dea41SMatthias Ringwald     HFP_PARSER_CUSTOM_COMMAND
3233deb3ec6SMatthias Ringwald } hfp_parser_state_t;
3243deb3ec6SMatthias Ringwald 
3259cc9ffe4SMilanka Ringwald typedef enum {
32645796ff1SMilanka Ringwald     HFP_VOICE_RECOGNITION_STATE_AG_READY = 0,
32745796ff1SMilanka Ringwald     HFP_VOICE_RECOGNITION_STATE_AG_READY_TO_ACCEPT_AUDIO_INPUT = 1,
328cf75be85SMilanka Ringwald     HFP_VOICE_RECOGNITION_STATE_AG_IS_STARTING_SOUND = 2,
3299cc9ffe4SMilanka Ringwald     HFP_VOICE_RECOGNITION_STATE_AG_IS_PROCESSING_AUDIO_INPUT = 4
3309cc9ffe4SMilanka Ringwald } hfp_voice_recognition_state_t;
3319cc9ffe4SMilanka Ringwald 
3329cc9ffe4SMilanka Ringwald typedef enum {
3339cc9ffe4SMilanka Ringwald     HFP_TEXT_TYPE_RECOGNISED_FROM_HF_AUDIO = 0,
3349cc9ffe4SMilanka Ringwald     HFP_TEXT_TYPE_MESSAGE_FROM_AG,
3359cc9ffe4SMilanka Ringwald     HFP_TEXT_TYPE_QUESTION_FROM_AG,
3369cc9ffe4SMilanka Ringwald     HFP_TEXT_TYPE_ERROR_FROM_AG
3379cc9ffe4SMilanka Ringwald } hfp_text_type_t;
3389cc9ffe4SMilanka Ringwald 
3399cc9ffe4SMilanka Ringwald typedef enum {
340db3cdbd4SMilanka Ringwald     HFP_TEXT_OPERATION_NEW_TEXT = 1,
341db3cdbd4SMilanka Ringwald     HFP_TEXT_OPERATION_REPLACE,
342db3cdbd4SMilanka Ringwald     HFP_TEXT_OPERATION_APPEND
343db3cdbd4SMilanka Ringwald } hfp_text_operation_t;
3443deb3ec6SMatthias Ringwald 
3453deb3ec6SMatthias Ringwald typedef enum {
3463deb3ec6SMatthias Ringwald     HFP_IDLE = 0, //0
3473deb3ec6SMatthias Ringwald     HFP_SDP_QUERY_RFCOMM_CHANNEL,
3481d9c9c90SMilanka Ringwald     HFP_W2_SEND_SDP_QUERY,
349a0ffb263SMatthias Ringwald     HFP_W4_SDP_QUERY_COMPLETE,
3503deb3ec6SMatthias Ringwald     HFP_W4_RFCOMM_CONNECTED,
3513deb3ec6SMatthias Ringwald 
3521d9c9c90SMilanka Ringwald     HFP_EXCHANGE_SUPPORTED_FEATURES,   // 5
3531d9c9c90SMilanka Ringwald     HFP_W4_EXCHANGE_SUPPORTED_FEATURES,
3543deb3ec6SMatthias Ringwald 
3553deb3ec6SMatthias Ringwald     HFP_NOTIFY_ON_CODECS,
3563deb3ec6SMatthias Ringwald     HFP_W4_NOTIFY_ON_CODECS,
3573deb3ec6SMatthias Ringwald 
3583deb3ec6SMatthias Ringwald     HFP_RETRIEVE_INDICATORS,
3591d9c9c90SMilanka Ringwald     HFP_W4_RETRIEVE_INDICATORS,        // 10
3603deb3ec6SMatthias Ringwald 
3611d9c9c90SMilanka Ringwald     HFP_RETRIEVE_INDICATORS_STATUS,
3623deb3ec6SMatthias Ringwald     HFP_W4_RETRIEVE_INDICATORS_STATUS,
3633deb3ec6SMatthias Ringwald 
3643deb3ec6SMatthias Ringwald     HFP_ENABLE_INDICATORS_STATUS_UPDATE,
3653deb3ec6SMatthias Ringwald     HFP_W4_ENABLE_INDICATORS_STATUS_UPDATE,
3663deb3ec6SMatthias Ringwald 
3671d9c9c90SMilanka Ringwald     HFP_RETRIEVE_CAN_HOLD_CALL,        // 15
3681d9c9c90SMilanka Ringwald     HFP_W4_RETRIEVE_CAN_HOLD_CALL,
3693deb3ec6SMatthias Ringwald 
3703deb3ec6SMatthias Ringwald     HFP_LIST_GENERIC_STATUS_INDICATORS,
3713deb3ec6SMatthias Ringwald     HFP_W4_LIST_GENERIC_STATUS_INDICATORS,
3723deb3ec6SMatthias Ringwald 
3733deb3ec6SMatthias Ringwald     HFP_RETRIEVE_GENERIC_STATUS_INDICATORS,
3741d9c9c90SMilanka Ringwald     HFP_W4_RETRIEVE_GENERIC_STATUS_INDICATORS,  //20
3753deb3ec6SMatthias Ringwald 
3761d9c9c90SMilanka Ringwald     HFP_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS,
3773deb3ec6SMatthias Ringwald     HFP_W4_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS,
3783deb3ec6SMatthias Ringwald 
379498a8121SMilanka Ringwald     HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED,  //23
3803deb3ec6SMatthias Ringwald 
381aa4dd815SMatthias Ringwald     HFP_W2_CONNECT_SCO,
382aa4dd815SMatthias Ringwald     HFP_W4_SCO_CONNECTED,
3833deb3ec6SMatthias Ringwald 
3843deb3ec6SMatthias Ringwald     HFP_AUDIO_CONNECTION_ESTABLISHED,
3853deb3ec6SMatthias Ringwald 
386be55a11dSMilanka Ringwald 
3873deb3ec6SMatthias Ringwald     HFP_W2_DISCONNECT_SCO,
388aa4dd815SMatthias Ringwald     HFP_W4_SCO_DISCONNECTED,
38948e6eeeeSMatthias Ringwald     HFP_W4_SCO_DISCONNECTED_TO_SHUTDOWN,
39048e6eeeeSMatthias Ringwald     HFP_W4_WBS_SHUTDOWN,
3913deb3ec6SMatthias Ringwald 
3923deb3ec6SMatthias Ringwald     HFP_W2_DISCONNECT_RFCOMM,
3933deb3ec6SMatthias Ringwald     HFP_W4_RFCOMM_DISCONNECTED,
3943deb3ec6SMatthias Ringwald     HFP_W4_RFCOMM_DISCONNECTED_AND_RESTART,
3953deb3ec6SMatthias Ringwald     HFP_W4_CONNECTION_ESTABLISHED_TO_SHUTDOWN
3963deb3ec6SMatthias Ringwald } hfp_state_t;
3973deb3ec6SMatthias Ringwald 
398be55a11dSMilanka Ringwald 
399be55a11dSMilanka Ringwald typedef enum {
400fdda66c0SMilanka Ringwald     // shared between normal voice recognition and enhanced one
401be55a11dSMilanka Ringwald     HFP_VRA_VOICE_RECOGNITION_OFF,
402be55a11dSMilanka Ringwald 
403fd4151d1SMilanka Ringwald     HFP_VRA_W2_SEND_VOICE_RECOGNITION_OFF,
404be55a11dSMilanka Ringwald     HFP_VRA_W4_VOICE_RECOGNITION_OFF,
405fd4151d1SMilanka Ringwald 
406fd4151d1SMilanka Ringwald     HFP_VRA_W2_SEND_VOICE_RECOGNITION_ACTIVATED,
407be55a11dSMilanka Ringwald     HFP_VRA_W4_VOICE_RECOGNITION_ACTIVATED,
408be55a11dSMilanka Ringwald     HFP_VRA_VOICE_RECOGNITION_ACTIVATED,
409be55a11dSMilanka Ringwald 
410adb00feeSMilanka Ringwald     HFP_VRA_W2_SEND_ENHANCED_VOICE_RECOGNITION_READY_FOR_AUDIO,
411adb00feeSMilanka Ringwald     HFP_VRA_W4_ENHANCED_VOICE_RECOGNITION_READY_FOR_AUDIO,
412adb00feeSMilanka Ringwald     HFP_VRA_ENHANCED_VOICE_RECOGNITION_READY_FOR_AUDIO,
413fdda66c0SMilanka Ringwald 
414cf75be85SMilanka Ringwald     HFP_VRA_W2_SEND_ENHANCED_VOICE_RECOGNITION_STATUS,
415b95cac54SMilanka Ringwald     HFP_VRA_W2_SEND_ENHANCED_VOICE_RECOGNITION_MSG
416db3cdbd4SMilanka Ringwald } hfp_voice_recognition_activation_status_t;
417be55a11dSMilanka Ringwald 
41845796ff1SMilanka Ringwald typedef struct {
41945796ff1SMilanka Ringwald     uint16_t text_id;
42045796ff1SMilanka Ringwald     hfp_text_type_t text_type;
42145796ff1SMilanka Ringwald     hfp_text_operation_t text_operation;
422b95cac54SMilanka Ringwald     const char * text;
42345796ff1SMilanka Ringwald } hfp_voice_recognition_message_t;
42445796ff1SMilanka Ringwald 
425aa4dd815SMatthias Ringwald typedef enum {
426aa4dd815SMatthias Ringwald     HFP_CODECS_IDLE,
427aa4dd815SMatthias Ringwald     HFP_CODECS_RECEIVED_LIST,
428aa4dd815SMatthias Ringwald     HFP_CODECS_RECEIVED_TRIGGER_CODEC_EXCHANGE,
429aa4dd815SMatthias Ringwald     HFP_CODECS_W4_AG_COMMON_CODEC,
430aa4dd815SMatthias Ringwald     HFP_CODECS_AG_SENT_COMMON_CODEC,
431aa4dd815SMatthias Ringwald     HFP_CODECS_AG_RESEND_COMMON_CODEC,
432ce263fc8SMatthias Ringwald     HFP_CODECS_HF_CONFIRMED_CODEC,
433aa4dd815SMatthias Ringwald     HFP_CODECS_EXCHANGED,
434aa4dd815SMatthias Ringwald     HFP_CODECS_ERROR
435aa4dd815SMatthias Ringwald } hfp_codecs_state_t;
436aa4dd815SMatthias Ringwald 
437aa4dd815SMatthias Ringwald typedef enum {
438aa4dd815SMatthias Ringwald     HFP_CALL_IDLE,
439aa4dd815SMatthias Ringwald     HFP_CALL_TRIGGER_AUDIO_CONNECTION,
440aa4dd815SMatthias Ringwald     HFP_CALL_W4_AUDIO_CONNECTION_FOR_IN_BAND_RING,
4419493406bSMilanka Ringwald     HFP_CALL_INCOMING_RINGING,
442aa4dd815SMatthias Ringwald     HFP_CALL_W4_AUDIO_CONNECTION_FOR_ACTIVE,
443aa4dd815SMatthias Ringwald     HFP_CALL_ACTIVE,
444aa4dd815SMatthias Ringwald     HFP_CALL_W2_SEND_CALL_WAITING,
445aa4dd815SMatthias Ringwald     HFP_CALL_W4_CHLD,
446aa4dd815SMatthias Ringwald     HFP_CALL_OUTGOING_INITIATED,
447aa4dd815SMatthias Ringwald     HFP_CALL_OUTGOING_DIALING,
448aa4dd815SMatthias Ringwald     HFP_CALL_OUTGOING_RINGING
449aa4dd815SMatthias Ringwald } hfp_call_state_t;
450aa4dd815SMatthias Ringwald 
451aa4dd815SMatthias Ringwald typedef enum{
452ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_DIR_OUTGOING,
453ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_DIR_INCOMING
454ce263fc8SMatthias Ringwald } hfp_enhanced_call_dir_t;
455ce263fc8SMatthias Ringwald 
456ce263fc8SMatthias Ringwald typedef enum{
457ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_STATUS_ACTIVE,
458ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_STATUS_HELD,
459ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_STATUS_OUTGOING_DIALING,
460ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_STATUS_OUTGOING_ALERTING,
461ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_STATUS_INCOMING,
462ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_STATUS_INCOMING_WAITING,
463ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_STATUS_CALL_HELD_BY_RESPONSE_AND_HOLD
464ce263fc8SMatthias Ringwald } hfp_enhanced_call_status_t;
465ce263fc8SMatthias Ringwald 
466ce263fc8SMatthias Ringwald typedef enum{
467ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_MODE_VOICE,
468ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_MODE_DATA,
469ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_MODE_FAX
470ce263fc8SMatthias Ringwald } hfp_enhanced_call_mode_t;
471ce263fc8SMatthias Ringwald 
472ce263fc8SMatthias Ringwald typedef enum{
473ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_MPTY_NOT_A_CONFERENCE_CALL,
474ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL
475ce263fc8SMatthias Ringwald } hfp_enhanced_call_mpty_t;
476ce263fc8SMatthias Ringwald 
477ce263fc8SMatthias Ringwald typedef enum {
478ce263fc8SMatthias Ringwald     HFP_RESPONSE_AND_HOLD_INCOMING_ON_HOLD = 0,
479ce263fc8SMatthias Ringwald     HFP_RESPONSE_AND_HOLD_HELD_INCOMING_ACCEPTED,
480ce263fc8SMatthias Ringwald     HFP_RESPONSE_AND_HOLD_HELD_INCOMING_REJECTED
481ce263fc8SMatthias Ringwald } hfp_response_and_hold_state_t;
482ce263fc8SMatthias Ringwald 
483ce263fc8SMatthias Ringwald typedef enum {
484ce263fc8SMatthias Ringwald     HFP_HF_QUERY_OPERATOR_FORMAT_NOT_SET = 0,
485ce263fc8SMatthias Ringwald     HFP_HF_QUERY_OPERATOR_SET_FORMAT,
486ce263fc8SMatthias Ringwald     HFP_HF_QUERY_OPERATOR_W4_SET_FORMAT_OK,
487ce263fc8SMatthias Ringwald     HFP_HF_QUERY_OPERATOR_FORMAT_SET,
488ce263fc8SMatthias Ringwald     HFP_HF_QUERY_OPERATOR_SEND_QUERY,
489ce263fc8SMatthias Ringwald     HPF_HF_QUERY_OPERATOR_W4_RESULT
490ce263fc8SMatthias Ringwald } hfp_hf_query_operator_state_t;
491ce263fc8SMatthias Ringwald 
492ce263fc8SMatthias Ringwald typedef enum {
493ce263fc8SMatthias Ringwald     HFP_LINK_SETTINGS_D0 = 0,
494ce263fc8SMatthias Ringwald     HFP_LINK_SETTINGS_D1,
495ce263fc8SMatthias Ringwald     HFP_LINK_SETTINGS_S1,
496ce263fc8SMatthias Ringwald     HFP_LINK_SETTINGS_S2,
497ce263fc8SMatthias Ringwald     HFP_LINK_SETTINGS_S3,
498ce263fc8SMatthias Ringwald     HFP_LINK_SETTINGS_S4,
499ce263fc8SMatthias Ringwald     HFP_LINK_SETTINGS_T1,
500b5c379c1SMatthias Ringwald     HFP_LINK_SETTINGS_T2,
501b5c379c1SMatthias Ringwald     HFP_LINK_SETTINGS_NONE,
502b5c379c1SMatthias Ringwald } hfp_link_settings_t;
503ce263fc8SMatthias Ringwald 
504ce263fc8SMatthias Ringwald typedef enum{
505aa4dd815SMatthias Ringwald     HFP_NONE_SM,
506aa4dd815SMatthias Ringwald     HFP_SLC_SM,
507aa4dd815SMatthias Ringwald     HFP_SLC_QUERIES_SM,
508aa4dd815SMatthias Ringwald     HFP_CODECS_CONNECTION_SM,
509aa4dd815SMatthias Ringwald     HFP_AUDIO_CONNECTION_SM,
510aa4dd815SMatthias Ringwald     HFP_CALL_SM
511aa4dd815SMatthias Ringwald } hfp_state_machine_t;
512aa4dd815SMatthias Ringwald 
5133deb3ec6SMatthias Ringwald typedef struct{
5143deb3ec6SMatthias Ringwald     uint16_t uuid;
5153deb3ec6SMatthias Ringwald     uint8_t state; // enabled
5163deb3ec6SMatthias Ringwald } hfp_generic_status_indicator_t;
5173deb3ec6SMatthias Ringwald 
5183deb3ec6SMatthias Ringwald typedef struct{
5193deb3ec6SMatthias Ringwald     uint8_t index;
5203deb3ec6SMatthias Ringwald     char name[HFP_MAX_INDICATOR_DESC_SIZE];
5213deb3ec6SMatthias Ringwald     uint8_t min_range;
5223deb3ec6SMatthias Ringwald     uint8_t max_range;
5233deb3ec6SMatthias Ringwald     uint8_t status;
5243deb3ec6SMatthias Ringwald     uint8_t mandatory;
5253deb3ec6SMatthias Ringwald     uint8_t enabled;
5263deb3ec6SMatthias Ringwald     uint8_t status_changed;
5273deb3ec6SMatthias Ringwald } hfp_ag_indicator_t;
5283deb3ec6SMatthias Ringwald 
5293deb3ec6SMatthias Ringwald typedef struct{
53089425bfcSMilanka Ringwald     char name[HFP_CALL_SERVICE_SIZE];
5313deb3ec6SMatthias Ringwald } hfp_call_service_t;
5323deb3ec6SMatthias Ringwald 
5333deb3ec6SMatthias Ringwald 
5343deb3ec6SMatthias Ringwald typedef struct{
5353deb3ec6SMatthias Ringwald     uint8_t mode;
5363deb3ec6SMatthias Ringwald     uint8_t format;
53789425bfcSMilanka Ringwald     char name[HFP_MAX_NETWORK_OPERATOR_NAME_SIZE]; // enabled
5383deb3ec6SMatthias Ringwald } hfp_network_opearator_t;
5393deb3ec6SMatthias Ringwald 
5403deb3ec6SMatthias Ringwald 
5413deb3ec6SMatthias Ringwald typedef struct hfp_connection {
542665d90f2SMatthias Ringwald     btstack_linked_item_t    item;
5433deb3ec6SMatthias Ringwald 
544323d3000SMatthias Ringwald     // local role: HF or AG
545323d3000SMatthias Ringwald     hfp_role_t local_role;
546323d3000SMatthias Ringwald 
5473deb3ec6SMatthias Ringwald     bd_addr_t remote_addr;
548fc64f94aSMatthias Ringwald     hci_con_handle_t acl_handle;
549fc64f94aSMatthias Ringwald     hci_con_handle_t sco_handle;
550d9290e95SMatthias Ringwald     uint16_t packet_types;
551ab2445a0SMatthias Ringwald     uint8_t rfcomm_channel_nr;
5523deb3ec6SMatthias Ringwald     uint16_t rfcomm_cid;
5536504a03aSMilanka Ringwald     uint16_t rfcomm_mtu;
5543deb3ec6SMatthias Ringwald 
555aa4dd815SMatthias Ringwald     hfp_state_machine_t state_machine;
556aa4dd815SMatthias Ringwald     hfp_call_state_t call_state;
5573deb3ec6SMatthias Ringwald     hfp_state_t state;
558aa4dd815SMatthias Ringwald     hfp_codecs_state_t codecs_state;
559aa4dd815SMatthias Ringwald 
560323d3000SMatthias Ringwald     // needed for reestablishing connection - service uuid of the remote
5613deb3ec6SMatthias Ringwald     uint16_t service_uuid;
5623deb3ec6SMatthias Ringwald 
5633deb3ec6SMatthias Ringwald     // used during service level connection establishment
5643deb3ec6SMatthias Ringwald     hfp_command_t command;
5653deb3ec6SMatthias Ringwald     hfp_parser_state_t parser_state;
5663deb3ec6SMatthias Ringwald     int      parser_item_index;
567ce263fc8SMatthias Ringwald     int      parser_indicator_index;
5680222a807SMatthias Ringwald     uint32_t parser_indicator_value;
5691dddc4f4SMatthias Ringwald     bool     parser_quoted;
570471dea41SMatthias Ringwald 
571471dea41SMatthias Ringwald     // line buffer is always \0 terminated
572db3cdbd4SMilanka Ringwald     uint8_t  line_buffer[HFP_MAX_VR_TEXT_SIZE];
5733deb3ec6SMatthias Ringwald     int      line_size;
5743deb3ec6SMatthias Ringwald 
5753deb3ec6SMatthias Ringwald     uint32_t remote_supported_features;
5763deb3ec6SMatthias Ringwald 
57725789943SMilanka Ringwald     uint16_t remote_codecs_nr;
57825789943SMilanka Ringwald     uint8_t  remote_codecs[HFP_MAX_NUM_CODECS];
579667ec068SMatthias Ringwald 
58025789943SMilanka Ringwald     uint16_t ag_indicators_nr;
58125789943SMilanka Ringwald     hfp_ag_indicator_t ag_indicators[HFP_MAX_NUM_INDICATORS];
582667ec068SMatthias Ringwald     uint32_t ag_indicators_status_update_bitmap;
583667ec068SMatthias Ringwald     uint8_t  enable_status_update_for_ag_indicators;
584667ec068SMatthias Ringwald 
58525789943SMilanka Ringwald     uint16_t remote_call_services_index;
58625789943SMilanka Ringwald     hfp_call_service_t remote_call_services[HFP_MAX_NUM_CALL_SERVICES];
5873deb3ec6SMatthias Ringwald 
5883deb3ec6SMatthias Ringwald     // TODO: use bitmap.
58925789943SMilanka Ringwald     uint16_t generic_status_indicators_nr;
590667ec068SMatthias Ringwald     uint32_t generic_status_update_bitmap;
59125789943SMilanka Ringwald     hfp_generic_status_indicator_t generic_status_indicators[HFP_MAX_NUM_INDICATORS];
5923deb3ec6SMatthias Ringwald 
5933deb3ec6SMatthias Ringwald     hfp_network_opearator_t network_operator;
5943deb3ec6SMatthias Ringwald 
5953deb3ec6SMatthias Ringwald     // Retrieved during service level connection establishment, not used yet
5963deb3ec6SMatthias Ringwald     uint8_t  negotiated_codec;
5973deb3ec6SMatthias Ringwald 
598aa4dd815SMatthias Ringwald     // HF -> AG configuration
599aa4dd815SMatthias Ringwald     uint8_t clip_enabled;
600aa4dd815SMatthias Ringwald     uint8_t call_waiting_notification_enabled;
601aa4dd815SMatthias Ringwald 
6023deb3ec6SMatthias Ringwald     // TODO: put these bit flags in a bitmap
603aa4dd815SMatthias Ringwald     uint8_t ok_pending;
6043deb3ec6SMatthias Ringwald     uint8_t send_error;
60599af1e28SMilanka Ringwald 
606dd533208SMatthias Ringwald     bool found_equal_sign;
607ce263fc8SMatthias Ringwald     uint8_t ignore_value;
6083deb3ec6SMatthias Ringwald 
6093deb3ec6SMatthias Ringwald     uint8_t change_status_update_for_individual_ag_indicators;
6103deb3ec6SMatthias Ringwald     uint8_t operator_name_changed;
6113deb3ec6SMatthias Ringwald 
6123deb3ec6SMatthias Ringwald     uint8_t enable_extended_audio_gateway_error_report;
613a0ffb263SMatthias Ringwald     uint8_t extended_audio_gateway_error_value;
6143deb3ec6SMatthias Ringwald     uint8_t extended_audio_gateway_error;
6153deb3ec6SMatthias Ringwald 
6163deb3ec6SMatthias Ringwald     // establish codecs connection
6173deb3ec6SMatthias Ringwald     uint8_t suggested_codec;
6183deb3ec6SMatthias Ringwald     uint8_t codec_confirmed;
619bc1b1537SMilanka Ringwald     uint8_t sco_for_msbc_failed;
6202ee45eb2SMilanka Ringwald     uint8_t trigger_codec_exchange;
621cb81d35dSMatthias Ringwald 
622cb81d35dSMatthias Ringwald     // establish audio connection
623cb81d35dSMatthias Ringwald     hfp_link_settings_t link_setting;
624cb81d35dSMatthias Ringwald     uint8_t accept_sco; // 1 = SCO, 2 = eSCO
625cb81d35dSMatthias Ringwald 
6263deb3ec6SMatthias Ringwald     uint8_t establish_audio_connection;
6273deb3ec6SMatthias Ringwald     uint8_t release_audio_connection;
6288439fb24SMilanka Ringwald     uint8_t release_slc_connection;
6293deb3ec6SMatthias Ringwald 
630aa4dd815SMatthias Ringwald     uint8_t microphone_gain;
631aa4dd815SMatthias Ringwald     uint8_t send_microphone_gain;
632aa4dd815SMatthias Ringwald 
633aa4dd815SMatthias Ringwald     uint8_t speaker_gain;
634aa4dd815SMatthias Ringwald     uint8_t send_speaker_gain;
635aa4dd815SMatthias Ringwald 
636aa4dd815SMatthias Ringwald     uint8_t send_phone_number_for_voice_tag;
637ce263fc8SMatthias Ringwald     uint8_t send_ag_status_indicators;
638ad902e3dSMatthias Ringwald     uint8_t send_ag_indicators_segment;
639a5bdcda8SMatthias Ringwald     uint8_t send_response_and_hold_status;  // 0 - don't send. BRTH:0 == 1, ..
640ce263fc8SMatthias Ringwald 
64151a2ebdeSMatthias Ringwald     // HF: AT Command, AG: Unsolicited Result Code
64251a2ebdeSMatthias Ringwald     const char * send_custom_message;
64351a2ebdeSMatthias Ringwald 
6446d9a41f9SMatthias Ringwald     // HF:  Unsolicited Result Code, AG:  AT Command
6456d9a41f9SMatthias Ringwald     uint16_t custom_at_command_id;
6466d9a41f9SMatthias Ringwald 
64784fb9ac1SMilanka Ringwald     bool emit_vra_enabled_after_audio_established;
648ce263fc8SMatthias Ringwald     // AG only
649ce263fc8SMatthias Ringwald     uint8_t change_in_band_ring_tone_setting;
650ce263fc8SMatthias Ringwald     uint8_t ag_ring;
651ce263fc8SMatthias Ringwald     uint8_t ag_send_clip;
652ce263fc8SMatthias Ringwald     uint8_t ag_echo_and_noise_reduction;
653754910caSMilanka Ringwald     // used by AG: HFP parser stores here the activation value issued by HF
654734ef2bdSMilanka Ringwald     uint8_t ag_activate_voice_recognition_value;
6551a26de69SMilanka Ringwald     bool    ag_audio_connection_opened_before_vra;
6560b4debbfSMilanka Ringwald 
657a0ffb263SMatthias Ringwald     uint8_t ag_notify_incoming_call_waiting;
658ce263fc8SMatthias Ringwald     uint8_t send_subscriber_number;
659ce263fc8SMatthias Ringwald     uint8_t next_subscriber_number_to_send;
6600222a807SMatthias Ringwald     uint8_t ag_call_hold_action;
6610222a807SMatthias Ringwald     uint8_t ag_response_and_hold_action;
6620222a807SMatthias Ringwald     uint8_t ag_dtmf_code;
663245852b7SMilanka Ringwald     bool    ag_send_no_carrier;
6648f8818a4SMatthias Ringwald     bool    ag_vra_send_command;
6659430c71eSMatthias Ringwald     bool    ag_send_in_band_ring_tone_setting;
666a814da6aSMatthias Ringwald     bool    ag_send_common_codec;
667e7c46708SMatthias Ringwald     bool    ag_vra_requested_by_hf;
668ce263fc8SMatthias Ringwald 
669ce263fc8SMatthias Ringwald     int send_status_of_current_calls;
6709cae807eSMatthias Ringwald     int next_call_index;
671ce263fc8SMatthias Ringwald 
672ce263fc8SMatthias Ringwald     // HF only
673347d46c8SMilanka Ringwald     // HF: track command for which ok/error response need to be received
674347d46c8SMilanka Ringwald     hfp_command_t response_pending_for_command;
675347d46c8SMilanka Ringwald 
676ce263fc8SMatthias Ringwald     hfp_hf_query_operator_state_t hf_query_operator_state;
677ce263fc8SMatthias Ringwald     uint8_t hf_answer_incoming_call;
678ce263fc8SMatthias Ringwald     uint8_t hf_initiate_outgoing_call;
679ce263fc8SMatthias Ringwald     uint8_t hf_initiate_memory_dialing;
680ce263fc8SMatthias Ringwald     uint8_t hf_initiate_redial_last_number;
6811cc65c4fSMatthias Ringwald     bool    hf_send_codec_confirm;
6821cc65c4fSMatthias Ringwald     bool    hf_send_supported_codecs;
6831cc65c4fSMatthias Ringwald 
684a0ffb263SMatthias Ringwald     int memory_id;
685ce263fc8SMatthias Ringwald 
686ce263fc8SMatthias Ringwald     uint8_t hf_send_clip_enable;
687ce263fc8SMatthias Ringwald     uint8_t hf_send_chup;
688ce263fc8SMatthias Ringwald     uint8_t hf_send_chld_0;
689ce263fc8SMatthias Ringwald     uint8_t hf_send_chld_1;
690ce263fc8SMatthias Ringwald     uint8_t hf_send_chld_2;
691ce263fc8SMatthias Ringwald     uint8_t hf_send_chld_3;
692ce263fc8SMatthias Ringwald     uint8_t hf_send_chld_4;
693667ec068SMatthias Ringwald     uint8_t hf_send_chld_x;
694667ec068SMatthias Ringwald     uint8_t hf_send_chld_x_index;
695ce263fc8SMatthias Ringwald     char    hf_send_dtmf_code;
696ce263fc8SMatthias Ringwald     uint8_t hf_send_binp;
697667ec068SMatthias Ringwald     uint8_t hf_send_clcc;
698667ec068SMatthias Ringwald     uint8_t hf_send_rrh;
699667ec068SMatthias Ringwald     char    hf_send_rrh_command;
700667ec068SMatthias Ringwald     uint8_t hf_send_cnum;
701667ec068SMatthias Ringwald 
702ce263fc8SMatthias Ringwald     uint8_t hf_activate_call_waiting_notification;
703ce263fc8SMatthias Ringwald     uint8_t hf_deactivate_call_waiting_notification;
704ce263fc8SMatthias Ringwald 
705ce263fc8SMatthias Ringwald     uint8_t hf_activate_calling_line_notification;
706ce263fc8SMatthias Ringwald     uint8_t hf_deactivate_calling_line_notification;
707ce263fc8SMatthias Ringwald     uint8_t hf_deactivate_echo_canceling_and_noise_reduction;
70856f1adacSMilanka Ringwald 
7090c738fd4SMilanka Ringwald     hfp_voice_recognition_activation_status_t vra_state;
7100c738fd4SMilanka Ringwald     hfp_voice_recognition_activation_status_t vra_state_requested;
711de9e0ea7SMilanka Ringwald     bool deactivate_voice_recognition;
712de9e0ea7SMilanka Ringwald     bool activate_voice_recognition;
713cf75be85SMilanka Ringwald     bool enhanced_voice_recognition_enabled;
714be55a11dSMilanka Ringwald 
715cf75be85SMilanka Ringwald     // ih HF, used by parser, in AG used for commands
7160b4debbfSMilanka Ringwald     uint8_t ag_vra_status;
717db3cdbd4SMilanka Ringwald     hfp_voice_recognition_state_t ag_vra_state;
71845796ff1SMilanka Ringwald     hfp_voice_recognition_message_t ag_msg;
719b95cac54SMilanka Ringwald     uint16_t ag_vra_msg_length;
720ce263fc8SMatthias Ringwald 
721667ec068SMatthias Ringwald     uint8_t clcc_idx;
722667ec068SMatthias Ringwald     uint8_t clcc_dir;
723667ec068SMatthias Ringwald     uint8_t clcc_status;
724667ec068SMatthias Ringwald     uint8_t clcc_mode;
725667ec068SMatthias Ringwald     uint8_t clcc_mpty;
726667ec068SMatthias Ringwald 
727d0c20769SMatthias Ringwald     uint8_t call_index;
728a0ffb263SMatthias Ringwald     // also used for CLCC, CCWA, CLIP if set
729ce263fc8SMatthias Ringwald     uint8_t bnip_type;       // 0 == not set
730fc8835faSMilanka Ringwald     char    bnip_number[HFP_BNEP_NUM_MAX_SIZE]; //
731125560b8SMatthias Ringwald     bool    clip_have_alpha;
732ce263fc8SMatthias Ringwald 
7333721a235SMatthias Ringwald #ifdef ENABLE_CC256X_ASSISTED_HFP
7343721a235SMatthias Ringwald     bool cc256x_send_write_codec_config;
7353721a235SMatthias Ringwald     bool cc256x_send_wbs_associate;
7363721a235SMatthias Ringwald     bool cc256x_send_wbs_disassociate;
7373721a235SMatthias Ringwald #endif
738689d4323SMatthias Ringwald #ifdef ENABLE_BCM_PCM_WBS
739689d4323SMatthias Ringwald     bool bcm_send_enable_wbs;
740689d4323SMatthias Ringwald     bool bcm_send_disable_wbs;
741689d4323SMatthias Ringwald     bool bcm_send_write_i2spcm_interface_param;
742689d4323SMatthias Ringwald #endif
7432b5f92fdSMatthias Ringwald #ifdef ENABLE_RTK_PCM_WBS
7442b5f92fdSMatthias Ringwald     bool rtk_send_sco_config;
7452b5f92fdSMatthias Ringwald #endif
7463deb3ec6SMatthias Ringwald } hfp_connection_t;
7473deb3ec6SMatthias Ringwald 
748471dea41SMatthias Ringwald /**
749471dea41SMatthias Ringwald  * @brief Struct to register custom AT Command.
750471dea41SMatthias Ringwald  */
751471dea41SMatthias Ringwald typedef struct {
752471dea41SMatthias Ringwald     btstack_linked_item_t * next;
753471dea41SMatthias Ringwald     const char *            command;
754471dea41SMatthias Ringwald     uint16_t                command_id;
755471dea41SMatthias Ringwald } hfp_custom_at_command_t;
756471dea41SMatthias Ringwald 
7573deb3ec6SMatthias Ringwald // UTILS_START : TODO move to utils
7585ebff802SMatthias Ringwald int send_str_over_rfcomm(uint16_t cid, const char * command);
7593deb3ec6SMatthias Ringwald int join(char * buffer, int buffer_size, uint8_t * values, int values_nr);
7603deb3ec6SMatthias Ringwald int join_bitmap(char * buffer, int buffer_size, uint32_t values, int values_nr);
7613deb3ec6SMatthias Ringwald int get_bit(uint16_t bitmap, int position);
7623deb3ec6SMatthias Ringwald int store_bit(uint32_t bitmap, int position, uint8_t value);
7633deb3ec6SMatthias Ringwald // UTILS_END
7643deb3ec6SMatthias Ringwald 
76525ffee39SMatthias Ringwald #define HFP_H2_SYNC_FRAME_SIZE 60
7662288067bSMatthias Ringwald // HFP H2 Synchronization
76725ffee39SMatthias Ringwald typedef struct {
76825ffee39SMatthias Ringwald     // callback returns true if data was valid
76925ffee39SMatthias Ringwald     bool        (*callback)(bool bad_frame, const uint8_t * frame_data, uint16_t frame_len);
77025ffee39SMatthias Ringwald     uint8_t     frame_data[HFP_H2_SYNC_FRAME_SIZE];
77125ffee39SMatthias Ringwald     uint16_t    frame_len;
77225ffee39SMatthias Ringwald     uint16_t    dropped_bytes;
77325ffee39SMatthias Ringwald } hfp_h2_sync_t;
77425ffee39SMatthias Ringwald 
77525ffee39SMatthias Ringwald /**
77625ffee39SMatthias Ringwald  * @brief Init HFP H2 Sync state
77725ffee39SMatthias Ringwald  * @param hfp_h2_sync
77825ffee39SMatthias Ringwald  * @param callback
77925ffee39SMatthias Ringwald  */
78025ffee39SMatthias Ringwald void hfp_h2_sync_init(hfp_h2_sync_t * hfp_h2_sync,
78125ffee39SMatthias Ringwald                       bool (*callback)(bool bad_frame, const uint8_t * frame_data, uint16_t frame_len));
78225ffee39SMatthias Ringwald /**
78325ffee39SMatthias Ringwald  * @brief Process H2 data and execute callback for frames with valid H2 header
78425ffee39SMatthias Ringwald  * @param hfp_h2_sync
78525ffee39SMatthias Ringwald  * @param bad_frame
78625ffee39SMatthias Ringwald  * @param frame_data
78725ffee39SMatthias Ringwald  * @param frame_len
78825ffee39SMatthias Ringwald  */
78925ffee39SMatthias Ringwald void hfp_h2_sync_process(hfp_h2_sync_t *hfp_h2_sync, bool bad_frame, const uint8_t *frame_data, uint16_t frame_len);
79025ffee39SMatthias Ringwald 
79125ffee39SMatthias Ringwald 
79225ffee39SMatthias Ringwald // other
79325ffee39SMatthias Ringwald 
79448e6eeeeSMatthias Ringwald void hfp_finalize_connection_context(hfp_connection_t * hfp_connection);
795f14c5dafSMatthias Ringwald void hfp_emit_sco_connection_established(hfp_connection_t *hfp_connection, uint8_t status, uint8_t negotiated_codec,
7965e8e3664SMatthias Ringwald                                          uint16_t rx_packet_length, uint16_t tx_packet_length);
797f2a3f984SMilanka Ringwald 
798ca59be51SMatthias Ringwald void hfp_set_ag_callback(btstack_packet_handler_t callback);
799ca59be51SMatthias Ringwald void hfp_set_ag_rfcomm_packet_handler(btstack_packet_handler_t handler);
800f4000eebSMatthias Ringwald 
801ca59be51SMatthias Ringwald void hfp_set_hf_callback(btstack_packet_handler_t callback);
802ca59be51SMatthias Ringwald void hfp_set_hf_rfcomm_packet_handler(btstack_packet_handler_t handler);
803d68dcce1SMatthias Ringwald 
804520c92d5SMatthias Ringwald void hfp_init(void);
80520b2edb6SMatthias Ringwald void hfp_deinit(void);
806520c92d5SMatthias Ringwald 
807471dea41SMatthias Ringwald void hfp_register_custom_ag_command(hfp_custom_at_command_t * at_command);
8087404dce3SMatthias Ringwald void hfp_register_custom_hf_command(hfp_custom_at_command_t * at_command);
809471dea41SMatthias Ringwald 
8109b1c3b4dSMatthias Ringwald void hfp_create_sdp_record(uint8_t * service, uint32_t service_record_handle, uint16_t service_uuid, int rfcomm_channel_nr, const char * name);
811405014fbSMatthias Ringwald void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size, hfp_role_t local_role);
81227950165SMatthias Ringwald void hfp_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size, hfp_role_t local_role);
813ca59be51SMatthias Ringwald void hfp_emit_event(hfp_connection_t * hfp_connection, uint8_t event_subtype, uint8_t value);
814ca59be51SMatthias Ringwald void hfp_emit_simple_event(hfp_connection_t * hfp_connection, uint8_t event_subtype);
815ca59be51SMatthias Ringwald void hfp_emit_string_event(hfp_connection_t * hfp_connection, uint8_t event_subtype, const char * value);
8167095467fSMatthias Ringwald void hfp_emit_slc_connection_event(hfp_role_t local_role, uint8_t status, hci_con_handle_t con_handle, bd_addr_t addr);
817aa4dd815SMatthias Ringwald 
818a95ec82fSMilanka Ringwald /**
819553a4a56SMilanka Ringwald  * @brief Emit HFP_SUBEVENT_VOICE_RECOGNITION_ENABLED event
820a95ec82fSMilanka Ringwald  * @param hfp_connection
821a95ec82fSMilanka Ringwald  * @param status ERROR_CODE_SUCCESS if successful, otherwise ERROR_CODE_COMMAND_DISALLOWED
822a95ec82fSMilanka Ringwald  */
823553a4a56SMilanka Ringwald void hfp_emit_voice_recognition_enabled(hfp_connection_t * hfp_connection, uint8_t status);
824553a4a56SMilanka Ringwald 
825553a4a56SMilanka Ringwald /**
826553a4a56SMilanka Ringwald  * @brief Emit HFP_SUBEVENT_VOICE_RECOGNITION_DISABLED event
827553a4a56SMilanka Ringwald  * @param hfp_connection
828553a4a56SMilanka Ringwald  * @param status ERROR_CODE_SUCCESS if successful, otherwise ERROR_CODE_COMMAND_DISALLOWED
829553a4a56SMilanka Ringwald  */
830553a4a56SMilanka Ringwald void hfp_emit_voice_recognition_disabled(hfp_connection_t * hfp_connection, uint8_t status);
831553a4a56SMilanka Ringwald 
832de9e0ea7SMilanka Ringwald void hfp_emit_enhanced_voice_recognition_hf_ready_for_audio_event(hfp_connection_t * hfp_connection, uint8_t status);
833cf75be85SMilanka Ringwald void hfp_emit_enhanced_voice_recognition_state_event(hfp_connection_t * hfp_connection, uint8_t status);
834a95ec82fSMilanka Ringwald 
8353deb3ec6SMatthias Ringwald hfp_connection_t * get_hfp_connection_context_for_rfcomm_cid(uint16_t cid);
836405014fbSMatthias Ringwald hfp_connection_t * get_hfp_connection_context_for_bd_addr(bd_addr_t bd_addr, hfp_role_t hfp_role);
837405014fbSMatthias Ringwald hfp_connection_t * get_hfp_connection_context_for_sco_handle(uint16_t handle, hfp_role_t hfp_role);
838405014fbSMatthias Ringwald hfp_connection_t * get_hfp_connection_context_for_acl_handle(uint16_t handle, hfp_role_t hfp_role);
839aa4dd815SMatthias Ringwald 
8408f2a52f4SMatthias Ringwald btstack_linked_list_t * hfp_get_connections(void);
841a0ffb263SMatthias Ringwald void hfp_parse(hfp_connection_t * connection, uint8_t byte, int isHandsFree);
842471dea41SMatthias Ringwald void hfp_parser_reset_line_buffer(hfp_connection_t *hfp_connection);
8433deb3ec6SMatthias Ringwald 
8444eb3f1d8SMilanka Ringwald /**
8454eb3f1d8SMilanka Ringwald  * @brief Establish RFCOMM connection, and perform service level connection agreement:
8464eb3f1d8SMilanka Ringwald  * @param bd_addr
8475ca6cd56SMilanka Ringwald  * @param service_uuid
8485ca6cd56SMilanka Ringwald  * @param local_role
8494eb3f1d8SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
8504eb3f1d8SMilanka Ringwald  *                  - ERROR_CODE_COMMAND_DISALLOWED if connection already exists, or
8514eb3f1d8SMilanka Ringwald  *                  - BTSTACK_MEMORY_ALLOC_FAILED
8524eb3f1d8SMilanka Ringwald  */
8534eb3f1d8SMilanka Ringwald uint8_t hfp_establish_service_level_connection(bd_addr_t bd_addr, uint16_t service_uuid, hfp_role_t local_role);
8544eb3f1d8SMilanka Ringwald 
8555ca6cd56SMilanka Ringwald /**
8565ca6cd56SMilanka Ringwald  * @brief Prepare connection for audio and SLC connections release
8575ca6cd56SMilanka Ringwald  * @param hfp_connection
8585ca6cd56SMilanka Ringwald  */
859657bc59fSMilanka Ringwald void hfp_trigger_release_service_level_connection(hfp_connection_t * hfp_connection);
8605ca6cd56SMilanka Ringwald 
8615ca6cd56SMilanka Ringwald /**
8625ca6cd56SMilanka Ringwald  * @brief Prepare connection for audio connection release
8635ca6cd56SMilanka Ringwald  * @param hfp_connection
8645ca6cd56SMilanka Ringwald  */
8650b4debbfSMilanka Ringwald uint8_t hfp_trigger_release_audio_connection(hfp_connection_t * hfp_connection);
8661ffa0dd9SMilanka Ringwald 
867657bc59fSMilanka Ringwald void hfp_reset_context_flags(hfp_connection_t * hfp_connection);
8683deb3ec6SMatthias Ringwald 
869*6b3901f2SMatthias Ringwald // @returns if an SCO setup is active in either role
870*6b3901f2SMatthias Ringwald bool hfp_sco_setup_active(void);
871*6b3901f2SMatthias Ringwald 
872657bc59fSMilanka Ringwald void hfp_setup_synchronous_connection(hfp_connection_t * hfp_connection);
873cb81d35dSMatthias Ringwald void hfp_accept_synchronous_connection(hfp_connection_t * hfp_connection, bool incoming_eSCO);
874*6b3901f2SMatthias Ringwald 
8756a7f44bdSMilanka Ringwald int hfp_supports_codec(uint8_t codec, int codecs_nr, uint8_t * codecs);
876d715cf51SMatthias Ringwald void hfp_hf_drop_mSBC_if_eSCO_not_supported(uint8_t * codecs, uint8_t * codecs_nr);
877e453c1d9SMatthias Ringwald void hfp_init_link_settings(hfp_connection_t * hfp_connection, uint8_t eSCO_S4_supported);
878b4320e7fSMatthias Ringwald hfp_link_settings_t hfp_next_link_setting(hfp_link_settings_t current_setting, uint16_t local_sco_packet_types,
879b4320e7fSMatthias Ringwald                                           uint16_t remote_sco_packet_types, bool eSCO_s4_supported,
880b4320e7fSMatthias Ringwald                                           uint8_t negotiated_codec);
881ce263fc8SMatthias Ringwald 
8823deb3ec6SMatthias Ringwald const char * hfp_hf_feature(int index);
8833deb3ec6SMatthias Ringwald const char * hfp_ag_feature(int index);
8843deb3ec6SMatthias Ringwald 
885186dd3d2SMatthias Ringwald void hfp_log_rfcomm_message(const char * tag, uint8_t * packet, uint16_t size);
886186dd3d2SMatthias Ringwald 
8870aee97efSMilanka Ringwald const char * hfp_enhanced_call_dir2str(uint16_t index);
8880aee97efSMilanka Ringwald const char * hfp_enhanced_call_status2str(uint16_t index);
8890aee97efSMilanka Ringwald const char * hfp_enhanced_call_mode2str(uint16_t index);
8900aee97efSMilanka Ringwald const char * hfp_enhanced_call_mpty2str(uint16_t index);
8910aee97efSMilanka Ringwald 
8923721a235SMatthias Ringwald #ifdef ENABLE_CC256X_ASSISTED_HFP
8933721a235SMatthias Ringwald void hfp_cc256x_prepare_for_sco(hfp_connection_t * hfp_connection);
8943721a235SMatthias Ringwald void hfp_cc256x_write_codec_config(hfp_connection_t * hfp_connection);
8953721a235SMatthias Ringwald #endif
896689d4323SMatthias Ringwald #ifdef ENABLE_BCM_PCM_WBS
897689d4323SMatthias Ringwald void hfp_bcm_prepare_for_sco(hfp_connection_t * hfp_connection);
898689d4323SMatthias Ringwald void hfp_bcm_write_i2spcm_interface_param (hfp_connection_t * hfp_connection);
899689d4323SMatthias Ringwald #endif
9003721a235SMatthias Ringwald 
901991c26beSMatthias Ringwald /**
902352a0504SMatthias Ringwald  * @brief Set packet types for SCO connections
903991c26beSMatthias Ringwald  * @param common single packet_types: HFP_SCO_PACKET_TYPES_*
904991c26beSMatthias Ringwald  */
905991c26beSMatthias Ringwald void hfp_set_sco_packet_types(uint16_t packet_types);
906991c26beSMatthias Ringwald 
907991c26beSMatthias Ringwald /**
908352a0504SMatthias Ringwald  * @brief Get packet types for SCO connections
9096b65794dSMilanka Ringwald  * @return packet_types
910991c26beSMatthias Ringwald  */
911991c26beSMatthias Ringwald uint16_t hfp_get_sco_packet_types(void);
912991c26beSMatthias Ringwald 
9133deb3ec6SMatthias Ringwald #if defined __cplusplus
9143deb3ec6SMatthias Ringwald }
9153deb3ec6SMatthias Ringwald #endif
9163deb3ec6SMatthias Ringwald 
91780e33422SMatthias Ringwald #endif // BTSTACK_HFP_H
918