blob: 520729649c819a202719ea3473e99b83ab823f26 [file] [log] [blame]
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -07001/*
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)(const RawAddress *bd_addr,
171 bthf_client_connection_state_t state,
172 unsigned int peer_feat,
173 unsigned int chld_feat);
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)(const RawAddress *bd_addr,
179 bthf_client_audio_state_t state);
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)(const RawAddress *bd_addr, bthf_client_vr_state_t state);
185
186/** Callback for network state change
187 */
188typedef void (* bthf_client_network_state_callback) (const RawAddress *bd_addr,
189 bthf_client_network_state_t state);
190
191/** Callback for network roaming status change
192 */
193typedef void (* bthf_client_network_roaming_callback) (const RawAddress *bd_addr,
194 bthf_client_service_type_t type);
195
196/** Callback for signal strength indication
197 */
198typedef void (* bthf_client_network_signal_callback) (const RawAddress *bd_addr,
199 int signal_strength);
200
201/** Callback for battery level indication
202 */
203typedef void (* bthf_client_battery_level_callback) (const RawAddress *bd_addr,
204 int battery_level);
205
206/** Callback for current operator name
207 */
208typedef void (* bthf_client_current_operator_callback) (const RawAddress *bd_addr,
209 const char *name);
210
211/** Callback for call indicator
212 */
213typedef void (* bthf_client_call_callback) (const RawAddress *bd_addr, bthf_client_call_t call);
214
215/** Callback for callsetup indicator
216 */
217typedef void (* bthf_client_callsetup_callback) (const RawAddress *bd_addr,
218 bthf_client_callsetup_t callsetup);
219
220/** Callback for callheld indicator
221 */
222typedef void (* bthf_client_callheld_callback) (const RawAddress *bd_addr,
223 bthf_client_callheld_t callheld);
224
225/** Callback for response and hold
226 */
227typedef void (* bthf_client_resp_and_hold_callback) (const RawAddress *bd_addr,
228 bthf_client_resp_and_hold_t resp_and_hold);
229
230/** Callback for Calling Line Identification notification
231 * Will be called only when there is an incoming call and number is provided.
232 */
233typedef void (* bthf_client_clip_callback) (const RawAddress *bd_addr, const char *number);
234
235/**
236 * Callback for Call Waiting notification
237 */
238typedef void (* bthf_client_call_waiting_callback) (const RawAddress *bd_addr, const char *number);
239
240/**
241 * Callback for listing current calls. Can be called multiple time.
242 * If number is unknown NULL is passed.
243 */
244typedef void (*bthf_client_current_calls) (const RawAddress *bd_addr, int index,
245 bthf_client_call_direction_t dir,
246 bthf_client_call_state_t state,
247 bthf_client_call_mpty_type_t mpty,
248 const char *number);
249
250/** Callback for audio volume change
251 */
252typedef void (*bthf_client_volume_change_callback) (const RawAddress *bd_addr,
253 bthf_client_volume_type_t type,
254 int volume);
255
256/** Callback for command complete event
257 * cme is valid only for BTHF_CLIENT_CMD_COMPLETE_ERROR_CME type
258 */
259typedef void (*bthf_client_cmd_complete_callback) (const RawAddress *bd_addr,
260 bthf_client_cmd_complete_t type,
261 int cme);
262
263/** Callback for subscriber information
264 */
265typedef void (* bthf_client_subscriber_info_callback) (const RawAddress *bd_addr,
266 const char *name,
267 bthf_client_subscriber_service_type_t type);
268
269/** Callback for in-band ring tone settings
270 */
271typedef void (* bthf_client_in_band_ring_tone_callback) (const RawAddress *bd_addr,
272 bthf_client_in_band_ring_state_t state);
273
274/**
275 * Callback for requested number from AG
276 */
277typedef void (* bthf_client_last_voice_tag_number_callback) (const RawAddress *bd_addr,
278 const char *number);
279
280/**
281 * Callback for sending ring indication to app
282 */
283typedef void (* bthf_client_ring_indication_callback) (const RawAddress *bd_addr);
284
285/** BT-HF callback structure. */
286typedef struct {
287 /** set to sizeof(BtHfClientCallbacks) */
288 size_t size;
289 bthf_client_connection_state_callback connection_state_cb;
290 bthf_client_audio_state_callback audio_state_cb;
291 bthf_client_vr_cmd_callback vr_cmd_cb;
292 bthf_client_network_state_callback network_state_cb;
293 bthf_client_network_roaming_callback network_roaming_cb;
294 bthf_client_network_signal_callback network_signal_cb;
295 bthf_client_battery_level_callback battery_level_cb;
296 bthf_client_current_operator_callback current_operator_cb;
297 bthf_client_call_callback call_cb;
298 bthf_client_callsetup_callback callsetup_cb;
299 bthf_client_callheld_callback callheld_cb;
300 bthf_client_resp_and_hold_callback resp_and_hold_cb;
301 bthf_client_clip_callback clip_cb;
302 bthf_client_call_waiting_callback call_waiting_cb;
303 bthf_client_current_calls current_calls_cb;
304 bthf_client_volume_change_callback volume_change_cb;
305 bthf_client_cmd_complete_callback cmd_complete_cb;
306 bthf_client_subscriber_info_callback subscriber_info_cb;
307 bthf_client_in_band_ring_tone_callback in_band_ring_tone_cb;
308 bthf_client_last_voice_tag_number_callback last_voice_tag_number_callback;
309 bthf_client_ring_indication_callback ring_indication_cb;
310} bthf_client_callbacks_t;
311
312/** Represents the standard BT-HF interface. */
313typedef struct {
314
315 /** set to sizeof(BtHfClientInterface) */
316 size_t size;
317 /**
318 * Register the BtHf callbacks
319 */
320 bt_status_t (*init)(bthf_client_callbacks_t* callbacks);
321
322 /** connect to audio gateway */
323 bt_status_t (*connect)(RawAddress *bd_addr);
324
325 /** disconnect from audio gateway */
326 bt_status_t (*disconnect)(const RawAddress *bd_addr);
327
328 /** create an audio connection */
329 bt_status_t (*connect_audio)(const RawAddress *bd_addr);
330
331 /** close the audio connection */
332 bt_status_t (*disconnect_audio)(const RawAddress *bd_addr);
333
334 /** start voice recognition */
335 bt_status_t (*start_voice_recognition)(const RawAddress *bd_addr);
336
337 /** stop voice recognition */
338 bt_status_t (*stop_voice_recognition)(const RawAddress *bd_addr);
339
340 /** volume control */
341 bt_status_t (*volume_control) (const RawAddress *bd_addr,
342 bthf_client_volume_type_t type,
343 int volume);
344
345 /** place a call with number a number
346 * if number is NULL last called number is called (aka re-dial)*/
347 bt_status_t (*dial) (const RawAddress *bd_addr, const char *number);
348
349 /** place a call with number specified by location (speed dial) */
350 bt_status_t (*dial_memory) (const RawAddress *bd_addr, int location);
351
352 /** perform specified call related action
353 * idx is limited only for enhanced call control related action
354 */
355 bt_status_t (*handle_call_action) (const RawAddress *bd_addr,
356 bthf_client_call_action_t action,
357 int idx);
358
359 /** query list of current calls */
360 bt_status_t (*query_current_calls) (const RawAddress *bd_addr);
361
362 /** query name of current selected operator */
363 bt_status_t (*query_current_operator_name) (const RawAddress *bd_addr);
364
365 /** Retrieve subscriber information */
366 bt_status_t (*retrieve_subscriber_info) (const RawAddress *bd_addr);
367
368 /** Send DTMF code*/
369 bt_status_t (*send_dtmf) (const RawAddress *bd_addr, char code);
370
371 /** Request a phone number from AG corresponding to last voice tag recorded */
372 bt_status_t (*request_last_voice_tag_number) (const RawAddress *bd_addr);
373
374 /** Closes the interface. */
375 void (*cleanup)(void);
376
377 /** Send AT Command. */
378 bt_status_t (*send_at_cmd) (const RawAddress *bd_addr, int cmd, int val1, int val2, const char *arg);
379} bthf_client_interface_t;
380
381__END_DECLS
382
383#endif /* ANDROID_INCLUDE_BT_HF_CLIENT_H */