1 /* 2 * Copyright (C) 2012-2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_INCLUDE_BT_HF_CLIENT_H 18 #define ANDROID_INCLUDE_BT_HF_CLIENT_H 19 20 __BEGIN_DECLS 21 22 typedef enum { 23 BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED = 0, 24 BTHF_CLIENT_CONNECTION_STATE_CONNECTING, 25 BTHF_CLIENT_CONNECTION_STATE_CONNECTED, 26 BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED, 27 BTHF_CLIENT_CONNECTION_STATE_DISCONNECTING 28 } bthf_client_connection_state_t; 29 30 typedef enum { 31 BTHF_CLIENT_AUDIO_STATE_DISCONNECTED = 0, 32 BTHF_CLIENT_AUDIO_STATE_CONNECTING, 33 BTHF_CLIENT_AUDIO_STATE_CONNECTED, 34 BTHF_CLIENT_AUDIO_STATE_CONNECTED_MSBC, 35 } bthf_client_audio_state_t; 36 37 typedef enum { 38 BTHF_CLIENT_VR_STATE_STOPPED = 0, 39 BTHF_CLIENT_VR_STATE_STARTED 40 } bthf_client_vr_state_t; 41 42 typedef enum { 43 BTHF_CLIENT_VOLUME_TYPE_SPK = 0, 44 BTHF_CLIENT_VOLUME_TYPE_MIC 45 } bthf_client_volume_type_t; 46 47 typedef enum { 48 BTHF_CLIENT_NETWORK_STATE_NOT_AVAILABLE = 0, 49 BTHF_CLIENT_NETWORK_STATE_AVAILABLE 50 } bthf_client_network_state_t; 51 52 typedef enum { 53 BTHF_CLIENT_SERVICE_TYPE_HOME = 0, 54 BTHF_CLIENT_SERVICE_TYPE_ROAMING 55 } bthf_client_service_type_t; 56 57 typedef enum { 58 BTHF_CLIENT_CALL_STATE_ACTIVE = 0, 59 BTHF_CLIENT_CALL_STATE_HELD, 60 BTHF_CLIENT_CALL_STATE_DIALING, 61 BTHF_CLIENT_CALL_STATE_ALERTING, 62 BTHF_CLIENT_CALL_STATE_INCOMING, 63 BTHF_CLIENT_CALL_STATE_WAITING, 64 BTHF_CLIENT_CALL_STATE_HELD_BY_RESP_HOLD, 65 } bthf_client_call_state_t; 66 67 typedef enum { 68 BTHF_CLIENT_CALL_NO_CALLS_IN_PROGRESS = 0, 69 BTHF_CLIENT_CALL_CALLS_IN_PROGRESS 70 } bthf_client_call_t; 71 72 typedef enum { 73 BTHF_CLIENT_CALLSETUP_NONE = 0, 74 BTHF_CLIENT_CALLSETUP_INCOMING, 75 BTHF_CLIENT_CALLSETUP_OUTGOING, 76 BTHF_CLIENT_CALLSETUP_ALERTING 77 78 } bthf_client_callsetup_t; 79 80 typedef enum { 81 BTHF_CLIENT_CALLHELD_NONE = 0, 82 BTHF_CLIENT_CALLHELD_HOLD_AND_ACTIVE, 83 BTHF_CLIENT_CALLHELD_HOLD, 84 } bthf_client_callheld_t; 85 86 typedef enum { 87 BTHF_CLIENT_RESP_AND_HOLD_HELD = 0, 88 BTRH_CLIENT_RESP_AND_HOLD_ACCEPT, 89 BTRH_CLIENT_RESP_AND_HOLD_REJECT, 90 } bthf_client_resp_and_hold_t; 91 92 typedef enum { 93 BTHF_CLIENT_CALL_DIRECTION_OUTGOING = 0, 94 BTHF_CLIENT_CALL_DIRECTION_INCOMING 95 } bthf_client_call_direction_t; 96 97 typedef enum { 98 BTHF_CLIENT_CALL_MPTY_TYPE_SINGLE = 0, 99 BTHF_CLIENT_CALL_MPTY_TYPE_MULTI 100 } bthf_client_call_mpty_type_t; 101 102 typedef enum { 103 BTHF_CLIENT_CMD_COMPLETE_OK = 0, 104 BTHF_CLIENT_CMD_COMPLETE_ERROR, 105 BTHF_CLIENT_CMD_COMPLETE_ERROR_NO_CARRIER, 106 BTHF_CLIENT_CMD_COMPLETE_ERROR_BUSY, 107 BTHF_CLIENT_CMD_COMPLETE_ERROR_NO_ANSWER, 108 BTHF_CLIENT_CMD_COMPLETE_ERROR_DELAYED, 109 BTHF_CLIENT_CMD_COMPLETE_ERROR_BLACKLISTED, 110 BTHF_CLIENT_CMD_COMPLETE_ERROR_CME 111 } bthf_client_cmd_complete_t; 112 113 typedef enum { 114 BTHF_CLIENT_CALL_ACTION_CHLD_0 = 0, 115 BTHF_CLIENT_CALL_ACTION_CHLD_1, 116 BTHF_CLIENT_CALL_ACTION_CHLD_2, 117 BTHF_CLIENT_CALL_ACTION_CHLD_3, 118 BTHF_CLIENT_CALL_ACTION_CHLD_4, 119 BTHF_CLIENT_CALL_ACTION_CHLD_1x, 120 BTHF_CLIENT_CALL_ACTION_CHLD_2x, 121 BTHF_CLIENT_CALL_ACTION_ATA, 122 BTHF_CLIENT_CALL_ACTION_CHUP, 123 BTHF_CLIENT_CALL_ACTION_BTRH_0, 124 BTHF_CLIENT_CALL_ACTION_BTRH_1, 125 BTHF_CLIENT_CALL_ACTION_BTRH_2, 126 } bthf_client_call_action_t; 127 128 typedef enum { 129 BTHF_CLIENT_SERVICE_UNKNOWN = 0, 130 BTHF_CLIENT_SERVICE_VOICE, 131 BTHF_CLIENT_SERVICE_FAX 132 } bthf_client_subscriber_service_type_t; 133 134 typedef enum { 135 BTHF_CLIENT_IN_BAND_RINGTONE_NOT_PROVIDED = 0, 136 BTHF_CLIENT_IN_BAND_RINGTONE_PROVIDED, 137 } bthf_client_in_band_ring_state_t; 138 139 /* Peer features masks */ 140 #define BTHF_CLIENT_PEER_FEAT_3WAY 0x00000001 /* Three-way calling */ 141 #define BTHF_CLIENT_PEER_FEAT_ECNR \ 142 0x00000002 /* Echo cancellation and/or noise reduction */ 143 #define BTHF_CLIENT_PEER_FEAT_VREC 0x00000004 /* Voice recognition */ 144 #define BTHF_CLIENT_PEER_FEAT_INBAND 0x00000008 /* In-band ring tone */ 145 #define BTHF_CLIENT_PEER_FEAT_VTAG \ 146 0x00000010 /* Attach a phone number to a voice tag */ 147 #define BTHF_CLIENT_PEER_FEAT_REJECT \ 148 0x00000020 /* Ability to reject incoming call */ 149 #define BTHF_CLIENT_PEER_FEAT_ECS 0x00000040 /* Enhanced Call Status */ 150 #define BTHF_CLIENT_PEER_FEAT_ECC 0x00000080 /* Enhanced Call Control */ 151 #define BTHF_CLIENT_PEER_FEAT_EXTERR 0x00000100 /* Extended error codes */ 152 #define BTHF_CLIENT_PEER_FEAT_CODEC 0x00000200 /* Codec Negotiation */ 153 154 /* Peer call handling features masks */ 155 #define BTHF_CLIENT_CHLD_FEAT_REL \ 156 0x00000001 /* 0 Release waiting call or held calls */ 157 #define BTHF_CLIENT_CHLD_FEAT_REL_ACC \ 158 0x00000002 /* 1 Release active calls and accept other \ 159 (waiting or held) cal */ 160 #define BTHF_CLIENT_CHLD_FEAT_REL_X \ 161 0x00000004 /* 1x Release specified active call only */ 162 #define BTHF_CLIENT_CHLD_FEAT_HOLD_ACC \ 163 0x00000008 /* 2 Active calls on hold and accept other \ 164 (waiting or held) call */ 165 #define BTHF_CLIENT_CHLD_FEAT_PRIV_X \ 166 0x00000010 /* 2x Request private mode with specified \ 167 call (put the rest on hold) */ 168 #define BTHF_CLIENT_CHLD_FEAT_MERGE \ 169 0x00000020 /* 3 Add held call to multiparty */ 170 #define BTHF_CLIENT_CHLD_FEAT_MERGE_DETACH \ 171 0x00000040 /* 4 Connect two calls and leave \ 172 (disconnect from) multiparty */ 173 174 /** Callback for connection state change. 175 * state will have one of the values from BtHfConnectionState 176 * peer/chld_features are valid only for 177 * BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED state 178 */ 179 typedef void (*bthf_client_connection_state_callback)( 180 const RawAddress* bd_addr, bthf_client_connection_state_t state, 181 unsigned int peer_feat, unsigned int chld_feat); 182 183 /** Callback for audio connection state change. 184 * state will have one of the values from BtHfAudioState 185 */ 186 typedef void (*bthf_client_audio_state_callback)( 187 const RawAddress* bd_addr, bthf_client_audio_state_t state); 188 189 /** Callback for VR connection state change. 190 * state will have one of the values from BtHfVRState 191 */ 192 typedef void (*bthf_client_vr_cmd_callback)(const RawAddress* bd_addr, 193 bthf_client_vr_state_t state); 194 195 /** Callback for network state change 196 */ 197 typedef void (*bthf_client_network_state_callback)( 198 const RawAddress* bd_addr, bthf_client_network_state_t state); 199 200 /** Callback for network roaming status change 201 */ 202 typedef void (*bthf_client_network_roaming_callback)( 203 const RawAddress* bd_addr, bthf_client_service_type_t type); 204 205 /** Callback for signal strength indication 206 */ 207 typedef void (*bthf_client_network_signal_callback)(const RawAddress* bd_addr, 208 int signal_strength); 209 210 /** Callback for battery level indication 211 */ 212 typedef void (*bthf_client_battery_level_callback)(const RawAddress* bd_addr, 213 int battery_level); 214 215 /** Callback for current operator name 216 */ 217 typedef void (*bthf_client_current_operator_callback)(const RawAddress* bd_addr, 218 const char* name); 219 220 /** Callback for call indicator 221 */ 222 typedef void (*bthf_client_call_callback)(const RawAddress* bd_addr, 223 bthf_client_call_t call); 224 225 /** Callback for callsetup indicator 226 */ 227 typedef void (*bthf_client_callsetup_callback)( 228 const RawAddress* bd_addr, bthf_client_callsetup_t callsetup); 229 230 /** Callback for callheld indicator 231 */ 232 typedef void (*bthf_client_callheld_callback)(const RawAddress* bd_addr, 233 bthf_client_callheld_t callheld); 234 235 /** Callback for response and hold 236 */ 237 typedef void (*bthf_client_resp_and_hold_callback)( 238 const RawAddress* bd_addr, bthf_client_resp_and_hold_t resp_and_hold); 239 240 /** Callback for Calling Line Identification notification 241 * Will be called only when there is an incoming call and number is provided. 242 */ 243 typedef void (*bthf_client_clip_callback)(const RawAddress* bd_addr, 244 const char* number); 245 246 /** 247 * Callback for Call Waiting notification 248 */ 249 typedef void (*bthf_client_call_waiting_callback)(const RawAddress* bd_addr, 250 const char* number); 251 252 /** 253 * Callback for listing current calls. Can be called multiple time. 254 * If number is unknown NULL is passed. 255 */ 256 typedef void (*bthf_client_current_calls)(const RawAddress* bd_addr, int index, 257 bthf_client_call_direction_t dir, 258 bthf_client_call_state_t state, 259 bthf_client_call_mpty_type_t mpty, 260 const char* number); 261 262 /** Callback for audio volume change 263 */ 264 typedef void (*bthf_client_volume_change_callback)( 265 const RawAddress* bd_addr, bthf_client_volume_type_t type, int volume); 266 267 /** Callback for command complete event 268 * cme is valid only for BTHF_CLIENT_CMD_COMPLETE_ERROR_CME type 269 */ 270 typedef void (*bthf_client_cmd_complete_callback)( 271 const RawAddress* bd_addr, bthf_client_cmd_complete_t type, int cme); 272 273 /** Callback for subscriber information 274 */ 275 typedef void (*bthf_client_subscriber_info_callback)( 276 const RawAddress* bd_addr, const char* name, 277 bthf_client_subscriber_service_type_t type); 278 279 /** Callback for in-band ring tone settings 280 */ 281 typedef void (*bthf_client_in_band_ring_tone_callback)( 282 const RawAddress* bd_addr, bthf_client_in_band_ring_state_t state); 283 284 /** 285 * Callback for requested number from AG 286 */ 287 typedef void (*bthf_client_last_voice_tag_number_callback)( 288 const RawAddress* bd_addr, const char* number); 289 290 /** 291 * Callback for sending ring indication to app 292 */ 293 typedef void (*bthf_client_ring_indication_callback)(const RawAddress* bd_addr); 294 295 /** BT-HF callback structure. */ 296 typedef struct { 297 /** set to sizeof(BtHfClientCallbacks) */ 298 size_t size; 299 bthf_client_connection_state_callback connection_state_cb; 300 bthf_client_audio_state_callback audio_state_cb; 301 bthf_client_vr_cmd_callback vr_cmd_cb; 302 bthf_client_network_state_callback network_state_cb; 303 bthf_client_network_roaming_callback network_roaming_cb; 304 bthf_client_network_signal_callback network_signal_cb; 305 bthf_client_battery_level_callback battery_level_cb; 306 bthf_client_current_operator_callback current_operator_cb; 307 bthf_client_call_callback call_cb; 308 bthf_client_callsetup_callback callsetup_cb; 309 bthf_client_callheld_callback callheld_cb; 310 bthf_client_resp_and_hold_callback resp_and_hold_cb; 311 bthf_client_clip_callback clip_cb; 312 bthf_client_call_waiting_callback call_waiting_cb; 313 bthf_client_current_calls current_calls_cb; 314 bthf_client_volume_change_callback volume_change_cb; 315 bthf_client_cmd_complete_callback cmd_complete_cb; 316 bthf_client_subscriber_info_callback subscriber_info_cb; 317 bthf_client_in_band_ring_tone_callback in_band_ring_tone_cb; 318 bthf_client_last_voice_tag_number_callback last_voice_tag_number_callback; 319 bthf_client_ring_indication_callback ring_indication_cb; 320 } bthf_client_callbacks_t; 321 322 /** Represents the standard BT-HF interface. */ 323 typedef struct { 324 /** set to sizeof(BtHfClientInterface) */ 325 size_t size; 326 /** 327 * Register the BtHf callbacks 328 */ 329 bt_status_t (*init)(bthf_client_callbacks_t* callbacks); 330 331 /** connect to audio gateway */ 332 bt_status_t (*connect)(RawAddress* bd_addr); 333 334 /** disconnect from audio gateway */ 335 bt_status_t (*disconnect)(const RawAddress* bd_addr); 336 337 /** create an audio connection */ 338 bt_status_t (*connect_audio)(const RawAddress* bd_addr); 339 340 /** close the audio connection */ 341 bt_status_t (*disconnect_audio)(const RawAddress* bd_addr); 342 343 /** start voice recognition */ 344 bt_status_t (*start_voice_recognition)(const RawAddress* bd_addr); 345 346 /** stop voice recognition */ 347 bt_status_t (*stop_voice_recognition)(const RawAddress* bd_addr); 348 349 /** volume control */ 350 bt_status_t (*volume_control)(const RawAddress* bd_addr, 351 bthf_client_volume_type_t type, int volume); 352 353 /** place a call with number a number 354 * if number is NULL last called number is called (aka re-dial)*/ 355 bt_status_t (*dial)(const RawAddress* bd_addr, const char* number); 356 357 /** place a call with number specified by location (speed dial) */ 358 bt_status_t (*dial_memory)(const RawAddress* bd_addr, int location); 359 360 /** perform specified call related action 361 * idx is limited only for enhanced call control related action 362 */ 363 bt_status_t (*handle_call_action)(const RawAddress* bd_addr, 364 bthf_client_call_action_t action, int idx); 365 366 /** query list of current calls */ 367 bt_status_t (*query_current_calls)(const RawAddress* bd_addr); 368 369 /** query name of current selected operator */ 370 bt_status_t (*query_current_operator_name)(const RawAddress* bd_addr); 371 372 /** Retrieve subscriber information */ 373 bt_status_t (*retrieve_subscriber_info)(const RawAddress* bd_addr); 374 375 /** Send DTMF code*/ 376 bt_status_t (*send_dtmf)(const RawAddress* bd_addr, char code); 377 378 /** Request a phone number from AG corresponding to last voice tag recorded */ 379 bt_status_t (*request_last_voice_tag_number)(const RawAddress* bd_addr); 380 381 /** Closes the interface. */ 382 void (*cleanup)(void); 383 384 /** Send AT Command. */ 385 bt_status_t (*send_at_cmd)(const RawAddress* bd_addr, int cmd, int val1, 386 int val2, const char* arg); 387 } bthf_client_interface_t; 388 389 __END_DECLS 390 391 #endif /* ANDROID_INCLUDE_BT_HF_CLIENT_H */ 392