blob: 0a77675a1e51e8b0e25012594cb615ad5c28d3df [file] [log] [blame]
Andre Eisenbach05f49542012-09-18 12:15:26 -07001/*
2 * Copyright (C) 2012 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_H
18#define ANDROID_INCLUDE_BT_HF_H
19
20__BEGIN_DECLS
21
22/* AT response code - OK/Error */
23typedef enum {
24 BTHF_AT_RESPONSE_ERROR = 0,
25 BTHF_AT_RESPONSE_OK
26} bthf_at_response_t;
27
28typedef enum {
29 BTHF_CONNECTION_STATE_DISCONNECTED = 0,
30 BTHF_CONNECTION_STATE_CONNECTING,
31 BTHF_CONNECTION_STATE_CONNECTED,
32 BTHF_CONNECTION_STATE_SLC_CONNECTED,
33 BTHF_CONNECTION_STATE_DISCONNECTING
34} bthf_connection_state_t;
35
36typedef enum {
37 BTHF_AUDIO_STATE_DISCONNECTED = 0,
38 BTHF_AUDIO_STATE_CONNECTING,
39 BTHF_AUDIO_STATE_CONNECTED,
40 BTHF_AUDIO_STATE_DISCONNECTING
41} bthf_audio_state_t;
42
43typedef enum {
44 BTHF_VR_STATE_STOPPED = 0,
45 BTHF_VR_STATE_STARTED
46} bthf_vr_state_t;
47
48typedef enum {
49 BTHF_VOLUME_TYPE_SPK = 0,
50 BTHF_VOLUME_TYPE_MIC
51} bthf_volume_type_t;
52
53/* Noise Reduction and Echo Cancellation */
54typedef enum
55{
56 BTHF_NREC_STOP,
57 BTHF_NREC_START
58} bthf_nrec_t;
59
Mudumba Ananth3c4db4c2014-04-27 21:04:35 -070060/* WBS codec setting */
61typedef enum
62{
63 BTHF_WBS_NONE,
64 BTHF_WBS_NO,
65 BTHF_WBS_YES
66}bthf_wbs_config_t;
67
Andre Eisenbach05f49542012-09-18 12:15:26 -070068/* CHLD - Call held handling */
69typedef enum
70{
71 BTHF_CHLD_TYPE_RELEASEHELD, // Terminate all held or set UDUB("busy") to a waiting call
72 BTHF_CHLD_TYPE_RELEASEACTIVE_ACCEPTHELD, // Terminate all active calls and accepts a waiting/held call
73 BTHF_CHLD_TYPE_HOLDACTIVE_ACCEPTHELD, // Hold all active calls and accepts a waiting/held call
74 BTHF_CHLD_TYPE_ADDHELDTOCONF, // Add all held calls to a conference
75} bthf_chld_type_t;
76
Mudumba Ananthf991edf2016-02-29 02:14:09 -080077
78/* HF Indicators HFP 1.7 */
79typedef enum
80{
81 BTHF_HF_IND_ENHANCED_DRIVER_SAFETY = 1,
82 BTHF_HF_IND_BATTERY_LEVEL_STATUS = 2,
83} bthf_hf_ind_type_t;
84
85typedef enum
86{
87 BTHF_HF_IND_DISABLED = 0,
88 BTHF_HF_IND_ENABLED,
89} bthf_hf_ind_status_t;
90
Andre Eisenbach05f49542012-09-18 12:15:26 -070091/** Callback for connection state change.
92 * state will have one of the values from BtHfConnectionState
93 */
94typedef void (* bthf_connection_state_callback)(bthf_connection_state_t state, bt_bdaddr_t *bd_addr);
95
96/** Callback for audio connection state change.
97 * state will have one of the values from BtHfAudioState
98 */
99typedef void (* bthf_audio_state_callback)(bthf_audio_state_t state, bt_bdaddr_t *bd_addr);
100
101/** Callback for VR connection state change.
102 * state will have one of the values from BtHfVRState
103 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700104typedef void (* bthf_vr_cmd_callback)(bthf_vr_state_t state, bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700105
106/** Callback for answer incoming call (ATA)
107 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700108typedef void (* bthf_answer_call_cmd_callback)(bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700109
110/** Callback for disconnect call (AT+CHUP)
111 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700112typedef void (* bthf_hangup_call_cmd_callback)(bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700113
114/** Callback for disconnect call (AT+CHUP)
115 * type will denote Speaker/Mic gain (BtHfVolumeControl).
116 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700117typedef void (* bthf_volume_cmd_callback)(bthf_volume_type_t type, int volume, bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700118
119/** Callback for dialing an outgoing call
120 * If number is NULL, redial
121 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700122typedef void (* bthf_dial_call_cmd_callback)(char *number, bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700123
124/** Callback for sending DTMF tones
125 * tone contains the dtmf character to be sent
126 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700127typedef void (* bthf_dtmf_cmd_callback)(char tone, bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700128
129/** Callback for enabling/disabling noise reduction/echo cancellation
130 * value will be 1 to enable, 0 to disable
131 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700132typedef void (* bthf_nrec_cmd_callback)(bthf_nrec_t nrec, bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700133
Mudumba Ananth3c4db4c2014-04-27 21:04:35 -0700134/** Callback for AT+BCS and event from BAC
135 * WBS enable, WBS disable
136 */
137typedef void (* bthf_wbs_callback)(bthf_wbs_config_t wbs, bt_bdaddr_t *bd_addr);
138
Andre Eisenbach05f49542012-09-18 12:15:26 -0700139/** Callback for call hold handling (AT+CHLD)
140 * value will contain the call hold command (0, 1, 2, 3)
141 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700142typedef void (* bthf_chld_cmd_callback)(bthf_chld_type_t chld, bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700143
144/** Callback for CNUM (subscriber number)
145 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700146typedef void (* bthf_cnum_cmd_callback)(bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700147
148/** Callback for indicators (CIND)
149 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700150typedef void (* bthf_cind_cmd_callback)(bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700151
152/** Callback for operator selection (COPS)
153 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700154typedef void (* bthf_cops_cmd_callback)(bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700155
156/** Callback for call list (AT+CLCC)
157 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700158typedef void (* bthf_clcc_cmd_callback) (bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700159
160/** Callback for unknown AT command recd from HF
161 * at_string will contain the unparsed AT string
162 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700163typedef void (* bthf_unknown_at_cmd_callback)(char *at_string, bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700164
165/** Callback for keypressed (HSP) event.
166 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700167typedef void (* bthf_key_pressed_cmd_callback)(bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700168
Mudumba Ananthf991edf2016-02-29 02:14:09 -0800169/** Callback for BIND. Pass the remote HF Indicators supported.
170 */
171typedef void (* bthf_bind_cmd_callback)(char *at_string, bt_bdaddr_t *bd_addr);
172
173/** Callback for BIEV. Pass the change in the Remote HF indicator values
174 */
175typedef void (* bthf_biev_cmd_callback)(bthf_hf_ind_type_t ind_id, int ind_value,
176 bt_bdaddr_t *bd_addr);
177
Andre Eisenbach05f49542012-09-18 12:15:26 -0700178/** BT-HF callback structure. */
179typedef struct {
180 /** set to sizeof(BtHfCallbacks) */
181 size_t size;
182 bthf_connection_state_callback connection_state_cb;
183 bthf_audio_state_callback audio_state_cb;
184 bthf_vr_cmd_callback vr_cmd_cb;
185 bthf_answer_call_cmd_callback answer_call_cmd_cb;
186 bthf_hangup_call_cmd_callback hangup_call_cmd_cb;
187 bthf_volume_cmd_callback volume_cmd_cb;
188 bthf_dial_call_cmd_callback dial_call_cmd_cb;
189 bthf_dtmf_cmd_callback dtmf_cmd_cb;
190 bthf_nrec_cmd_callback nrec_cmd_cb;
Mudumba Ananth3c4db4c2014-04-27 21:04:35 -0700191 bthf_wbs_callback wbs_cb;
Andre Eisenbach05f49542012-09-18 12:15:26 -0700192 bthf_chld_cmd_callback chld_cmd_cb;
193 bthf_cnum_cmd_callback cnum_cmd_cb;
194 bthf_cind_cmd_callback cind_cmd_cb;
195 bthf_cops_cmd_callback cops_cmd_cb;
196 bthf_clcc_cmd_callback clcc_cmd_cb;
197 bthf_unknown_at_cmd_callback unknown_at_cmd_cb;
Mudumba Ananthf991edf2016-02-29 02:14:09 -0800198 bthf_bind_cmd_callback bind_cb;
199 bthf_biev_cmd_callback biev_cb;
Andre Eisenbach05f49542012-09-18 12:15:26 -0700200 bthf_key_pressed_cmd_callback key_pressed_cmd_cb;
201} bthf_callbacks_t;
202
203/** Network Status */
204typedef enum
205{
206 BTHF_NETWORK_STATE_NOT_AVAILABLE = 0,
207 BTHF_NETWORK_STATE_AVAILABLE
208} bthf_network_state_t;
209
210/** Service type */
211typedef enum
212{
213 BTHF_SERVICE_TYPE_HOME = 0,
214 BTHF_SERVICE_TYPE_ROAMING
215} bthf_service_type_t;
216
217typedef enum {
218 BTHF_CALL_STATE_ACTIVE = 0,
219 BTHF_CALL_STATE_HELD,
220 BTHF_CALL_STATE_DIALING,
221 BTHF_CALL_STATE_ALERTING,
222 BTHF_CALL_STATE_INCOMING,
223 BTHF_CALL_STATE_WAITING,
224 BTHF_CALL_STATE_IDLE
225} bthf_call_state_t;
226
227typedef enum {
228 BTHF_CALL_DIRECTION_OUTGOING = 0,
229 BTHF_CALL_DIRECTION_INCOMING
230} bthf_call_direction_t;
231
232typedef enum {
233 BTHF_CALL_TYPE_VOICE = 0,
234 BTHF_CALL_TYPE_DATA,
235 BTHF_CALL_TYPE_FAX
236} bthf_call_mode_t;
237
238typedef enum {
239 BTHF_CALL_MPTY_TYPE_SINGLE = 0,
240 BTHF_CALL_MPTY_TYPE_MULTI
241} bthf_call_mpty_type_t;
242
243typedef enum {
244 BTHF_CALL_ADDRTYPE_UNKNOWN = 0x81,
245 BTHF_CALL_ADDRTYPE_INTERNATIONAL = 0x91
246} bthf_call_addrtype_t;
247/** Represents the standard BT-HF interface. */
248typedef struct {
249
250 /** set to sizeof(BtHfInterface) */
251 size_t size;
252 /**
253 * Register the BtHf callbacks
254 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700255 bt_status_t (*init)( bthf_callbacks_t* callbacks, int max_hf_clients);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700256
257 /** connect to headset */
258 bt_status_t (*connect)( bt_bdaddr_t *bd_addr );
259
260 /** dis-connect from headset */
261 bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr );
262
263 /** create an audio connection */
264 bt_status_t (*connect_audio)( bt_bdaddr_t *bd_addr );
265
266 /** close the audio connection */
267 bt_status_t (*disconnect_audio)( bt_bdaddr_t *bd_addr );
268
269 /** start voice recognition */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700270 bt_status_t (*start_voice_recognition)( bt_bdaddr_t *bd_addr );
Andre Eisenbach05f49542012-09-18 12:15:26 -0700271
272 /** stop voice recognition */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700273 bt_status_t (*stop_voice_recognition)( bt_bdaddr_t *bd_addr );
Andre Eisenbach05f49542012-09-18 12:15:26 -0700274
275 /** volume control */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700276 bt_status_t (*volume_control) (bthf_volume_type_t type, int volume, bt_bdaddr_t *bd_addr );
Andre Eisenbach05f49542012-09-18 12:15:26 -0700277
278 /** Combined device status change notification */
279 bt_status_t (*device_status_notification)(bthf_network_state_t ntk_state, bthf_service_type_t svc_type, int signal,
280 int batt_chg);
281
282 /** Response for COPS command */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700283 bt_status_t (*cops_response)(const char *cops, bt_bdaddr_t *bd_addr );
Andre Eisenbach05f49542012-09-18 12:15:26 -0700284
285 /** Response for CIND command */
286 bt_status_t (*cind_response)(int svc, int num_active, int num_held, bthf_call_state_t call_setup_state,
Sunny Kapdi6253b052014-03-14 18:21:58 -0700287 int signal, int roam, int batt_chg, bt_bdaddr_t *bd_addr );
Andre Eisenbach05f49542012-09-18 12:15:26 -0700288
289 /** Pre-formatted AT response, typically in response to unknown AT cmd */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700290 bt_status_t (*formatted_at_response)(const char *rsp, bt_bdaddr_t *bd_addr );
Andre Eisenbach05f49542012-09-18 12:15:26 -0700291
292 /** ok/error response
293 * ERROR (0)
294 * OK (1)
295 */
Sunny Kapdi6253b052014-03-14 18:21:58 -0700296 bt_status_t (*at_response) (bthf_at_response_t response_code, int error_code, bt_bdaddr_t *bd_addr );
Andre Eisenbach05f49542012-09-18 12:15:26 -0700297
298 /** response for CLCC command
299 * Can be iteratively called for each call index
300 * Call index of 0 will be treated as NULL termination (Completes response)
301 */
302 bt_status_t (*clcc_response) (int index, bthf_call_direction_t dir,
303 bthf_call_state_t state, bthf_call_mode_t mode,
304 bthf_call_mpty_type_t mpty, const char *number,
Sunny Kapdi6253b052014-03-14 18:21:58 -0700305 bthf_call_addrtype_t type, bt_bdaddr_t *bd_addr );
Andre Eisenbach05f49542012-09-18 12:15:26 -0700306
307 /** notify of a call state change
308 * Each update notifies
309 * 1. Number of active/held/ringing calls
310 * 2. call_state: This denotes the state change that triggered this msg
311 * This will take one of the values from BtHfCallState
312 * 3. number & type: valid only for incoming & waiting call
313 */
314 bt_status_t (*phone_state_change) (int num_active, int num_held, bthf_call_state_t call_setup_state,
315 const char *number, bthf_call_addrtype_t type);
316
317 /** Closes the interface. */
318 void (*cleanup)( void );
Mudumba Ananth3c4db4c2014-04-27 21:04:35 -0700319
320 /** configureation for the SCO codec */
321 bt_status_t (*configure_wbs)( bt_bdaddr_t *bd_addr ,bthf_wbs_config_t config );
Mudumba Ananthf991edf2016-02-29 02:14:09 -0800322
323 /** Response for HF Indicator change (+BIND) */
324 bt_status_t (*bind_response)(bthf_hf_ind_type_t ind_id, bthf_hf_ind_status_t ind_status,
325 bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700326} bthf_interface_t;
327
328__END_DECLS
329
330#endif /* ANDROID_INCLUDE_BT_HF_H */