Home | History | Annotate | Download | only in include
      1 /******************************************************************************
      2  *
      3  *  Copyright (c) 2014 The Android Open Source Project
      4  *  Copyright (C) 2003-2012 Broadcom Corporation
      5  *
      6  *  Licensed under the Apache License, Version 2.0 (the "License");
      7  *  you may not use this file except in compliance with the License.
      8  *  You may obtain a copy of the License at:
      9  *
     10  *  http://www.apache.org/licenses/LICENSE-2.0
     11  *
     12  *  Unless required by applicable law or agreed to in writing, software
     13  *  distributed under the License is distributed on an "AS IS" BASIS,
     14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15  *  See the License for the specific language governing permissions and
     16  *  limitations under the License.
     17  *
     18  ******************************************************************************/
     19 
     20 /******************************************************************************
     21  *
     22  *  This is the public interface file for the handsfree (HF role) subsystem
     23  *
     24  ******************************************************************************/
     25 #ifndef BTA_HF_CLIENT_API_H
     26 #define BTA_HF_CLIENT_API_H
     27 
     28 #include "bta_api.h"
     29 
     30 /*****************************************************************************
     31 **  Constants and data types
     32 *****************************************************************************/
     33 
     34 /* HFP peer (AG) features*/
     35 #define BTA_HF_CLIENT_PEER_FEAT_3WAY   0x00000001  /* Three-way calling */
     36 #define BTA_HF_CLIENT_PEER_FEAT_ECNR   0x00000002  /* Echo cancellation and/or noise reduction */
     37 #define BTA_HF_CLIENT_PEER_FEAT_VREC   0x00000004  /* Voice recognition */
     38 #define BTA_HF_CLIENT_PEER_INBAND      0x00000008  /* In-band ring tone */
     39 #define BTA_HF_CLIENT_PEER_VTAG        0x00000010  /* Attach a phone number to a voice tag */
     40 #define BTA_HF_CLIENT_PEER_REJECT      0x00000020  /* Ability to reject incoming call */
     41 #define BTA_HF_CLIENT_PEER_ECS         0x00000040  /* Enhanced Call Status */
     42 #define BTA_HF_CLIENT_PEER_ECC         0x00000080  /* Enhanced Call Control */
     43 #define BTA_HF_CLIENT_PEER_EXTERR      0x00000100  /* Extended error codes */
     44 #define BTA_HF_CLIENT_PEER_CODEC       0x00000200  /* Codec Negotiation */
     45 
     46 typedef UINT16 tBTA_HF_CLIENT_PEER_FEAT;
     47 
     48 /* HFP HF features */
     49 #define BTA_HF_CLIENT_FEAT_ECNR        0x00000001  /* Echo cancellation and/or noise reduction */
     50 #define BTA_HF_CLIENT_FEAT_3WAY        0x00000002  /* Call waiting and three-way calling */
     51 #define BTA_HF_CLIENT_FEAT_CLI         0x00000004  /* Caller ID presentation capability */
     52 #define BTA_HF_CLIENT_FEAT_VREC        0x00000008  /* Voice recognition activation */
     53 #define BTA_HF_CLIENT_FEAT_VOL         0x00000010  /* Remote volume control */
     54 #define BTA_HF_CLIENT_FEAT_ECS         0x00000020  /* Enhanced Call Status */
     55 #define BTA_HF_CLIENT_FEAT_ECC         0x00000040  /* Enhanced Call Control */
     56 #define BTA_HF_CLIENT_FEAT_CODEC       0x00000080  /* Codec Negotiation */
     57 
     58 /* HFP HF extended call handling - masks not related to any spec */
     59 #define BTA_HF_CLIENT_CHLD_REL          0x00000001  /* 0  Release waiting call or held calls */
     60 #define BTA_HF_CLIENT_CHLD_REL_ACC      0x00000002  /* 1  Release active calls and accept other (waiting or held) cal */
     61 #define BTA_HF_CLIENT_CHLD_REL_X        0x00000004  /* 1x Release x call*/
     62 #define BTA_HF_CLIENT_CHLD_HOLD_ACC     0x00000008  /* 2  Active calls on hold and accept other call */
     63 #define BTA_HF_CLIENT_CHLD_PRIV_X       0x00000010  /* 2x Active multiparty call on hold except call x */
     64 #define BTA_HF_CLIENT_CHLD_MERGE        0x00000020  /* 3  Add held call to multiparty */
     65 #define BTA_HF_CLIENT_CHLD_MERGE_DETACH 0x00000040  /* 4  Add held call to multiparty */
     66 
     67 typedef UINT16 tBTA_HF_CLIENT_CHLD_FEAT;
     68 
     69 /* HFP AG errors ot OK sent to HF Unit */
     70 #define BTA_HF_CLIENT_AT_RESULT_OK            0
     71 #define BTA_HF_CLIENT_AT_RESULT_ERROR         1
     72 #define BTA_HF_CLIENT_AT_RESULT_NO_CARRIER    2
     73 #define BTA_HF_CLIENT_AT_RESULT_BUSY          3
     74 #define BTA_HF_CLIENT_AT_RESULT_NO_ANSWER     4
     75 #define BTA_HF_CLIENT_AT_RESULT_DELAY         5
     76 #define BTA_HF_CLIENT_AT_RESULT_BLACKLISTED   6
     77 #define BTA_HF_CLIENT_AT_RESULT_CME           7
     78 
     79 typedef UINT8 tBTA_HF_CLIENT_AT_RESULT_TYPE;
     80 
     81 /* HF Client callback events */
     82 #define BTA_HF_CLIENT_ENABLE_EVT            0  /* HF Client enabled */
     83 #define BTA_HF_CLIENT_REGISTER_EVT          1  /* HF Client registered */
     84 #define BTA_HF_CLIENT_OPEN_EVT              2  /* HF Client connection open */
     85 #define BTA_HF_CLIENT_CLOSE_EVT             3  /* HF Client connection closed */
     86 #define BTA_HF_CLIENT_CONN_EVT              4  /* Service level connection opened */
     87 #define BTA_HF_CLIENT_AUDIO_OPEN_EVT        5  /* Audio connection open */
     88 #define BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT   6  /* Audio connection with mSBC codec open */
     89 #define BTA_HF_CLIENT_AUDIO_CLOSE_EVT       7  /* Audio connection closed */
     90 #define BTA_HF_CLIENT_SPK_EVT               8  /* Speaker volume changed */
     91 #define BTA_HF_CLIENT_MIC_EVT               9  /* Microphone volume changed */
     92 #define BTA_HF_CLIENT_IND_EVT               10 /* Indicator */
     93 #define BTA_HF_CLIENT_VOICE_REC_EVT         11 /* AG changed voice recognition setting */
     94 #define BTA_HF_CLIENT_OPERATOR_NAME_EVT     12 /* Operator name acquired */
     95 #define BTA_HF_CLIENT_CLIP_EVT              13 /* Calling line identification event */
     96 #define BTA_HF_CLIENT_CCWA_EVT              14 /* Call waiting notification */
     97 #define BTA_HF_CLIENT_AT_RESULT_EVT         15 /* Call waiting notification */
     98 #define BTA_HF_CLIENT_CLCC_EVT              16 /* current call event */
     99 #define BTA_HF_CLIENT_CNUM_EVT              17 /* subscriber information event */
    100 #define BTA_HF_CLIENT_BTRH_EVT              18 /* bluetooth response and hold event */
    101 #define BTA_HF_CLIENT_BSIR_EVT              19 /* in-band ring tone setting changed event */
    102 #define BTA_HF_CLIENT_BINP_EVT              20 /* binp number event */
    103 #define BTA_HF_CLIENT_RING_INDICATION       21 /* HF Client ring indication */
    104 #define BTA_HF_CLIENT_DISABLE_EVT           30 /* HF Client disabled */
    105 
    106 typedef UINT8 tBTA_HF_CLIENT_EVT;
    107 
    108 /* HF Client open status */
    109 #define BTA_HF_CLIENT_SUCCESS          0 /* Connection successfully opened */
    110 #define BTA_HF_CLIENT_FAIL_SDP         1 /* Open failed due to SDP */
    111 #define BTA_HF_CLIENT_FAIL_RFCOMM      2 /* Open failed due to RFCOMM */
    112 #define BTA_HF_CLIENT_FAIL_RESOURCES   3 /* out of resources failure  */
    113 
    114 typedef UINT8 tBTA_HF_CLIENT_STATUS;
    115 
    116 /* indicator type */
    117 #define BTA_HF_CLIENT_IND_BATTCH    0  /* Battery charge indicator */
    118 #define BTA_HF_CLIENT_IND_SIGNAL    1  /* Signal Strength indicator */
    119 #define BTA_HF_CLIENT_IND_SERVICE   2  /* Service availability indicator */
    120 #define BTA_HF_CLIENT_IND_CALL      3  /* Standard call status indicator*/
    121 #define BTA_HF_CLIENT_IND_ROAM      4  /* Roaming status indicator */
    122 #define BTA_HF_CLIENT_IND_CALLSETUP 5  /* Call setup status indicator */
    123 #define BTA_HF_CLIENT_IND_CALLHELD  6  /* Call hold status indicator */
    124 
    125 typedef UINT8 tBTA_HF_CLIENT_IND_TYPE;
    126 
    127 /* AT commands */
    128 #define BTA_HF_CLIENT_AT_CMD_VTS    0
    129 #define BTA_HF_CLIENT_AT_CMD_BTRH   1
    130 #define BTA_HF_CLIENT_AT_CMD_CHUP   2
    131 #define BTA_HF_CLIENT_AT_CMD_CHLD   3
    132 #define BTA_HF_CLIENT_AT_CMD_BCC    4
    133 #define BTA_HF_CLIENT_AT_CMD_CNUM   5
    134 #define BTA_HF_CLIENT_AT_CMD_ATA    6
    135 #define BTA_HF_CLIENT_AT_CMD_COPS   7
    136 #define BTA_HF_CLIENT_AT_CMD_ATD    8
    137 #define BTA_HF_CLIENT_AT_CMD_VGM    9
    138 #define BTA_HF_CLIENT_AT_CMD_VGS    10
    139 #define BTA_HF_CLIENT_AT_CMD_BVRA   11
    140 #define BTA_HF_CLIENT_AT_CMD_CLCC   12
    141 #define BTA_HF_CLIENT_AT_CMD_BINP   13
    142 #define BTA_HF_CLIENT_AT_CMD_BLDN   14
    143 #define BTA_HF_CLIENT_AT_CMD_NREC   15
    144 
    145 typedef UINT8 tBTA_HF_CLIENT_AT_CMD_TYPE;
    146 
    147 /* data associated with most non-AT events */
    148 /* placeholder, if not needed should be removed*/
    149 typedef struct
    150 {
    151 } tBTA_HF_CLIENT_HDR;
    152 
    153 /* data associated with BTA_HF_CLIENT_REGISTER_EVT */
    154 typedef struct
    155 {
    156     tBTA_HF_CLIENT_HDR      hdr;
    157     UINT16                  handle;
    158     tBTA_HF_CLIENT_STATUS   status;
    159 } tBTA_HF_CLIENT_REGISTER;
    160 
    161 /* data associated with BTA_HF_CLIENT_OPEN_EVT */
    162 typedef struct
    163 {
    164     tBTA_HF_CLIENT_HDR      hdr;
    165     BD_ADDR                 bd_addr;
    166     tBTA_HF_CLIENT_STATUS   status;
    167 } tBTA_HF_CLIENT_OPEN;
    168 
    169 /* data associated with BTA_HF_CLIENT_CONN_EVT */
    170 typedef struct
    171 {
    172     tBTA_HF_CLIENT_HDR         hdr;
    173     tBTA_HF_CLIENT_PEER_FEAT   peer_feat;
    174     tBTA_HF_CLIENT_CHLD_FEAT   chld_feat;
    175 } tBTA_HF_CLIENT_CONN;
    176 
    177 /* data associated with BTA_HF_CLIENT_IND_EVT event */
    178 typedef struct
    179 {
    180     tBTA_HF_CLIENT_HDR         hdr;
    181     tBTA_HF_CLIENT_IND_TYPE    type;
    182     UINT16                     value;
    183 } tBTA_HF_CLIENT_IND;
    184 
    185 /* data associated with BTA_HF_CLIENT_OPERATOR_NAME_EVT */
    186 #define BTA_HF_CLIENT_OPERATOR_NAME_LEN 16
    187 typedef struct
    188 {
    189     char                       name[BTA_HF_CLIENT_OPERATOR_NAME_LEN + 1];
    190 } tBTA_HF_CLIENT_OPERATOR_NAME;
    191 
    192 /* data associated with BTA_HF_CLIENT_CLIP_EVT  and BTA_HF_CLIENT_CCWA_EVT*/
    193 #define BTA_HF_CLIENT_NUMBER_LEN 32
    194 typedef struct
    195 {
    196     char                       number[BTA_HF_CLIENT_NUMBER_LEN + 1];
    197 } tBTA_HF_CLIENT_NUMBER;
    198 
    199 /* data associated with BTA_HF_CLIENT_AT_RESULT_EVT event */
    200 typedef struct
    201 {
    202     tBTA_HF_CLIENT_AT_RESULT_TYPE    type;
    203     UINT16                           cme;
    204 } tBTA_HF_CLIENT_AT_RESULT;
    205 
    206 /* data associated with BTA_HF_CLIENT_CLCC_EVT event */
    207 typedef struct
    208 {
    209     UINT32                     idx;
    210     BOOLEAN                    inc;
    211     UINT8                      status;
    212     BOOLEAN                    mpty;
    213     BOOLEAN                    number_present;
    214     char                       number[BTA_HF_CLIENT_NUMBER_LEN + 1];
    215 } tBTA_HF_CLIENT_CLCC;
    216 
    217 /* data associated with BTA_HF_CLIENT_CNUM_EVT event */
    218 typedef struct
    219 {
    220     UINT16                     service;
    221     char                       number[BTA_HF_CLIENT_NUMBER_LEN + 1];
    222 } tBTA_HF_CLIENT_CNUM;
    223 
    224 /* data associated with other events */
    225 typedef struct
    226 {
    227     UINT16                     value;
    228 } tBTA_HF_CLIENT_VAL;
    229 
    230 /* union of data associated with AG callback */
    231 typedef union
    232 {
    233     tBTA_HF_CLIENT_HDR              hdr;
    234     tBTA_HF_CLIENT_REGISTER         reg;
    235     tBTA_HF_CLIENT_OPEN             open;
    236     tBTA_HF_CLIENT_CONN             conn;
    237     tBTA_HF_CLIENT_IND              ind;
    238     tBTA_HF_CLIENT_VAL              val;
    239     tBTA_HF_CLIENT_OPERATOR_NAME    operator;
    240     tBTA_HF_CLIENT_NUMBER           number;
    241     tBTA_HF_CLIENT_AT_RESULT        result;
    242     tBTA_HF_CLIENT_CLCC             clcc;
    243     tBTA_HF_CLIENT_CNUM             cnum;
    244 } tBTA_HF_CLIENT;
    245 
    246 typedef UINT32 tBTA_HF_CLIENT_FEAT;
    247 
    248 /* HF Client callback */
    249 typedef void (tBTA_HF_CLIENT_CBACK)(tBTA_HF_CLIENT_EVT event, tBTA_HF_CLIENT *p_data);
    250 
    251 #ifdef __cplusplus
    252 extern "C"
    253 {
    254 #endif
    255 
    256 /*****************************************************************************
    257 **  External Function Declarations
    258 *****************************************************************************/
    259 
    260 /*******************************************************************************
    261 **
    262 ** Function         BTA_HfClientEnable
    263 **
    264 ** Description      Enable the HF CLient service. When the enable
    265 **                  operation is complete the callback function will be
    266 **                  called with a BTA_HF_CLIENT_ENABLE_EVT. This function must
    267 **                  be called before other function in the HF CLient API are
    268 **                  called.
    269 **
    270 ** Returns          BTA_SUCCESS if OK, BTA_FAILURE otherwise.
    271 **
    272 *******************************************************************************/
    273 tBTA_STATUS BTA_HfClientEnable(tBTA_HF_CLIENT_CBACK *p_cback);
    274 
    275 /*******************************************************************************
    276 **
    277 ** Function         BTA_HfClientDisable
    278 **
    279 ** Description      Disable the HF Client service
    280 **
    281 **
    282 ** Returns          void
    283 **
    284 *******************************************************************************/
    285 void BTA_HfClientDisable(void);
    286 
    287 /*******************************************************************************
    288 **
    289 ** Function         BTA_HfClientRegister
    290 **
    291 ** Description      Register an HF Client service.
    292 **
    293 **
    294 ** Returns          void
    295 **
    296 *******************************************************************************/
    297 void BTA_HfClientRegister(tBTA_SEC sec_mask, tBTA_HF_CLIENT_FEAT features,
    298                           char *p_service_name);
    299 
    300 /*******************************************************************************
    301 **
    302 ** Function         BTA_HfClientDeregister
    303 **
    304 ** Description      Deregister an HF Client service.
    305 **
    306 **
    307 ** Returns          void
    308 **
    309 *******************************************************************************/
    310 void BTA_HfClientDeregister(UINT16 handle);
    311 
    312 /*******************************************************************************
    313 **
    314 ** Function         BTA_HfClientOpen
    315 **
    316 ** Description      Opens a connection to an audio gateway.
    317 **                  When connection is open callback function is called
    318 **                  with a BTA_HF_CLIENT_OPEN_EVT. Only the data connection is
    319 **                  opened. The audio connection is not opened.
    320 **
    321 **
    322 ** Returns          void
    323 **
    324 *******************************************************************************/
    325 void BTA_HfClientOpen(UINT16 handle, BD_ADDR bd_addr, tBTA_SEC sec_mask);
    326 
    327 /*******************************************************************************
    328 **
    329 ** Function         BTA_HfClientClose
    330 **
    331 ** Description      Close the current connection to an audio gateway.
    332 **                  Any current audio connection will also be closed
    333 **
    334 **
    335 ** Returns          void
    336 **
    337 *******************************************************************************/
    338 void BTA_HfClientClose(UINT16 handle);
    339 
    340 /*******************************************************************************
    341 **
    342 ** Function         BTA_HfCllientAudioOpen
    343 **
    344 ** Description      Opens an audio connection to the currently connected
    345 **                 audio gateway
    346 **
    347 **
    348 ** Returns          void
    349 **
    350 *******************************************************************************/
    351 void BTA_HfClientAudioOpen(UINT16 handle);
    352 
    353 /*******************************************************************************
    354 **
    355 ** Function         BTA_HfClientAudioClose
    356 **
    357 ** Description      Close the currently active audio connection to an audio
    358 **                  gateway. The data connection remains open
    359 **
    360 **
    361 ** Returns          void
    362 **
    363 *******************************************************************************/
    364 void BTA_HfClientAudioClose(UINT16 handle);
    365 
    366 /*******************************************************************************
    367 **
    368 ** Function         BTA_HfClientSendAT
    369 **
    370 ** Description      send AT command
    371 **
    372 **
    373 ** Returns          void
    374 **
    375 *******************************************************************************/
    376 void BTA_HfClientSendAT(UINT16 handle, tBTA_HF_CLIENT_AT_CMD_TYPE at, UINT32 val1, UINT32 val2, const char *str);
    377 
    378 #ifdef __cplusplus
    379 }
    380 #endif
    381 
    382 #endif /* BTA_HF_CLIENT_API_H */
    383