Home | History | Annotate | Download | only in include
      1 /******************************************************************************
      2  *
      3  *  Copyright (C) 2003-2012 Broadcom Corporation
      4  *
      5  *  Licensed under the Apache License, Version 2.0 (the "License");
      6  *  you may not use this file except in compliance with the License.
      7  *  You may obtain a copy of the License at:
      8  *
      9  *  http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  *
     17  ******************************************************************************/
     18 
     19 /******************************************************************************
     20  *
     21  *  This is the public interface file for the audio gateway (AG) subsystem
     22  *  of BTA, Broadcom's Bluetooth application layer for mobile phones.
     23  *
     24  ******************************************************************************/
     25 #ifndef BTA_AG_API_H
     26 #define BTA_AG_API_H
     27 
     28 #include "bta_api.h"
     29 
     30 /*****************************************************************************
     31  *  Constants and data types
     32  ****************************************************************************/
     33 #define HFP_VERSION_1_1 0x0101
     34 #define HFP_VERSION_1_5 0x0105
     35 #define HFP_VERSION_1_6 0x0106
     36 #define HFP_VERSION_1_7 0x0107
     37 
     38 #define HSP_VERSION_1_0 0x0100
     39 #define HSP_VERSION_1_2 0x0102
     40 
     41 /* Note, if you change the default version here, please also change the one in
     42  * bta_hs_api.h, they are meant to be the same.
     43  */
     44 #ifndef BTA_HFP_VERSION
     45 #define BTA_HFP_VERSION HFP_VERSION_1_7
     46 #endif
     47 
     48 /* AG feature masks */
     49 #define BTA_AG_FEAT_3WAY 0x00000001   /* Three-way calling */
     50 #define BTA_AG_FEAT_ECNR 0x00000002   /* Echo cancellation/noise reduction */
     51 #define BTA_AG_FEAT_VREC 0x00000004   /* Voice recognition */
     52 #define BTA_AG_FEAT_INBAND 0x00000008 /* In-band ring tone */
     53 #define BTA_AG_FEAT_VTAG 0x00000010   /* Attach a phone number to a voice tag */
     54 #define BTA_AG_FEAT_REJECT 0x00000020 /* Ability to reject incoming call */
     55 #define BTA_AG_FEAT_ECS 0x00000040    /* Enhanced Call Status */
     56 #define BTA_AG_FEAT_ECC 0x00000080    /* Enhanced Call Control */
     57 #define BTA_AG_FEAT_EXTERR 0x00000100 /* Extended error codes */
     58 #define BTA_AG_FEAT_CODEC 0x00000200  /* Codec Negotiation */
     59 
     60 /* Valid feature bit mask for HFP 1.6 (and below) */
     61 #define HFP_1_6_FEAT_MASK 0x000003FF
     62 
     63 /* HFP 1.7+ */
     64 #define BTA_AG_FEAT_HF_IND 0x00000400 /* HF Indicators */
     65 #define BTA_AG_FEAT_ESCO 0x00000800   /* eSCO S4 (and T2) setting supported */
     66 
     67 /* Proprietary features: using 31 ~ 16 bits */
     68 #define BTA_AG_FEAT_BTRH 0x00010000    /* CCAP incoming call hold */
     69 #define BTA_AG_FEAT_UNAT 0x00020000    /* Pass unknown AT commands to app */
     70 #define BTA_AG_FEAT_NOSCO 0x00040000   /* No SCO control performed by BTA AG */
     71 #define BTA_AG_FEAT_NO_ESCO 0x00080000 /* Do not allow or use eSCO */
     72 #define BTA_AG_FEAT_VOIP 0x00100000    /* VoIP call */
     73 
     74 typedef uint32_t tBTA_AG_FEAT;
     75 
     76 /* AG parse mode */
     77 #define BTA_AG_PARSE 0 /* Perform AT command parsing in AG */
     78 
     79 /* Pass data directly to phone's AT command interpreter */
     80 #define BTA_AG_PASS_THROUGH 1
     81 
     82 typedef uint8_t tBTA_AG_PARSE_MODE;
     83 
     84 /* AG open status */
     85 #define BTA_AG_SUCCESS 0        /* Connection successfully opened */
     86 #define BTA_AG_FAIL_SDP 1       /* Open failed due to SDP */
     87 #define BTA_AG_FAIL_RFCOMM 2    /* Open failed due to RFCOMM */
     88 #define BTA_AG_FAIL_RESOURCES 3 /* out of resources failure */
     89 
     90 /* Status to disallow passing AT Events after BTIF */
     91 #define BTA_AG_DISALLOW_AT 5
     92 
     93 typedef uint8_t tBTA_AG_STATUS;
     94 
     95 /* handle values used with BTA_AgResult */
     96 #define BTA_AG_HANDLE_NONE 0
     97 #define BTA_AG_HANDLE_ALL 0xFFFF
     98 /* It is safe to use the same value as BTA_AG_HANDLE_ALL
     99  * HANDLE_ALL is used for delivering indication
    100  * SCO_NO_CHANGE is used for changing sco behavior
    101  * They donot interfere with each other
    102  */
    103 
    104 /* Number of supported HF indicators, there is one HF indicator so far i.e.
    105                                                    enhanced driver status. */
    106 /* Number of supported HF indicators,
    107    1 for Enhanced Safety Status
    108    2 for Battery Level Status */
    109 #ifndef BTA_AG_NUM_LOCAL_HF_IND
    110 #define BTA_AG_NUM_LOCAL_HF_IND 2
    111 #endif
    112 
    113 #define BTA_AG_HANDLE_SCO_NO_CHANGE 0xFFFF
    114 
    115 /* AG result codes used with BTA_AgResult */
    116 #define BTA_AG_SPK_RES 0         /* Update speaker volume */
    117 #define BTA_AG_MIC_RES 1         /* Update microphone volume */
    118 #define BTA_AG_INBAND_RING_RES 2 /* Update inband ring state */
    119 #define BTA_AG_CIND_RES 3        /* Send indicator response for AT+CIND */
    120 #define BTA_AG_BINP_RES 4     /* Send phone number for voice tag for AT+BINP */
    121 #define BTA_AG_IND_RES 5      /* Update an indicator value */
    122 #define BTA_AG_BVRA_RES 6     /* Update voice recognition state */
    123 #define BTA_AG_CNUM_RES 7     /* Send subscriber number response for AT+CNUM */
    124 #define BTA_AG_BTRH_RES 8     /* Send CCAP incoming call hold */
    125 #define BTA_AG_CLCC_RES 9     /* Query list of calls */
    126 #define BTA_AG_COPS_RES 10    /* Read network operator */
    127 #define BTA_AG_IN_CALL_RES 11 /* Indicate incoming phone call */
    128 #define BTA_AG_IN_CALL_CONN_RES 12  /* Incoming phone call connected */
    129 #define BTA_AG_CALL_WAIT_RES 13     /* Call waiting notification */
    130 #define BTA_AG_OUT_CALL_ORIG_RES 14 /* Outgoing phone call origination */
    131 
    132 /* Outgoing phone call alerting remote party */
    133 #define BTA_AG_OUT_CALL_ALERT_RES 15
    134 #define BTA_AG_OUT_CALL_CONN_RES 16 /* Outgoing phone call connected */
    135 
    136 /* Incoming/outgoing 3-way canceled before connected */
    137 #define BTA_AG_CALL_CANCEL_RES 17
    138 #define BTA_AG_END_CALL_RES 18     /* End call */
    139 #define BTA_AG_IN_CALL_HELD_RES 19 /* Incoming call held */
    140 #define BTA_AG_UNAT_RES 20         /* Response to unknown AT command event */
    141 #define BTA_AG_MULTI_CALL_RES 21   /* SLC at three way call */
    142 #define BTA_AG_BIND_RES 22         /* Activate/Deactivate HF indicator */
    143 
    144 typedef uint8_t tBTA_AG_RES;
    145 
    146 /* HFP peer features */
    147 #define BTA_AG_PEER_FEAT_ECNR 0x0001   /* Echo cancellation/noise reduction */
    148 #define BTA_AG_PEER_FEAT_3WAY 0x0002   /* Call waiting and three-way calling */
    149 #define BTA_AG_PEER_FEAT_CLI 0x0004    /* Caller ID presentation capability */
    150 #define BTA_AG_PEER_FEAT_VREC 0x0008   /* Voice recognition activation */
    151 #define BTA_AG_PEER_FEAT_VOL 0x0010    /* Remote volume control */
    152 #define BTA_AG_PEER_FEAT_ECS 0x0020    /* Enhanced Call Status */
    153 #define BTA_AG_PEER_FEAT_ECC 0x0040    /* Enhanced Call Control */
    154 #define BTA_AG_PEER_FEAT_CODEC 0x0080  /* Codec Negotiation */
    155 #define BTA_AG_PEER_FEAT_HF_IND 0x0100 /* HF Indicators */
    156 #define BTA_AG_PEER_FEAT_ESCO 0x0200   /* eSCO S4 (and T2) setting supported */
    157 
    158 /* Proprietary features: using bits after 12 */
    159 
    160 /* Pass unknown AT command responses to application */
    161 #define BTA_AG_PEER_FEAT_UNAT 0x1000
    162 #define BTA_AG_PEER_FEAT_VOIP 0x2000 /* VoIP call */
    163 
    164 typedef uint16_t tBTA_AG_PEER_FEAT;
    165 
    166 /* HFP peer supported codec masks */
    167 // TODO(google) This should use common definitions
    168 #define BTA_AG_CODEC_NONE BTM_SCO_CODEC_NONE
    169 #define BTA_AG_CODEC_CVSD BTM_SCO_CODEC_CVSD /* CVSD */
    170 #define BTA_AG_CODEC_MSBC BTM_SCO_CODEC_MSBC /* mSBC */
    171 typedef uint16_t tBTA_AG_PEER_CODEC;
    172 
    173 /* HFP errcode - Set when BTA_AG_OK_ERROR is returned in 'ok_flag' */
    174 #define BTA_AG_ERR_PHONE_FAILURE 0     /* Phone Failure */
    175 #define BTA_AG_ERR_NO_CONN_PHONE 1     /* No connection to phone */
    176 #define BTA_AG_ERR_OP_NOT_ALLOWED 3    /* Operation not allowed */
    177 #define BTA_AG_ERR_OP_NOT_SUPPORTED 4  /* Operation not supported */
    178 #define BTA_AG_ERR_PHSIM_PIN_REQ 5     /* PH-SIM PIN required */
    179 #define BTA_AG_ERR_SIM_NOT_INSERTED 10 /* SIM not inserted */
    180 #define BTA_AG_ERR_SIM_PIN_REQ 11      /* SIM PIN required */
    181 #define BTA_AG_ERR_SIM_PUK_REQ 12      /* SIM PUK required */
    182 #define BTA_AG_ERR_SIM_FAILURE 13      /* SIM failure */
    183 #define BTA_AG_ERR_SIM_BUSY 14         /* SIM busy */
    184 #define BTA_AG_ERR_INCORRECT_PWD 16    /* Incorrect password */
    185 #define BTA_AG_ERR_SIM_PIN2_REQ 17     /* SIM PIN2 required */
    186 #define BTA_AG_ERR_SIM_PUK2_REQ 18     /* SIM PUK2 required */
    187 #define BTA_AG_ERR_MEMORY_FULL 20      /* Memory full */
    188 #define BTA_AG_ERR_INVALID_INDEX 21    /* Invalid index */
    189 #define BTA_AG_ERR_MEMORY_FAILURE 23   /* Memory failure */
    190 #define BTA_AG_ERR_TEXT_TOO_LONG 24    /* Text string too long */
    191 #define BTA_AG_ERR_INV_CHAR_IN_TSTR 25 /* Invalid characters in text string */
    192 #define BTA_AG_ERR_DSTR_TOO_LONG 26    /* Dial string too long */
    193 #define BTA_AG_ERR_INV_CHAR_IN_DSTR 27 /* Invalid characters in dial string */
    194 #define BTA_AG_ERR_NO_NETWORK_SERV 30  /* No network service */
    195 #define BTA_AG_ERR_NETWORK_TIME_OUT 31 /* Network timeout */
    196 /* Network not allowed - emergency service only */
    197 #define BTA_AG_ERR_NO_NET_EMG_ONLY 32
    198 /* AG cannot create simultaneous VoIP and CS calls */
    199 #define BTA_AG_ERR_VOIP_CS_CALLS 33
    200 #define BTA_AG_ERR_NOT_FOR_VOIP 34  /* Not supported on this call type(VoIP) */
    201 #define BTA_AG_ERR_SIP_RESP_CODE 35 /* SIP 3 digit response code */
    202 
    203 #if 0 /* Not Used in Bluetooth HFP 1.5 Specification */
    204 #define BTA_AG_ERR_PHADAP_LNK_RES 2   /* Phone-adapter link reserved */
    205 #define BTA_AG_ERR_PHFSIM_PIN_REQ 6   /* PH-FSIM PIN required */
    206 #define BTA_AG_ERR_PHFSIM_PUK_REQ 7   /* PH-FSIM PUK required */
    207 #define BTA_AG_ERR_SIM_WRONG 15       /* SIM wrong */
    208 #define BTA_AG_ERR_NOT_FOUND 22       /* Not found */
    209 #define BTA_AG_ERR_NETWORK_TIMEOUT 31 /* Network timeout */
    210 #define BTA_AG_ERR_NET_PIN_REQ 40     /* Network personalization PIN required */
    211 #define BTA_AG_ERR_NET_PUK_REQ 41     /* Network personalization PUK required */
    212 /* Network subset personalization PIN required */
    213 #define BTA_AG_ERR_SUBSET_PIN_REQ 42
    214 /* Network subset personalization PUK required */
    215 #define BTA_AG_ERR_SUBSET_PUK_REQ 43
    216 /* Service provider personalization PIN required */
    217 #define BTA_AG_ERR_SERVPRO_PIN_REQ 44
    218 /* Service provider personalization PUK required */
    219 #define BTA_AG_ERR_SERVPRO_PUK_REQ 45
    220 /* Corporate personalization PIN required */
    221 #define BTA_AG_ERR_CORP_PIN_REQ 46
    222 /* Corporate personalization PUK required */
    223 #define BTA_AG_ERR_CORP_PUK_REQ 47
    224 #define BTA_AG_ERR_UNKNOWN 100 /* Unknown error */
    225 
    226 /* GPRS-related errors */
    227 #define BTA_AG_ERR_ILL_MS 103  /* Illegal MS (#3) */
    228 #define BTA_AG_ERR_ILL_ME 106  /* Illegal ME (#6) */
    229 #define BTA_AG_ERR_GPRS_NOT_ALLOWED 107 /* GPRS services not allowed (#7) */
    230 #define BTA_AG_ERR_PLMN_NOT_ALLOWED 111 /* PLMN services not allowed (#11) */
    231 #define BTA_AG_ERR_LOC_NOT_ALLOWED 112  /* Location area not allowed (#12) */
    232 /* Roaming not allowed in this location area (#13) */
    233 #define BTA_AG_ERR_ROAM_NOT_ALLOWED 113
    234 /* Errors related to a failure to Activate a Context */
    235 #define BTA_AG_ERR_OPT_NOT_SUPP 132 /* Service option not supported (#32) */
    236 /* Requested service option not subscribed (#33) */
    237 #define BTA_AG_ERR_OPT_NOT_SUBSCR 133
    238 /* Service option temporarily out of order (#34) */
    239 #define BTA_AG_ERR_OPT_OUT_OF_ORDER 134
    240 #define BTA_AG_ERR_PDP_AUTH_FAILURE 149 /* PDP authentication failure */
    241 /* Other GPRS errors */
    242 #define BTA_AG_ERR_INV_MOBILE_CLASS 150 /* Invalid mobile class */
    243 #define BTA_AG_ERR_UNSPEC_GPRS_ERR 148  /* Unspecified GPRS error */
    244 #endif                                  /* Unused error codes */
    245 
    246 /* HFP result data 'ok_flag' */
    247 #define BTA_AG_OK_CONTINUE 0 /* Send out response (more responses coming) */
    248 #define BTA_AG_OK_DONE 1     /* Send out response followed by OK (finished) */
    249 #define BTA_AG_OK_ERROR 2    /* Error response */
    250 
    251 /* BTRH values */
    252 #define BTA_AG_BTRH_SET_HOLD 0 /* Put incoming call on hold */
    253 #define BTA_AG_BTRH_SET_ACC 1  /* Accept incoming call on hold */
    254 #define BTA_AG_BTRH_SET_REJ 2  /* Reject incoming call on hold */
    255 #define BTA_AG_BTRH_READ 3     /* Read the current value */
    256 #define BTA_AG_BTRH_NO_RESP 4  /* Not in RH States (reply to read) */
    257 
    258 /* ASCII character string of arguments to the AT command or result */
    259 #ifndef BTA_AG_AT_MAX_LEN
    260 #define BTA_AG_AT_MAX_LEN 256
    261 #endif
    262 
    263 /* data associated with BTA_AG_IND_RES */
    264 typedef struct {
    265   uint16_t id;
    266   uint16_t value;
    267   bool on_demand;
    268 } tBTA_AG_IND;
    269 
    270 /* data type for BTA_AgResult() */
    271 typedef struct {
    272   char str[BTA_AG_AT_MAX_LEN + 1];
    273   tBTA_AG_IND ind;
    274   uint16_t num;
    275   uint16_t audio_handle;
    276   uint16_t errcode; /* Valid only if 'ok_flag' is set to BTA_AG_OK_ERROR */
    277   uint8_t
    278       ok_flag; /* Indicates if response is finished, and if error occurred */
    279   bool state;
    280 } tBTA_AG_RES_DATA;
    281 
    282 /* AG callback events */
    283 #define BTA_AG_ENABLE_EVT 0      /* AG enabled */
    284 #define BTA_AG_REGISTER_EVT 1    /* AG registered */
    285 #define BTA_AG_OPEN_EVT 2        /* AG connection open */
    286 #define BTA_AG_CLOSE_EVT 3       /* AG connection closed */
    287 #define BTA_AG_CONN_EVT 4        /* Service level connection opened */
    288 #define BTA_AG_AUDIO_OPEN_EVT 5  /* Audio connection open */
    289 #define BTA_AG_AUDIO_CLOSE_EVT 6 /* Audio connection closed */
    290 #define BTA_AG_SPK_EVT 7         /* Speaker volume changed */
    291 #define BTA_AG_MIC_EVT 8         /* Microphone volume changed */
    292 #define BTA_AG_AT_CKPD_EVT 9     /* CKPD from the HS */
    293 #define BTA_AG_DISABLE_EVT 30    /* AG disabled */
    294 #define BTA_AG_WBS_EVT 31 /* SCO codec info */
    295 /* Values below are for HFP only */
    296 #define BTA_AG_AT_A_EVT 10    /* Answer a call */
    297 #define BTA_AG_AT_D_EVT 11    /* Place a call using number or memory dial */
    298 #define BTA_AG_AT_CHLD_EVT 12 /* Call hold */
    299 #define BTA_AG_AT_CHUP_EVT 13 /* Hang up a call */
    300 #define BTA_AG_AT_CIND_EVT 14 /* Read indicator settings */
    301 #define BTA_AG_AT_VTS_EVT 15  /* Transmit DTMF tone */
    302 #define BTA_AG_AT_BINP_EVT 16 /* Retrieve number from voice tag */
    303 #define BTA_AG_AT_BLDN_EVT 17 /* Place call to last dialed number */
    304 #define BTA_AG_AT_BVRA_EVT 18 /* Enable/disable voice recognition */
    305 #define BTA_AG_AT_NREC_EVT 19 /* Disable echo canceling */
    306 #define BTA_AG_AT_CNUM_EVT 20 /* Retrieve subscriber number */
    307 #define BTA_AG_AT_BTRH_EVT 21 /* CCAP-style incoming call hold */
    308 #define BTA_AG_AT_CLCC_EVT 22 /* Query list of current calls */
    309 #define BTA_AG_AT_COPS_EVT 23 /* Query list of current calls */
    310 #define BTA_AG_AT_UNAT_EVT 24 /* Unknown AT command */
    311 #define BTA_AG_AT_CBC_EVT 25  /* Battery Level report from HF */
    312 #define BTA_AG_AT_BAC_EVT 26  /* avablable codec */
    313 #define BTA_AG_AT_BCS_EVT 27  /* Codec select */
    314 #define BTA_AG_AT_BIND_EVT 28 /* HF indicator */
    315 #define BTA_AG_AT_BIEV_EVT 29 /* HF indicator updates from peer */
    316 
    317 typedef uint8_t tBTA_AG_EVT;
    318 
    319 /* data associated with most non-AT events */
    320 typedef struct {
    321   uint16_t handle;
    322   uint8_t app_id;
    323   tBTA_AG_STATUS status;
    324 } tBTA_AG_HDR;
    325 
    326 /* data associated with BTA_AG_REGISTER_EVT */
    327 typedef struct {
    328   tBTA_AG_HDR hdr;
    329   tBTA_AG_STATUS status;
    330 } tBTA_AG_REGISTER;
    331 
    332 /* data associated with BTA_AG_OPEN_EVT */
    333 typedef struct {
    334   tBTA_AG_HDR hdr;
    335   RawAddress bd_addr;
    336   tBTA_SERVICE_ID service_id;
    337   tBTA_AG_STATUS status;
    338 } tBTA_AG_OPEN;
    339 
    340 /* data associated with BTA_AG_CLOSE_EVT */
    341 typedef struct {
    342   tBTA_AG_HDR hdr;
    343   RawAddress bd_addr;
    344 } tBTA_AG_CLOSE;
    345 
    346 /* data associated with BTA_AG_CONN_EVT */
    347 typedef struct {
    348   tBTA_AG_HDR hdr;
    349   tBTA_AG_PEER_FEAT peer_feat;
    350   RawAddress bd_addr;
    351   tBTA_AG_PEER_CODEC peer_codec;
    352 } tBTA_AG_CONN;
    353 
    354 /* data associated with AT command event */
    355 typedef struct {
    356   tBTA_AG_HDR hdr;
    357   RawAddress bd_addr;
    358   char str[BTA_AG_AT_MAX_LEN + 1];
    359   uint16_t num;
    360   uint8_t idx;   /* call number used by CLCC and CHLD */
    361   uint16_t lidx; /* long index, ex, HF indicator */
    362 } tBTA_AG_VAL;
    363 
    364 /* union of data associated with AG callback */
    365 typedef union {
    366   tBTA_AG_HDR hdr;
    367   tBTA_AG_REGISTER reg;
    368   tBTA_AG_OPEN open;
    369   tBTA_AG_CLOSE close;
    370   tBTA_AG_CONN conn;
    371   tBTA_AG_VAL val;
    372 } tBTA_AG;
    373 
    374 /* AG callback */
    375 typedef void(tBTA_AG_CBACK)(tBTA_AG_EVT event, tBTA_AG* p_data);
    376 
    377 /* indicator constants HFP 1.1 and later */
    378 #define BTA_AG_IND_CALL 1      /* position of call indicator */
    379 #define BTA_AG_IND_CALLSETUP 2 /* position of callsetup indicator */
    380 #define BTA_AG_IND_SERVICE 3   /* position of service indicator */
    381 
    382 /* indicator constants HFP 1.5 and later */
    383 #define BTA_AG_IND_SIGNAL 4   /* position of signal strength indicator */
    384 #define BTA_AG_IND_ROAM 5     /* position of roaming indicator */
    385 #define BTA_AG_IND_BATTCHG 6  /* position of battery charge indicator */
    386 #define BTA_AG_IND_CALLHELD 7 /* position of callheld indicator */
    387 #define BTA_AG_IND_BEARER 8   /* position of bearer indicator */
    388 
    389 /* call indicator values */
    390 #define BTA_AG_CALL_INACTIVE 0 /* Phone call inactive */
    391 #define BTA_AG_CALL_ACTIVE 1   /* Phone call active */
    392 
    393 /* callsetup indicator values */
    394 #define BTA_AG_CALLSETUP_NONE 0     /* Not currently in call set up */
    395 #define BTA_AG_CALLSETUP_INCOMING 1 /* Incoming call process ongoing */
    396 #define BTA_AG_CALLSETUP_OUTGOING 2 /* Outgoing call set up is ongoing */
    397 /* Remote party being alerted in an outgoing call */
    398 #define BTA_AG_CALLSETUP_ALERTING 3
    399 
    400 /* service indicator values */
    401 #define BTA_AG_SERVICE_NONE 0    /* Neither CS nor VoIP service is available */
    402 #define BTA_AG_SERVICE_CS 1      /* Only CS service is available */
    403 #define BTA_AG_SERVICE_VOIP 2    /* Only VoIP service is available */
    404 #define BTA_AG_SERVICE_CS_VOIP 3 /* Both CS and VoIP services available */
    405 
    406 /* callheld indicator values */
    407 #define BTA_AG_CALLHELD_INACTIVE 0 /* No held calls */
    408 #define BTA_AG_CALLHELD_ACTIVE 1   /* Call held and call active */
    409 #define BTA_AG_CALLHELD_NOACTIVE 2 /* Call held and no call active */
    410 
    411 /* signal strength indicator values */
    412 #define BTA_AG_ROAMING_INACTIVE 0 /* Phone call inactive */
    413 #define BTA_AG_ROAMING_ACTIVE 1   /* Phone call active */
    414 
    415 /* bearer indicator values */
    416 #define BTA_AG_BEARER_WLAN 0      /* WLAN         */
    417 #define BTA_AG_BEARER_BLUETOOTH 1 /* Bluetooth    */
    418 #define BTA_AG_BEARER_WIRED 2     /* Wired        */
    419 #define BTA_AG_BEARER_2G3G 3      /* 2G 3G        */
    420 #define BTA_AG_BEARER_WIMAX 4     /* WIMAX        */
    421 #define BTA_AG_BEARER_RES1 5      /* Reserved     */
    422 #define BTA_AG_BEARER_RES2 6      /* Reserved     */
    423 #define BTA_AG_BEARER_RES3 7      /* Reserved     */
    424 
    425 /* type for HF indicator */
    426 typedef struct {
    427   uint16_t ind_id;
    428   bool is_supported;
    429   bool is_enable;
    430   uint32_t ind_min_val;
    431   uint32_t ind_max_val;
    432 } tBTA_AG_HF_IND;
    433 
    434 /* AG configuration structure */
    435 typedef struct {
    436   const char* cind_info;
    437   const char* bind_info;
    438   uint8_t num_local_hf_ind;
    439   int32_t conn_tout;
    440   uint16_t sco_pkt_types;
    441   const char* chld_val_ecc;
    442   const char* chld_val;
    443 } tBTA_AG_CFG;
    444 
    445 /*****************************************************************************
    446  *  External Function Declarations
    447  ****************************************************************************/
    448 
    449 /*******************************************************************************
    450  *
    451  * Function         BTA_AgEnable
    452  *
    453  * Description      Enable the audio gateway service. When the enable
    454  *                  operation is complete the callback function will be
    455  *                  called with a BTA_AG_ENABLE_EVT. This function must
    456  *                  be called before other function in the AG API are
    457  *                  called.
    458  *
    459  * Returns          BTA_SUCCESS if OK, BTA_FAILURE otherwise.
    460  *
    461  ******************************************************************************/
    462 tBTA_STATUS BTA_AgEnable(tBTA_AG_PARSE_MODE parse_mode, tBTA_AG_CBACK* p_cback);
    463 
    464 /*******************************************************************************
    465  *
    466  * Function         BTA_AgDisable
    467  *
    468  * Description      Disable the audio gateway service
    469  *
    470  *
    471  * Returns          void
    472  *
    473  ******************************************************************************/
    474 void BTA_AgDisable(void);
    475 
    476 /*******************************************************************************
    477  *
    478  * Function         BTA_AgRegister
    479  *
    480  * Description      Register an Audio Gateway service.
    481  *
    482  *
    483  * Returns          void
    484  *
    485  ******************************************************************************/
    486 void BTA_AgRegister(tBTA_SERVICE_MASK services, tBTA_SEC sec_mask,
    487                     tBTA_AG_FEAT features, const char* p_service_names[],
    488                     uint8_t app_id);
    489 
    490 /*******************************************************************************
    491  *
    492  * Function         BTA_AgDeregister
    493  *
    494  * Description      Deregister an audio gateway service.
    495  *
    496  *
    497  * Returns          void
    498  *
    499  ******************************************************************************/
    500 void BTA_AgDeregister(uint16_t handle);
    501 
    502 /*******************************************************************************
    503  *
    504  * Function         BTA_AgOpen
    505  *
    506  * Description      Opens a connection to a headset or hands-free device.
    507  *                  When connection is open callback function is called
    508  *                  with a BTA_AG_OPEN_EVT. Only the data connection is
    509  *                  opened. The audio connection is not opened.
    510  *
    511  *
    512  * Returns          void
    513  *
    514  ******************************************************************************/
    515 void BTA_AgOpen(uint16_t handle, const RawAddress& bd_addr, tBTA_SEC sec_mask,
    516                 tBTA_SERVICE_MASK services);
    517 
    518 /*******************************************************************************
    519  *
    520  * Function         BTA_AgClose
    521  *
    522  * Description      Close the current connection to a headset or a handsfree
    523  *                  Any current audio connection will also be closed
    524  *
    525  *
    526  * Returns          void
    527  *
    528  ******************************************************************************/
    529 void BTA_AgClose(uint16_t handle);
    530 
    531 /*******************************************************************************
    532  *
    533  * Function         BTA_AgAudioOpen
    534  *
    535  * Description      Opens an audio connection to the currently connected
    536  *                  headset or hnadsfree
    537  *
    538  *
    539  * Returns          void
    540  *
    541  ******************************************************************************/
    542 void BTA_AgAudioOpen(uint16_t handle);
    543 
    544 /*******************************************************************************
    545  *
    546  * Function         BTA_AgAudioClose
    547  *
    548  * Description      Close the currently active audio connection to a headset
    549  *                  or hnadsfree. The data connection remains open
    550  *
    551  *
    552  * Returns          void
    553  *
    554  ******************************************************************************/
    555 void BTA_AgAudioClose(uint16_t handle);
    556 
    557 /*******************************************************************************
    558  *
    559  * Function         BTA_AgResult
    560  *
    561  * Description      Send an AT result code to a headset or hands-free device.
    562  *                  This function is only used when the AG parse mode is set
    563  *                  to BTA_AG_PARSE.
    564  *
    565  *
    566  * Returns          void
    567  *
    568  ******************************************************************************/
    569 void BTA_AgResult(uint16_t handle, tBTA_AG_RES result,
    570                   tBTA_AG_RES_DATA* p_data);
    571 
    572 /*******************************************************************************
    573  *
    574  * Function         BTA_AgSetCodec
    575  *
    576  * Description      Specify the codec type to be used for the subsequent
    577  *                  audio connection.
    578  *
    579  *
    580  *
    581  * Returns          void
    582  *
    583  ******************************************************************************/
    584 void BTA_AgSetCodec(uint16_t handle, tBTA_AG_PEER_CODEC codec);
    585 
    586 void BTA_AgSetScoAllowed(bool value);
    587 
    588 #endif /* BTA_AG_API_H */
    589