1 // Copyright 2018 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 16 /******************************************************************************* 17 * 18 * Filename: btc_hf_client.h 19 * 20 * Description: Main API header file for all BTC HF client functions accessed 21 * from internal stack. 22 * 23 *******************************************************************************/ 24 25 #ifndef __BTC_HF_CLIENT_H__ 26 #define __BTC_HF_CLIENT_H__ 27 28 #include "common/bt_target.h" 29 #include "esp_hf_client_api.h" 30 #include "btc/btc_task.h" 31 #include "btc/btc_common.h" 32 #include "bta/bta_hf_client_api.h" 33 34 #if (BTC_HF_CLIENT_INCLUDED == TRUE) 35 /******************************************************************************* 36 ** Type definitions for callback functions 37 ********************************************************************************/ 38 typedef enum { 39 BTC_HF_CLIENT_INIT_EVT, 40 BTC_HF_CLIENT_DEINIT_EVT, 41 BTC_HF_CLIENT_CONNECT_EVT, 42 BTC_HF_CLIENT_DISCONNECT_EVT, 43 BTC_HF_CLIENT_CONNECT_AUDIO_EVT, 44 BTC_HF_CLIENT_DISCONNECT_AUDIO_EVT, 45 BTC_HF_CLIENT_START_VOICE_RECOGNITION_EVT, 46 BTC_HF_CLIENT_STOP_VOICE_RECOGNITION_EVT, 47 BTC_HF_CLIENT_VOLUME_UPDATE_EVT, 48 BTC_HF_CLIENT_DIAL_EVT, 49 BTC_HF_CLIENT_DIAL_MEMORY_EVT, 50 BTC_HF_CLIENT_SEND_CHLD_CMD_EVT, 51 BTC_HF_CLIENT_SEND_BTRH_CMD_EVT, 52 BTC_HF_CLIENT_ANSWER_CALL_EVT, 53 BTC_HF_CLIENT_REJECT_CALL_EVT, 54 BTC_HF_CLIENT_QUERY_CURRENT_CALLS_EVT, 55 BTC_HF_CLIENT_QUERY_CURRENT_OPERATOR_NAME_EVT, 56 BTC_HF_CLIENT_RETRIEVE_SUBSCRIBER_INFO_EVT, 57 BTC_HF_CLIENT_SEND_DTMF_EVT, 58 BTC_HF_CLIENT_REQUEST_LAST_VOICE_TAG_NUMBER_EVT, 59 BTC_HF_CLIENT_REGISTER_DATA_CALLBACK_EVT, 60 BTC_HF_CLIENT_SEND_NREC_EVT, 61 } btc_hf_client_act_t; 62 63 /* btc_hf_client_args_t */ 64 typedef union { 65 // BTC_HF_CLIENT_CONNECT_EVT 66 bt_bdaddr_t connect; 67 68 // BTC_HF_CLIENT_DISCONNECT_EVT 69 bt_bdaddr_t disconnect; 70 71 // BTC_HF_CLIENT_CONNECT_AUDIO_EVT 72 bt_bdaddr_t connect_audio; 73 74 // BTC_HF_CLIENT_DISCONNECT_AUDIO_EVT 75 bt_bdaddr_t disconnect_audio; 76 77 // BTC_HF_CLIENT_VOLUME_UPDATE_EVT, 78 struct volume_update_args { 79 esp_hf_volume_control_target_t type; 80 int volume; 81 } volume_update; 82 83 // BTC_HF_CLIENT_DIAL_EVT 84 struct dial_args { 85 char number[ESP_BT_HF_CLIENT_NUMBER_LEN + 1]; 86 } dial; 87 88 // BTC_HF_CLIENT_DIAL_MEMORY_EVT 89 struct dial_memory_args { 90 int location; 91 } dial_memory; 92 93 // BTC_HF_CLIENT_SEND_CHLD_CMD_EVT 94 struct send_chld_cmd_args { 95 esp_hf_chld_type_t type; 96 int idx; 97 } chld; 98 99 // BTC_HF_CLIENT_SEND_BTRH_CMD_EVT 100 struct send_btrh_cmd_args { 101 esp_hf_btrh_cmd_t cmd; 102 } btrh; 103 104 // BTC_HF_CLIENT_SEND_DTMF_EVT 105 struct send_dtmf { 106 char code; 107 } send_dtmf; 108 109 // BTC_HF_CLIENT_REGISTER_DATA_CALLBACK_EVT 110 struct reg_data_callback { 111 esp_hf_client_incoming_data_cb_t recv; 112 esp_hf_client_outgoing_data_cb_t send; 113 } reg_data_cb; 114 } btc_hf_client_args_t; 115 116 /************************************************************************************ 117 ** Local type definitions 118 ************************************************************************************/ 119 /* BTC-HF control block to map bdaddr to BTA handle */ 120 typedef struct 121 { 122 bool initialized; 123 UINT16 handle; 124 bt_bdaddr_t connected_bda; 125 esp_hf_client_connection_state_t state; 126 esp_hf_vr_state_t vr_state; 127 tBTA_HF_CLIENT_PEER_FEAT peer_feat; 128 tBTA_HF_CLIENT_CHLD_FEAT chld_feat; 129 } btc_hf_client_cb_t; 130 131 typedef struct 132 { 133 UINT32 btc_hf_client_features; 134 btc_hf_client_cb_t btc_hf_client_cb; 135 esp_hf_client_incoming_data_cb_t btc_hf_client_incoming_data_cb; 136 esp_hf_client_outgoing_data_cb_t btc_hf_client_outgoing_data_cb; 137 }hf_client_local_param_t; 138 139 #if HFP_DYNAMIC_MEMORY == TRUE 140 extern hf_client_local_param_t *hf_client_local_param_ptr; 141 #define hf_client_local_param (*hf_client_local_param_ptr) 142 #endif 143 144 /******************************************************************************* 145 ** BTC HF AG API 146 ********************************************************************************/ 147 148 void btc_hf_client_call_handler(btc_msg_t *msg); 149 150 void btc_hf_client_cb_handler(btc_msg_t *msg); 151 152 void btc_hf_client_incoming_data_cb_to_app(const uint8_t *data, uint32_t len); 153 154 uint32_t btc_hf_client_outgoing_data_cb_to_app(uint8_t *data, uint32_t len); 155 #endif ///BTC_HF_CLIENT_INCLUDED == TRUE 156 157 #endif /* __BTC_HF_CLIENT_H__ */ 158