Mesh: Add support for Node Reset in OAL & HAL
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / hardware / bt_hf_client.h
1 /*
2  * Copyright (c) 2013, The Linux Foundation. All rights reserved.
3  * Not a Contribution
4  * Copyright (C) 2012 The Android Open Source Project
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifndef ANDROID_INCLUDE_BT_HF_CLIENT_H
20 #define ANDROID_INCLUDE_BT_HF_CLIENT_H
21
22 __BEGIN_DECLS
23
24 typedef enum {
25         BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED = 0,
26         BTHF_CLIENT_CONNECTION_STATE_CONNECTING,
27         BTHF_CLIENT_CONNECTION_STATE_CONNECTED,
28         BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED,
29         BTHF_CLIENT_CONNECTION_STATE_DISCONNECTING
30 } bthf_client_connection_state_t;
31
32 typedef enum {
33         BTHF_CLIENT_AUDIO_STATE_DISCONNECTED = 0,
34         BTHF_CLIENT_AUDIO_STATE_CONNECTING,
35         BTHF_CLIENT_AUDIO_STATE_CONNECTED,
36         BTHF_CLIENT_AUDIO_STATE_CONNECTED_MSBC,
37 } bthf_client_audio_state_t;
38
39 typedef enum {
40         BTHF_CLIENT_VR_STATE_STOPPED = 0,
41         BTHF_CLIENT_VR_STATE_STARTED
42 } bthf_client_vr_state_t;
43
44 typedef enum {
45         BTHF_CLIENT_VOLUME_TYPE_SPK = 0,
46         BTHF_CLIENT_VOLUME_TYPE_MIC
47 } bthf_client_volume_type_t;
48
49 typedef enum {
50         BTHF_CLIENT_NETWORK_STATE_NOT_AVAILABLE = 0,
51         BTHF_CLIENT_NETWORK_STATE_AVAILABLE
52 } bthf_client_network_state_t;
53
54 typedef enum {
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 (waiting or held) cal */
156 #define BTHF_CLIENT_CHLD_FEAT_REL_X         0x00000004  /* 1x Release specified active call only */
157 #define BTHF_CLIENT_CHLD_FEAT_HOLD_ACC      0x00000008  /* 2  Active calls on hold and accept other (waiting or held) call */
158 #define BTHF_CLIENT_CHLD_FEAT_PRIV_X        0x00000010  /* 2x Request private mode with specified call (put the rest on hold) */
159 #define BTHF_CLIENT_CHLD_FEAT_MERGE         0x00000020  /* 3  Add held call to multiparty */
160 #define BTHF_CLIENT_CHLD_FEAT_MERGE_DETACH  0x00000040  /* 4  Connect two calls and leave (disconnect from) multiparty */
161
162 /** Callback for connection state change.
163  *  state will have one of the values from BtHfConnectionState
164  *  peer/chld_features are valid only for BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED state
165  */
166 typedef void (*bthf_client_connection_state_callback)(bthf_client_connection_state_t state, unsigned int peer_feat, unsigned int chld_feat, bt_bdaddr_t *bd_addr);
167
168 /** Callback for audio connection state change.
169  *  state will have one of the values from BtHfAudioState
170  */
171 typedef void (*bthf_client_audio_state_callback)(bthf_client_audio_state_t state, bt_bdaddr_t *bd_addr);
172
173 /** Callback for VR connection state change.
174  *  state will have one of the values from BtHfVRState
175  */
176 typedef void (*bthf_client_vr_cmd_callback)(bthf_client_vr_state_t state);
177
178 /** Callback for network state change
179  */
180 typedef void (*bthf_client_network_state_callback) (bthf_client_network_state_t state);
181
182 /** Callback for network roaming status change
183  */
184 typedef void (*bthf_client_network_roaming_callback) (bthf_client_service_type_t type);
185
186 /** Callback for signal strength indication
187  */
188 typedef void (*bthf_client_network_signal_callback) (int signal_strength);
189
190 /** Callback for battery level indication
191  */
192 typedef void (*bthf_client_battery_level_callback) (int battery_level);
193
194 /** Callback for current operator name
195  */
196 typedef void (*bthf_client_current_operator_callback) (const char *name);
197
198 /** Callback for call indicator
199  */
200 typedef void (*bthf_client_call_callback) (bthf_client_call_t call);
201
202 /** Callback for callsetup indicator
203  */
204 typedef void (*bthf_client_callsetup_callback) (bthf_client_callsetup_t callsetup);
205
206 /** Callback for callheld indicator
207  */
208 typedef void (*bthf_client_callheld_callback) (bthf_client_callheld_t callheld);
209
210 /** Callback for response and hold
211  */
212 typedef void (*bthf_client_resp_and_hold_callback) (bthf_client_resp_and_hold_t resp_and_hold);
213
214 /** Callback for Calling Line Identification notification
215  *  Will be called only when there is an incoming call and number is provided.
216  */
217 typedef void (*bthf_client_clip_callback) (const char *number);
218
219 /**
220  * Callback for Call Waiting notification
221  */
222 typedef void (*bthf_client_call_waiting_callback) (const char *number);
223
224 /**
225  *  Callback for listing current calls. Can be called multiple time.
226  *  If number is unknown NULL is passed.
227  */
228 typedef void (*bthf_client_current_calls) (int index, bthf_client_call_direction_t dir,
229                 bthf_client_call_state_t state,
230                 bthf_client_call_mpty_type_t mpty,
231                 const char *number);
232
233 /** Callback for audio volume change
234  */
235 typedef void (*bthf_client_volume_change_callback) (bthf_client_volume_type_t type, int volume);
236
237 /** Callback for command complete event
238  *  cme is valid only for BTHF_CLIENT_CMD_COMPLETE_ERROR_CME type
239  */
240 typedef void (*bthf_client_cmd_complete_callback) (bthf_client_cmd_complete_t type, int cme);
241
242 /** Callback for subscriber information
243  */
244 typedef void (*bthf_client_subscriber_info_callback) (const char *name, bthf_client_subscriber_service_type_t type);
245
246 /** Callback for in-band ring tone settings
247  */
248 typedef void (*bthf_client_in_band_ring_tone_callback) (bthf_client_in_band_ring_state_t state);
249
250 /**
251  * Callback for requested number from AG
252  */
253 typedef void (*bthf_client_last_voice_tag_number_callback) (const char *number);
254
255 /**
256  * Callback for sending ring indication to app
257  */
258 typedef void (*bthf_client_ring_indication_callback) (void);
259
260 /**
261  * Callback for sending voice data to app
262  */
263 typedef void (*bthf_client_get_voice_data_callback) (uint8_t *p_buf, uint8_t len);
264
265 /** BT-HF callback structure. */
266 typedef struct {
267         /** set to sizeof(BtHfClientCallbacks) */
268         size_t      size;
269         bthf_client_connection_state_callback  connection_state_cb;
270         bthf_client_audio_state_callback       audio_state_cb;
271         bthf_client_vr_cmd_callback            vr_cmd_cb;
272         bthf_client_network_state_callback     network_state_cb;
273         bthf_client_network_roaming_callback   network_roaming_cb;
274         bthf_client_network_signal_callback    network_signal_cb;
275         bthf_client_battery_level_callback     battery_level_cb;
276         bthf_client_current_operator_callback  current_operator_cb;
277         bthf_client_call_callback              call_cb;
278         bthf_client_callsetup_callback         callsetup_cb;
279         bthf_client_callheld_callback          callheld_cb;
280         bthf_client_resp_and_hold_callback     resp_and_hold_cb;
281         bthf_client_clip_callback              clip_cb;
282         bthf_client_call_waiting_callback      call_waiting_cb;
283         bthf_client_current_calls              current_calls_cb;
284         bthf_client_volume_change_callback     volume_change_cb;
285         bthf_client_cmd_complete_callback      cmd_complete_cb;
286         bthf_client_subscriber_info_callback   subscriber_info_cb;
287         bthf_client_in_band_ring_tone_callback in_band_ring_tone_cb;
288         bthf_client_last_voice_tag_number_callback last_voice_tag_number_callback;
289         bthf_client_ring_indication_callback   ring_indication_cb;
290         bthf_client_get_voice_data_callback    get_voice_data_cb;
291 } bthf_client_callbacks_t;
292
293 /** Represents the standard BT-HF interface. */
294 typedef struct {
295
296         /** set to sizeof(BtHfClientInterface) */
297         size_t size;
298         /**
299         * Register the BtHf callbacks
300         */
301         bt_status_t (*init)(bthf_client_callbacks_t* callbacks);
302
303         /** connect to audio gateway */
304         bt_status_t (*connect)(bt_bdaddr_t *bd_addr);
305
306         /** disconnect from audio gateway */
307         bt_status_t (*disconnect)(bt_bdaddr_t *bd_addr);
308
309         /** create an audio connection */
310         bt_status_t (*connect_audio)(bt_bdaddr_t *bd_addr);
311
312         /** close the audio connection */
313         bt_status_t (*disconnect_audio)(bt_bdaddr_t *bd_addr);
314
315         /** start voice recognition */
316         bt_status_t (*start_voice_recognition)(void);
317
318         /** stop voice recognition */
319         bt_status_t (*stop_voice_recognition)(void);
320
321         /** volume control */
322         bt_status_t (*volume_control) (bthf_client_volume_type_t type, int volume);
323
324         /** place a call with number a number
325         * if number is NULL last called number is called (aka re-dial)*/
326         bt_status_t (*dial) (const char *number);
327
328         /** place a call with number specified by location (speed dial) */
329         bt_status_t (*dial_memory) (int location);
330
331         /** perform specified call related action
332         * idx is limited only for enhanced call control related action
333         */
334         bt_status_t (*handle_call_action) (bthf_client_call_action_t action, int idx);
335
336         /** query list of current calls */
337         bt_status_t (*query_current_calls) (void);
338
339         /** query name of current selected operator */
340         bt_status_t (*query_current_operator_name) (void);
341
342         /** Retrieve subscriber information */
343         bt_status_t (*retrieve_subscriber_info) (void);
344
345         /** Send DTMF code*/
346         bt_status_t (*send_dtmf) (char code);
347
348         /** Request a phone number from AG corresponding to last voice tag recorded */
349         bt_status_t (*request_last_voice_tag_number) (void);
350
351         /** Closes the interface. */
352         void (*cleanup)(void);
353
354         /** Send AT Command. */
355         bt_status_t (*send_at_cmd) (int cmd, int val1, int val2, const char *arg);
356
357         /** send sco packet over HCI */
358         bt_status_t (*send_voice_data)(unsigned char *p_buf, unsigned char len);
359 } bthf_client_interface_t;
360
361 __END_DECLS
362
363 #endif /* ANDROID_INCLUDE_BT_HF_CLIENT_H */