2 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2012 The Android Open Source Project
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef ANDROID_INCLUDE_BT_HF_CLIENT_H
20 #define ANDROID_INCLUDE_BT_HF_CLIENT_H
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;
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;
40 BTHF_CLIENT_VR_STATE_STOPPED = 0,
41 BTHF_CLIENT_VR_STATE_STARTED
42 } bthf_client_vr_state_t;
45 BTHF_CLIENT_VOLUME_TYPE_SPK = 0,
46 BTHF_CLIENT_VOLUME_TYPE_MIC
47 } bthf_client_volume_type_t;
50 BTHF_CLIENT_NETWORK_STATE_NOT_AVAILABLE = 0,
51 BTHF_CLIENT_NETWORK_STATE_AVAILABLE
52 } bthf_client_network_state_t;
55 BTHF_CLIENT_SERVICE_TYPE_HOME = 0,
56 BTHF_CLIENT_SERVICE_TYPE_ROAMING
57 } bthf_client_service_type_t;
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;
70 BTHF_CLIENT_CALL_NO_CALLS_IN_PROGRESS = 0,
71 BTHF_CLIENT_CALL_CALLS_IN_PROGRESS
75 BTHF_CLIENT_CALLSETUP_NONE = 0,
76 BTHF_CLIENT_CALLSETUP_INCOMING,
77 BTHF_CLIENT_CALLSETUP_OUTGOING,
78 BTHF_CLIENT_CALLSETUP_ALERTING
80 } bthf_client_callsetup_t;
83 BTHF_CLIENT_CALLHELD_NONE = 0,
84 BTHF_CLIENT_CALLHELD_HOLD_AND_ACTIVE,
85 BTHF_CLIENT_CALLHELD_HOLD,
86 } bthf_client_callheld_t;
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;
95 BTHF_CLIENT_CALL_DIRECTION_OUTGOING = 0,
96 BTHF_CLIENT_CALL_DIRECTION_INCOMING
97 } bthf_client_call_direction_t;
100 BTHF_CLIENT_CALL_MPTY_TYPE_SINGLE = 0,
101 BTHF_CLIENT_CALL_MPTY_TYPE_MULTI
102 } bthf_client_call_mpty_type_t;
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;
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;
131 BTHF_CLIENT_SERVICE_UNKNOWN = 0,
132 BTHF_CLIENT_SERVICE_VOICE,
133 BTHF_CLIENT_SERVICE_FAX
134 } bthf_client_subscriber_service_type_t;
137 BTHF_CLIENT_IN_BAND_RINGTONE_NOT_PROVIDED = 0,
138 BTHF_CLIENT_IN_BAND_RINGTONE_PROVIDED,
139 } bthf_client_in_band_ring_state_t;
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 */
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 */
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
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);
168 /** Callback for audio connection state change.
169 * state will have one of the values from BtHfAudioState
171 typedef void (*bthf_client_audio_state_callback)(bthf_client_audio_state_t state, bt_bdaddr_t *bd_addr);
173 /** Callback for VR connection state change.
174 * state will have one of the values from BtHfVRState
176 typedef void (*bthf_client_vr_cmd_callback)(bthf_client_vr_state_t state);
178 /** Callback for network state change
180 typedef void (*bthf_client_network_state_callback) (bthf_client_network_state_t state);
182 /** Callback for network roaming status change
184 typedef void (*bthf_client_network_roaming_callback) (bthf_client_service_type_t type);
186 /** Callback for signal strength indication
188 typedef void (*bthf_client_network_signal_callback) (int signal_strength);
190 /** Callback for battery level indication
192 typedef void (*bthf_client_battery_level_callback) (int battery_level);
194 /** Callback for current operator name
196 typedef void (*bthf_client_current_operator_callback) (const char *name);
198 /** Callback for call indicator
200 typedef void (*bthf_client_call_callback) (bthf_client_call_t call);
202 /** Callback for callsetup indicator
204 typedef void (*bthf_client_callsetup_callback) (bthf_client_callsetup_t callsetup);
206 /** Callback for callheld indicator
208 typedef void (*bthf_client_callheld_callback) (bthf_client_callheld_t callheld);
210 /** Callback for response and hold
212 typedef void (*bthf_client_resp_and_hold_callback) (bthf_client_resp_and_hold_t resp_and_hold);
214 /** Callback for Calling Line Identification notification
215 * Will be called only when there is an incoming call and number is provided.
217 typedef void (*bthf_client_clip_callback) (const char *number);
220 * Callback for Call Waiting notification
222 typedef void (*bthf_client_call_waiting_callback) (const char *number);
225 * Callback for listing current calls. Can be called multiple time.
226 * If number is unknown NULL is passed.
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,
233 /** Callback for audio volume change
235 typedef void (*bthf_client_volume_change_callback) (bthf_client_volume_type_t type, int volume);
237 /** Callback for command complete event
238 * cme is valid only for BTHF_CLIENT_CMD_COMPLETE_ERROR_CME type
240 typedef void (*bthf_client_cmd_complete_callback) (bthf_client_cmd_complete_t type, int cme);
242 /** Callback for subscriber information
244 typedef void (*bthf_client_subscriber_info_callback) (const char *name, bthf_client_subscriber_service_type_t type);
246 /** Callback for in-band ring tone settings
248 typedef void (*bthf_client_in_band_ring_tone_callback) (bthf_client_in_band_ring_state_t state);
251 * Callback for requested number from AG
253 typedef void (*bthf_client_last_voice_tag_number_callback) (const char *number);
256 * Callback for sending ring indication to app
258 typedef void (*bthf_client_ring_indication_callback) (void);
261 * Callback for sending voice data to app
263 typedef void (*bthf_client_get_voice_data_callback) (uint8_t *p_buf, uint8_t len);
265 /** BT-HF callback structure. */
267 /** set to sizeof(BtHfClientCallbacks) */
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;
293 /** Represents the standard BT-HF interface. */
296 /** set to sizeof(BtHfClientInterface) */
299 * Register the BtHf callbacks
301 bt_status_t (*init)(bthf_client_callbacks_t* callbacks);
303 /** connect to audio gateway */
304 bt_status_t (*connect)(bt_bdaddr_t *bd_addr);
306 /** disconnect from audio gateway */
307 bt_status_t (*disconnect)(bt_bdaddr_t *bd_addr);
309 /** create an audio connection */
310 bt_status_t (*connect_audio)(bt_bdaddr_t *bd_addr);
312 /** close the audio connection */
313 bt_status_t (*disconnect_audio)(bt_bdaddr_t *bd_addr);
315 /** start voice recognition */
316 bt_status_t (*start_voice_recognition)(void);
318 /** stop voice recognition */
319 bt_status_t (*stop_voice_recognition)(void);
321 /** volume control */
322 bt_status_t (*volume_control) (bthf_client_volume_type_t type, int volume);
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);
328 /** place a call with number specified by location (speed dial) */
329 bt_status_t (*dial_memory) (int location);
331 /** perform specified call related action
332 * idx is limited only for enhanced call control related action
334 bt_status_t (*handle_call_action) (bthf_client_call_action_t action, int idx);
336 /** query list of current calls */
337 bt_status_t (*query_current_calls) (void);
339 /** query name of current selected operator */
340 bt_status_t (*query_current_operator_name) (void);
342 /** Retrieve subscriber information */
343 bt_status_t (*retrieve_subscriber_info) (void);
346 bt_status_t (*send_dtmf) (char code);
348 /** Request a phone number from AG corresponding to last voice tag recorded */
349 bt_status_t (*request_last_voice_tag_number) (void);
351 /** Closes the interface. */
352 void (*cleanup)(void);
354 /** Send AT Command. */
355 bt_status_t (*send_at_cmd) (int cmd, int val1, int val2, const char *arg);
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;
363 #endif /* ANDROID_INCLUDE_BT_HF_CLIENT_H */