blob: 0577e97d4b56d0c10a29fc542c1145c63f0483a2 [file] [log] [blame]
Hemant Guptae7737c82013-08-19 18:02:54 +05301/*
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
22typedef 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
30typedef 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
37typedef enum {
38 BTHF_CLIENT_VR_STATE_STOPPED = 0,
39 BTHF_CLIENT_VR_STATE_STARTED
40} bthf_client_vr_state_t;
41
42typedef enum {
43 BTHF_CLIENT_VOLUME_TYPE_SPK = 0,
44 BTHF_CLIENT_VOLUME_TYPE_MIC
45} bthf_client_volume_type_t;
46
47typedef enum
48{
49 BTHF_CLIENT_NETWORK_STATE_NOT_AVAILABLE = 0,
50 BTHF_CLIENT_NETWORK_STATE_AVAILABLE
51} bthf_client_network_state_t;
52
53typedef enum
54{
55 BTHF_CLIENT_SERVICE_TYPE_HOME = 0,
56 BTHF_CLIENT_SERVICE_TYPE_ROAMING
57} bthf_client_service_type_t;
58
59typedef 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
69typedef enum {
70 BTHF_CLIENT_CALL_NO_CALLS_IN_PROGRESS = 0,
71 BTHF_CLIENT_CALL_CALLS_IN_PROGRESS
72} bthf_client_call_t;
73
74typedef 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
82typedef 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
88typedef 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
94typedef enum {
95 BTHF_CLIENT_CALL_DIRECTION_OUTGOING = 0,
96 BTHF_CLIENT_CALL_DIRECTION_INCOMING
97} bthf_client_call_direction_t;
98
99typedef enum {
100 BTHF_CLIENT_CALL_MPTY_TYPE_SINGLE = 0,
101 BTHF_CLIENT_CALL_MPTY_TYPE_MULTI
102} bthf_client_call_mpty_type_t;
103
104typedef 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
115typedef 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
130typedef 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
136typedef 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 */
170typedef 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 */
178typedef 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 */
184typedef void (* bthf_client_vr_cmd_callback)(bthf_client_vr_state_t state);
185
186/** Callback for network state change
187 */
188typedef void (* bthf_client_network_state_callback) (bthf_client_network_state_t state);
189
190/** Callback for network roaming status change
191 */
192typedef void (* bthf_client_network_roaming_callback) (bthf_client_service_type_t type);
193
194/** Callback for signal strength indication
195 */
196typedef void (* bthf_client_network_signal_callback) (int signal_strength);
197
198/** Callback for battery level indication
199 */
200typedef void (* bthf_client_battery_level_callback) (int battery_level);
201
202/** Callback for current operator name
203 */
204typedef void (* bthf_client_current_operator_callback) (const char *name);
205
206/** Callback for call indicator
207 */
208typedef void (* bthf_client_call_callback) (bthf_client_call_t call);
209
210/** Callback for callsetup indicator
211 */
212typedef void (* bthf_client_callsetup_callback) (bthf_client_callsetup_t callsetup);
213
214/** Callback for callheld indicator
215 */
216typedef void (* bthf_client_callheld_callback) (bthf_client_callheld_t callheld);
217
218/** Callback for response and hold
219 */
220typedef 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 */
225typedef void (* bthf_client_clip_callback) (const char *number);
226
227/**
228 * Callback for Call Waiting notification
229 */
230typedef 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 */
236typedef 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 */
243typedef 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 */
248typedef void (*bthf_client_cmd_complete_callback) (bthf_client_cmd_complete_t type, int cme);
249
250/** Callback for subscriber information
251 */
252typedef 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 */
257typedef 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 */
262typedef void (* bthf_client_last_voice_tag_number_callback) (const char *number);
263
264/**
265 * Callback for sending ring indication to app
266 */
267typedef void (* bthf_client_ring_indication_callback) (void);
268
Satish Kodishala1ec90ad2015-05-06 19:25:42 +0530269/**
270 * Callback for sending cgmi indication to app
271 */
272typedef void (* bthf_client_cgmi_indication_callback) (const char *str);
273
274/**
275 * Callback for sending cgmm indication to app
276 */
277typedef void (* bthf_client_cgmm_indication_callback) (const char *str);
278
Hemant Guptae7737c82013-08-19 18:02:54 +0530279/** BT-HF callback structure. */
280typedef struct {
281 /** set to sizeof(BtHfClientCallbacks) */
282 size_t size;
283 bthf_client_connection_state_callback connection_state_cb;
284 bthf_client_audio_state_callback audio_state_cb;
285 bthf_client_vr_cmd_callback vr_cmd_cb;
286 bthf_client_network_state_callback network_state_cb;
287 bthf_client_network_roaming_callback network_roaming_cb;
288 bthf_client_network_signal_callback network_signal_cb;
289 bthf_client_battery_level_callback battery_level_cb;
290 bthf_client_current_operator_callback current_operator_cb;
291 bthf_client_call_callback call_cb;
292 bthf_client_callsetup_callback callsetup_cb;
293 bthf_client_callheld_callback callheld_cb;
294 bthf_client_resp_and_hold_callback resp_and_hold_cb;
295 bthf_client_clip_callback clip_cb;
296 bthf_client_call_waiting_callback call_waiting_cb;
297 bthf_client_current_calls current_calls_cb;
298 bthf_client_volume_change_callback volume_change_cb;
299 bthf_client_cmd_complete_callback cmd_complete_cb;
300 bthf_client_subscriber_info_callback subscriber_info_cb;
301 bthf_client_in_band_ring_tone_callback in_band_ring_tone_cb;
302 bthf_client_last_voice_tag_number_callback last_voice_tag_number_callback;
303 bthf_client_ring_indication_callback ring_indication_cb;
Satish Kodishala1ec90ad2015-05-06 19:25:42 +0530304 bthf_client_cgmi_indication_callback cgmi_cb;
305 bthf_client_cgmm_indication_callback cgmm_cb;
Hemant Guptae7737c82013-08-19 18:02:54 +0530306} bthf_client_callbacks_t;
307
308/** Represents the standard BT-HF interface. */
309typedef struct {
310
311 /** set to sizeof(BtHfClientInterface) */
312 size_t size;
313 /**
314 * Register the BtHf callbacks
315 */
316 bt_status_t (*init)(bthf_client_callbacks_t* callbacks);
317
318 /** connect to audio gateway */
319 bt_status_t (*connect)(bt_bdaddr_t *bd_addr);
320
321 /** disconnect from audio gateway */
322 bt_status_t (*disconnect)(bt_bdaddr_t *bd_addr);
323
324 /** create an audio connection */
325 bt_status_t (*connect_audio)(bt_bdaddr_t *bd_addr);
326
327 /** close the audio connection */
328 bt_status_t (*disconnect_audio)(bt_bdaddr_t *bd_addr);
329
330 /** start voice recognition */
331 bt_status_t (*start_voice_recognition)(void);
332
333 /** stop voice recognition */
334 bt_status_t (*stop_voice_recognition)(void);
335
336 /** volume control */
337 bt_status_t (*volume_control) (bthf_client_volume_type_t type, int volume);
338
339 /** place a call with number a number
340 * if number is NULL last called number is called (aka re-dial)*/
341 bt_status_t (*dial) (const char *number);
342
343 /** place a call with number specified by location (speed dial) */
344 bt_status_t (*dial_memory) (int location);
345
346 /** perform specified call related action
347 * idx is limited only for enhanced call control related action
348 */
349 bt_status_t (*handle_call_action) (bthf_client_call_action_t action, int idx);
350
351 /** query list of current calls */
352 bt_status_t (*query_current_calls) (void);
353
354 /** query name of current selected operator */
355 bt_status_t (*query_current_operator_name) (void);
356
357 /** Retrieve subscriber information */
358 bt_status_t (*retrieve_subscriber_info) (void);
359
360 /** Send DTMF code*/
361 bt_status_t (*send_dtmf) (char code);
362
363 /** Request a phone number from AG corresponding to last voice tag recorded */
364 bt_status_t (*request_last_voice_tag_number) (void);
365
366 /** Closes the interface. */
367 void (*cleanup)(void);
368
369 /** Send AT Command. */
370 bt_status_t (*send_at_cmd) (int cmd, int val1, int val2, const char *arg);
371} bthf_client_interface_t;
372
373__END_DECLS
374
375#endif /* ANDROID_INCLUDE_BT_HF_CLIENT_H */