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