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 161f39f7f89SMatthias Ringwald // Apple Extensions 162f39f7f89SMatthias Ringwald #define HFP_APPLE_ACCESSORY_INFORMATION "+XAPL" 163f39f7f89SMatthias Ringwald #define HFP_APPLE_ACCESSORY_STATE "+IPHONEACCEV" 164f39f7f89SMatthias Ringwald #define HFP_APPLE_SIRI_STATE "+APLSIRI" 165f39f7f89SMatthias Ringwald #define HFP_APPLE_SIRI_EYES_FREE_MODE "+APLEFM" 166*959f2ebcSMatthias Ringwald #define HFP_APPLE_ACCESSORY_VERSION_LEN 16 167f39f7f89SMatthias Ringwald 1683deb3ec6SMatthias Ringwald #define HFP_OK "OK" 1693deb3ec6SMatthias Ringwald #define HFP_ERROR "ERROR" 170ce263fc8SMatthias Ringwald #define HFP_RING "RING" 1713deb3ec6SMatthias Ringwald 1723deb3ec6SMatthias Ringwald // Codecs 1733deb3ec6SMatthias Ringwald #define HFP_CODEC_CVSD 0x01 1743deb3ec6SMatthias Ringwald #define HFP_CODEC_MSBC 0x02 175fda8f1b4SMatthias Ringwald #define HFP_CODEC_LC3_SWB 0x03 1763deb3ec6SMatthias Ringwald 1773deb3ec6SMatthias Ringwald typedef enum { 178520c92d5SMatthias Ringwald HFP_ROLE_INVALID = 0, 179520c92d5SMatthias Ringwald HFP_ROLE_AG, 180323d3000SMatthias Ringwald HFP_ROLE_HF, 181323d3000SMatthias Ringwald } hfp_role_t; 182323d3000SMatthias Ringwald 183323d3000SMatthias Ringwald typedef enum { 1843deb3ec6SMatthias Ringwald HFP_CMD_NONE = 0, 1853deb3ec6SMatthias Ringwald HFP_CMD_ERROR, 186aa4dd815SMatthias Ringwald HFP_CMD_UNKNOWN, 1873deb3ec6SMatthias Ringwald HFP_CMD_OK, 188ce263fc8SMatthias Ringwald HFP_CMD_RING, 189245852b7SMilanka Ringwald HFP_CMD_SUPPORTED_FEATURES, // 5 1903deb3ec6SMatthias Ringwald HFP_CMD_AVAILABLE_CODECS, 19184a0c24eSMatthias Ringwald HFP_CMD_RETRIEVE_AG_INDICATORS_GENERIC, 192aa4dd815SMatthias Ringwald HFP_CMD_RETRIEVE_AG_INDICATORS, 193aa4dd815SMatthias Ringwald HFP_CMD_RETRIEVE_AG_INDICATORS_STATUS, 194245852b7SMilanka Ringwald HFP_CMD_ENABLE_INDICATOR_STATUS_UPDATE, // 10 1953deb3ec6SMatthias Ringwald HFP_CMD_ENABLE_INDIVIDUAL_AG_INDICATOR_STATUS_UPDATE, 1963deb3ec6SMatthias Ringwald HFP_CMD_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES, 197aa4dd815SMatthias Ringwald HFP_CMD_ENABLE_CLIP, 198a0ffb263SMatthias Ringwald HFP_CMD_AG_SENT_CLIP_INFORMATION, 199245852b7SMilanka Ringwald HFP_CMD_ENABLE_CALL_WAITING_NOTIFICATION, // 15 200a0ffb263SMatthias Ringwald HFP_CMD_AG_SENT_CALL_WAITING_NOTIFICATION_UPDATE, 201aa4dd815SMatthias Ringwald HFP_CMD_LIST_GENERIC_STATUS_INDICATORS, 202aa4dd815SMatthias Ringwald HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS, 203aa4dd815SMatthias Ringwald HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS_STATE, 204245852b7SMilanka Ringwald HFP_CMD_SET_GENERIC_STATUS_INDICATOR_STATUS, // 20 2053deb3ec6SMatthias Ringwald HFP_CMD_TRANSFER_AG_INDICATOR_STATUS, 206aa4dd815SMatthias Ringwald HFP_CMD_QUERY_OPERATOR_SELECTION_NAME, 207aa4dd815SMatthias Ringwald HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT, 2083deb3ec6SMatthias Ringwald HFP_CMD_ENABLE_EXTENDED_AUDIO_GATEWAY_ERROR, 209245852b7SMilanka Ringwald HFP_CMD_EXTENDED_AUDIO_GATEWAY_ERROR, // 25 2103deb3ec6SMatthias Ringwald HFP_CMD_TRIGGER_CODEC_CONNECTION_SETUP, 211aa4dd815SMatthias Ringwald HFP_CMD_AG_SEND_COMMON_CODEC, 2123deb3ec6SMatthias Ringwald HFP_CMD_AG_SUGGESTED_CODEC, 213aa4dd815SMatthias Ringwald HFP_CMD_HF_CONFIRMED_CODEC, 214498a8121SMilanka Ringwald HFP_CMD_CALL_ANSWERED, // 30 215aa4dd815SMatthias Ringwald HFP_CMD_CALL_HOLD, 216aa4dd815SMatthias Ringwald HFP_CMD_HANG_UP_CALL, 217aa4dd815SMatthias Ringwald HFP_CMD_CHANGE_IN_BAND_RING_TONE_SETTING, 218aa4dd815SMatthias Ringwald HFP_CMD_CALL_PHONE_NUMBER, 219498a8121SMilanka Ringwald HFP_CMD_REDIAL_LAST_NUMBER, // 35 220aa4dd815SMatthias Ringwald HFP_CMD_TURN_OFF_EC_AND_NR, 221498a8121SMilanka Ringwald HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION, // 37 222aa4dd815SMatthias Ringwald HFP_CMD_HF_ACTIVATE_VOICE_RECOGNITION, 223aa4dd815SMatthias Ringwald HFP_CMD_HF_REQUEST_PHONE_NUMBER, 224ce263fc8SMatthias Ringwald HFP_CMD_AG_SENT_PHONE_NUMBER, 225aa4dd815SMatthias Ringwald HFP_CMD_TRANSMIT_DTMF_CODES, 226aa4dd815SMatthias Ringwald HFP_CMD_SET_MICROPHONE_GAIN, 227ce263fc8SMatthias Ringwald HFP_CMD_SET_SPEAKER_GAIN, 228ce263fc8SMatthias Ringwald HFP_CMD_GET_SUBSCRIBER_NUMBER_INFORMATION, 229ce263fc8SMatthias Ringwald HFP_CMD_LIST_CURRENT_CALLS, 230ce263fc8SMatthias Ringwald HFP_CMD_RESPONSE_AND_HOLD_QUERY, 231ce263fc8SMatthias Ringwald HFP_CMD_RESPONSE_AND_HOLD_COMMAND, 232667ec068SMatthias Ringwald HFP_CMD_RESPONSE_AND_HOLD_STATUS, 23351a2ebdeSMatthias Ringwald HFP_CMD_HF_INDICATOR_STATUS, 234f39f7f89SMatthias Ringwald HFP_CMD_APPLE_ACCESSORY_INFORMATION, 235f39f7f89SMatthias Ringwald HFP_CMD_APPLE_ACCESSORY_STATE, 236f39f7f89SMatthias Ringwald HFP_CMD_APPLE_DEVICE_INFORMATION, 23751a2ebdeSMatthias Ringwald HFP_CMD_CUSTOM_MESSAGE 2383deb3ec6SMatthias Ringwald } hfp_command_t; 2393deb3ec6SMatthias Ringwald 240aa4dd815SMatthias Ringwald 2413deb3ec6SMatthias Ringwald typedef enum { 2423deb3ec6SMatthias Ringwald HFP_CME_ERROR_AG_FAILURE = 0, 2433deb3ec6SMatthias Ringwald HFP_CME_ERROR_NO_CONNECTION_TO_PHONE, 2443deb3ec6SMatthias Ringwald HFP_CME_ERROR_2, 2453deb3ec6SMatthias Ringwald HFP_CME_ERROR_OPERATION_NOT_ALLOWED, 2463deb3ec6SMatthias Ringwald HFP_CME_ERROR_OPERATION_NOT_SUPPORTED, 2473deb3ec6SMatthias Ringwald HFP_CME_ERROR_PH_SIM_PIN_REQUIRED, 2483deb3ec6SMatthias Ringwald HFP_CME_ERROR_6, 2493deb3ec6SMatthias Ringwald HFP_CME_ERROR_7, 2503deb3ec6SMatthias Ringwald HFP_CME_ERROR_8, 2513deb3ec6SMatthias Ringwald HFP_CME_ERROR_9, 2523deb3ec6SMatthias Ringwald HFP_CME_ERROR_SIM_NOT_INSERTED, 2533deb3ec6SMatthias Ringwald HFP_CME_ERROR_SIM_PIN_REQUIRED, 2543deb3ec6SMatthias Ringwald HFP_CME_ERROR_SIM_PUK_REQUIRED, 2553deb3ec6SMatthias Ringwald HFP_CME_ERROR_SIM_FAILURE, 2563deb3ec6SMatthias Ringwald HFP_CME_ERROR_SIM_BUSY, 2573deb3ec6SMatthias Ringwald HFP_CME_ERROR_15, 2583deb3ec6SMatthias Ringwald HFP_CME_ERROR_INCORRECT_PASSWORD, 2593deb3ec6SMatthias Ringwald HFP_CME_ERROR_SIM_PIN2_REQUIRED, 2603deb3ec6SMatthias Ringwald HFP_CME_ERROR_SIM_PUK2_REQUIRED, 2613deb3ec6SMatthias Ringwald HFP_CME_ERROR_19, 2623deb3ec6SMatthias Ringwald HFP_CME_ERROR_MEMORY_FULL, 2633deb3ec6SMatthias Ringwald HFP_CME_ERROR_INVALID_INDEX, 2643deb3ec6SMatthias Ringwald HFP_CME_ERROR_22, 2653deb3ec6SMatthias Ringwald HFP_CME_ERROR_MEMORY_FAILURE, 2663deb3ec6SMatthias Ringwald HFP_CME_ERROR_TEXT_STRING_TOO_LONG, 2673deb3ec6SMatthias Ringwald HFP_CME_ERROR_INVALID_CHARACTERS_IN_TEXT_STRING, 2683deb3ec6SMatthias Ringwald HFP_CME_ERROR_DIAL_STRING_TOO_LONG, 2693deb3ec6SMatthias Ringwald HFP_CME_ERROR_INVALID_CHARACTERS_IN_DIAL_STRING, 2703deb3ec6SMatthias Ringwald HFP_CME_ERROR_28, 2713deb3ec6SMatthias Ringwald HFP_CME_ERROR_29, 2723deb3ec6SMatthias Ringwald HFP_CME_ERROR_NO_NETWORK_SERVICE, 2733deb3ec6SMatthias Ringwald HFP_CME_ERROR_NETWORK_TIMEOUT, 2743deb3ec6SMatthias Ringwald HFP_CME_ERROR_NETWORK_NOT_ALLOWED_EMERGENCY_CALLS_ONLY 2753deb3ec6SMatthias Ringwald } hfp_cme_error_t; 2763deb3ec6SMatthias Ringwald 2773deb3ec6SMatthias Ringwald typedef enum { 2783deb3ec6SMatthias Ringwald HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS = 0, 2793deb3ec6SMatthias Ringwald HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT 2803deb3ec6SMatthias Ringwald } hfp_call_status_t; 2813deb3ec6SMatthias Ringwald 2823deb3ec6SMatthias Ringwald typedef enum { 2833deb3ec6SMatthias Ringwald HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS = 0, 2843deb3ec6SMatthias Ringwald HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS, 2853deb3ec6SMatthias Ringwald HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_DIALING_STATE, 2863deb3ec6SMatthias Ringwald HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_ALERTING_STATE 2873deb3ec6SMatthias Ringwald } hfp_callsetup_status_t; 2883deb3ec6SMatthias Ringwald 2893deb3ec6SMatthias Ringwald typedef enum { 290aa4dd815SMatthias Ringwald HFP_CALLHELD_STATUS_NO_CALLS_HELD = 0, 291aa4dd815SMatthias Ringwald HFP_CALLHELD_STATUS_CALL_ON_HOLD_OR_SWAPPED, 292aa4dd815SMatthias Ringwald HFP_CALLHELD_STATUS_CALL_ON_HOLD_AND_NO_ACTIVE_CALLS 2933deb3ec6SMatthias Ringwald } hfp_callheld_status_t; 2943deb3ec6SMatthias Ringwald 295d210d9c4SMatthias Ringwald 2963deb3ec6SMatthias Ringwald typedef enum { 297aa4dd815SMatthias Ringwald HFP_AG_INCOMING_CALL, 298aa4dd815SMatthias Ringwald HFP_AG_INCOMING_CALL_ACCEPTED_BY_AG, 299aa4dd815SMatthias Ringwald HFP_AG_INCOMING_CALL_ACCEPTED_BY_HF, 300aa4dd815SMatthias Ringwald HFP_AG_AUDIO_CONNECTION_ESTABLISHED, 301fe899794SMatthias Ringwald HFP_AG_OUTGOING_CALL_INITIATED_BY_AG, 3029ff73f41SMatthias Ringwald HFP_AG_OUTGOING_CALL_INITIATED_BY_HF, 303aa4dd815SMatthias Ringwald HFP_AG_OUTGOING_CALL_REJECTED, 304aa4dd815SMatthias Ringwald HFP_AG_OUTGOING_CALL_ACCEPTED, 305aa4dd815SMatthias Ringwald HFP_AG_OUTGOING_CALL_RINGING, 306aa4dd815SMatthias Ringwald HFP_AG_OUTGOING_CALL_ESTABLISHED, 307aa4dd815SMatthias Ringwald HFP_AG_OUTGOING_REDIAL_INITIATED, 308ce263fc8SMatthias Ringwald HFP_AG_HELD_CALL_JOINED_BY_AG, 309aa4dd815SMatthias Ringwald HFP_AG_TERMINATE_CALL_BY_AG, 310aa4dd815SMatthias Ringwald HFP_AG_TERMINATE_CALL_BY_HF, 311aa4dd815SMatthias Ringwald HFP_AG_CALL_DROPPED, 312ce263fc8SMatthias Ringwald HFP_AG_RESPONSE_AND_HOLD_ACCEPT_INCOMING_CALL_BY_AG, 313ce263fc8SMatthias Ringwald HFP_AG_RESPONSE_AND_HOLD_ACCEPT_HELD_CALL_BY_AG, 314ce263fc8SMatthias Ringwald HFP_AG_RESPONSE_AND_HOLD_REJECT_HELD_CALL_BY_AG, 315ce263fc8SMatthias Ringwald HFP_AG_RESPONSE_AND_HOLD_ACCEPT_INCOMING_CALL_BY_HF, 316ce263fc8SMatthias Ringwald HFP_AG_RESPONSE_AND_HOLD_ACCEPT_HELD_CALL_BY_HF, 317d210d9c4SMatthias Ringwald HFP_AG_RESPONSE_AND_HOLD_REJECT_HELD_CALL_BY_HF, 318d210d9c4SMatthias Ringwald HFP_AG_CALL_HOLD_USER_BUSY, 319d210d9c4SMatthias Ringwald HFP_AG_CALL_HOLD_RELEASE_ACTIVE_ACCEPT_HELD_OR_WAITING_CALL, 320d210d9c4SMatthias Ringwald HFP_AG_CALL_HOLD_PARK_ACTIVE_ACCEPT_HELD_OR_WAITING_CALL, 321d210d9c4SMatthias Ringwald HFP_AG_CALL_HOLD_ADD_HELD_CALL, 322d0c20769SMatthias Ringwald HFP_AG_CALL_HOLD_EXIT_AND_JOIN_CALLS, 323d0c20769SMatthias Ringwald HFP_AG_SET_CLIP 324aa4dd815SMatthias Ringwald } hfp_ag_call_event_t; 325aa4dd815SMatthias Ringwald 326aa4dd815SMatthias Ringwald 327aa4dd815SMatthias Ringwald typedef enum { 3283deb3ec6SMatthias Ringwald HFP_PARSER_CMD_HEADER = 0, 3293deb3ec6SMatthias Ringwald HFP_PARSER_CMD_SEQUENCE, 3303deb3ec6SMatthias Ringwald HFP_PARSER_SECOND_ITEM, 331471dea41SMatthias Ringwald HFP_PARSER_THIRD_ITEM, 332471dea41SMatthias Ringwald HFP_PARSER_CUSTOM_COMMAND 3333deb3ec6SMatthias Ringwald } hfp_parser_state_t; 3343deb3ec6SMatthias Ringwald 3359cc9ffe4SMilanka Ringwald typedef enum { 33645796ff1SMilanka Ringwald HFP_VOICE_RECOGNITION_STATE_AG_READY = 0, 33745796ff1SMilanka Ringwald HFP_VOICE_RECOGNITION_STATE_AG_READY_TO_ACCEPT_AUDIO_INPUT = 1, 338cf75be85SMilanka Ringwald HFP_VOICE_RECOGNITION_STATE_AG_IS_STARTING_SOUND = 2, 3399cc9ffe4SMilanka Ringwald HFP_VOICE_RECOGNITION_STATE_AG_IS_PROCESSING_AUDIO_INPUT = 4 3409cc9ffe4SMilanka Ringwald } hfp_voice_recognition_state_t; 3419cc9ffe4SMilanka Ringwald 3429cc9ffe4SMilanka Ringwald typedef enum { 3439cc9ffe4SMilanka Ringwald HFP_TEXT_TYPE_RECOGNISED_FROM_HF_AUDIO = 0, 3449cc9ffe4SMilanka Ringwald HFP_TEXT_TYPE_MESSAGE_FROM_AG, 3459cc9ffe4SMilanka Ringwald HFP_TEXT_TYPE_QUESTION_FROM_AG, 3469cc9ffe4SMilanka Ringwald HFP_TEXT_TYPE_ERROR_FROM_AG 3479cc9ffe4SMilanka Ringwald } hfp_text_type_t; 3489cc9ffe4SMilanka Ringwald 3499cc9ffe4SMilanka Ringwald typedef enum { 350db3cdbd4SMilanka Ringwald HFP_TEXT_OPERATION_NEW_TEXT = 1, 351db3cdbd4SMilanka Ringwald HFP_TEXT_OPERATION_REPLACE, 352db3cdbd4SMilanka Ringwald HFP_TEXT_OPERATION_APPEND 353db3cdbd4SMilanka Ringwald } hfp_text_operation_t; 3543deb3ec6SMatthias Ringwald 3553deb3ec6SMatthias Ringwald typedef enum { 3563deb3ec6SMatthias Ringwald HFP_IDLE = 0, //0 3573deb3ec6SMatthias Ringwald HFP_SDP_QUERY_RFCOMM_CHANNEL, 3581d9c9c90SMilanka Ringwald HFP_W2_SEND_SDP_QUERY, 359a0ffb263SMatthias Ringwald HFP_W4_SDP_QUERY_COMPLETE, 3603deb3ec6SMatthias Ringwald HFP_W4_RFCOMM_CONNECTED, 3613deb3ec6SMatthias Ringwald 3621d9c9c90SMilanka Ringwald HFP_EXCHANGE_SUPPORTED_FEATURES, // 5 3631d9c9c90SMilanka Ringwald HFP_W4_EXCHANGE_SUPPORTED_FEATURES, 3643deb3ec6SMatthias Ringwald 3653deb3ec6SMatthias Ringwald HFP_NOTIFY_ON_CODECS, 3663deb3ec6SMatthias Ringwald HFP_W4_NOTIFY_ON_CODECS, 3673deb3ec6SMatthias Ringwald 3683deb3ec6SMatthias Ringwald HFP_RETRIEVE_INDICATORS, 3691d9c9c90SMilanka Ringwald HFP_W4_RETRIEVE_INDICATORS, // 10 3703deb3ec6SMatthias Ringwald 3711d9c9c90SMilanka Ringwald HFP_RETRIEVE_INDICATORS_STATUS, 3723deb3ec6SMatthias Ringwald HFP_W4_RETRIEVE_INDICATORS_STATUS, 3733deb3ec6SMatthias Ringwald 3743deb3ec6SMatthias Ringwald HFP_ENABLE_INDICATORS_STATUS_UPDATE, 3753deb3ec6SMatthias Ringwald HFP_W4_ENABLE_INDICATORS_STATUS_UPDATE, 3763deb3ec6SMatthias Ringwald 3771d9c9c90SMilanka Ringwald HFP_RETRIEVE_CAN_HOLD_CALL, // 15 3781d9c9c90SMilanka Ringwald HFP_W4_RETRIEVE_CAN_HOLD_CALL, 3793deb3ec6SMatthias Ringwald 3803deb3ec6SMatthias Ringwald HFP_LIST_GENERIC_STATUS_INDICATORS, 3813deb3ec6SMatthias Ringwald HFP_W4_LIST_GENERIC_STATUS_INDICATORS, 3823deb3ec6SMatthias Ringwald 3833deb3ec6SMatthias Ringwald HFP_RETRIEVE_GENERIC_STATUS_INDICATORS, 3841d9c9c90SMilanka Ringwald HFP_W4_RETRIEVE_GENERIC_STATUS_INDICATORS, //20 3853deb3ec6SMatthias Ringwald 3861d9c9c90SMilanka Ringwald HFP_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS, 3873deb3ec6SMatthias Ringwald HFP_W4_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS, 3883deb3ec6SMatthias Ringwald 389498a8121SMilanka Ringwald HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED, //23 3903deb3ec6SMatthias Ringwald 391aa4dd815SMatthias Ringwald HFP_W2_CONNECT_SCO, 392aa4dd815SMatthias Ringwald HFP_W4_SCO_CONNECTED, 3933deb3ec6SMatthias Ringwald 3943deb3ec6SMatthias Ringwald HFP_AUDIO_CONNECTION_ESTABLISHED, 3953deb3ec6SMatthias Ringwald 396be55a11dSMilanka Ringwald 3973deb3ec6SMatthias Ringwald HFP_W2_DISCONNECT_SCO, 398aa4dd815SMatthias Ringwald HFP_W4_SCO_DISCONNECTED, 39948e6eeeeSMatthias Ringwald HFP_W4_SCO_DISCONNECTED_TO_SHUTDOWN, 40048e6eeeeSMatthias Ringwald HFP_W4_WBS_SHUTDOWN, 4013deb3ec6SMatthias Ringwald 4023deb3ec6SMatthias Ringwald HFP_W2_DISCONNECT_RFCOMM, 4033deb3ec6SMatthias Ringwald HFP_W4_RFCOMM_DISCONNECTED, 4043deb3ec6SMatthias Ringwald HFP_W4_RFCOMM_DISCONNECTED_AND_RESTART, 4053deb3ec6SMatthias Ringwald HFP_W4_CONNECTION_ESTABLISHED_TO_SHUTDOWN 4063deb3ec6SMatthias Ringwald } hfp_state_t; 4073deb3ec6SMatthias Ringwald 408be55a11dSMilanka Ringwald 409be55a11dSMilanka Ringwald typedef enum { 410fdda66c0SMilanka Ringwald // shared between normal voice recognition and enhanced one 411be55a11dSMilanka Ringwald HFP_VRA_VOICE_RECOGNITION_OFF, 412be55a11dSMilanka Ringwald 413fd4151d1SMilanka Ringwald HFP_VRA_W2_SEND_VOICE_RECOGNITION_OFF, 414be55a11dSMilanka Ringwald HFP_VRA_W4_VOICE_RECOGNITION_OFF, 415fd4151d1SMilanka Ringwald 416fd4151d1SMilanka Ringwald HFP_VRA_W2_SEND_VOICE_RECOGNITION_ACTIVATED, 417be55a11dSMilanka Ringwald HFP_VRA_W4_VOICE_RECOGNITION_ACTIVATED, 418be55a11dSMilanka Ringwald HFP_VRA_VOICE_RECOGNITION_ACTIVATED, 419be55a11dSMilanka Ringwald 420adb00feeSMilanka Ringwald HFP_VRA_W2_SEND_ENHANCED_VOICE_RECOGNITION_READY_FOR_AUDIO, 421adb00feeSMilanka Ringwald HFP_VRA_W4_ENHANCED_VOICE_RECOGNITION_READY_FOR_AUDIO, 422adb00feeSMilanka Ringwald HFP_VRA_ENHANCED_VOICE_RECOGNITION_READY_FOR_AUDIO, 423fdda66c0SMilanka Ringwald 424cf75be85SMilanka Ringwald HFP_VRA_W2_SEND_ENHANCED_VOICE_RECOGNITION_STATUS, 425b95cac54SMilanka Ringwald HFP_VRA_W2_SEND_ENHANCED_VOICE_RECOGNITION_MSG 426db3cdbd4SMilanka Ringwald } hfp_voice_recognition_activation_status_t; 427be55a11dSMilanka Ringwald 42845796ff1SMilanka Ringwald typedef struct { 42945796ff1SMilanka Ringwald uint16_t text_id; 43045796ff1SMilanka Ringwald hfp_text_type_t text_type; 43145796ff1SMilanka Ringwald hfp_text_operation_t text_operation; 432b95cac54SMilanka Ringwald const char * text; 43345796ff1SMilanka Ringwald } hfp_voice_recognition_message_t; 43445796ff1SMilanka Ringwald 435aa4dd815SMatthias Ringwald typedef enum { 436aa4dd815SMatthias Ringwald HFP_CODECS_IDLE, 437aa4dd815SMatthias Ringwald HFP_CODECS_RECEIVED_LIST, 438aa4dd815SMatthias Ringwald HFP_CODECS_RECEIVED_TRIGGER_CODEC_EXCHANGE, 439aa4dd815SMatthias Ringwald HFP_CODECS_W4_AG_COMMON_CODEC, 440aa4dd815SMatthias Ringwald HFP_CODECS_AG_SENT_COMMON_CODEC, 441aa4dd815SMatthias Ringwald HFP_CODECS_AG_RESEND_COMMON_CODEC, 442ce263fc8SMatthias Ringwald HFP_CODECS_HF_CONFIRMED_CODEC, 443aa4dd815SMatthias Ringwald HFP_CODECS_EXCHANGED, 444aa4dd815SMatthias Ringwald HFP_CODECS_ERROR 445aa4dd815SMatthias Ringwald } hfp_codecs_state_t; 446aa4dd815SMatthias Ringwald 447aa4dd815SMatthias Ringwald typedef enum { 448aa4dd815SMatthias Ringwald HFP_CALL_IDLE, 449aa4dd815SMatthias Ringwald HFP_CALL_TRIGGER_AUDIO_CONNECTION, 450aa4dd815SMatthias Ringwald HFP_CALL_W4_AUDIO_CONNECTION_FOR_IN_BAND_RING, 4519493406bSMilanka Ringwald HFP_CALL_INCOMING_RINGING, 452aa4dd815SMatthias Ringwald HFP_CALL_W4_AUDIO_CONNECTION_FOR_ACTIVE, 453aa4dd815SMatthias Ringwald HFP_CALL_ACTIVE, 454aa4dd815SMatthias Ringwald HFP_CALL_W2_SEND_CALL_WAITING, 455aa4dd815SMatthias Ringwald HFP_CALL_W4_CHLD, 456aa4dd815SMatthias Ringwald HFP_CALL_OUTGOING_INITIATED, 457aa4dd815SMatthias Ringwald HFP_CALL_OUTGOING_DIALING, 458aa4dd815SMatthias Ringwald HFP_CALL_OUTGOING_RINGING 459aa4dd815SMatthias Ringwald } hfp_call_state_t; 460aa4dd815SMatthias Ringwald 461aa4dd815SMatthias Ringwald typedef enum{ 462ce263fc8SMatthias Ringwald HFP_ENHANCED_CALL_DIR_OUTGOING, 463ce263fc8SMatthias Ringwald HFP_ENHANCED_CALL_DIR_INCOMING 464ce263fc8SMatthias Ringwald } hfp_enhanced_call_dir_t; 465ce263fc8SMatthias Ringwald 466ce263fc8SMatthias Ringwald typedef enum{ 467ce263fc8SMatthias Ringwald HFP_ENHANCED_CALL_STATUS_ACTIVE, 468ce263fc8SMatthias Ringwald HFP_ENHANCED_CALL_STATUS_HELD, 469ce263fc8SMatthias Ringwald HFP_ENHANCED_CALL_STATUS_OUTGOING_DIALING, 470ce263fc8SMatthias Ringwald HFP_ENHANCED_CALL_STATUS_OUTGOING_ALERTING, 471ce263fc8SMatthias Ringwald HFP_ENHANCED_CALL_STATUS_INCOMING, 472ce263fc8SMatthias Ringwald HFP_ENHANCED_CALL_STATUS_INCOMING_WAITING, 473ce263fc8SMatthias Ringwald HFP_ENHANCED_CALL_STATUS_CALL_HELD_BY_RESPONSE_AND_HOLD 474ce263fc8SMatthias Ringwald } hfp_enhanced_call_status_t; 475ce263fc8SMatthias Ringwald 476ce263fc8SMatthias Ringwald typedef enum{ 477ce263fc8SMatthias Ringwald HFP_ENHANCED_CALL_MODE_VOICE, 478ce263fc8SMatthias Ringwald HFP_ENHANCED_CALL_MODE_DATA, 479ce263fc8SMatthias Ringwald HFP_ENHANCED_CALL_MODE_FAX 480ce263fc8SMatthias Ringwald } hfp_enhanced_call_mode_t; 481ce263fc8SMatthias Ringwald 482ce263fc8SMatthias Ringwald typedef enum{ 483ce263fc8SMatthias Ringwald HFP_ENHANCED_CALL_MPTY_NOT_A_CONFERENCE_CALL, 484ce263fc8SMatthias Ringwald HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL 485ce263fc8SMatthias Ringwald } hfp_enhanced_call_mpty_t; 486ce263fc8SMatthias Ringwald 487ce263fc8SMatthias Ringwald typedef enum { 488ce263fc8SMatthias Ringwald HFP_RESPONSE_AND_HOLD_INCOMING_ON_HOLD = 0, 489ce263fc8SMatthias Ringwald HFP_RESPONSE_AND_HOLD_HELD_INCOMING_ACCEPTED, 490ce263fc8SMatthias Ringwald HFP_RESPONSE_AND_HOLD_HELD_INCOMING_REJECTED 491ce263fc8SMatthias Ringwald } hfp_response_and_hold_state_t; 492ce263fc8SMatthias Ringwald 493ce263fc8SMatthias Ringwald typedef enum { 494ce263fc8SMatthias Ringwald HFP_HF_QUERY_OPERATOR_FORMAT_NOT_SET = 0, 495ce263fc8SMatthias Ringwald HFP_HF_QUERY_OPERATOR_SET_FORMAT, 496ce263fc8SMatthias Ringwald HFP_HF_QUERY_OPERATOR_W4_SET_FORMAT_OK, 497ce263fc8SMatthias Ringwald HFP_HF_QUERY_OPERATOR_FORMAT_SET, 498ce263fc8SMatthias Ringwald HFP_HF_QUERY_OPERATOR_SEND_QUERY, 499ce263fc8SMatthias Ringwald HPF_HF_QUERY_OPERATOR_W4_RESULT 500ce263fc8SMatthias Ringwald } hfp_hf_query_operator_state_t; 501ce263fc8SMatthias Ringwald 502ce263fc8SMatthias Ringwald typedef enum { 503ce263fc8SMatthias Ringwald HFP_LINK_SETTINGS_D0 = 0, 504ce263fc8SMatthias Ringwald HFP_LINK_SETTINGS_D1, 505ce263fc8SMatthias Ringwald HFP_LINK_SETTINGS_S1, 506ce263fc8SMatthias Ringwald HFP_LINK_SETTINGS_S2, 507ce263fc8SMatthias Ringwald HFP_LINK_SETTINGS_S3, 508ce263fc8SMatthias Ringwald HFP_LINK_SETTINGS_S4, 509ce263fc8SMatthias Ringwald HFP_LINK_SETTINGS_T1, 510b5c379c1SMatthias Ringwald HFP_LINK_SETTINGS_T2, 511b5c379c1SMatthias Ringwald HFP_LINK_SETTINGS_NONE, 512b5c379c1SMatthias Ringwald } hfp_link_settings_t; 513ce263fc8SMatthias Ringwald 514ce263fc8SMatthias Ringwald typedef enum{ 515aa4dd815SMatthias Ringwald HFP_NONE_SM, 516aa4dd815SMatthias Ringwald HFP_SLC_SM, 517aa4dd815SMatthias Ringwald HFP_SLC_QUERIES_SM, 518aa4dd815SMatthias Ringwald HFP_CODECS_CONNECTION_SM, 519aa4dd815SMatthias Ringwald HFP_AUDIO_CONNECTION_SM, 520aa4dd815SMatthias Ringwald HFP_CALL_SM 521aa4dd815SMatthias Ringwald } hfp_state_machine_t; 522aa4dd815SMatthias Ringwald 5233deb3ec6SMatthias Ringwald typedef struct{ 5243deb3ec6SMatthias Ringwald uint16_t uuid; 5253deb3ec6SMatthias Ringwald uint8_t state; // enabled 5263deb3ec6SMatthias Ringwald } hfp_generic_status_indicator_t; 5273deb3ec6SMatthias Ringwald 5283deb3ec6SMatthias Ringwald typedef struct{ 5293deb3ec6SMatthias Ringwald uint8_t index; 5303deb3ec6SMatthias Ringwald char name[HFP_MAX_INDICATOR_DESC_SIZE]; 5313deb3ec6SMatthias Ringwald uint8_t min_range; 5323deb3ec6SMatthias Ringwald uint8_t max_range; 5333deb3ec6SMatthias Ringwald uint8_t status; 5343deb3ec6SMatthias Ringwald uint8_t mandatory; 5353deb3ec6SMatthias Ringwald uint8_t enabled; 5363deb3ec6SMatthias Ringwald uint8_t status_changed; 5373deb3ec6SMatthias Ringwald } hfp_ag_indicator_t; 5383deb3ec6SMatthias Ringwald 5393deb3ec6SMatthias Ringwald typedef struct{ 54089425bfcSMilanka Ringwald char name[HFP_CALL_SERVICE_SIZE]; 5413deb3ec6SMatthias Ringwald } hfp_call_service_t; 5423deb3ec6SMatthias Ringwald 5433deb3ec6SMatthias Ringwald 5443deb3ec6SMatthias Ringwald typedef struct{ 5453deb3ec6SMatthias Ringwald uint8_t mode; 5463deb3ec6SMatthias Ringwald uint8_t format; 54789425bfcSMilanka Ringwald char name[HFP_MAX_NETWORK_OPERATOR_NAME_SIZE]; // enabled 5483deb3ec6SMatthias Ringwald } hfp_network_opearator_t; 5493deb3ec6SMatthias Ringwald 5503deb3ec6SMatthias Ringwald 5513deb3ec6SMatthias Ringwald typedef struct hfp_connection { 552665d90f2SMatthias Ringwald btstack_linked_item_t item; 5533deb3ec6SMatthias Ringwald 554323d3000SMatthias Ringwald // local role: HF or AG 555323d3000SMatthias Ringwald hfp_role_t local_role; 556323d3000SMatthias Ringwald 5573deb3ec6SMatthias Ringwald bd_addr_t remote_addr; 558fc64f94aSMatthias Ringwald hci_con_handle_t acl_handle; 559fc64f94aSMatthias Ringwald hci_con_handle_t sco_handle; 560d9290e95SMatthias Ringwald uint16_t packet_types; 561ab2445a0SMatthias Ringwald uint8_t rfcomm_channel_nr; 5623deb3ec6SMatthias Ringwald uint16_t rfcomm_cid; 5636504a03aSMilanka Ringwald uint16_t rfcomm_mtu; 5643deb3ec6SMatthias Ringwald 565aa4dd815SMatthias Ringwald hfp_state_machine_t state_machine; 566aa4dd815SMatthias Ringwald hfp_call_state_t call_state; 5673deb3ec6SMatthias Ringwald hfp_state_t state; 568aa4dd815SMatthias Ringwald hfp_codecs_state_t codecs_state; 569aa4dd815SMatthias Ringwald 570323d3000SMatthias Ringwald // needed for reestablishing connection - service uuid of the remote 5713deb3ec6SMatthias Ringwald uint16_t service_uuid; 5723deb3ec6SMatthias Ringwald 5733deb3ec6SMatthias Ringwald // used during service level connection establishment 5743deb3ec6SMatthias Ringwald hfp_command_t command; 5753deb3ec6SMatthias Ringwald hfp_parser_state_t parser_state; 5763deb3ec6SMatthias Ringwald int parser_item_index; 577ce263fc8SMatthias Ringwald int parser_indicator_index; 5780222a807SMatthias Ringwald uint32_t parser_indicator_value; 5791dddc4f4SMatthias Ringwald bool parser_quoted; 580471dea41SMatthias Ringwald 581471dea41SMatthias Ringwald // line buffer is always \0 terminated 582db3cdbd4SMilanka Ringwald uint8_t line_buffer[HFP_MAX_VR_TEXT_SIZE]; 5833deb3ec6SMatthias Ringwald int line_size; 5843deb3ec6SMatthias Ringwald 5853deb3ec6SMatthias Ringwald uint32_t remote_supported_features; 5863deb3ec6SMatthias Ringwald 58725789943SMilanka Ringwald uint16_t remote_codecs_nr; 58825789943SMilanka Ringwald uint8_t remote_codecs[HFP_MAX_NUM_CODECS]; 589667ec068SMatthias Ringwald 59025789943SMilanka Ringwald uint16_t ag_indicators_nr; 59125789943SMilanka Ringwald hfp_ag_indicator_t ag_indicators[HFP_MAX_NUM_INDICATORS]; 592667ec068SMatthias Ringwald uint32_t ag_indicators_status_update_bitmap; 593667ec068SMatthias Ringwald uint8_t enable_status_update_for_ag_indicators; 594667ec068SMatthias Ringwald 59525789943SMilanka Ringwald uint16_t remote_call_services_index; 59625789943SMilanka Ringwald hfp_call_service_t remote_call_services[HFP_MAX_NUM_CALL_SERVICES]; 5973deb3ec6SMatthias Ringwald 5983deb3ec6SMatthias Ringwald // TODO: use bitmap. 59925789943SMilanka Ringwald uint16_t generic_status_indicators_nr; 600667ec068SMatthias Ringwald uint32_t generic_status_update_bitmap; 60125789943SMilanka Ringwald hfp_generic_status_indicator_t generic_status_indicators[HFP_MAX_NUM_INDICATORS]; 6023deb3ec6SMatthias Ringwald 6033deb3ec6SMatthias Ringwald hfp_network_opearator_t network_operator; 6043deb3ec6SMatthias Ringwald 6053deb3ec6SMatthias Ringwald // Retrieved during service level connection establishment, not used yet 6063deb3ec6SMatthias Ringwald uint8_t negotiated_codec; 6073deb3ec6SMatthias Ringwald 608aa4dd815SMatthias Ringwald // HF -> AG configuration 609aa4dd815SMatthias Ringwald uint8_t clip_enabled; 610aa4dd815SMatthias Ringwald uint8_t call_waiting_notification_enabled; 611aa4dd815SMatthias Ringwald 6123deb3ec6SMatthias Ringwald // TODO: put these bit flags in a bitmap 613aa4dd815SMatthias Ringwald uint8_t ok_pending; 6143deb3ec6SMatthias Ringwald uint8_t send_error; 61599af1e28SMilanka Ringwald 616dd533208SMatthias Ringwald bool found_equal_sign; 617ce263fc8SMatthias Ringwald uint8_t ignore_value; 6183deb3ec6SMatthias Ringwald 6193deb3ec6SMatthias Ringwald uint8_t change_status_update_for_individual_ag_indicators; 6203deb3ec6SMatthias Ringwald uint8_t operator_name_changed; 6213deb3ec6SMatthias Ringwald 6223deb3ec6SMatthias Ringwald uint8_t enable_extended_audio_gateway_error_report; 623a0ffb263SMatthias Ringwald uint8_t extended_audio_gateway_error_value; 6243deb3ec6SMatthias Ringwald uint8_t extended_audio_gateway_error; 6253deb3ec6SMatthias Ringwald 6263deb3ec6SMatthias Ringwald // establish codecs connection 6273deb3ec6SMatthias Ringwald uint8_t suggested_codec; 6283deb3ec6SMatthias Ringwald uint8_t codec_confirmed; 629bc1b1537SMilanka Ringwald uint8_t sco_for_msbc_failed; 6302ee45eb2SMilanka Ringwald uint8_t trigger_codec_exchange; 631cb81d35dSMatthias Ringwald 632cb81d35dSMatthias Ringwald // establish audio connection 633cb81d35dSMatthias Ringwald hfp_link_settings_t link_setting; 634cb81d35dSMatthias Ringwald uint8_t accept_sco; // 1 = SCO, 2 = eSCO 635cb81d35dSMatthias Ringwald 6363deb3ec6SMatthias Ringwald uint8_t establish_audio_connection; 6373deb3ec6SMatthias Ringwald uint8_t release_audio_connection; 6388439fb24SMilanka Ringwald uint8_t release_slc_connection; 6393deb3ec6SMatthias Ringwald 640aa4dd815SMatthias Ringwald uint8_t microphone_gain; 641aa4dd815SMatthias Ringwald uint8_t send_microphone_gain; 642aa4dd815SMatthias Ringwald 643aa4dd815SMatthias Ringwald uint8_t speaker_gain; 644aa4dd815SMatthias Ringwald uint8_t send_speaker_gain; 645aa4dd815SMatthias Ringwald 646aa4dd815SMatthias Ringwald uint8_t send_phone_number_for_voice_tag; 647ce263fc8SMatthias Ringwald uint8_t send_ag_status_indicators; 648ad902e3dSMatthias Ringwald uint8_t send_ag_indicators_segment; 649a5bdcda8SMatthias Ringwald uint8_t send_response_and_hold_status; // 0 - don't send. BRTH:0 == 1, .. 650ce263fc8SMatthias Ringwald 651f39f7f89SMatthias Ringwald // Apple Accessory Support 652f39f7f89SMatthias Ringwald bool send_apple_information; 653f39f7f89SMatthias Ringwald bool apple_accessory_commands_supported; 654f39f7f89SMatthias Ringwald // - HF to send 655f39f7f89SMatthias Ringwald int8_t apple_accessory_battery_level; 656f39f7f89SMatthias Ringwald int8_t apple_accessory_docked; 657f39f7f89SMatthias Ringwald // - AG Parser 658f39f7f89SMatthias Ringwald uint16_t apple_accessory_product_id; 659f39f7f89SMatthias Ringwald uint16_t apple_accessory_vendor_id; 660f39f7f89SMatthias Ringwald uint8_t apple_accessory_features; 661f39f7f89SMatthias Ringwald uint8_t apple_accessory_key; 662*959f2ebcSMatthias Ringwald char apple_accessory_version[HFP_APPLE_ACCESSORY_VERSION_LEN]; 66351a2ebdeSMatthias Ringwald // HF: AT Command, AG: Unsolicited Result Code 66451a2ebdeSMatthias Ringwald const char * send_custom_message; 66551a2ebdeSMatthias Ringwald 6666d9a41f9SMatthias Ringwald // HF: Unsolicited Result Code, AG: AT Command 6676d9a41f9SMatthias Ringwald uint16_t custom_at_command_id; 6686d9a41f9SMatthias Ringwald 66984fb9ac1SMilanka Ringwald bool emit_vra_enabled_after_audio_established; 670ce263fc8SMatthias Ringwald // AG only 671ce263fc8SMatthias Ringwald uint8_t change_in_band_ring_tone_setting; 672ce263fc8SMatthias Ringwald uint8_t ag_ring; 673ce263fc8SMatthias Ringwald uint8_t ag_send_clip; 674ce263fc8SMatthias Ringwald uint8_t ag_echo_and_noise_reduction; 675754910caSMilanka Ringwald // used by AG: HFP parser stores here the activation value issued by HF 676734ef2bdSMilanka Ringwald uint8_t ag_activate_voice_recognition_value; 6771a26de69SMilanka Ringwald bool ag_audio_connection_opened_before_vra; 6780b4debbfSMilanka Ringwald 679a0ffb263SMatthias Ringwald uint8_t ag_notify_incoming_call_waiting; 680ce263fc8SMatthias Ringwald uint8_t send_subscriber_number; 681ce263fc8SMatthias Ringwald uint8_t next_subscriber_number_to_send; 6820222a807SMatthias Ringwald uint8_t ag_call_hold_action; 6830222a807SMatthias Ringwald uint8_t ag_response_and_hold_action; 6840222a807SMatthias Ringwald uint8_t ag_dtmf_code; 68540a8ee13SMatthias Ringwald bool ag_in_band_ring_tone_active; 686245852b7SMilanka Ringwald bool ag_send_no_carrier; 6878f8818a4SMatthias Ringwald bool ag_vra_send_command; 6889430c71eSMatthias Ringwald bool ag_send_in_band_ring_tone_setting; 689a814da6aSMatthias Ringwald bool ag_send_common_codec; 690e7c46708SMatthias Ringwald bool ag_vra_requested_by_hf; 691ce263fc8SMatthias Ringwald 692ce263fc8SMatthias Ringwald int send_status_of_current_calls; 6939cae807eSMatthias Ringwald int next_call_index; 694ce263fc8SMatthias Ringwald 695ce263fc8SMatthias Ringwald // HF only 696347d46c8SMilanka Ringwald // HF: track command for which ok/error response need to be received 697347d46c8SMilanka Ringwald hfp_command_t response_pending_for_command; 698347d46c8SMilanka Ringwald 699ce263fc8SMatthias Ringwald hfp_hf_query_operator_state_t hf_query_operator_state; 700ce263fc8SMatthias Ringwald uint8_t hf_answer_incoming_call; 701ce263fc8SMatthias Ringwald uint8_t hf_initiate_outgoing_call; 702ce263fc8SMatthias Ringwald uint8_t hf_initiate_memory_dialing; 703ce263fc8SMatthias Ringwald uint8_t hf_initiate_redial_last_number; 7041cc65c4fSMatthias Ringwald bool hf_send_codec_confirm; 7051cc65c4fSMatthias Ringwald bool hf_send_supported_codecs; 7061cc65c4fSMatthias Ringwald 707a0ffb263SMatthias Ringwald int memory_id; 708ce263fc8SMatthias Ringwald 709ce263fc8SMatthias Ringwald uint8_t hf_send_clip_enable; 710ce263fc8SMatthias Ringwald uint8_t hf_send_chup; 711ce263fc8SMatthias Ringwald uint8_t hf_send_chld_0; 712ce263fc8SMatthias Ringwald uint8_t hf_send_chld_1; 713ce263fc8SMatthias Ringwald uint8_t hf_send_chld_2; 714ce263fc8SMatthias Ringwald uint8_t hf_send_chld_3; 715ce263fc8SMatthias Ringwald uint8_t hf_send_chld_4; 716667ec068SMatthias Ringwald uint8_t hf_send_chld_x; 717667ec068SMatthias Ringwald uint8_t hf_send_chld_x_index; 718ce263fc8SMatthias Ringwald char hf_send_dtmf_code; 719ce263fc8SMatthias Ringwald uint8_t hf_send_binp; 720667ec068SMatthias Ringwald uint8_t hf_send_clcc; 721667ec068SMatthias Ringwald uint8_t hf_send_rrh; 722667ec068SMatthias Ringwald char hf_send_rrh_command; 723667ec068SMatthias Ringwald uint8_t hf_send_cnum; 724667ec068SMatthias Ringwald 725ce263fc8SMatthias Ringwald uint8_t hf_activate_call_waiting_notification; 726ce263fc8SMatthias Ringwald uint8_t hf_deactivate_call_waiting_notification; 727ce263fc8SMatthias Ringwald 728ce263fc8SMatthias Ringwald uint8_t hf_activate_calling_line_notification; 729ce263fc8SMatthias Ringwald uint8_t hf_deactivate_calling_line_notification; 730ce263fc8SMatthias Ringwald uint8_t hf_deactivate_echo_canceling_and_noise_reduction; 73156f1adacSMilanka Ringwald 73266093044SMilanka Ringwald hfp_call_status_t hf_call_status; 73366093044SMilanka Ringwald hfp_callsetup_status_t hf_callsetup_status; 73466093044SMilanka Ringwald hfp_callheld_status_t hf_callheld_status; 73566093044SMilanka Ringwald 7360c738fd4SMilanka Ringwald hfp_voice_recognition_activation_status_t vra_state; 7370c738fd4SMilanka Ringwald hfp_voice_recognition_activation_status_t vra_state_requested; 738de9e0ea7SMilanka Ringwald bool deactivate_voice_recognition; 739de9e0ea7SMilanka Ringwald bool activate_voice_recognition; 740cf75be85SMilanka Ringwald bool enhanced_voice_recognition_enabled; 741be55a11dSMilanka Ringwald 742cf75be85SMilanka Ringwald // ih HF, used by parser, in AG used for commands 7430b4debbfSMilanka Ringwald uint8_t ag_vra_status; 744db3cdbd4SMilanka Ringwald hfp_voice_recognition_state_t ag_vra_state; 74545796ff1SMilanka Ringwald hfp_voice_recognition_message_t ag_msg; 746b95cac54SMilanka Ringwald uint16_t ag_vra_msg_length; 747ce263fc8SMatthias Ringwald 748667ec068SMatthias Ringwald uint8_t clcc_idx; 749667ec068SMatthias Ringwald uint8_t clcc_dir; 750667ec068SMatthias Ringwald uint8_t clcc_status; 751667ec068SMatthias Ringwald uint8_t clcc_mode; 752667ec068SMatthias Ringwald uint8_t clcc_mpty; 753667ec068SMatthias Ringwald 754d0c20769SMatthias Ringwald uint8_t call_index; 755a0ffb263SMatthias Ringwald // also used for CLCC, CCWA, CLIP if set 756ce263fc8SMatthias Ringwald uint8_t bnip_type; // 0 == not set 757fc8835faSMilanka Ringwald char bnip_number[HFP_BNEP_NUM_MAX_SIZE]; // 758125560b8SMatthias Ringwald bool clip_have_alpha; 759ce263fc8SMatthias Ringwald 7603721a235SMatthias Ringwald #ifdef ENABLE_CC256X_ASSISTED_HFP 7613721a235SMatthias Ringwald bool cc256x_send_write_codec_config; 7623721a235SMatthias Ringwald bool cc256x_send_wbs_associate; 7633721a235SMatthias Ringwald bool cc256x_send_wbs_disassociate; 7643721a235SMatthias Ringwald #endif 765689d4323SMatthias Ringwald #ifdef ENABLE_BCM_PCM_WBS 766689d4323SMatthias Ringwald bool bcm_send_enable_wbs; 767689d4323SMatthias Ringwald bool bcm_send_disable_wbs; 768689d4323SMatthias Ringwald bool bcm_send_write_i2spcm_interface_param; 769689d4323SMatthias Ringwald #endif 7702b5f92fdSMatthias Ringwald #ifdef ENABLE_RTK_PCM_WBS 7712b5f92fdSMatthias Ringwald bool rtk_send_sco_config; 7722b5f92fdSMatthias Ringwald #endif 7735fd6f360SMatthias Ringwald #ifdef ENABLE_NXP_PCM_WBS 7745fd6f360SMatthias Ringwald hci_con_handle_t nxp_start_audio_handle; 7755fd6f360SMatthias Ringwald hci_con_handle_t nxp_stop_audio_handle; 7765fd6f360SMatthias Ringwald #endif 7773deb3ec6SMatthias Ringwald } hfp_connection_t; 7783deb3ec6SMatthias Ringwald 779471dea41SMatthias Ringwald /** 780471dea41SMatthias Ringwald * @brief Struct to register custom AT Command. 781471dea41SMatthias Ringwald */ 782471dea41SMatthias Ringwald typedef struct { 783471dea41SMatthias Ringwald btstack_linked_item_t * next; 784471dea41SMatthias Ringwald const char * command; 785471dea41SMatthias Ringwald uint16_t command_id; 786471dea41SMatthias Ringwald } hfp_custom_at_command_t; 787471dea41SMatthias Ringwald 7883deb3ec6SMatthias Ringwald // UTILS_START : TODO move to utils 7895ebff802SMatthias Ringwald int send_str_over_rfcomm(uint16_t cid, const char * command); 7903deb3ec6SMatthias Ringwald int join(char * buffer, int buffer_size, uint8_t * values, int values_nr); 7913deb3ec6SMatthias Ringwald int join_bitmap(char * buffer, int buffer_size, uint32_t values, int values_nr); 7923deb3ec6SMatthias Ringwald int get_bit(uint16_t bitmap, int position); 7933deb3ec6SMatthias Ringwald int store_bit(uint32_t bitmap, int position, uint8_t value); 7943deb3ec6SMatthias Ringwald // UTILS_END 7953deb3ec6SMatthias Ringwald 79625ffee39SMatthias Ringwald #define HFP_H2_SYNC_FRAME_SIZE 60 7972288067bSMatthias Ringwald // HFP H2 Synchronization 79825ffee39SMatthias Ringwald typedef struct { 79925ffee39SMatthias Ringwald // callback returns true if data was valid 80025ffee39SMatthias Ringwald bool (*callback)(bool bad_frame, const uint8_t * frame_data, uint16_t frame_len); 80125ffee39SMatthias Ringwald uint8_t frame_data[HFP_H2_SYNC_FRAME_SIZE]; 80225ffee39SMatthias Ringwald uint16_t frame_len; 80325ffee39SMatthias Ringwald uint16_t dropped_bytes; 80425ffee39SMatthias Ringwald } hfp_h2_sync_t; 80525ffee39SMatthias Ringwald 80625ffee39SMatthias Ringwald /** 80725ffee39SMatthias Ringwald * @brief Init HFP H2 Sync state 80825ffee39SMatthias Ringwald * @param hfp_h2_sync 80925ffee39SMatthias Ringwald * @param callback 81025ffee39SMatthias Ringwald */ 81125ffee39SMatthias Ringwald void hfp_h2_sync_init(hfp_h2_sync_t * hfp_h2_sync, 81225ffee39SMatthias Ringwald bool (*callback)(bool bad_frame, const uint8_t * frame_data, uint16_t frame_len)); 81325ffee39SMatthias Ringwald /** 81425ffee39SMatthias Ringwald * @brief Process H2 data and execute callback for frames with valid H2 header 81525ffee39SMatthias Ringwald * @param hfp_h2_sync 81625ffee39SMatthias Ringwald * @param bad_frame 81725ffee39SMatthias Ringwald * @param frame_data 81825ffee39SMatthias Ringwald * @param frame_len 81925ffee39SMatthias Ringwald */ 82025ffee39SMatthias 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); 82125ffee39SMatthias Ringwald 82225ffee39SMatthias Ringwald 82325ffee39SMatthias Ringwald // other 82425ffee39SMatthias Ringwald 82548e6eeeeSMatthias Ringwald void hfp_finalize_connection_context(hfp_connection_t * hfp_connection); 826f14c5dafSMatthias Ringwald void hfp_emit_sco_connection_established(hfp_connection_t *hfp_connection, uint8_t status, uint8_t negotiated_codec, 8275e8e3664SMatthias Ringwald uint16_t rx_packet_length, uint16_t tx_packet_length); 828f2a3f984SMilanka Ringwald 829ca59be51SMatthias Ringwald void hfp_set_ag_callback(btstack_packet_handler_t callback); 830ca59be51SMatthias Ringwald void hfp_set_ag_rfcomm_packet_handler(btstack_packet_handler_t handler); 831f4000eebSMatthias Ringwald 832ca59be51SMatthias Ringwald void hfp_set_hf_callback(btstack_packet_handler_t callback); 833ca59be51SMatthias Ringwald void hfp_set_hf_rfcomm_packet_handler(btstack_packet_handler_t handler); 83421df969bSMatthias Ringwald void hfp_set_hf_indicators(uint8_t indicators_nr, const uint8_t * indicators); 835d68dcce1SMatthias Ringwald 836520c92d5SMatthias Ringwald void hfp_init(void); 83720b2edb6SMatthias Ringwald void hfp_deinit(void); 838520c92d5SMatthias Ringwald 839471dea41SMatthias Ringwald void hfp_register_custom_ag_command(hfp_custom_at_command_t * at_command); 8407404dce3SMatthias Ringwald void hfp_register_custom_hf_command(hfp_custom_at_command_t * at_command); 841471dea41SMatthias Ringwald 8429b1c3b4dSMatthias 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); 843405014fbSMatthias Ringwald void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size, hfp_role_t local_role); 84427950165SMatthias Ringwald void hfp_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size, hfp_role_t local_role); 845ca59be51SMatthias Ringwald void hfp_emit_event(hfp_connection_t * hfp_connection, uint8_t event_subtype, uint8_t value); 846ca59be51SMatthias Ringwald void hfp_emit_simple_event(hfp_connection_t * hfp_connection, uint8_t event_subtype); 847ca59be51SMatthias Ringwald void hfp_emit_string_event(hfp_connection_t * hfp_connection, uint8_t event_subtype, const char * value); 8487095467fSMatthias 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); 849aa4dd815SMatthias Ringwald 850a95ec82fSMilanka Ringwald /** 851553a4a56SMilanka Ringwald * @brief Emit HFP_SUBEVENT_VOICE_RECOGNITION_ENABLED event 852a95ec82fSMilanka Ringwald * @param hfp_connection 853a95ec82fSMilanka Ringwald * @param status ERROR_CODE_SUCCESS if successful, otherwise ERROR_CODE_COMMAND_DISALLOWED 854a95ec82fSMilanka Ringwald */ 855553a4a56SMilanka Ringwald void hfp_emit_voice_recognition_enabled(hfp_connection_t * hfp_connection, uint8_t status); 856553a4a56SMilanka Ringwald 857553a4a56SMilanka Ringwald /** 858553a4a56SMilanka Ringwald * @brief Emit HFP_SUBEVENT_VOICE_RECOGNITION_DISABLED event 859553a4a56SMilanka Ringwald * @param hfp_connection 860553a4a56SMilanka Ringwald * @param status ERROR_CODE_SUCCESS if successful, otherwise ERROR_CODE_COMMAND_DISALLOWED 861553a4a56SMilanka Ringwald */ 862553a4a56SMilanka Ringwald void hfp_emit_voice_recognition_disabled(hfp_connection_t * hfp_connection, uint8_t status); 863553a4a56SMilanka Ringwald 864de9e0ea7SMilanka Ringwald void hfp_emit_enhanced_voice_recognition_hf_ready_for_audio_event(hfp_connection_t * hfp_connection, uint8_t status); 865cf75be85SMilanka Ringwald void hfp_emit_enhanced_voice_recognition_state_event(hfp_connection_t * hfp_connection, uint8_t status); 866a95ec82fSMilanka Ringwald 8673deb3ec6SMatthias Ringwald hfp_connection_t * get_hfp_connection_context_for_rfcomm_cid(uint16_t cid); 868405014fbSMatthias Ringwald hfp_connection_t * get_hfp_connection_context_for_bd_addr(bd_addr_t bd_addr, hfp_role_t hfp_role); 869405014fbSMatthias Ringwald hfp_connection_t * get_hfp_connection_context_for_sco_handle(uint16_t handle, hfp_role_t hfp_role); 870405014fbSMatthias Ringwald hfp_connection_t * get_hfp_connection_context_for_acl_handle(uint16_t handle, hfp_role_t hfp_role); 871aa4dd815SMatthias Ringwald 8728f2a52f4SMatthias Ringwald btstack_linked_list_t * hfp_get_connections(void); 873a0ffb263SMatthias Ringwald void hfp_parse(hfp_connection_t * connection, uint8_t byte, int isHandsFree); 874471dea41SMatthias Ringwald void hfp_parser_reset_line_buffer(hfp_connection_t *hfp_connection); 8753deb3ec6SMatthias Ringwald 8764eb3f1d8SMilanka Ringwald /** 8774eb3f1d8SMilanka Ringwald * @brief Establish RFCOMM connection, and perform service level connection agreement: 8784eb3f1d8SMilanka Ringwald * @param bd_addr 8795ca6cd56SMilanka Ringwald * @param service_uuid 8805ca6cd56SMilanka Ringwald * @param local_role 8814eb3f1d8SMilanka Ringwald * @return status ERROR_CODE_SUCCESS if successful, otherwise: 8824eb3f1d8SMilanka Ringwald * - ERROR_CODE_COMMAND_DISALLOWED if connection already exists, or 8834eb3f1d8SMilanka Ringwald * - BTSTACK_MEMORY_ALLOC_FAILED 8844eb3f1d8SMilanka Ringwald */ 8854eb3f1d8SMilanka Ringwald uint8_t hfp_establish_service_level_connection(bd_addr_t bd_addr, uint16_t service_uuid, hfp_role_t local_role); 8864eb3f1d8SMilanka Ringwald 8875ca6cd56SMilanka Ringwald /** 8885ca6cd56SMilanka Ringwald * @brief Prepare connection for audio and SLC connections release 8895ca6cd56SMilanka Ringwald * @param hfp_connection 8905ca6cd56SMilanka Ringwald */ 891657bc59fSMilanka Ringwald void hfp_trigger_release_service_level_connection(hfp_connection_t * hfp_connection); 8925ca6cd56SMilanka Ringwald 8935ca6cd56SMilanka Ringwald /** 8945ca6cd56SMilanka Ringwald * @brief Prepare connection for audio connection release 8955ca6cd56SMilanka Ringwald * @param hfp_connection 8965ca6cd56SMilanka Ringwald */ 8970b4debbfSMilanka Ringwald uint8_t hfp_trigger_release_audio_connection(hfp_connection_t * hfp_connection); 8981ffa0dd9SMilanka Ringwald 899657bc59fSMilanka Ringwald void hfp_reset_context_flags(hfp_connection_t * hfp_connection); 9003deb3ec6SMatthias Ringwald 9016b3901f2SMatthias Ringwald // @returns if an SCO setup is active in either role 9026b3901f2SMatthias Ringwald bool hfp_sco_setup_active(void); 9036b3901f2SMatthias Ringwald 904657bc59fSMilanka Ringwald void hfp_setup_synchronous_connection(hfp_connection_t * hfp_connection); 905cb81d35dSMatthias Ringwald void hfp_accept_synchronous_connection(hfp_connection_t * hfp_connection, bool incoming_eSCO); 9066b3901f2SMatthias Ringwald 9076a7f44bdSMilanka Ringwald int hfp_supports_codec(uint8_t codec, int codecs_nr, uint8_t * codecs); 908d715cf51SMatthias Ringwald void hfp_hf_drop_mSBC_if_eSCO_not_supported(uint8_t * codecs, uint8_t * codecs_nr); 909e453c1d9SMatthias Ringwald void hfp_init_link_settings(hfp_connection_t * hfp_connection, uint8_t eSCO_S4_supported); 910b4320e7fSMatthias Ringwald hfp_link_settings_t hfp_next_link_setting(hfp_link_settings_t current_setting, uint16_t local_sco_packet_types, 911b4320e7fSMatthias Ringwald uint16_t remote_sco_packet_types, bool eSCO_s4_supported, 912b4320e7fSMatthias Ringwald uint8_t negotiated_codec); 91332459254SMatthias Ringwald hfp_link_settings_t hfp_safe_settings_for_context(bool use_eSCO, uint8_t negotiated_codec, bool secure_connection_in_use); 914ce263fc8SMatthias Ringwald 9153deb3ec6SMatthias Ringwald const char * hfp_hf_feature(int index); 9163deb3ec6SMatthias Ringwald const char * hfp_ag_feature(int index); 9173deb3ec6SMatthias Ringwald 918186dd3d2SMatthias Ringwald void hfp_log_rfcomm_message(const char * tag, uint8_t * packet, uint16_t size); 919186dd3d2SMatthias Ringwald 9200aee97efSMilanka Ringwald const char * hfp_enhanced_call_dir2str(uint16_t index); 9210aee97efSMilanka Ringwald const char * hfp_enhanced_call_status2str(uint16_t index); 9220aee97efSMilanka Ringwald const char * hfp_enhanced_call_mode2str(uint16_t index); 9230aee97efSMilanka Ringwald const char * hfp_enhanced_call_mpty2str(uint16_t index); 9240aee97efSMilanka Ringwald 9250327df7dSMatthias Ringwald /** 9260327df7dSMatthias Ringwald * @brief Prepare for immediate SCO connection. 9270327df7dSMatthias Ringwald * Triggers sending of vendor-specific commands to enable mSBC Codec in Controller 9280327df7dSMatthias Ringwald * @param hfp_connection 9290327df7dSMatthias Ringwald */ 9300327df7dSMatthias Ringwald void hfp_prepare_for_sco(hfp_connection_t * hfp_connection); 9313721a235SMatthias Ringwald 9322e8bf247SMatthias Ringwald #ifdef ENABLE_BCM_PCM_WBS 9332e8bf247SMatthias Ringwald void hfp_bcm_write_i2spcm_interface_param (hfp_connection_t * hfp_connection); 9342e8bf247SMatthias Ringwald #endif 9352e8bf247SMatthias Ringwald 936991c26beSMatthias Ringwald /** 937352a0504SMatthias Ringwald * @brief Set packet types for SCO connections 938991c26beSMatthias Ringwald * @param common single packet_types: HFP_SCO_PACKET_TYPES_* 939991c26beSMatthias Ringwald */ 940991c26beSMatthias Ringwald void hfp_set_sco_packet_types(uint16_t packet_types); 941991c26beSMatthias Ringwald 942991c26beSMatthias Ringwald /** 943352a0504SMatthias Ringwald * @brief Get packet types for SCO connections 9446b65794dSMilanka Ringwald * @return packet_types 945991c26beSMatthias Ringwald */ 946991c26beSMatthias Ringwald uint16_t hfp_get_sco_packet_types(void); 947991c26beSMatthias Ringwald 9483deb3ec6SMatthias Ringwald #if defined __cplusplus 9493deb3ec6SMatthias Ringwald } 9503deb3ec6SMatthias Ringwald #endif 9513deb3ec6SMatthias Ringwald 95280e33422SMatthias Ringwald #endif // BTSTACK_HFP_H 953