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 #include "bta_hfp_defs.h" 30 31 #if (BTA_HF_INCLUDED == TRUE) 32 /***************************************************************************** 33 ** Constants and data types 34 *****************************************************************************/ 35 36 /* Hands-Free unit(HF) version */ 37 #define HFP_HF_VERSION_1_6 0x0106 /* v1.6 */ 38 #define HFP_HF_VERSION_1_7 0x0107 /* v1.7 */ 39 40 /* HFP peer (AG) features*/ 41 #define BTA_HF_CLIENT_PEER_FEAT_3WAY 0x00000001 /* Three-way calling */ 42 #define BTA_HF_CLIENT_PEER_FEAT_ECNR 0x00000002 /* Echo cancellation and/or noise reduction */ 43 #define BTA_HF_CLIENT_PEER_FEAT_VREC 0x00000004 /* Voice recognition */ 44 #define BTA_HF_CLIENT_PEER_INBAND 0x00000008 /* In-band ring tone */ 45 #define BTA_HF_CLIENT_PEER_VTAG 0x00000010 /* Attach a phone number to a voice tag */ 46 #define BTA_HF_CLIENT_PEER_REJECT 0x00000020 /* Ability to reject incoming call */ 47 #define BTA_HF_CLIENT_PEER_ECS 0x00000040 /* Enhanced Call Status */ 48 #define BTA_HF_CLIENT_PEER_ECC 0x00000080 /* Enhanced Call Control */ 49 #define BTA_HF_CLIENT_PEER_EXTERR 0x00000100 /* Extended error codes */ 50 #define BTA_HF_CLIENT_PEER_CODEC 0x00000200 /* Codec Negotiation */ 51 /* HFP 1.7+ */ 52 #define BTA_HF_CLIENT_PEER_HF_IND 0x00000400 /* HF Indicators */ 53 #define BTA_HF_CLIENT_PEER_ESCO_S4 0x00000800 /* eSCO S4 Setting Supported */ 54 55 typedef UINT16 tBTA_HF_CLIENT_PEER_FEAT; 56 57 /* HFP HF features */ 58 #define BTA_HF_CLIENT_FEAT_ECNR 0x00000001 /* Echo cancellation and/or noise reduction */ 59 #define BTA_HF_CLIENT_FEAT_3WAY 0x00000002 /* Call waiting and three-way calling */ 60 #define BTA_HF_CLIENT_FEAT_CLI 0x00000004 /* Caller ID presentation capability */ 61 #define BTA_HF_CLIENT_FEAT_VREC 0x00000008 /* Voice recognition activation */ 62 #define BTA_HF_CLIENT_FEAT_VOL 0x00000010 /* Remote volume control */ 63 #define BTA_HF_CLIENT_FEAT_ECS 0x00000020 /* Enhanced Call Status */ 64 #define BTA_HF_CLIENT_FEAT_ECC 0x00000040 /* Enhanced Call Control */ 65 #define BTA_HF_CLIENT_FEAT_CODEC 0x00000080 /* Codec Negotiation */ 66 #define BTA_HF_CLIENT_FEAT_HF_IND 0x00000100 /* HF indicators */ 67 #define BTA_HF_CLIENT_FEAT_ESCO_S4 0x00000200 /* eSCO S4 Setting Supported */ 68 69 /* HFP HF extended call handling - masks not related to any spec */ 70 #define BTA_HF_CLIENT_CHLD_REL 0x00000001 /* 0 Release waiting call or held calls */ 71 #define BTA_HF_CLIENT_CHLD_REL_ACC 0x00000002 /* 1 Release active calls and accept other (waiting or held) cal */ 72 #define BTA_HF_CLIENT_CHLD_REL_X 0x00000004 /* 1x Release x call*/ 73 #define BTA_HF_CLIENT_CHLD_HOLD_ACC 0x00000008 /* 2 Active calls on hold and accept other call */ 74 #define BTA_HF_CLIENT_CHLD_PRIV_X 0x00000010 /* 2x Active multiparty call on hold except call x */ 75 #define BTA_HF_CLIENT_CHLD_MERGE 0x00000020 /* 3 Add held call to multiparty */ 76 #define BTA_HF_CLIENT_CHLD_MERGE_DETACH 0x00000040 /* 4 Add held call to multiparty */ 77 78 typedef UINT16 tBTA_HF_CLIENT_CHLD_FEAT; 79 80 /* HFP AG errors ot OK sent to HF Unit */ 81 #define BTA_HF_CLIENT_AT_RESULT_OK 0 82 #define BTA_HF_CLIENT_AT_RESULT_ERROR 1 83 #define BTA_HF_CLIENT_AT_RESULT_NO_CARRIER 2 84 #define BTA_HF_CLIENT_AT_RESULT_BUSY 3 85 #define BTA_HF_CLIENT_AT_RESULT_NO_ANSWER 4 86 #define BTA_HF_CLIENT_AT_RESULT_DELAY 5 87 #define BTA_HF_CLIENT_AT_RESULT_BLACKLISTED 6 88 #define BTA_HF_CLIENT_AT_RESULT_CME 7 89 90 typedef UINT8 tBTA_HF_CLIENT_AT_RESULT_TYPE; 91 92 /* HF Client callback events */ 93 #define BTA_HF_CLIENT_ENABLE_EVT 0 /* HF Client enabled */ 94 #define BTA_HF_CLIENT_REGISTER_EVT 1 /* HF Client registered */ 95 #define BTA_HF_CLIENT_OPEN_EVT 2 /* HF Client connection open */ 96 #define BTA_HF_CLIENT_CLOSE_EVT 3 /* HF Client connection closed */ 97 #define BTA_HF_CLIENT_CONN_EVT 4 /* Service level connection opened */ 98 #define BTA_HF_CLIENT_AUDIO_OPEN_EVT 5 /* Audio connection open */ 99 #define BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT 6 /* Audio connection with mSBC codec open */ 100 #define BTA_HF_CLIENT_AUDIO_CLOSE_EVT 7 /* Audio connection closed */ 101 #define BTA_HF_CLIENT_SPK_EVT 8 /* Speaker volume changed */ 102 #define BTA_HF_CLIENT_MIC_EVT 9 /* Microphone volume changed */ 103 #define BTA_HF_CLIENT_IND_EVT 10 /* Indicator */ 104 #define BTA_HF_CLIENT_VOICE_REC_EVT 11 /* AG changed voice recognition setting */ 105 #define BTA_HF_CLIENT_OPERATOR_NAME_EVT 12 /* Operator name acquired */ 106 #define BTA_HF_CLIENT_CLIP_EVT 13 /* Calling line identification event */ 107 #define BTA_HF_CLIENT_CCWA_EVT 14 /* Call waiting notification */ 108 #define BTA_HF_CLIENT_AT_RESULT_EVT 15 /* Call waiting notification */ 109 #define BTA_HF_CLIENT_CLCC_EVT 16 /* current call event */ 110 #define BTA_HF_CLIENT_CNUM_EVT 17 /* subscriber information event */ 111 #define BTA_HF_CLIENT_BTRH_EVT 18 /* bluetooth response and hold event */ 112 #define BTA_HF_CLIENT_BSIR_EVT 19 /* in-band ring tone setting changed event */ 113 #define BTA_HF_CLIENT_BINP_EVT 20 /* binp number event */ 114 #define BTA_HF_CLIENT_RING_INDICATION 21 /* HF Client ring indication */ 115 #define BTA_HF_CLIENT_DISABLE_EVT 30 /* HF Client disabled */ 116 117 typedef UINT8 tBTA_HF_CLIENT_EVT; 118 119 /* HF Client open status */ 120 #define BTA_HF_CLIENT_SUCCESS 0 /* Connection successfully opened */ 121 #define BTA_HF_CLIENT_FAIL_SDP 1 /* Open failed due to SDP */ 122 #define BTA_HF_CLIENT_FAIL_RFCOMM 2 /* Open failed due to RFCOMM */ 123 #define BTA_HF_CLIENT_FAIL_RESOURCES 3 /* out of resources failure */ 124 125 typedef UINT8 tBTA_HF_CLIENT_STATUS; 126 127 /* indicator constants HFP 1.1 and later */ 128 #define BTA_HF_CLIENT_IND_CALL 0 /* position of call indicator */ 129 #define BTA_HF_CLIENT_IND_CALLSETUP 1 /* position of callsetup indicator */ 130 #define BTA_HF_CLIENT_IND_SERVICE 2 /* position of service indicator */ 131 /* indicator constants HFP 1.5 and later */ 132 #define BTA_HF_CLIENT_IND_SIGNAL 3 /* position of signal strength indicator */ 133 #define BTA_HF_CLIENT_IND_ROAM 4 /* position of roaming indicator */ 134 #define BTA_HF_CLIENT_IND_BATTCH 5 /* position of battery charge indicator */ 135 #define BTA_HF_CLIENT_IND_CALLHELD 6 /* position of callheld indicator */ 136 #define BTA_HF_CLIENT_IND_BEARER 7 /* position of bearer indicator */ 137 typedef UINT8 tBTA_HF_CLIENT_IND_TYPE; 138 139 /* AT commands */ 140 #define BTA_HF_CLIENT_AT_CMD_VTS 0 141 #define BTA_HF_CLIENT_AT_CMD_BTRH 1 142 #define BTA_HF_CLIENT_AT_CMD_CHUP 2 143 #define BTA_HF_CLIENT_AT_CMD_CHLD 3 144 #define BTA_HF_CLIENT_AT_CMD_BCC 4 145 #define BTA_HF_CLIENT_AT_CMD_CNUM 5 146 #define BTA_HF_CLIENT_AT_CMD_ATA 6 147 #define BTA_HF_CLIENT_AT_CMD_COPS 7 148 #define BTA_HF_CLIENT_AT_CMD_ATD 8 149 #define BTA_HF_CLIENT_AT_CMD_VGM 9 150 #define BTA_HF_CLIENT_AT_CMD_VGS 10 151 #define BTA_HF_CLIENT_AT_CMD_BVRA 11 152 #define BTA_HF_CLIENT_AT_CMD_CLCC 12 153 #define BTA_HF_CLIENT_AT_CMD_BINP 13 154 #define BTA_HF_CLIENT_AT_CMD_BLDN 14 155 #define BTA_HF_CLIENT_AT_CMD_NREC 15 156 157 typedef UINT8 tBTA_HF_CLIENT_AT_CMD_TYPE; 158 159 /* data associated with most non-AT events */ 160 /* placeholder, if not needed should be removed*/ 161 typedef struct { 162 } tBTA_HF_CLIENT_HDR; 163 164 /* data associated with BTA_HF_CLIENT_REGISTER_EVT */ 165 typedef struct { 166 tBTA_HF_CLIENT_HDR hdr; 167 UINT16 handle; 168 tBTA_HF_CLIENT_STATUS status; 169 } tBTA_HF_CLIENT_REGISTER; 170 171 /* data associated with BTA_HF_CLIENT_OPEN_EVT */ 172 typedef struct { 173 tBTA_HF_CLIENT_HDR hdr; 174 BD_ADDR bd_addr; 175 tBTA_HF_CLIENT_STATUS status; 176 } tBTA_HF_CLIENT_OPEN; 177 178 /* data associated with BTA_HF_CLIENT_CONN_EVT */ 179 typedef struct { 180 tBTA_HF_CLIENT_HDR hdr; 181 tBTA_HF_CLIENT_PEER_FEAT peer_feat; 182 tBTA_HF_CLIENT_CHLD_FEAT chld_feat; 183 } tBTA_HF_CLIENT_CONN; 184 185 /* data associated with BTA_HF_CLIENT_IND_EVT event */ 186 typedef struct { 187 tBTA_HF_CLIENT_HDR hdr; 188 tBTA_HF_CLIENT_IND_TYPE type; 189 UINT16 value; 190 } tBTA_HF_CLIENT_IND; 191 192 /* data associated with BTA_HF_CLIENT_OPERATOR_NAME_EVT */ 193 #define BTA_HF_CLIENT_OPERATOR_NAME_LEN 16 194 typedef struct { 195 char name[BTA_HF_CLIENT_OPERATOR_NAME_LEN + 1]; 196 } tBTA_HF_CLIENT_OPERATOR_NAME; 197 198 /* data associated with BTA_HF_CLIENT_CLIP_EVT and BTA_HF_CLIENT_CCWA_EVT*/ 199 #define BTA_HF_CLIENT_NUMBER_LEN 32 200 typedef struct { 201 char number[BTA_HF_CLIENT_NUMBER_LEN + 1]; 202 } tBTA_HF_CLIENT_NUMBER; 203 204 /* data associated with BTA_HF_CLIENT_AT_RESULT_EVT event */ 205 typedef struct { 206 tBTA_HF_CLIENT_AT_RESULT_TYPE type; 207 UINT16 cme; 208 } tBTA_HF_CLIENT_AT_RESULT; 209 210 /* data associated with BTA_HF_CLIENT_CLCC_EVT event */ 211 typedef struct { 212 UINT32 idx; 213 BOOLEAN inc; 214 UINT8 status; 215 BOOLEAN mpty; 216 BOOLEAN number_present; 217 char number[BTA_HF_CLIENT_NUMBER_LEN + 1]; 218 } tBTA_HF_CLIENT_CLCC; 219 220 /* data associated with BTA_HF_CLIENT_CNUM_EVT event */ 221 typedef struct { 222 UINT16 service; 223 char number[BTA_HF_CLIENT_NUMBER_LEN + 1]; 224 } tBTA_HF_CLIENT_CNUM; 225 226 /* data associated with other events */ 227 typedef struct { 228 UINT16 value; 229 } tBTA_HF_CLIENT_VAL; 230 231 /* union of data associated with AG callback */ 232 typedef union { 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, void *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 #if (BTM_SCO_HCI_INCLUDED == TRUE ) 379 void BTA_HfClientCiData(void); 380 #endif /*#if (BTM_SCO_HCI_INCLUDED == TRUE ) */ 381 382 int BTA_HfClientGetCbDataSize(tBTA_HF_CLIENT_EVT event); 383 384 #ifdef __cplusplus 385 } 386 #endif 387 #endif /* #if (BTA_HF_INCLUDED == TRUE) */ 388 #endif /* BTA_HF_CLIENT_API_H */ 389