xref: /btstack/src/classic/hfp.h (revision 4eb3f1d888912cdcda915d037f318a0b138a37d9)
13deb3ec6SMatthias Ringwald /*
23deb3ec6SMatthias Ringwald  * Copyright (C) 2014 BlueKitchen GmbH
33deb3ec6SMatthias Ringwald  *
43deb3ec6SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
53deb3ec6SMatthias Ringwald  * modification, are permitted provided that the following conditions
63deb3ec6SMatthias Ringwald  * are met:
73deb3ec6SMatthias Ringwald  *
83deb3ec6SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
93deb3ec6SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
103deb3ec6SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
113deb3ec6SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
123deb3ec6SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
133deb3ec6SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
143deb3ec6SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
153deb3ec6SMatthias Ringwald  *    from this software without specific prior written permission.
163deb3ec6SMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
173deb3ec6SMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
183deb3ec6SMatthias Ringwald  *    monetary gain.
193deb3ec6SMatthias Ringwald  *
203deb3ec6SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
213deb3ec6SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
223deb3ec6SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
233deb3ec6SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
243deb3ec6SMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
253deb3ec6SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
263deb3ec6SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
273deb3ec6SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
283deb3ec6SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
293deb3ec6SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
303deb3ec6SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
313deb3ec6SMatthias Ringwald  * SUCH DAMAGE.
323deb3ec6SMatthias Ringwald  *
333deb3ec6SMatthias Ringwald  * Please inquire about commercial licensing options at
343deb3ec6SMatthias Ringwald  * [email protected]
353deb3ec6SMatthias Ringwald  *
363deb3ec6SMatthias Ringwald  */
373deb3ec6SMatthias Ringwald 
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 
533deb3ec6SMatthias Ringwald 
543deb3ec6SMatthias Ringwald /* HF Supported Features:
553deb3ec6SMatthias Ringwald 0: EC and/or NR function
563deb3ec6SMatthias Ringwald 1: Three-way calling
573deb3ec6SMatthias Ringwald 2: CLI presentation capability
583deb3ec6SMatthias Ringwald 3: Voice recognition activation
593deb3ec6SMatthias Ringwald 4: Remote volume control
603deb3ec6SMatthias Ringwald 5: Enhanced call status
613deb3ec6SMatthias Ringwald 6: Enhanced call control
623deb3ec6SMatthias Ringwald 7: Codec negotiation
633deb3ec6SMatthias Ringwald 8: HF Indicators
643deb3ec6SMatthias Ringwald 9: eSCO S4 (and T2) Settings Supported
653deb3ec6SMatthias Ringwald 10-31: Reserved for future definition
663deb3ec6SMatthias Ringwald */
673deb3ec6SMatthias Ringwald #define HFP_HFSF_EC_NR_FUNCTION                          0
68aa4dd815SMatthias Ringwald #define HFP_HFSF_THREE_WAY_CALLING                       1
694f84bf36SMatthias Ringwald #define HFP_HFSF_CLI_PRESENTATION_CAPABILITY             2
70aa4dd815SMatthias Ringwald #define HFP_HFSF_VOICE_RECOGNITION_FUNCTION              3
714f84bf36SMatthias Ringwald #define HFP_HFSF_REMOTE_VOLUME_CONTROL                   4
724f84bf36SMatthias Ringwald #define HFP_HFSF_ENHANCED_CALL_STATUS                    5
734f84bf36SMatthias Ringwald #define HFP_HFSF_ENHANCED_CALL_CONTROL                   6
743deb3ec6SMatthias Ringwald #define HFP_HFSF_CODEC_NEGOTIATION                       7
753deb3ec6SMatthias Ringwald #define HFP_HFSF_HF_INDICATORS                           8
76ce263fc8SMatthias Ringwald #define HFP_HFSF_ESCO_S4                                 9
77ef3ae4ebSMilanka Ringwald #define HFP_HFSF_ENHANCED_VOICE_RECOGNITION_STATUS      10
78ef3ae4ebSMilanka Ringwald #define HFP_HFSF_VOICE_RECOGNITION_TEXT                 11
793deb3ec6SMatthias Ringwald 
803deb3ec6SMatthias Ringwald /* AG Supported Features:
813deb3ec6SMatthias Ringwald 0: Three-way calling
823deb3ec6SMatthias Ringwald 1: EC and/or NR function
833deb3ec6SMatthias Ringwald 2: Voice recognition function
843deb3ec6SMatthias Ringwald 3: In-band ring tone capability
853deb3ec6SMatthias Ringwald 4: Attach a number to a voice tag
863deb3ec6SMatthias Ringwald 5: Ability to reject a call
873deb3ec6SMatthias Ringwald 6: Enhanced call status
883deb3ec6SMatthias Ringwald 7: Enhanced call control
893deb3ec6SMatthias Ringwald 8: Extended Error Result Codes
903deb3ec6SMatthias Ringwald 9: Codec negotiation
913deb3ec6SMatthias Ringwald 10: HF Indicators
923deb3ec6SMatthias Ringwald 11: eSCO S4 (and T2) Settings Supported
933deb3ec6SMatthias Ringwald 12-31: Reserved for future definition
943deb3ec6SMatthias Ringwald */
953deb3ec6SMatthias Ringwald #define HFP_AGSF_THREE_WAY_CALLING                       0
963deb3ec6SMatthias Ringwald #define HFP_AGSF_EC_NR_FUNCTION                          1
97aa4dd815SMatthias Ringwald #define HFP_AGSF_VOICE_RECOGNITION_FUNCTION              2
98aa4dd815SMatthias Ringwald #define HFP_AGSF_IN_BAND_RING_TONE                       3
994f84bf36SMatthias Ringwald #define HFP_AGSF_ATTACH_A_NUMBER_TO_A_VOICE_TAG          4
1004f84bf36SMatthias Ringwald #define HFP_AGSF_ABILITY_TO_REJECT_A_CALL                5
1014f84bf36SMatthias Ringwald #define HFP_AGSF_ENHANCED_CALL_STATUS                    6
1024f84bf36SMatthias Ringwald #define HFP_AGSF_ENHANCED_CALL_CONTROL                   7
1034f84bf36SMatthias Ringwald #define HFP_AGSF_EXTENDED_ERROR_RESULT_CODES             8
1043deb3ec6SMatthias Ringwald #define HFP_AGSF_CODEC_NEGOTIATION                       9
1053deb3ec6SMatthias Ringwald #define HFP_AGSF_HF_INDICATORS                          10
106ce263fc8SMatthias Ringwald #define HFP_AGSF_ESCO_S4                                11
107ef3ae4ebSMilanka Ringwald #define HFP_AGSF_ENHANCED_VOICE_RECOGNITION_STATUS      12
108ef3ae4ebSMilanka Ringwald #define HFP_AGSF_VOICE_RECOGNITION_TEXT                 13
1093deb3ec6SMatthias Ringwald 
1103deb3ec6SMatthias Ringwald #define HFP_DEFAULT_HF_SUPPORTED_FEATURES 0x0000
1113deb3ec6SMatthias Ringwald #define HFP_DEFAULT_AG_SUPPORTED_FEATURES 0x0009
1123deb3ec6SMatthias Ringwald 
11325789943SMilanka Ringwald #define HFP_MAX_NUM_INDICATORS                  10
11425789943SMilanka Ringwald #define HFP_MAX_NUM_CALL_SERVICES               20
11525789943SMilanka Ringwald #define HFP_CALL_SERVICE_SIZE                    3
11625789943SMilanka Ringwald #define HFP_MAX_NUM_CODECS                      10
11725789943SMilanka Ringwald 
1183deb3ec6SMatthias Ringwald #define HFP_MAX_INDICATOR_DESC_SIZE  20
119db3cdbd4SMilanka Ringwald #define HFP_MAX_VR_TEXT_SIZE        100
12089425bfcSMilanka Ringwald #define HFP_MAX_NETWORK_OPERATOR_NAME_SIZE 17
12125789943SMilanka Ringwald 
1223deb3ec6SMatthias Ringwald 
1233deb3ec6SMatthias Ringwald #define HFP_SUPPORTED_FEATURES "+BRSF"
1243deb3ec6SMatthias Ringwald #define HFP_AVAILABLE_CODECS "+BAC"
1253deb3ec6SMatthias Ringwald #define HFP_INDICATOR "+CIND"
1263deb3ec6SMatthias Ringwald #define HFP_ENABLE_STATUS_UPDATE_FOR_AG_INDICATORS "+CMER"
127aa4dd815SMatthias Ringwald #define HFP_ENABLE_CLIP "+CLIP"
128aa4dd815SMatthias Ringwald #define HFP_ENABLE_CALL_WAITING_NOTIFICATION "+CCWA"
1293deb3ec6SMatthias Ringwald #define HFP_UPDATE_ENABLE_STATUS_FOR_INDIVIDUAL_AG_INDICATORS "+BIA" // +BIA:<enabled>,,<enabled>,,,<enabled>
1303deb3ec6SMatthias Ringwald #define HFP_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES "+CHLD"
1313deb3ec6SMatthias Ringwald #define HFP_GENERIC_STATUS_INDICATOR "+BIND"
1323deb3ec6SMatthias Ringwald #define HFP_TRANSFER_AG_INDICATOR_STATUS "+CIEV" // +CIEV: <index>,<value>
133ce263fc8SMatthias Ringwald #define HFP_TRANSFER_HF_INDICATOR_STATUS "+BIEV" // +BIEC: <index>,<value>
1343deb3ec6SMatthias Ringwald #define HFP_QUERY_OPERATOR_SELECTION "+COPS"     // +COPS: <mode>,0,<opearator>
1353deb3ec6SMatthias Ringwald #define HFP_ENABLE_EXTENDED_AUDIO_GATEWAY_ERROR "+CMEE"
1363deb3ec6SMatthias Ringwald #define HFP_EXTENDED_AUDIO_GATEWAY_ERROR "+CME ERROR"
1373deb3ec6SMatthias Ringwald #define HFP_TRIGGER_CODEC_CONNECTION_SETUP "+BCC"
1383deb3ec6SMatthias Ringwald #define HFP_CONFIRM_COMMON_CODEC "+BCS"
13997d2cadbSMatthias Ringwald #define HFP_ANSWER_CALL "ATA"
140aa4dd815SMatthias Ringwald #define HFP_HANG_UP_CALL "+CHUP"
141aa4dd815SMatthias Ringwald #define HFP_CHANGE_IN_BAND_RING_TONE_SETTING "+BSIR"
142aa4dd815SMatthias Ringwald #define HFP_CALL_PHONE_NUMBER "ATD"
143ce263fc8SMatthias Ringwald #define HFP_REDIAL_LAST_NUMBER "+BLDN"
144aa4dd815SMatthias Ringwald #define HFP_TURN_OFF_EC_AND_NR "+NREC" // EC (Echo CAnceling), NR (Noise Reduction)
145ef3ae4ebSMilanka Ringwald #define HFP_ACTIVATE_VOICE_RECOGNITION "+BVRA" // Voice Recognition
146aa4dd815SMatthias Ringwald #define HFP_SET_MICROPHONE_GAIN  "+VGM"
147aa4dd815SMatthias Ringwald #define HFP_SET_SPEAKER_GAIN     "+VGS"
148aa4dd815SMatthias Ringwald #define HFP_PHONE_NUMBER_FOR_VOICE_TAG "+BINP"
149aa4dd815SMatthias Ringwald #define HFP_TRANSMIT_DTMF_CODES  "+VTS"
150ce263fc8SMatthias Ringwald #define HFP_SUBSCRIBER_NUMBER_INFORMATION "+CNUM"
151ce263fc8SMatthias Ringwald #define HFP_LIST_CURRENT_CALLS "+CLCC"
152ce263fc8SMatthias Ringwald #define HFP_RESPONSE_AND_HOLD "+BTRH"
1533deb3ec6SMatthias Ringwald 
1543deb3ec6SMatthias Ringwald #define HFP_OK "OK"
1553deb3ec6SMatthias Ringwald #define HFP_ERROR "ERROR"
156ce263fc8SMatthias Ringwald #define HFP_RING "RING"
1573deb3ec6SMatthias Ringwald 
1583deb3ec6SMatthias Ringwald // Codecs
1593deb3ec6SMatthias Ringwald #define HFP_CODEC_CVSD 0x01
1603deb3ec6SMatthias Ringwald #define HFP_CODEC_MSBC 0x02
1613deb3ec6SMatthias Ringwald 
1623deb3ec6SMatthias Ringwald typedef enum {
163520c92d5SMatthias Ringwald     HFP_ROLE_INVALID = 0,
164520c92d5SMatthias Ringwald     HFP_ROLE_AG,
165323d3000SMatthias Ringwald     HFP_ROLE_HF,
166323d3000SMatthias Ringwald } hfp_role_t;
167323d3000SMatthias Ringwald 
168323d3000SMatthias Ringwald typedef enum {
1693deb3ec6SMatthias Ringwald     HFP_CMD_NONE = 0,
1703deb3ec6SMatthias Ringwald     HFP_CMD_ERROR,
171aa4dd815SMatthias Ringwald     HFP_CMD_UNKNOWN,
1723deb3ec6SMatthias Ringwald     HFP_CMD_OK,
173ce263fc8SMatthias Ringwald     HFP_CMD_RING,
174245852b7SMilanka Ringwald     HFP_CMD_SUPPORTED_FEATURES,                             // 5
1753deb3ec6SMatthias Ringwald     HFP_CMD_AVAILABLE_CODECS,
17684a0c24eSMatthias Ringwald     HFP_CMD_RETRIEVE_AG_INDICATORS_GENERIC,
177aa4dd815SMatthias Ringwald     HFP_CMD_RETRIEVE_AG_INDICATORS,
178aa4dd815SMatthias Ringwald     HFP_CMD_RETRIEVE_AG_INDICATORS_STATUS,
179245852b7SMilanka Ringwald     HFP_CMD_ENABLE_INDICATOR_STATUS_UPDATE,                 // 10
1803deb3ec6SMatthias Ringwald     HFP_CMD_ENABLE_INDIVIDUAL_AG_INDICATOR_STATUS_UPDATE,
1813deb3ec6SMatthias Ringwald     HFP_CMD_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES,
182aa4dd815SMatthias Ringwald     HFP_CMD_ENABLE_CLIP,
183a0ffb263SMatthias Ringwald     HFP_CMD_AG_SENT_CLIP_INFORMATION,
184245852b7SMilanka Ringwald     HFP_CMD_ENABLE_CALL_WAITING_NOTIFICATION,               // 15
185a0ffb263SMatthias Ringwald     HFP_CMD_AG_SENT_CALL_WAITING_NOTIFICATION_UPDATE,
186aa4dd815SMatthias Ringwald     HFP_CMD_LIST_GENERIC_STATUS_INDICATORS,
187aa4dd815SMatthias Ringwald     HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS,
188aa4dd815SMatthias Ringwald     HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS_STATE,
189245852b7SMilanka Ringwald     HFP_CMD_SET_GENERIC_STATUS_INDICATOR_STATUS,            // 20
1903deb3ec6SMatthias Ringwald     HFP_CMD_TRANSFER_AG_INDICATOR_STATUS,
191aa4dd815SMatthias Ringwald     HFP_CMD_QUERY_OPERATOR_SELECTION_NAME,
192aa4dd815SMatthias Ringwald     HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT,
1933deb3ec6SMatthias Ringwald     HFP_CMD_ENABLE_EXTENDED_AUDIO_GATEWAY_ERROR,
194245852b7SMilanka Ringwald     HFP_CMD_EXTENDED_AUDIO_GATEWAY_ERROR,                   // 25
1953deb3ec6SMatthias Ringwald     HFP_CMD_TRIGGER_CODEC_CONNECTION_SETUP,
196aa4dd815SMatthias Ringwald     HFP_CMD_AG_SEND_COMMON_CODEC,
1973deb3ec6SMatthias Ringwald     HFP_CMD_AG_SUGGESTED_CODEC,
198aa4dd815SMatthias Ringwald     HFP_CMD_HF_CONFIRMED_CODEC,
199aa4dd815SMatthias Ringwald     HFP_CMD_CALL_ANSWERED,
200aa4dd815SMatthias Ringwald     HFP_CMD_CALL_HOLD,
201aa4dd815SMatthias Ringwald     HFP_CMD_HANG_UP_CALL,
202aa4dd815SMatthias Ringwald     HFP_CMD_CHANGE_IN_BAND_RING_TONE_SETTING,
203aa4dd815SMatthias Ringwald     HFP_CMD_CALL_PHONE_NUMBER,
204aa4dd815SMatthias Ringwald     HFP_CMD_REDIAL_LAST_NUMBER,
205aa4dd815SMatthias Ringwald     HFP_CMD_TURN_OFF_EC_AND_NR,
206aa4dd815SMatthias Ringwald     HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION,
207aa4dd815SMatthias Ringwald     HFP_CMD_HF_ACTIVATE_VOICE_RECOGNITION,
20845796ff1SMilanka Ringwald     HFP_CMD_AG_ACTIVATE_ENHANCED_VOICE_RECOGNITION,
209aa4dd815SMatthias Ringwald     HFP_CMD_HF_REQUEST_PHONE_NUMBER,
210ce263fc8SMatthias Ringwald     HFP_CMD_AG_SENT_PHONE_NUMBER,
211aa4dd815SMatthias Ringwald     HFP_CMD_TRANSMIT_DTMF_CODES,
212aa4dd815SMatthias Ringwald     HFP_CMD_SET_MICROPHONE_GAIN,
213ce263fc8SMatthias Ringwald     HFP_CMD_SET_SPEAKER_GAIN,
214ce263fc8SMatthias Ringwald     HFP_CMD_GET_SUBSCRIBER_NUMBER_INFORMATION,
215ce263fc8SMatthias Ringwald     HFP_CMD_LIST_CURRENT_CALLS,
216ce263fc8SMatthias Ringwald     HFP_CMD_RESPONSE_AND_HOLD_QUERY,
217ce263fc8SMatthias Ringwald     HFP_CMD_RESPONSE_AND_HOLD_COMMAND,
218667ec068SMatthias Ringwald     HFP_CMD_RESPONSE_AND_HOLD_STATUS,
219ce263fc8SMatthias Ringwald     HFP_CMD_HF_INDICATOR_STATUS
2203deb3ec6SMatthias Ringwald } hfp_command_t;
2213deb3ec6SMatthias Ringwald 
222aa4dd815SMatthias Ringwald 
2233deb3ec6SMatthias Ringwald typedef enum {
2243deb3ec6SMatthias Ringwald     HFP_CME_ERROR_AG_FAILURE = 0,
2253deb3ec6SMatthias Ringwald     HFP_CME_ERROR_NO_CONNECTION_TO_PHONE,
2263deb3ec6SMatthias Ringwald     HFP_CME_ERROR_2,
2273deb3ec6SMatthias Ringwald     HFP_CME_ERROR_OPERATION_NOT_ALLOWED,
2283deb3ec6SMatthias Ringwald     HFP_CME_ERROR_OPERATION_NOT_SUPPORTED,
2293deb3ec6SMatthias Ringwald     HFP_CME_ERROR_PH_SIM_PIN_REQUIRED,
2303deb3ec6SMatthias Ringwald     HFP_CME_ERROR_6,
2313deb3ec6SMatthias Ringwald     HFP_CME_ERROR_7,
2323deb3ec6SMatthias Ringwald     HFP_CME_ERROR_8,
2333deb3ec6SMatthias Ringwald     HFP_CME_ERROR_9,
2343deb3ec6SMatthias Ringwald     HFP_CME_ERROR_SIM_NOT_INSERTED,
2353deb3ec6SMatthias Ringwald     HFP_CME_ERROR_SIM_PIN_REQUIRED,
2363deb3ec6SMatthias Ringwald     HFP_CME_ERROR_SIM_PUK_REQUIRED,
2373deb3ec6SMatthias Ringwald     HFP_CME_ERROR_SIM_FAILURE,
2383deb3ec6SMatthias Ringwald     HFP_CME_ERROR_SIM_BUSY,
2393deb3ec6SMatthias Ringwald     HFP_CME_ERROR_15,
2403deb3ec6SMatthias Ringwald     HFP_CME_ERROR_INCORRECT_PASSWORD,
2413deb3ec6SMatthias Ringwald     HFP_CME_ERROR_SIM_PIN2_REQUIRED,
2423deb3ec6SMatthias Ringwald     HFP_CME_ERROR_SIM_PUK2_REQUIRED,
2433deb3ec6SMatthias Ringwald     HFP_CME_ERROR_19,
2443deb3ec6SMatthias Ringwald     HFP_CME_ERROR_MEMORY_FULL,
2453deb3ec6SMatthias Ringwald     HFP_CME_ERROR_INVALID_INDEX,
2463deb3ec6SMatthias Ringwald     HFP_CME_ERROR_22,
2473deb3ec6SMatthias Ringwald     HFP_CME_ERROR_MEMORY_FAILURE,
2483deb3ec6SMatthias Ringwald     HFP_CME_ERROR_TEXT_STRING_TOO_LONG,
2493deb3ec6SMatthias Ringwald     HFP_CME_ERROR_INVALID_CHARACTERS_IN_TEXT_STRING,
2503deb3ec6SMatthias Ringwald     HFP_CME_ERROR_DIAL_STRING_TOO_LONG,
2513deb3ec6SMatthias Ringwald     HFP_CME_ERROR_INVALID_CHARACTERS_IN_DIAL_STRING,
2523deb3ec6SMatthias Ringwald     HFP_CME_ERROR_28,
2533deb3ec6SMatthias Ringwald     HFP_CME_ERROR_29,
2543deb3ec6SMatthias Ringwald     HFP_CME_ERROR_NO_NETWORK_SERVICE,
2553deb3ec6SMatthias Ringwald     HFP_CME_ERROR_NETWORK_TIMEOUT,
2563deb3ec6SMatthias Ringwald     HFP_CME_ERROR_NETWORK_NOT_ALLOWED_EMERGENCY_CALLS_ONLY
2573deb3ec6SMatthias Ringwald } hfp_cme_error_t;
2583deb3ec6SMatthias Ringwald 
2593deb3ec6SMatthias Ringwald typedef enum {
2603deb3ec6SMatthias Ringwald     HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS = 0,
2613deb3ec6SMatthias Ringwald     HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT
2623deb3ec6SMatthias Ringwald } hfp_call_status_t;
2633deb3ec6SMatthias Ringwald 
2643deb3ec6SMatthias Ringwald typedef enum {
2653deb3ec6SMatthias Ringwald     HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS = 0,
2663deb3ec6SMatthias Ringwald     HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS,
2673deb3ec6SMatthias Ringwald     HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_DIALING_STATE,
2683deb3ec6SMatthias Ringwald     HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_ALERTING_STATE
2693deb3ec6SMatthias Ringwald } hfp_callsetup_status_t;
2703deb3ec6SMatthias Ringwald 
2713deb3ec6SMatthias Ringwald typedef enum {
272aa4dd815SMatthias Ringwald     HFP_CALLHELD_STATUS_NO_CALLS_HELD = 0,
273aa4dd815SMatthias Ringwald     HFP_CALLHELD_STATUS_CALL_ON_HOLD_OR_SWAPPED,
274aa4dd815SMatthias Ringwald     HFP_CALLHELD_STATUS_CALL_ON_HOLD_AND_NO_ACTIVE_CALLS
2753deb3ec6SMatthias Ringwald } hfp_callheld_status_t;
2763deb3ec6SMatthias Ringwald 
277d210d9c4SMatthias Ringwald 
2783deb3ec6SMatthias Ringwald typedef enum {
279aa4dd815SMatthias Ringwald     HFP_AG_INCOMING_CALL,
280aa4dd815SMatthias Ringwald     HFP_AG_INCOMING_CALL_ACCEPTED_BY_AG,
281aa4dd815SMatthias Ringwald     HFP_AG_INCOMING_CALL_ACCEPTED_BY_HF,
282aa4dd815SMatthias Ringwald     HFP_AG_AUDIO_CONNECTION_ESTABLISHED,
283fe899794SMatthias Ringwald     HFP_AG_OUTGOING_CALL_INITIATED_BY_AG,
2849ff73f41SMatthias Ringwald     HFP_AG_OUTGOING_CALL_INITIATED_BY_HF,
285aa4dd815SMatthias Ringwald     HFP_AG_OUTGOING_CALL_REJECTED,
286aa4dd815SMatthias Ringwald     HFP_AG_OUTGOING_CALL_ACCEPTED,
287aa4dd815SMatthias Ringwald     HFP_AG_OUTGOING_CALL_RINGING,
288aa4dd815SMatthias Ringwald     HFP_AG_OUTGOING_CALL_ESTABLISHED,
289aa4dd815SMatthias Ringwald     HFP_AG_OUTGOING_REDIAL_INITIATED,
290ce263fc8SMatthias Ringwald     HFP_AG_HELD_CALL_JOINED_BY_AG,
291aa4dd815SMatthias Ringwald     HFP_AG_TERMINATE_CALL_BY_AG,
292aa4dd815SMatthias Ringwald     HFP_AG_TERMINATE_CALL_BY_HF,
293aa4dd815SMatthias Ringwald     HFP_AG_CALL_DROPPED,
294ce263fc8SMatthias Ringwald     HFP_AG_RESPONSE_AND_HOLD_ACCEPT_INCOMING_CALL_BY_AG,
295ce263fc8SMatthias Ringwald     HFP_AG_RESPONSE_AND_HOLD_ACCEPT_HELD_CALL_BY_AG,
296ce263fc8SMatthias Ringwald     HFP_AG_RESPONSE_AND_HOLD_REJECT_HELD_CALL_BY_AG,
297ce263fc8SMatthias Ringwald     HFP_AG_RESPONSE_AND_HOLD_ACCEPT_INCOMING_CALL_BY_HF,
298ce263fc8SMatthias Ringwald     HFP_AG_RESPONSE_AND_HOLD_ACCEPT_HELD_CALL_BY_HF,
299d210d9c4SMatthias Ringwald     HFP_AG_RESPONSE_AND_HOLD_REJECT_HELD_CALL_BY_HF,
300d210d9c4SMatthias Ringwald     HFP_AG_CALL_HOLD_USER_BUSY,
301d210d9c4SMatthias Ringwald     HFP_AG_CALL_HOLD_RELEASE_ACTIVE_ACCEPT_HELD_OR_WAITING_CALL,
302d210d9c4SMatthias Ringwald     HFP_AG_CALL_HOLD_PARK_ACTIVE_ACCEPT_HELD_OR_WAITING_CALL,
303d210d9c4SMatthias Ringwald     HFP_AG_CALL_HOLD_ADD_HELD_CALL,
304d0c20769SMatthias Ringwald     HFP_AG_CALL_HOLD_EXIT_AND_JOIN_CALLS,
305d0c20769SMatthias Ringwald     HFP_AG_SET_CLIP
306aa4dd815SMatthias Ringwald } hfp_ag_call_event_t;
307aa4dd815SMatthias Ringwald 
308aa4dd815SMatthias Ringwald 
309aa4dd815SMatthias Ringwald typedef enum {
3103deb3ec6SMatthias Ringwald     HFP_PARSER_CMD_HEADER = 0,
3113deb3ec6SMatthias Ringwald     HFP_PARSER_CMD_SEQUENCE,
3123deb3ec6SMatthias Ringwald     HFP_PARSER_SECOND_ITEM,
3133deb3ec6SMatthias Ringwald     HFP_PARSER_THIRD_ITEM
3143deb3ec6SMatthias Ringwald } hfp_parser_state_t;
3153deb3ec6SMatthias Ringwald 
3169cc9ffe4SMilanka Ringwald typedef enum {
31745796ff1SMilanka Ringwald     HFP_VOICE_RECOGNITION_STATE_AG_READY = 0,
31845796ff1SMilanka Ringwald     HFP_VOICE_RECOGNITION_STATE_AG_READY_TO_ACCEPT_AUDIO_INPUT = 1,
3199cc9ffe4SMilanka Ringwald     HFP_VOICE_RECOGNITION_STATE_AG_IS_SENDING_AUDIO_TO_HF = 2,
3209cc9ffe4SMilanka Ringwald     HFP_VOICE_RECOGNITION_STATE_AG_IS_PROCESSING_AUDIO_INPUT = 4
3219cc9ffe4SMilanka Ringwald } hfp_voice_recognition_state_t;
3229cc9ffe4SMilanka Ringwald 
3239cc9ffe4SMilanka Ringwald typedef enum {
3249cc9ffe4SMilanka Ringwald     HFP_TEXT_TYPE_RECOGNISED_FROM_HF_AUDIO = 0,
3259cc9ffe4SMilanka Ringwald     HFP_TEXT_TYPE_MESSAGE_FROM_AG,
3269cc9ffe4SMilanka Ringwald     HFP_TEXT_TYPE_QUESTION_FROM_AG,
3279cc9ffe4SMilanka Ringwald     HFP_TEXT_TYPE_ERROR_FROM_AG
3289cc9ffe4SMilanka Ringwald } hfp_text_type_t;
3299cc9ffe4SMilanka Ringwald 
3309cc9ffe4SMilanka Ringwald typedef enum {
331db3cdbd4SMilanka Ringwald     HFP_TEXT_OPERATION_NEW_TEXT = 1,
332db3cdbd4SMilanka Ringwald     HFP_TEXT_OPERATION_REPLACE,
333db3cdbd4SMilanka Ringwald     HFP_TEXT_OPERATION_APPEND
334db3cdbd4SMilanka Ringwald } hfp_text_operation_t;
3353deb3ec6SMatthias Ringwald 
3363deb3ec6SMatthias Ringwald typedef enum {
3373deb3ec6SMatthias Ringwald     HFP_IDLE = 0, //0
3383deb3ec6SMatthias Ringwald     HFP_SDP_QUERY_RFCOMM_CHANNEL,
3391d9c9c90SMilanka Ringwald     HFP_W2_SEND_SDP_QUERY,
340a0ffb263SMatthias Ringwald     HFP_W4_SDP_QUERY_COMPLETE,
3413deb3ec6SMatthias Ringwald     HFP_W4_RFCOMM_CONNECTED,
3423deb3ec6SMatthias Ringwald 
3431d9c9c90SMilanka Ringwald     HFP_EXCHANGE_SUPPORTED_FEATURES,   // 5
3441d9c9c90SMilanka Ringwald     HFP_W4_EXCHANGE_SUPPORTED_FEATURES,
3453deb3ec6SMatthias Ringwald 
3463deb3ec6SMatthias Ringwald     HFP_NOTIFY_ON_CODECS,
3473deb3ec6SMatthias Ringwald     HFP_W4_NOTIFY_ON_CODECS,
3483deb3ec6SMatthias Ringwald 
3493deb3ec6SMatthias Ringwald     HFP_RETRIEVE_INDICATORS,
3501d9c9c90SMilanka Ringwald     HFP_W4_RETRIEVE_INDICATORS,        // 10
3513deb3ec6SMatthias Ringwald 
3521d9c9c90SMilanka Ringwald     HFP_RETRIEVE_INDICATORS_STATUS,
3533deb3ec6SMatthias Ringwald     HFP_W4_RETRIEVE_INDICATORS_STATUS,
3543deb3ec6SMatthias Ringwald 
3553deb3ec6SMatthias Ringwald     HFP_ENABLE_INDICATORS_STATUS_UPDATE,
3563deb3ec6SMatthias Ringwald     HFP_W4_ENABLE_INDICATORS_STATUS_UPDATE,
3573deb3ec6SMatthias Ringwald 
3581d9c9c90SMilanka Ringwald     HFP_RETRIEVE_CAN_HOLD_CALL,        // 15
3591d9c9c90SMilanka Ringwald     HFP_W4_RETRIEVE_CAN_HOLD_CALL,
3603deb3ec6SMatthias Ringwald 
3613deb3ec6SMatthias Ringwald     HFP_LIST_GENERIC_STATUS_INDICATORS,
3623deb3ec6SMatthias Ringwald     HFP_W4_LIST_GENERIC_STATUS_INDICATORS,
3633deb3ec6SMatthias Ringwald 
3643deb3ec6SMatthias Ringwald     HFP_RETRIEVE_GENERIC_STATUS_INDICATORS,
3651d9c9c90SMilanka Ringwald     HFP_W4_RETRIEVE_GENERIC_STATUS_INDICATORS,  //20
3663deb3ec6SMatthias Ringwald 
3671d9c9c90SMilanka Ringwald     HFP_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS,
3683deb3ec6SMatthias Ringwald     HFP_W4_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS,
3693deb3ec6SMatthias Ringwald 
370aa4dd815SMatthias Ringwald     HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED,
3713deb3ec6SMatthias Ringwald 
372aa4dd815SMatthias Ringwald     HFP_W2_CONNECT_SCO,
373aa4dd815SMatthias Ringwald     HFP_W4_SCO_CONNECTED,
3743deb3ec6SMatthias Ringwald 
3753deb3ec6SMatthias Ringwald     HFP_AUDIO_CONNECTION_ESTABLISHED,
3763deb3ec6SMatthias Ringwald 
377be55a11dSMilanka Ringwald 
3783deb3ec6SMatthias Ringwald     HFP_W2_DISCONNECT_SCO,
379aa4dd815SMatthias Ringwald     HFP_W4_SCO_DISCONNECTED,
38048e6eeeeSMatthias Ringwald     HFP_W4_SCO_DISCONNECTED_TO_SHUTDOWN,
38148e6eeeeSMatthias Ringwald     HFP_W4_WBS_SHUTDOWN,
3823deb3ec6SMatthias Ringwald 
3833deb3ec6SMatthias Ringwald     HFP_W2_DISCONNECT_RFCOMM,
3843deb3ec6SMatthias Ringwald     HFP_W4_RFCOMM_DISCONNECTED,
3853deb3ec6SMatthias Ringwald     HFP_W4_RFCOMM_DISCONNECTED_AND_RESTART,
3863deb3ec6SMatthias Ringwald     HFP_W4_CONNECTION_ESTABLISHED_TO_SHUTDOWN
3873deb3ec6SMatthias Ringwald } hfp_state_t;
3883deb3ec6SMatthias Ringwald 
389be55a11dSMilanka Ringwald 
390be55a11dSMilanka Ringwald typedef enum {
391be55a11dSMilanka Ringwald     HFP_VRA_VOICE_RECOGNITION_OFF,
392be55a11dSMilanka Ringwald 
393be55a11dSMilanka Ringwald     HFP_VRA_W4_VOICE_RECOGNITION_OFF,
394be55a11dSMilanka Ringwald     HFP_VRA_W4_VOICE_RECOGNITION_ACTIVATED,
395be55a11dSMilanka Ringwald     HFP_VRA_VOICE_RECOGNITION_ACTIVATED,
396be55a11dSMilanka Ringwald 
397be55a11dSMilanka Ringwald     HFP_VRA_W4_ENHANCED_VOICE_RECOGNITION_OFF,
398be55a11dSMilanka Ringwald     HFP_VRA_W4_ENHANCED_VOICE_RECOGNITION_ACTIVATED,
39945796ff1SMilanka Ringwald     HFP_VRA_W4_ENHANCED_VOICE_RECOGNITION_STATUS,
40045796ff1SMilanka Ringwald     HFP_VRA_W4_ENHANCED_VOICE_RECOGNITION_MSG,
401be55a11dSMilanka Ringwald     HFP_VRA_W4_ENHANCED_VOICE_RECOGNITION_NEW_SESSION,
402be55a11dSMilanka Ringwald     HFP_VRA_ENHANCED_VOICE_RECOGNITION_ACTIVATED
403db3cdbd4SMilanka Ringwald } hfp_voice_recognition_activation_status_t;
404be55a11dSMilanka Ringwald 
40545796ff1SMilanka Ringwald typedef struct {
40645796ff1SMilanka Ringwald     uint16_t text_id;
40745796ff1SMilanka Ringwald     hfp_text_type_t text_type;
40845796ff1SMilanka Ringwald     hfp_text_operation_t text_operation;
40945796ff1SMilanka Ringwald     uint8_t * text;
41045796ff1SMilanka Ringwald } hfp_voice_recognition_message_t;
41145796ff1SMilanka Ringwald 
412aa4dd815SMatthias Ringwald typedef enum {
413aa4dd815SMatthias Ringwald     HFP_CODECS_IDLE,
414aa4dd815SMatthias Ringwald     HFP_CODECS_RECEIVED_LIST,
415aa4dd815SMatthias Ringwald     HFP_CODECS_RECEIVED_TRIGGER_CODEC_EXCHANGE,
416aa4dd815SMatthias Ringwald     HFP_CODECS_W4_AG_COMMON_CODEC,
417aa4dd815SMatthias Ringwald     HFP_CODECS_AG_SENT_COMMON_CODEC,
418aa4dd815SMatthias Ringwald     HFP_CODECS_AG_RESEND_COMMON_CODEC,
419ce263fc8SMatthias Ringwald     HFP_CODECS_HF_CONFIRMED_CODEC,
420aa4dd815SMatthias Ringwald     HFP_CODECS_EXCHANGED,
421aa4dd815SMatthias Ringwald     HFP_CODECS_ERROR
422aa4dd815SMatthias Ringwald } hfp_codecs_state_t;
423aa4dd815SMatthias Ringwald 
424aa4dd815SMatthias Ringwald typedef enum {
425aa4dd815SMatthias Ringwald     HFP_CALL_IDLE,
426aa4dd815SMatthias Ringwald     HFP_CALL_TRIGGER_AUDIO_CONNECTION,
427aa4dd815SMatthias Ringwald     HFP_CALL_W4_AUDIO_CONNECTION_FOR_IN_BAND_RING,
428aa4dd815SMatthias Ringwald     HFP_CALL_RINGING,
429aa4dd815SMatthias Ringwald     HFP_CALL_W4_AUDIO_CONNECTION_FOR_ACTIVE,
430aa4dd815SMatthias Ringwald     HFP_CALL_ACTIVE,
431aa4dd815SMatthias Ringwald     HFP_CALL_W2_SEND_CALL_WAITING,
432aa4dd815SMatthias Ringwald     HFP_CALL_W4_CHLD,
433aa4dd815SMatthias Ringwald     HFP_CALL_OUTGOING_INITIATED,
434aa4dd815SMatthias Ringwald     HFP_CALL_OUTGOING_DIALING,
435aa4dd815SMatthias Ringwald     HFP_CALL_OUTGOING_RINGING
436aa4dd815SMatthias Ringwald } hfp_call_state_t;
437aa4dd815SMatthias Ringwald 
438aa4dd815SMatthias Ringwald typedef enum{
439ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_DIR_OUTGOING,
440ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_DIR_INCOMING
441ce263fc8SMatthias Ringwald } hfp_enhanced_call_dir_t;
442ce263fc8SMatthias Ringwald 
443ce263fc8SMatthias Ringwald typedef enum{
444ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_STATUS_ACTIVE,
445ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_STATUS_HELD,
446ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_STATUS_OUTGOING_DIALING,
447ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_STATUS_OUTGOING_ALERTING,
448ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_STATUS_INCOMING,
449ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_STATUS_INCOMING_WAITING,
450ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_STATUS_CALL_HELD_BY_RESPONSE_AND_HOLD
451ce263fc8SMatthias Ringwald } hfp_enhanced_call_status_t;
452ce263fc8SMatthias Ringwald 
453ce263fc8SMatthias Ringwald typedef enum{
454ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_MODE_VOICE,
455ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_MODE_DATA,
456ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_MODE_FAX
457ce263fc8SMatthias Ringwald } hfp_enhanced_call_mode_t;
458ce263fc8SMatthias Ringwald 
459ce263fc8SMatthias Ringwald typedef enum{
460ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_MPTY_NOT_A_CONFERENCE_CALL,
461ce263fc8SMatthias Ringwald     HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL
462ce263fc8SMatthias Ringwald } hfp_enhanced_call_mpty_t;
463ce263fc8SMatthias Ringwald 
464ce263fc8SMatthias Ringwald typedef enum {
465ce263fc8SMatthias Ringwald     HFP_RESPONSE_AND_HOLD_INCOMING_ON_HOLD = 0,
466ce263fc8SMatthias Ringwald     HFP_RESPONSE_AND_HOLD_HELD_INCOMING_ACCEPTED,
467ce263fc8SMatthias Ringwald     HFP_RESPONSE_AND_HOLD_HELD_INCOMING_REJECTED
468ce263fc8SMatthias Ringwald } hfp_response_and_hold_state_t;
469ce263fc8SMatthias Ringwald 
470ce263fc8SMatthias Ringwald typedef enum {
471ce263fc8SMatthias Ringwald     HFP_HF_QUERY_OPERATOR_FORMAT_NOT_SET = 0,
472ce263fc8SMatthias Ringwald     HFP_HF_QUERY_OPERATOR_SET_FORMAT,
473ce263fc8SMatthias Ringwald     HFP_HF_QUERY_OPERATOR_W4_SET_FORMAT_OK,
474ce263fc8SMatthias Ringwald     HFP_HF_QUERY_OPERATOR_FORMAT_SET,
475ce263fc8SMatthias Ringwald     HFP_HF_QUERY_OPERATOR_SEND_QUERY,
476ce263fc8SMatthias Ringwald     HPF_HF_QUERY_OPERATOR_W4_RESULT
477ce263fc8SMatthias Ringwald } hfp_hf_query_operator_state_t;
478ce263fc8SMatthias Ringwald 
479ce263fc8SMatthias Ringwald typedef enum {
480ce263fc8SMatthias Ringwald     HFP_LINK_SETTINGS_D0 = 0,
481ce263fc8SMatthias Ringwald     HFP_LINK_SETTINGS_D1,
482ce263fc8SMatthias Ringwald     HFP_LINK_SETTINGS_S1,
483ce263fc8SMatthias Ringwald     HFP_LINK_SETTINGS_S2,
484ce263fc8SMatthias Ringwald     HFP_LINK_SETTINGS_S3,
485ce263fc8SMatthias Ringwald     HFP_LINK_SETTINGS_S4,
486ce263fc8SMatthias Ringwald     HFP_LINK_SETTINGS_T1,
487b5c379c1SMatthias Ringwald     HFP_LINK_SETTINGS_T2,
488b5c379c1SMatthias Ringwald     HFP_LINK_SETTINGS_NONE,
489b5c379c1SMatthias Ringwald } hfp_link_settings_t;
490ce263fc8SMatthias Ringwald 
491ce263fc8SMatthias Ringwald typedef enum{
492aa4dd815SMatthias Ringwald     HFP_NONE_SM,
493aa4dd815SMatthias Ringwald     HFP_SLC_SM,
494aa4dd815SMatthias Ringwald     HFP_SLC_QUERIES_SM,
495aa4dd815SMatthias Ringwald     HFP_CODECS_CONNECTION_SM,
496aa4dd815SMatthias Ringwald     HFP_AUDIO_CONNECTION_SM,
497aa4dd815SMatthias Ringwald     HFP_CALL_SM
498aa4dd815SMatthias Ringwald } hfp_state_machine_t;
499aa4dd815SMatthias Ringwald 
5003deb3ec6SMatthias Ringwald typedef struct{
5013deb3ec6SMatthias Ringwald     uint16_t uuid;
5023deb3ec6SMatthias Ringwald     uint8_t state; // enabled
5033deb3ec6SMatthias Ringwald } hfp_generic_status_indicator_t;
5043deb3ec6SMatthias Ringwald 
5053deb3ec6SMatthias Ringwald typedef struct{
5063deb3ec6SMatthias Ringwald     uint8_t index;
5073deb3ec6SMatthias Ringwald     char name[HFP_MAX_INDICATOR_DESC_SIZE];
5083deb3ec6SMatthias Ringwald     uint8_t min_range;
5093deb3ec6SMatthias Ringwald     uint8_t max_range;
5103deb3ec6SMatthias Ringwald     uint8_t status;
5113deb3ec6SMatthias Ringwald     uint8_t mandatory;
5123deb3ec6SMatthias Ringwald     uint8_t enabled;
5133deb3ec6SMatthias Ringwald     uint8_t status_changed;
5143deb3ec6SMatthias Ringwald } hfp_ag_indicator_t;
5153deb3ec6SMatthias Ringwald 
5163deb3ec6SMatthias Ringwald typedef struct{
51789425bfcSMilanka Ringwald     char name[HFP_CALL_SERVICE_SIZE];
5183deb3ec6SMatthias Ringwald } hfp_call_service_t;
5193deb3ec6SMatthias Ringwald 
5203deb3ec6SMatthias Ringwald 
5213deb3ec6SMatthias Ringwald typedef struct{
5223deb3ec6SMatthias Ringwald     uint8_t mode;
5233deb3ec6SMatthias Ringwald     uint8_t format;
52489425bfcSMilanka Ringwald     char name[HFP_MAX_NETWORK_OPERATOR_NAME_SIZE]; // enabled
5253deb3ec6SMatthias Ringwald } hfp_network_opearator_t;
5263deb3ec6SMatthias Ringwald 
5273deb3ec6SMatthias Ringwald 
5283deb3ec6SMatthias Ringwald typedef struct hfp_connection {
529665d90f2SMatthias Ringwald     btstack_linked_item_t    item;
5303deb3ec6SMatthias Ringwald 
531323d3000SMatthias Ringwald     // local role: HF or AG
532323d3000SMatthias Ringwald     hfp_role_t local_role;
533323d3000SMatthias Ringwald 
5343deb3ec6SMatthias Ringwald     bd_addr_t remote_addr;
535fc64f94aSMatthias Ringwald     hci_con_handle_t acl_handle;
536fc64f94aSMatthias Ringwald     hci_con_handle_t sco_handle;
5373deb3ec6SMatthias Ringwald     uint16_t rfcomm_channel_nr;
5383deb3ec6SMatthias Ringwald     uint16_t rfcomm_cid;
5393deb3ec6SMatthias Ringwald 
540aa4dd815SMatthias Ringwald     hfp_state_machine_t state_machine;
541aa4dd815SMatthias Ringwald     hfp_call_state_t call_state;
5423deb3ec6SMatthias Ringwald     hfp_state_t state;
543aa4dd815SMatthias Ringwald     hfp_codecs_state_t codecs_state;
544aa4dd815SMatthias Ringwald 
545323d3000SMatthias Ringwald     // needed for reestablishing connection - service uuid of the remote
5463deb3ec6SMatthias Ringwald     uint16_t service_uuid;
5473deb3ec6SMatthias Ringwald 
5483deb3ec6SMatthias Ringwald     // used during service level connection establishment
5493deb3ec6SMatthias Ringwald     hfp_command_t command;
5503deb3ec6SMatthias Ringwald     hfp_parser_state_t parser_state;
5513deb3ec6SMatthias Ringwald     int      parser_item_index;
552ce263fc8SMatthias Ringwald     int      parser_indicator_index;
5530222a807SMatthias Ringwald     uint32_t parser_indicator_value;
5541dddc4f4SMatthias Ringwald     bool     parser_quoted;
555db3cdbd4SMilanka Ringwald     uint8_t  line_buffer[HFP_MAX_VR_TEXT_SIZE];
5563deb3ec6SMatthias Ringwald     int      line_size;
5573deb3ec6SMatthias Ringwald 
5583deb3ec6SMatthias Ringwald     uint32_t remote_supported_features;
5593deb3ec6SMatthias Ringwald 
56025789943SMilanka Ringwald     uint16_t remote_codecs_nr;
56125789943SMilanka Ringwald     uint8_t  remote_codecs[HFP_MAX_NUM_CODECS];
562667ec068SMatthias Ringwald 
56325789943SMilanka Ringwald     uint16_t ag_indicators_nr;
56425789943SMilanka Ringwald     hfp_ag_indicator_t ag_indicators[HFP_MAX_NUM_INDICATORS];
565667ec068SMatthias Ringwald     uint32_t ag_indicators_status_update_bitmap;
566667ec068SMatthias Ringwald     uint8_t  enable_status_update_for_ag_indicators;
567667ec068SMatthias Ringwald 
56825789943SMilanka Ringwald     uint16_t remote_call_services_index;
56925789943SMilanka Ringwald     hfp_call_service_t remote_call_services[HFP_MAX_NUM_CALL_SERVICES];
5703deb3ec6SMatthias Ringwald 
5713deb3ec6SMatthias Ringwald     // TODO: use bitmap.
57225789943SMilanka Ringwald     uint16_t generic_status_indicators_nr;
573667ec068SMatthias Ringwald     uint32_t generic_status_update_bitmap;
57425789943SMilanka Ringwald     hfp_generic_status_indicator_t generic_status_indicators[HFP_MAX_NUM_INDICATORS];
5753deb3ec6SMatthias Ringwald 
5763deb3ec6SMatthias Ringwald     hfp_network_opearator_t network_operator;
5773deb3ec6SMatthias Ringwald 
5783deb3ec6SMatthias Ringwald     // Retrieved during service level connection establishment, not used yet
5793deb3ec6SMatthias Ringwald     uint8_t  negotiated_codec;
5803deb3ec6SMatthias Ringwald 
581aa4dd815SMatthias Ringwald     // HF -> AG configuration
582aa4dd815SMatthias Ringwald     uint8_t clip_enabled;
583aa4dd815SMatthias Ringwald     uint8_t call_waiting_notification_enabled;
584aa4dd815SMatthias Ringwald 
5853deb3ec6SMatthias Ringwald     // TODO: put these bit flags in a bitmap
586aa4dd815SMatthias Ringwald     uint8_t ok_pending;
587aa4dd815SMatthias Ringwald     // uint8_t send_ok;
5883deb3ec6SMatthias Ringwald     uint8_t send_error;
5893deb3ec6SMatthias Ringwald 
590dd533208SMatthias Ringwald     bool found_equal_sign;
591ce263fc8SMatthias Ringwald     uint8_t ignore_value;
5923deb3ec6SMatthias Ringwald 
5933deb3ec6SMatthias Ringwald     uint8_t change_status_update_for_individual_ag_indicators;
5943deb3ec6SMatthias Ringwald     uint8_t operator_name_changed;
5953deb3ec6SMatthias Ringwald 
5963deb3ec6SMatthias Ringwald     uint8_t enable_extended_audio_gateway_error_report;
597a0ffb263SMatthias Ringwald     uint8_t extended_audio_gateway_error_value;
5983deb3ec6SMatthias Ringwald     uint8_t extended_audio_gateway_error;
5993deb3ec6SMatthias Ringwald 
6003deb3ec6SMatthias Ringwald     // establish codecs connection
6013deb3ec6SMatthias Ringwald     uint8_t suggested_codec;
6023deb3ec6SMatthias Ringwald     uint8_t codec_confirmed;
603bc1b1537SMilanka Ringwald     uint8_t sco_for_msbc_failed;
6042ee45eb2SMilanka Ringwald     uint8_t trigger_codec_exchange;
605cb81d35dSMatthias Ringwald 
606cb81d35dSMatthias Ringwald     // establish audio connection
607cb81d35dSMatthias Ringwald     hfp_link_settings_t link_setting;
608cb81d35dSMatthias Ringwald     uint8_t accept_sco; // 1 = SCO, 2 = eSCO
609cb81d35dSMatthias Ringwald 
6103deb3ec6SMatthias Ringwald     uint8_t establish_audio_connection;
6113deb3ec6SMatthias Ringwald     uint8_t release_audio_connection;
6128439fb24SMilanka Ringwald     uint8_t release_slc_connection;
6133deb3ec6SMatthias Ringwald 
614ec820d77SMatthias Ringwald     btstack_timer_source_t hfp_timeout;
615aa4dd815SMatthias Ringwald 
616aa4dd815SMatthias Ringwald     uint8_t microphone_gain;
617aa4dd815SMatthias Ringwald     uint8_t send_microphone_gain;
618aa4dd815SMatthias Ringwald 
619aa4dd815SMatthias Ringwald     uint8_t speaker_gain;
620aa4dd815SMatthias Ringwald     uint8_t send_speaker_gain;
621aa4dd815SMatthias Ringwald 
622aa4dd815SMatthias Ringwald     uint8_t send_phone_number_for_voice_tag;
623ce263fc8SMatthias Ringwald     uint8_t send_ag_status_indicators;
624ad902e3dSMatthias Ringwald     uint8_t send_ag_indicators_segment;
625a5bdcda8SMatthias Ringwald     uint8_t send_response_and_hold_status;  // 0 - don't send. BRTH:0 == 1, ..
626ce263fc8SMatthias Ringwald 
627ce263fc8SMatthias Ringwald     // AG only
628ce263fc8SMatthias Ringwald     uint8_t change_in_band_ring_tone_setting;
629ce263fc8SMatthias Ringwald     uint8_t ag_ring;
630ce263fc8SMatthias Ringwald     uint8_t ag_send_clip;
631ce263fc8SMatthias Ringwald     uint8_t ag_echo_and_noise_reduction;
632ce263fc8SMatthias Ringwald     uint8_t ag_activate_voice_recognition;
633a0ffb263SMatthias Ringwald     uint8_t ag_notify_incoming_call_waiting;
634ce263fc8SMatthias Ringwald     uint8_t send_subscriber_number;
635ce263fc8SMatthias Ringwald     uint8_t next_subscriber_number_to_send;
6360222a807SMatthias Ringwald     uint8_t ag_call_hold_action;
6370222a807SMatthias Ringwald     uint8_t ag_response_and_hold_action;
6380222a807SMatthias Ringwald     uint8_t ag_dtmf_code;
639245852b7SMilanka Ringwald     bool    ag_send_no_carrier;
640ce263fc8SMatthias Ringwald 
641ce263fc8SMatthias Ringwald     int send_status_of_current_calls;
6429cae807eSMatthias Ringwald     int next_call_index;
643ce263fc8SMatthias Ringwald 
644ce263fc8SMatthias Ringwald     // HF only
645ce263fc8SMatthias Ringwald     hfp_hf_query_operator_state_t hf_query_operator_state;
646ce263fc8SMatthias Ringwald     uint8_t hf_answer_incoming_call;
647ce263fc8SMatthias Ringwald     uint8_t hf_initiate_outgoing_call;
648ce263fc8SMatthias Ringwald     uint8_t hf_initiate_memory_dialing;
649ce263fc8SMatthias Ringwald     uint8_t hf_initiate_redial_last_number;
6501cc65c4fSMatthias Ringwald     bool    hf_send_codec_confirm;
6511cc65c4fSMatthias Ringwald     bool    hf_send_supported_codecs;
6521cc65c4fSMatthias Ringwald 
653a0ffb263SMatthias Ringwald     int memory_id;
654ce263fc8SMatthias Ringwald 
655ce263fc8SMatthias Ringwald     uint8_t hf_send_clip_enable;
656ce263fc8SMatthias Ringwald     uint8_t hf_send_chup;
657ce263fc8SMatthias Ringwald     uint8_t hf_send_chld_0;
658ce263fc8SMatthias Ringwald     uint8_t hf_send_chld_1;
659ce263fc8SMatthias Ringwald     uint8_t hf_send_chld_2;
660ce263fc8SMatthias Ringwald     uint8_t hf_send_chld_3;
661ce263fc8SMatthias Ringwald     uint8_t hf_send_chld_4;
662667ec068SMatthias Ringwald     uint8_t hf_send_chld_x;
663667ec068SMatthias Ringwald     uint8_t hf_send_chld_x_index;
664ce263fc8SMatthias Ringwald     char    hf_send_dtmf_code;
665ce263fc8SMatthias Ringwald     uint8_t hf_send_binp;
666667ec068SMatthias Ringwald     uint8_t hf_send_clcc;
667667ec068SMatthias Ringwald     uint8_t hf_send_rrh;
668667ec068SMatthias Ringwald     char    hf_send_rrh_command;
669667ec068SMatthias Ringwald     uint8_t hf_send_cnum;
670667ec068SMatthias Ringwald 
671ce263fc8SMatthias Ringwald     uint8_t hf_activate_call_waiting_notification;
672ce263fc8SMatthias Ringwald     uint8_t hf_deactivate_call_waiting_notification;
673ce263fc8SMatthias Ringwald 
674ce263fc8SMatthias Ringwald     uint8_t hf_activate_calling_line_notification;
675ce263fc8SMatthias Ringwald     uint8_t hf_deactivate_calling_line_notification;
676ce263fc8SMatthias Ringwald     uint8_t hf_activate_echo_canceling_and_noise_reduction;
677ce263fc8SMatthias Ringwald     uint8_t hf_deactivate_echo_canceling_and_noise_reduction;
67856f1adacSMilanka Ringwald 
679db3cdbd4SMilanka Ringwald     hfp_voice_recognition_activation_status_t vra_status;
680be55a11dSMilanka Ringwald 
681db3cdbd4SMilanka Ringwald     hfp_voice_recognition_activation_status_t ag_vra_status;
682db3cdbd4SMilanka Ringwald     hfp_voice_recognition_state_t ag_vra_state;
68345796ff1SMilanka Ringwald 
68445796ff1SMilanka Ringwald     hfp_voice_recognition_message_t ag_msg;
685ce263fc8SMatthias Ringwald 
686667ec068SMatthias Ringwald     uint8_t clcc_idx;
687667ec068SMatthias Ringwald     uint8_t clcc_dir;
688667ec068SMatthias Ringwald     uint8_t clcc_status;
689667ec068SMatthias Ringwald     uint8_t clcc_mode;
690667ec068SMatthias Ringwald     uint8_t clcc_mpty;
691667ec068SMatthias Ringwald 
692d0c20769SMatthias Ringwald     uint8_t call_index;
693a0ffb263SMatthias Ringwald     // also used for CLCC, CCWA, CLIP if set
694ce263fc8SMatthias Ringwald     uint8_t bnip_type;       // 0 == not set
695ce263fc8SMatthias Ringwald     char    bnip_number[25]; //
696ce263fc8SMatthias Ringwald 
6973721a235SMatthias Ringwald #ifdef ENABLE_CC256X_ASSISTED_HFP
6983721a235SMatthias Ringwald     bool cc256x_send_write_codec_config;
6993721a235SMatthias Ringwald     bool cc256x_send_wbs_associate;
7003721a235SMatthias Ringwald     bool cc256x_send_wbs_disassociate;
7013721a235SMatthias Ringwald #endif
702689d4323SMatthias Ringwald #ifdef ENABLE_BCM_PCM_WBS
703689d4323SMatthias Ringwald     bool bcm_send_enable_wbs;
704689d4323SMatthias Ringwald     bool bcm_send_disable_wbs;
705689d4323SMatthias Ringwald     bool bcm_send_write_i2spcm_interface_param;
706689d4323SMatthias Ringwald #endif
7073deb3ec6SMatthias Ringwald } hfp_connection_t;
7083deb3ec6SMatthias Ringwald 
7093deb3ec6SMatthias Ringwald // UTILS_START : TODO move to utils
7103deb3ec6SMatthias Ringwald int send_str_over_rfcomm(uint16_t cid, char * command);
7113deb3ec6SMatthias Ringwald int join(char * buffer, int buffer_size, uint8_t * values, int values_nr);
7123deb3ec6SMatthias Ringwald int join_bitmap(char * buffer, int buffer_size, uint32_t values, int values_nr);
7133deb3ec6SMatthias Ringwald int get_bit(uint16_t bitmap, int position);
7143deb3ec6SMatthias Ringwald int store_bit(uint32_t bitmap, int position, uint8_t value);
7153deb3ec6SMatthias Ringwald // UTILS_END
7163deb3ec6SMatthias Ringwald 
71748e6eeeeSMatthias Ringwald void hfp_finalize_connection_context(hfp_connection_t * hfp_connection);
718f2a3f984SMilanka Ringwald void hfp_emit_sco_event(hfp_connection_t * hfp_connection, uint8_t status, hci_con_handle_t con_handle, bd_addr_t addr, uint8_t  negotiated_codec);
719f2a3f984SMilanka Ringwald 
720ca59be51SMatthias Ringwald void hfp_set_ag_callback(btstack_packet_handler_t callback);
721ca59be51SMatthias Ringwald void hfp_set_ag_rfcomm_packet_handler(btstack_packet_handler_t handler);
722f4000eebSMatthias Ringwald 
723ca59be51SMatthias Ringwald void hfp_set_hf_callback(btstack_packet_handler_t callback);
724ca59be51SMatthias Ringwald void hfp_set_hf_rfcomm_packet_handler(btstack_packet_handler_t handler);
725d68dcce1SMatthias Ringwald 
726520c92d5SMatthias Ringwald void hfp_init(void);
72720b2edb6SMatthias Ringwald void hfp_deinit(void);
728520c92d5SMatthias Ringwald 
7299b1c3b4dSMatthias 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);
730405014fbSMatthias Ringwald void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size, hfp_role_t local_role);
73127950165SMatthias Ringwald void hfp_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size, hfp_role_t local_role);
732ca59be51SMatthias Ringwald void hfp_emit_event(hfp_connection_t * hfp_connection, uint8_t event_subtype, uint8_t value);
733ca59be51SMatthias Ringwald void hfp_emit_simple_event(hfp_connection_t * hfp_connection, uint8_t event_subtype);
734ca59be51SMatthias Ringwald void hfp_emit_string_event(hfp_connection_t * hfp_connection, uint8_t event_subtype, const char * value);
735ca59be51SMatthias Ringwald void hfp_emit_slc_connection_event(hfp_connection_t * hfp_connection, uint8_t status, hci_con_handle_t con_handle, bd_addr_t addr);
736aa4dd815SMatthias Ringwald 
7373deb3ec6SMatthias Ringwald hfp_connection_t * get_hfp_connection_context_for_rfcomm_cid(uint16_t cid);
738405014fbSMatthias Ringwald hfp_connection_t * get_hfp_connection_context_for_bd_addr(bd_addr_t bd_addr, hfp_role_t hfp_role);
739405014fbSMatthias Ringwald hfp_connection_t * get_hfp_connection_context_for_sco_handle(uint16_t handle, hfp_role_t hfp_role);
740405014fbSMatthias Ringwald hfp_connection_t * get_hfp_connection_context_for_acl_handle(uint16_t handle, hfp_role_t hfp_role);
741aa4dd815SMatthias Ringwald 
7428f2a52f4SMatthias Ringwald btstack_linked_list_t * hfp_get_connections(void);
743a0ffb263SMatthias Ringwald void hfp_parse(hfp_connection_t * connection, uint8_t byte, int isHandsFree);
7443deb3ec6SMatthias Ringwald 
7453deb3ec6SMatthias Ringwald void hfp_release_service_level_connection(hfp_connection_t * connection);
746*4eb3f1d8SMilanka Ringwald /**
747*4eb3f1d8SMilanka Ringwald  * @brief Establish RFCOMM connection, and perform service level connection agreement:
748*4eb3f1d8SMilanka Ringwald  * @param bd_addr
749*4eb3f1d8SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS if successful, otherwise:
750*4eb3f1d8SMilanka Ringwald  *                  - ERROR_CODE_COMMAND_DISALLOWED if connection already exists, or
751*4eb3f1d8SMilanka Ringwald  *                  - BTSTACK_MEMORY_ALLOC_FAILED
752*4eb3f1d8SMilanka Ringwald  */
753*4eb3f1d8SMilanka Ringwald uint8_t hfp_establish_service_level_connection(bd_addr_t bd_addr, uint16_t service_uuid, hfp_role_t local_role);
754*4eb3f1d8SMilanka Ringwald 
755a0ffb263SMatthias Ringwald void hfp_reset_context_flags(hfp_connection_t * connection);
7563deb3ec6SMatthias Ringwald 
757a0ffb263SMatthias Ringwald void hfp_release_audio_connection(hfp_connection_t * connection);
7583deb3ec6SMatthias Ringwald 
759eddcd308SMatthias Ringwald void hfp_setup_synchronous_connection(hfp_connection_t * connection);
760cb81d35dSMatthias Ringwald void hfp_accept_synchronous_connection(hfp_connection_t * hfp_connection, bool incoming_eSCO);
7616a7f44bdSMilanka Ringwald int hfp_supports_codec(uint8_t codec, int codecs_nr, uint8_t * codecs);
762d715cf51SMatthias Ringwald void hfp_hf_drop_mSBC_if_eSCO_not_supported(uint8_t * codecs, uint8_t * codecs_nr);
763e453c1d9SMatthias Ringwald void hfp_init_link_settings(hfp_connection_t * hfp_connection, uint8_t eSCO_S4_supported);
764e453c1d9SMatthias Ringwald hfp_link_settings_t hfp_next_link_setting(hfp_link_settings_t current_setting, bool local_eSCO_supported, bool remote_eSCO_supported, bool eSCO_s4_supported, uint8_t negotiated_codec);
765ce263fc8SMatthias Ringwald 
7663deb3ec6SMatthias Ringwald const char * hfp_hf_feature(int index);
7673deb3ec6SMatthias Ringwald const char * hfp_ag_feature(int index);
7683deb3ec6SMatthias Ringwald 
769186dd3d2SMatthias Ringwald void hfp_log_rfcomm_message(const char * tag, uint8_t * packet, uint16_t size);
770186dd3d2SMatthias Ringwald 
7710aee97efSMilanka Ringwald const char * hfp_enhanced_call_dir2str(uint16_t index);
7720aee97efSMilanka Ringwald const char * hfp_enhanced_call_status2str(uint16_t index);
7730aee97efSMilanka Ringwald const char * hfp_enhanced_call_mode2str(uint16_t index);
7740aee97efSMilanka Ringwald const char * hfp_enhanced_call_mpty2str(uint16_t index);
7750aee97efSMilanka Ringwald 
7763721a235SMatthias Ringwald #ifdef ENABLE_CC256X_ASSISTED_HFP
7773721a235SMatthias Ringwald void hfp_cc256x_prepare_for_sco(hfp_connection_t * hfp_connection);
7783721a235SMatthias Ringwald void hfp_cc256x_write_codec_config(hfp_connection_t * hfp_connection);
7793721a235SMatthias Ringwald #endif
780689d4323SMatthias Ringwald #ifdef ENABLE_BCM_PCM_WBS
781689d4323SMatthias Ringwald void hfp_bcm_prepare_for_sco(hfp_connection_t * hfp_connection);
782689d4323SMatthias Ringwald void hfp_bcm_write_i2spcm_interface_param (hfp_connection_t * hfp_connection);
783689d4323SMatthias Ringwald #endif
7843721a235SMatthias Ringwald 
785991c26beSMatthias Ringwald /**
786352a0504SMatthias Ringwald  * @brief Set packet types for SCO connections
787991c26beSMatthias Ringwald  * @param common single packet_types: HFP_SCO_PACKET_TYPES_*
788991c26beSMatthias Ringwald  */
789991c26beSMatthias Ringwald void hfp_set_sco_packet_types(uint16_t packet_types);
790991c26beSMatthias Ringwald 
791991c26beSMatthias Ringwald /**
792352a0504SMatthias Ringwald  * @brief Get packet types for SCO connections
793991c26beSMatthias Ringwald  * @returns packet_types
794991c26beSMatthias Ringwald  */
795991c26beSMatthias Ringwald uint16_t hfp_get_sco_packet_types(void);
796991c26beSMatthias Ringwald 
7973deb3ec6SMatthias Ringwald #if defined __cplusplus
7983deb3ec6SMatthias Ringwald }
7993deb3ec6SMatthias Ringwald #endif
8003deb3ec6SMatthias Ringwald 
80180e33422SMatthias Ringwald #endif // BTSTACK_HFP_H
802