1 // Copyright 2019 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef __ESP_HF_AG_API_H__ 16 #define __ESP_HF_AG_API_H__ 17 18 #include "esp_err.h" 19 #include "esp_bt_defs.h" 20 #include "esp_hf_defs.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 /* features masks of HF AG */ 27 #define ESP_HF_PEER_FEAT_3WAY 0x01 /* Three-way calling */ 28 #define ESP_HF_PEER_FEAT_ECNR 0x02 /* Echo cancellation and/or noise reduction */ 29 #define ESP_HF_PEER_FEAT_VREC 0x04 /* Voice recognition */ 30 #define ESP_HF_PEER_FEAT_INBAND 0x08 /* In-band ring tone */ 31 #define ESP_HF_PEER_FEAT_VTAG 0x10 /* Attach a phone number to a voice tag */ 32 #define ESP_HF_PEER_FEAT_REJECT 0x20 /* Ability to reject incoming call */ 33 #define ESP_HF_PEER_FEAT_ECS 0x40 /* Enhanced Call Status */ 34 #define ESP_HF_PEER_FEAT_ECC 0x80 /* Enhanced Call Control */ 35 #define ESP_HF_PEER_FEAT_EXTERR 0x100 /* Extended error codes */ 36 #define ESP_HF_PEER_FEAT_CODEC 0x200 /* Codec Negotiation */ 37 38 /* CHLD feature masks of HF AG */ 39 #define ESP_HF_CHLD_FEAT_REL 0x01 /* 0 Release waiting call or held calls */ 40 #define ESP_HF_CHLD_FEAT_REL_ACC 0x02 /* 1 Release active calls and accept other waiting or held call */ 41 #define ESP_HF_CHLD_FEAT_REL_X 0x04 /* 1x Release specified active call only */ 42 #define ESP_HF_CHLD_FEAT_HOLD_ACC 0x08 /* 2 Active calls on hold and accept other waiting or held call */ 43 #define ESP_HF_CHLD_FEAT_PRIV_X 0x10 /* 2x Request private mode with specified call(put the rest on hold) */ 44 #define ESP_HF_CHLD_FEAT_MERGE 0x20 /* 3 Add held call to multiparty */ 45 #define ESP_HF_CHLD_FEAT_MERGE_DETACH 0x40 /* 4 Connect two calls and leave(disconnect from multiparty) */ 46 47 /// HF callback events 48 typedef enum 49 { 50 ESP_HF_CONNECTION_STATE_EVT = 0, /*!< Connection state changed event */ 51 ESP_HF_AUDIO_STATE_EVT, /*!< Audio connection state change event */ 52 ESP_HF_BVRA_RESPONSE_EVT, /*!< Voice recognition state change event */ 53 ESP_HF_VOLUME_CONTROL_EVT, /*!< Audio volume control command from HF Client, provided by +VGM or +VGS message */ 54 55 ESP_HF_UNAT_RESPONSE_EVT, /*!< Unknown AT cmd Response*/ 56 ESP_HF_IND_UPDATE_EVT, /*!< Indicator Update Event*/ 57 ESP_HF_CIND_RESPONSE_EVT, /*!< Call And Device Indicator Response*/ 58 ESP_HF_COPS_RESPONSE_EVT, /*!< Current operator information */ 59 ESP_HF_CLCC_RESPONSE_EVT, /*!< List of current calls notification */ 60 ESP_HF_CNUM_RESPONSE_EVT, /*!< Subscriber information response from HF Client */ 61 ESP_HF_VTS_RESPONSE_EVT, /*!< Enable or not DTMF */ 62 ESP_HF_NREC_RESPONSE_EVT, /*!< Enable or not NREC */ 63 64 ESP_HF_ATA_RESPONSE_EVT, /*!< Answer an Incoming Call */ 65 ESP_HF_CHUP_RESPONSE_EVT, /*!< Reject an Incoming Call */ 66 ESP_HF_DIAL_EVT, /*!< Origin an outgoing call with specific number or the dial the last number */ 67 ESP_HF_WBS_RESPONSE_EVT, /*!< Codec Status */ 68 ESP_HF_BCS_RESPONSE_EVT, /*!< Final Codec Choice */ 69 } esp_hf_cb_event_t; 70 71 /// HFP AG callback parameters 72 typedef union 73 { 74 /** 75 * @brief ESP_HS_CONNECTION_STATE_EVT 76 */ 77 struct hf_conn_stat_param { 78 esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ 79 esp_hf_connection_state_t state; /*!< Connection state */ 80 uint32_t peer_feat; /*!< HF supported features */ 81 uint32_t chld_feat; /*!< AG supported features on call hold and multiparty services */ 82 } conn_stat; /*!< AG callback param of ESP_HF_CONNECTION_STATE_EVT */ 83 84 /** 85 * @brief ESP_HF_AUDIO_STATE_EVT 86 */ 87 struct hf_audio_stat_param { 88 esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */ 89 esp_hf_audio_state_t state; /*!< Audio connection state */ 90 } audio_stat; /*!< AG callback param of ESP_HF_AUDIO_STATE_EVT */ 91 92 /** 93 * @brief ESP_HF_BVRA_RESPONSE_EVT 94 */ 95 struct hf_vra_rep_param { 96 esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */ 97 esp_hf_vr_state_t value; /*!< Voice recognition state */ 98 } vra_rep; /*!< AG callback param of ESP_HF_BVRA_RESPONSE_EVT */ 99 100 /** 101 * @brief ESP_HF_VOLUME_CONTROL_EVT 102 */ 103 struct hf_volume_control_param { 104 esp_hf_volume_type_t type; /*!< Volume control target, speaker or microphone */ 105 int volume; /*!< Gain, ranges from 0 to 15 */ 106 } volume_control; /*!< AG callback param of ESP_HF_VOLUME_CONTROL_EVT */ 107 108 /** 109 * @brief ESP_HF_UNAT_RESPOSNE_EVT 110 */ 111 struct hf_unat_rep_param { 112 char *unat; /*!< Unknown AT command string */ 113 }unat_rep; /*!< AG callback param of ESP_HF_UNAT_RESPONSE_EVT */ 114 115 /** 116 * @brief ESP_HF_CIND_RESPONSE_EVT 117 */ 118 struct hf_cind_param { 119 esp_hf_call_status_t call_status; /*!< call status indicator */ 120 esp_hf_call_setup_status_t call_setup_status; /*!< call setup status indicator */ 121 esp_hf_network_state_t svc; /*!< bluetooth proprietary call hold status indicator */ 122 int signal_strength; /*!< bluetooth proprietary call hold status indicator */ 123 esp_hf_roaming_status_t roam; /*!< bluetooth proprietary call hold status indicator */ 124 int battery_level; /*!< battery charge value, ranges from 0 to 5 */ 125 esp_hf_call_held_status_t call_held_status; /*!< bluetooth proprietary call hold status indicator */ 126 } cind; /*!< AG callback param of ESP_HF_CIND_RESPONSE_EVT */ 127 128 /** 129 * @brief ESP_HF_DIAL_EVT 130 */ 131 struct hf_out_call_param { 132 esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */ 133 char *num_or_loc; /*!< location in phone memory */ 134 } out_call; /*!< AG callback param of ESP_HF_DIAL_EVT */ 135 136 /** 137 * @brief ESP_HF_VTS_RESPOSNE_EVT 138 */ 139 struct hf_vts_rep_param { 140 char *code; /*!< MTF code from HF Client */ 141 }vts_rep; /*!< AG callback param of ESP_HF_VTS_RESPONSE_EVT */ 142 143 /** 144 * @brief ESP_HF_NREC_RESPOSNE_EVT 145 */ 146 struct hf_nrec_param { 147 esp_hf_nrec_t state; /*!< NREC enabled or disabled */ 148 } nrec; /*!< AG callback param of ESP_HF_NREC_RESPONSE_EVT */ 149 150 /** 151 * @brief ESP_HF_WBS_RESPONSE_EVT 152 */ 153 struct hf_wbs_rep_param { 154 esp_hf_wbs_config_t codec; /*!< codec mode CVSD or mSBC */ 155 } wbs_rep; /*!< AG callback param of ESP_HF_WBS_RESPONSE_EVT */ 156 157 /** 158 * @brief ESP_HF_BCS_RESPONSE_EVT 159 */ 160 struct hf_bcs_rep_param { 161 esp_hf_wbs_config_t mode; /*!< codec mode CVSD or mSBC */ 162 } bcs_rep; /*!< AG callback param of ESP_HF_BCS_RESPONSE_EVT */ 163 164 } esp_hf_cb_param_t; /*!< HFP AG callback param compound*/ 165 166 /** 167 * @brief AG incoming data callback function, the callback is useful in case of 168 * Voice Over HCI. 169 * 170 * @param[in] buf : pointer to incoming data(payload of HCI synchronous data packet), the 171 * buffer is allocated inside bluetooth protocol stack and will be released after 172 * invoke of the callback is finished. 173 * 174 * @param[in] len : size(in bytes) in buf 175 */ 176 typedef void (* esp_hf_incoming_data_cb_t)(const uint8_t *buf, uint32_t len); 177 178 /** 179 * @brief AG outgoing data callback function, the callback is useful in case of 180 * Voice Over HCI. Once audio connection is set up and the application layer has 181 * prepared data to send, the lower layer will call this function to read data 182 * and then send. This callback is supposed to be implemented as non-blocking, 183 * and if data is not enough, return value 0 is supposed. 184 * 185 * @param[in] buf : pointer to incoming data(payload of HCI synchronous data packet), the 186 * buffer is allocated inside bluetooth protocol stack and will be released after 187 * invoke of the callback is finished. 188 * 189 * @param[in] len : size(in bytes) in buf 190 * 191 * @return length of data successfully read 192 */ 193 typedef uint32_t (* esp_hf_outgoing_data_cb_t) (uint8_t *buf, uint32_t len); 194 195 /** 196 * @brief HF AG callback function type 197 * 198 * @param event : Event type 199 * 200 * @param param : Pointer to callback parameter 201 */ 202 typedef void (* esp_hf_cb_t) (esp_hf_cb_event_t event, esp_hf_cb_param_t *param); 203 204 /************************************************************************************ 205 ** ESP HF API 206 ************************************************************************************/ 207 /** 208 * @brief Register application callback function to HFP AG module. 209 * This function should be called only after esp_bluedroid_enable() completes successfully. 210 * 211 * @param[in] callback: HFP AG event callback function 212 * 213 * @return 214 * - ESP_OK: success 215 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 216 * - ESP_FAIL: if callback is a NULL function pointer 217 * 218 */ 219 esp_err_t esp_bt_hf_register_callback(esp_hf_cb_t callback); 220 221 /** 222 * 223 * @brief Initialize the bluetooth HF AG module. 224 * This function should be called after esp_bluedroid_enable() completes successfully. 225 * 226 * @param[in] remote_addr: remote bluetooth device address 227 * 228 * @return 229 * - ESP_OK: if the initialization request is sent successfully 230 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 231 * - ESP_FAIL: others 232 * 233 */ 234 esp_err_t esp_bt_hf_init(esp_bd_addr_t remote_addr); 235 236 /** 237 * 238 * @brief De-initialize for HF AG module. 239 * This function should be called only after esp_bluedroid_enable() completes successfully. 240 * 241 * @param[in] remote_addr: remote bluetooth device address 242 * 243 * @return 244 * - ESP_OK: success 245 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 246 * - ESP_FAIL: others 247 * 248 */ 249 esp_err_t esp_bt_hf_deinit(esp_bd_addr_t remote_addr); 250 251 /** 252 * 253 * @brief To establish a Service Level Connection to remote bluetooth HFP client device. 254 * This function must be called after esp_bt_hf_init() and before esp_bt_hf_deinit(). 255 * 256 * @param[in] remote_bda: remote bluetooth HFP client device address 257 * 258 * @return 259 * - ESP_OK: connect request is sent to lower layer 260 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 261 * - ESP_FAIL: others 262 * 263 */ 264 esp_err_t esp_bt_hf_connect(esp_bd_addr_t remote_bda); 265 266 /** 267 * 268 * @brief Disconnect from the remote HFP client. This function must be called 269 * after esp_bt_hf_init() and before esp_bt_hf_deinit(). 270 * 271 * @param[in] remote_bda: remote bluetooth device address 272 * 273 * @return 274 * - ESP_OK: disconnect request is sent to lower layer 275 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 276 * - ESP_FAIL: others 277 * 278 */ 279 esp_err_t esp_bt_hf_disconnect(esp_bd_addr_t remote_bda); 280 281 /** 282 * 283 * @brief Create audio connection with remote HFP client. 284 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 285 * 286 * @param[in] remote_bda: remote bluetooth device address 287 * 288 * @return 289 * - ESP_OK: disconnect request is sent to lower layer 290 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 291 * - ESP_FAIL: others 292 * 293 */ 294 esp_err_t esp_bt_hf_connect_audio(esp_bd_addr_t remote_bda); 295 296 /** 297 * 298 * @brief Release the established audio connection with remote HFP client. 299 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 300 * 301 * @param[in] remote_bda: remote bluetooth device address 302 * 303 * @return 304 * - ESP_OK: disconnect request is sent to lower layer 305 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 306 * - ESP_FAIL: others 307 * 308 */ 309 esp_err_t esp_bt_hf_disconnect_audio(esp_bd_addr_t remote_bda); 310 311 /** 312 * 313 * @brief Response of Volume Recognition Command(AT+VRA) from HFP client. 314 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 315 * 316 * @param[in] remote_bda: the device address of voice recognization initiator 317 * 318 * @param[in] value: 0 - voice recognition disabled, 1- voice recognition enabled 319 * 320 * @return 321 * - ESP_OK: disconnect request is sent to lower layer 322 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 323 * - ESP_FAIL: others 324 * 325 */ 326 esp_err_t esp_bt_hf_vra(esp_bd_addr_t remote_bda, esp_hf_vr_state_t value); 327 328 /** 329 * 330 * @brief Volume synchronization with HFP client. 331 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 332 * 333 * @param[in] remote_bda: remote bluetooth device address 334 * 335 * @param[in] type: volume control target, speaker or microphone 336 * 337 * @param[in] volume: gain of the speaker of microphone, ranges 0 to 15 338 * 339 * @return 340 * - ESP_OK: disconnect request is sent to lower layer 341 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 342 * - ESP_FAIL: others 343 * 344 */ 345 esp_err_t esp_bt_hf_volume_control(esp_bd_addr_t remote_bda, esp_hf_volume_control_target_t type, int volume); 346 347 /** 348 * 349 * @brief Handle Unknown AT command from HFP Client. 350 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 351 * 352 * @param[in] remote_addr: remote bluetooth device address 353 * 354 * @param[in] unat: User AT command response to HF Client. 355 * It will response "ERROR" by default if unat is NULL. 356 * @return 357 * - ESP_OK: disconnect request is sent to lower layer 358 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 359 * - ESP_FAIL: others 360 * 361 */ 362 esp_err_t esp_hf_unat_response(esp_bd_addr_t remote_addr, char *unat); 363 364 /** 365 * 366 * @brief Unsolicited send extend AT error code to HFP Client. 367 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 368 * 369 * @param[in] remote_bda: remote bluetooth device address 370 * @param[in] response_code: AT command response code 371 * @param[in] error_code: CME error code 372 * @return 373 * - ESP_OK: disconnect request is sent to lower layer 374 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 375 * - ESP_FAIL: others 376 * 377 */ 378 esp_err_t esp_bt_hf_cmee_response(esp_bd_addr_t remote_bda, esp_hf_at_response_code_t response_code, esp_hf_cme_err_t error_code); 379 380 /** 381 * 382 * @brief Usolicited send device status notificationto HFP Client. 383 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 384 * 385 * @param[in] remote_addr: remote bluetooth device address 386 * @param[in] call_state: call state 387 * @param[in] call_setup_state: call setup state 388 * @param[in] ntk_state: network service state 389 * @param[in] signal: signal strength from 0 to 5 390 * @return 391 * - ESP_OK: disconnect request is sent to lower layer 392 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 393 * - ESP_FAIL: others 394 * 395 */ 396 esp_err_t esp_bt_hf_indchange_notification(esp_bd_addr_t remote_addr, esp_hf_call_status_t call_state, 397 esp_hf_call_setup_status_t call_setup_state, 398 esp_hf_network_state_t ntk_state, int signal); 399 400 /** 401 * 402 * @brief Response to device individual indicatiors to HFP Client. 403 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 404 * 405 * @param[in] remote_addr: remote bluetooth device address 406 * @param[in] call_state: call state 407 * @param[in] call_setup_state: call setup state 408 * @param[in] ntk_state: network service state 409 * @param[in] signal: signal strength from 0 to 5 410 * @param[in] roam: roam state 411 * @param[in] batt_lev: batery level from 0 to 5 412 * @param[in] call_held_status: call held status 413 * @return 414 * - ESP_OK: disconnect request is sent to lower layer 415 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 416 * - ESP_FAIL: others 417 * 418 */ 419 esp_err_t esp_bt_hf_cind_response(esp_bd_addr_t remote_addr, 420 esp_hf_call_status_t call_state, 421 esp_hf_call_setup_status_t call_setup_state, 422 esp_hf_network_state_t ntk_state, int signal, esp_hf_roaming_status_t roam, int batt_lev, 423 esp_hf_call_held_status_t call_held_status); 424 425 /** 426 * 427 * @brief Reponse for AT+COPS command from HF Client. 428 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 429 * 430 * @param[in] remote_addr: remote bluetooth device address 431 * @param[in] name: current operator name 432 * @return 433 * - ESP_OK: disconnect request is sent to lower layer 434 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 435 * - ESP_FAIL: others 436 * 437 */ 438 esp_err_t esp_bt_hf_cops_response(esp_bd_addr_t remote_addr, char *name); 439 440 /** 441 * 442 * @brief Response to AT+CLCC command from HFP Client. 443 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 444 * 445 * @param[in] remote_addr: remote bluetooth device address 446 * @param[in] index: the index of current call 447 * @param[in] dir: call direction (incoming/outgoing) 448 * @param[in] current_call_state: current call state 449 * @param[in] mode: current call mode (voice/data/fax) 450 * @param[in] mpty: single or multi type 451 * @param[in] number: current call number 452 * @param[in] type: international type or unknow 453 * @return 454 * - ESP_OK: disconnect request is sent to lower layer 455 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 456 * - ESP_FAIL: others 457 * 458 */ 459 esp_err_t esp_bt_hf_clcc_response(esp_bd_addr_t remote_addr, int index, esp_hf_current_call_direction_t dir, 460 esp_hf_current_call_status_t current_call_state, esp_hf_current_call_mode_t mode, 461 esp_hf_current_call_mpty_type_t mpty, char *number, esp_hf_call_addr_type_t type); 462 463 /** 464 * 465 * @brief Response for AT+CNUM command from HF Client. 466 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 467 * 468 * @param[in] remote_addr: remote bluetooth device address 469 * @param[in] number: registration number 470 * @param[in] type: service type (unknown/voice/fax) 471 * @return 472 * - ESP_OK: disconnect request is sent to lower layer 473 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 474 * - ESP_FAIL: others 475 * 476 */ 477 esp_err_t esp_bt_hf_cnum_response(esp_bd_addr_t remote_addr, char *number, esp_hf_subscriber_service_type_t type); 478 479 /** 480 * 481 * @brief Inform HF Client that AG Provided in-band ring tone or not. 482 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 483 * 484 * @param[in] remote_addr: remote bluetooth device address 485 * @param[in] state: in-band ring tone state 486 * @return 487 * - ESP_OK: disconnect request is sent to lower layer 488 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 489 * - ESP_FAIL: others 490 * 491 */ 492 esp_err_t esp_bt_hf_bsir(esp_bd_addr_t remote_addr, esp_hf_in_band_ring_state_t state); 493 494 /** 495 * 496 * @brief Answer Incoming Call from AG. 497 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 498 * 499 * @param[in] remote_addr: remote bluetooth device address 500 * @param[in] num_active: the number of active call 501 * @param[in] num_held: the number of held call 502 * @param[in] call_state: call state 503 * @param[in] call_setup_state: call setup state 504 * @param[in] number: number of the incoming call 505 * @param[in] call_addr_type: call address type 506 * @return 507 * - ESP_OK: disconnect request is sent to lower layer 508 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 509 * - ESP_FAIL: others 510 * 511 */ 512 esp_err_t esp_bt_hf_answer_call(esp_bd_addr_t remote_addr, int num_active, int num_held, 513 esp_hf_call_status_t call_state, esp_hf_call_setup_status_t call_setup_state, 514 char *number, esp_hf_call_addr_type_t call_addr_type); 515 516 /** 517 * 518 * @brief Reject Incoming Call from AG. 519 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 520 * 521 * @param[in] remote_addr: remote bluetooth device address 522 * @param[in] num_active: the number of active call 523 * @param[in] num_held: the number of held call 524 * @param[in] call_state: call state 525 * @param[in] call_setup_state: call setup state 526 * @param[in] number: number of the incoming call 527 * @param[in] call_addr_type: call address type 528 * @return 529 * - ESP_OK: disconnect request is sent to lower layer 530 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 531 * - ESP_FAIL: others 532 * 533 */ 534 esp_err_t esp_bt_hf_reject_call(esp_bd_addr_t remote_addr, int num_active, int num_held, 535 esp_hf_call_status_t call_state, esp_hf_call_setup_status_t call_setup_state, 536 char *number, esp_hf_call_addr_type_t call_addr_type); 537 538 /** 539 * 540 * @brief Initiate a call from AG. 541 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 542 * 543 * @param[in] remote_addr: remote bluetooth device address 544 * @param[in] num_active: the number of active call 545 * @param[in] num_held: the number of held call 546 * @param[in] call_state: call state 547 * @param[in] call_setup_state: call setup state 548 * @param[in] number: number of the outgoing call 549 * @param[in] call_addr_type: call address type 550 * @return 551 * - ESP_OK: disconnect request is sent to lower layer 552 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 553 * - ESP_FAIL: others 554 * 555 */ 556 esp_err_t esp_bt_hf_out_call(esp_bd_addr_t remote_addr, int num_active, int num_held, 557 esp_hf_call_status_t call_state, esp_hf_call_setup_status_t call_setup_state, 558 char *number, esp_hf_call_addr_type_t call_addr_type); 559 560 /** 561 * 562 * @brief End an ongoing call. 563 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 564 * 565 * @param[in] remote_addr: remote bluetooth device address 566 * @param[in] num_active: the number of active call 567 * @param[in] num_held: the number of held call 568 * @param[in] call_state: call state 569 * @param[in] call_setup_state: call setup state 570 * @param[in] number: number of the call 571 * @param[in] call_addr_type: call address type 572 * @return 573 * - ESP_OK: disconnect request is sent to lower layer 574 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 575 * - ESP_FAIL: others 576 * 577 */ 578 esp_err_t esp_bt_hf_end_call(esp_bd_addr_t remote_addr, int num_active, int num_held, 579 esp_hf_call_status_t call_state, esp_hf_call_setup_status_t call_setup_state, 580 char *number, esp_hf_call_addr_type_t call_addr_type); 581 582 /** 583 * @brief Register AG data output function. 584 * The callback is only used in the case that Voice Over HCI is enabled. 585 * 586 * @param[in] recv: HFP client incoming data callback function 587 * @param[in] send: HFP client outgoing data callback function 588 * 589 * @return 590 * - ESP_OK: success 591 * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled 592 * - ESP_FAIL: if callback is a NULL function pointer 593 * 594 */ 595 esp_err_t esp_bt_hf_register_data_callback(esp_hf_incoming_data_cb_t recv, esp_hf_outgoing_data_cb_t send); 596 597 598 /** 599 * @brief Trigger the lower-layer to fetch and send audio data. 600 * 601 * This function is only used in the case that Voice Over HCI is enabled. 602 * As a precondition to use this API, Service Level Connection shall exist with HFP client. 603 * After this function is called, lower layer will invoke esp_hf_client_outgoing_data_cb_t to fetch data 604 * 605 */ 606 void esp_hf_outgoing_data_ready(void); 607 608 #ifdef __cplusplus 609 } 610 #endif 611 612 #endif //__ESP_HF_AG_API_H__ 613