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 /** 296 * Callback for sending unknown (vendor specific) event 297 */ 298 typedef void (*bthf_client_unknown_event_callback)(const RawAddress* bd_addr, 299 const char* unknow_event); 300 301 /** BT-HF callback structure. */ 302 typedef struct { 303 /** set to sizeof(BtHfClientCallbacks) */ 304 size_t size; 305 bthf_client_connection_state_callback connection_state_cb; 306 bthf_client_audio_state_callback audio_state_cb; 307 bthf_client_vr_cmd_callback vr_cmd_cb; 308 bthf_client_network_state_callback network_state_cb; 309 bthf_client_network_roaming_callback network_roaming_cb; 310 bthf_client_network_signal_callback network_signal_cb; 311 bthf_client_battery_level_callback battery_level_cb; 312 bthf_client_current_operator_callback current_operator_cb; 313 bthf_client_call_callback call_cb; 314 bthf_client_callsetup_callback callsetup_cb; 315 bthf_client_callheld_callback callheld_cb; 316 bthf_client_resp_and_hold_callback resp_and_hold_cb; 317 bthf_client_clip_callback clip_cb; 318 bthf_client_call_waiting_callback call_waiting_cb; 319 bthf_client_current_calls current_calls_cb; 320 bthf_client_volume_change_callback volume_change_cb; 321 bthf_client_cmd_complete_callback cmd_complete_cb; 322 bthf_client_subscriber_info_callback subscriber_info_cb; 323 bthf_client_in_band_ring_tone_callback in_band_ring_tone_cb; 324 bthf_client_last_voice_tag_number_callback last_voice_tag_number_callback; 325 bthf_client_ring_indication_callback ring_indication_cb; 326 bthf_client_unknown_event_callback unknown_event_cb; 327 } bthf_client_callbacks_t; 328 329 /** Represents the standard BT-HF interface. */ 330 typedef struct { 331 /** set to sizeof(BtHfClientInterface) */ 332 size_t size; 333 /** 334 * Register the BtHf callbacks 335 */ 336 bt_status_t (*init)(bthf_client_callbacks_t* callbacks); 337 338 /** connect to audio gateway */ 339 bt_status_t (*connect)(RawAddress* bd_addr); 340 341 /** disconnect from audio gateway */ 342 bt_status_t (*disconnect)(const RawAddress* bd_addr); 343 344 /** create an audio connection */ 345 bt_status_t (*connect_audio)(const RawAddress* bd_addr); 346 347 /** close the audio connection */ 348 bt_status_t (*disconnect_audio)(const RawAddress* bd_addr); 349 350 /** start voice recognition */ 351 bt_status_t (*start_voice_recognition)(const RawAddress* bd_addr); 352 353 /** stop voice recognition */ 354 bt_status_t (*stop_voice_recognition)(const RawAddress* bd_addr); 355 356 /** volume control */ 357 bt_status_t (*volume_control)(const RawAddress* bd_addr, 358 bthf_client_volume_type_t type, int volume); 359 360 /** place a call with number a number 361 * if number is NULL last called number is called (aka re-dial)*/ 362 bt_status_t (*dial)(const RawAddress* bd_addr, const char* number); 363 364 /** place a call with number specified by location (speed dial) */ 365 bt_status_t (*dial_memory)(const RawAddress* bd_addr, int location); 366 367 /** perform specified call related action 368 * idx is limited only for enhanced call control related action 369 */ 370 bt_status_t (*handle_call_action)(const RawAddress* bd_addr, 371 bthf_client_call_action_t action, int idx); 372 373 /** query list of current calls */ 374 bt_status_t (*query_current_calls)(const RawAddress* bd_addr); 375 376 /** query name of current selected operator */ 377 bt_status_t (*query_current_operator_name)(const RawAddress* bd_addr); 378 379 /** Retrieve subscriber information */ 380 bt_status_t (*retrieve_subscriber_info)(const RawAddress* bd_addr); 381 382 /** Send DTMF code*/ 383 bt_status_t (*send_dtmf)(const RawAddress* bd_addr, char code); 384 385 /** Request a phone number from AG corresponding to last voice tag recorded */ 386 bt_status_t (*request_last_voice_tag_number)(const RawAddress* bd_addr); 387 388 /** Closes the interface. */ 389 void (*cleanup)(void); 390 391 /** Send AT Command. */ 392 bt_status_t (*send_at_cmd)(const RawAddress* bd_addr, int cmd, int val1, 393 int val2, const char* arg); 394 } bthf_client_interface_t; 395 396 __END_DECLS 397 398 #endif /* ANDROID_INCLUDE_BT_HF_CLIENT_H */ 399