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