2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef _BLUETOOTH_TELEPHONY_API_H_
19 #define _BLUETOOTH_TELEPHONY_API_H_
27 #endif /*__cplusplus*/
29 typedef void (*bt_telephony_func_ptr)(int, void *, void *);
31 #define BLUETOOTH_TELEPHONY_ERROR_NONE ((int)0)
32 #define BLUETOOTH_TELEPHONY_ERROR_INTERNAL \
33 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x01)
34 #define BLUETOOTH_TELEPHONY_ERROR_INVALID_PARAM \
35 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x02)
36 #define BLUETOOTH_TELEPHONY_ERROR_ALREADY_INITIALIZED \
37 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x03)
38 #define BLUETOOTH_TELEPHONY_ERROR_NOT_INITIALIZED \
39 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x04)
40 #define BLUETOOTH_TELEPHONY_ERROR_AUDIO_NOT_CONNECTED \
41 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x05)
42 #define BLUETOOTH_TELEPHONY_ERROR_NOT_ENABLED \
43 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x06)
44 #define BLUETOOTH_TELEPHONY_ERROR_NOT_AVAILABLE \
45 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x07)
46 #define BLUETOOTH_TELEPHONY_ERROR_NOT_CONNECTED \
47 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x08)
48 #define BLUETOOTH_TELEPHONY_ERROR_BUSY \
49 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x09)
50 #define BLUETOOTH_TELEPHONY_ERROR_ALREADY_EXSIST \
51 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0A)
52 #define BLUETOOTH_TELEPHONY_ERROR_NO_MEMORY \
53 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0B)
54 #define BLUETOOTH_TELEPHONY_ERROR_I_O_ERROR \
55 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0C)
56 #define BLUETOOTH_TELEPHONY_ERROR_ALREADY_CONNECTED \
57 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0D)
58 #define BLUETOOTH_TELEPHONY_ERROR_OPERATION_NOT_AVAILABLE \
59 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0E)
60 #define BLUETOOTH_TELEPHONY_ERROR_PERMISSION_DENIED \
61 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0F)
63 #define BT_ADDRESS_STR_LEN 18
64 #define BT_ADAPTER_PATH_LEN 50
65 #define BT_AUDIO_CALL_PATH_LEN 50
71 } telephony_event_param_t;
75 } telephony_event_callid_t;
79 } telephony_event_dtmf_t;
82 const gchar *remote_address;
84 } telephony_event_hf_battery_level_t;
87 BLUETOOTH_STATE_CONNECTED,
88 BLUETOOTH_STATE_PLAYING,
89 BLUETOOTH_STATE_DISCONNETED,
90 } bluetooth_headset_state_t;
93 BLUETOOTH_TELEPHONY_ERROR_INVALID_CHLD_INDEX,
94 BLUETOOTH_TELEPHONY_ERROR_BATTERY_STATUS,
95 BLUETOOTH_TELEPHONY_ERROR_SIGNAL_STATUS,
96 BLUETOOTH_TELEPHONY_ERROR_NOT_SUPPORTED,
97 BLUETOOTH_TELEPHONY_ERROR_APPLICATION,
98 BLUETOOTH_TELEPHONY_ERROR_INVALID_DTMF,
99 } bluetooth_telephony_error_t;
102 CSD_CALL_STATUS_IDLE,
103 CSD_CALL_STATUS_CREATE,
104 CSD_CALL_STATUS_COMING,
105 CSD_CALL_STATUS_PROCEEDING,
106 CSD_CALL_STATUS_MO_ALERTING,
107 CSD_CALL_STATUS_MT_ALERTING,
108 CSD_CALL_STATUS_WAITING,
109 CSD_CALL_STATUS_ANSWERED,
110 CSD_CALL_STATUS_ACTIVE,
111 CSD_CALL_STATUS_MO_RELEASE,
112 CSD_CALL_STATUS_MT_RELEASE,
113 CSD_CALL_STATUS_HOLD_INITIATED,
114 CSD_CALL_STATUS_HOLD,
115 CSD_CALL_STATUS_RETRIEVE_INITIATED,
116 CSD_CALL_STATUS_RECONNECT_PENDING,
117 CSD_CALL_STATUS_TERMINATED,
118 CSD_CALL_STATUS_SWAP_INITIATED,
119 } bt_telephony_call_status_t;
121 #define BLUETOOTH_EVENT_TYPE_TELEPHONY_BASE (unsigned int)(0x00500)
124 BLUETOOTH_EVENT_TELEPHONY_ANSWER_CALL = BLUETOOTH_EVENT_TYPE_TELEPHONY_BASE,
125 BLUETOOTH_EVENT_TELEPHONY_RELEASE_CALL,
126 BLUETOOTH_EVENT_TELEPHONY_REJECT_CALL,
127 BLUETOOTH_EVENT_TELEPHONY_CHLD_0_RELEASE_ALL_HELD_CALL,
128 BLUETOOTH_EVENT_TELEPHONY_CHLD_1_RELEASE_ALL_ACTIVE_CALL,
129 BLUETOOTH_EVENT_TELEPHONY_CHLD_2_ACTIVE_HELD_CALL,
130 BLUETOOTH_EVENT_TELEPHONY_CHLD_3_MERGE_CALL,
131 BLUETOOTH_EVENT_TELEPHONY_CHLD_4_EXPLICIT_CALL_TRANSFER,
132 BLUETOOTH_EVENT_TELEPHONY_SEND_DTMF,
133 BLUETOOTH_EVENT_TELEPHONY_HFP_CONNECTED,
134 BLUETOOTH_EVENT_TELEPHONY_HFP_DISCONNECTED,
135 BLUETOOTH_EVENT_TELEPHONY_AUDIO_CONNECTED,
136 BLUETOOTH_EVENT_TELEPHONY_AUDIO_DISCONNECTED,
137 BLUETOOTH_EVENT_TELEPHONY_SET_SPEAKER_GAIN,
138 BLUETOOTH_EVENT_TELEPHONY_SET_MIC_GAIN,
139 BLUETOOTH_EVENT_TELEPHONY_NREC_CHANGED,
140 BLUETOOTH_EVENT_TELEPHONY_VENDOR_AT_CMD,
141 BLUETOOTH_EVENT_TELEPHONY_HF_BATTERY_LEVEL_CHANGED,
142 } bluetooth_telephony_event_type;
145 BLUETOOTH_CALL_STATE_NONE,
146 BLUETOOTH_CALL_STATE_CONNECTED,
147 BLUETOOTH_CALL_STATE_HELD,
148 BLUETOOTH_CALL_STATE_DIALLING,
149 BLUETOOTH_CALL_STATE_ALERTING,
150 BLUETOOTH_CALL_STATE_INCOMING,
151 BLUETOOTH_CALL_STATE_WAITING,
152 BLUETOOTH_CALL_STATE_ERROR,
153 } bt_telephony_call_state_t;
156 BLUETOOTH_AGENT_ERROR_NONE,
157 BLUETOOTH_AGENT_ERROR_INTERNAL,
158 BLUETOOTH_AGENT_ERROR_NOT_AVAILABLE,
159 BLUETOOTH_AGENT_ERROR_NOT_CONNECTED,
160 BLUETOOTH_AGENT_ERROR_BUSY,
161 BLUETOOTH_AGENT_ERROR_INVALID_PARAM,
162 BLUETOOTH_AGENT_ERROR_ALREADY_EXSIST,
163 BLUETOOTH_AGENT_ERROR_ALREADY_CONNECTED,
164 BLUETOOTH_AGENT_ERROR_NO_MEMORY,
165 BLUETOOTH_AGENT_ERROR_I_O_ERROR,
166 BLUETOOTH_AGENT_ERROR_OPERATION_NOT_AVAILABLE,
167 BLUETOOTH_AGENT_ERROR_NO_CALL_LOGS,
168 BLUETOOTH_AGENT_ERROR_INVALID_MEMORY_INDEX,
169 BLUETOOTH_AGENT_ERROR_INVALID_CHLD_INDEX,
170 BLUETOOTH_AGENT_ERROR_BATTERY_STATUS,
171 BLUETOOTH_AGENT_ERROR_SIGNAL_STATUS,
172 BLUETOOTH_AGENT_ERROR_NOT_SUPPORTED,
173 BLUETOOTH_AGENT_ERROR_INVALID_NUMBER,
174 BLUETOOTH_AGENT_ERROR_APPLICATION,
175 BLUETOOTH_AGENT_ERROR_INVALID_DTMF,
176 } bluetooth_telephony_agent_error_t;
179 unsigned int call_id;
180 bt_telephony_call_state_t call_status;
182 } bt_telephony_call_status_info_t;
185 * @brief The function bluetooth_telephony_init is initialize telephony calls.
187 * @param[in] cb Callback function
188 * @param[in] user_data Data sent by application, which will be
189 * returned in event handler.
190 * @return int Zero on Success or reason for error if any.
193 int bluetooth_telephony_init(bt_telephony_func_ptr cb, void *user_data);
196 * @brief The function bluetooth_telephony_deinit is deinitialize telephony calls.
198 * @return int Zero on Success or reason for error if any.
201 int bluetooth_telephony_deinit(void);
204 * @brief The function bluetooth_telephony_audio_open is to open SCO channel
206 * @return int Zero on Success or reason for error if any.
209 int bluetooth_telephony_audio_open(void);
212 * @brief The function bluetooth_telephony_audio_close is to close SCO channel.
213 * that the Volume on AG is changed.
215 * @return int Zero on Success or reason for error if any.
218 int bluetooth_telephony_audio_close(void);
221 * @brief The function bluetooth_telephony_call_remote_ringing is send
224 * @param[in] call_id Call Id.
225 * @return int Zero on Success or reason for error if any.
228 int bluetooth_telephony_call_remote_ringing(unsigned int call_id);
231 * @brief The function bluetooth_telephony_call_answered is called to
234 * @param[in] call_id Call Id.
235 * @param[in] bt_audio flag
236 * @return int Zero on Success or reason for error if any.
239 int bluetooth_telephony_call_answered(unsigned int call_id,
240 unsigned int bt_audio);
243 * @brief The function bluetooth_telephony_call_end to end call
245 * @param[in] call_id Call Id.
246 * @return int Zero on Success or reason for error if any.
249 int bluetooth_telephony_call_end(unsigned int call_id);
252 * @brief The function bluetooth_telephony_call_held to hold call
254 * @param[in] call_id Call Id.
255 * @return int Zero on Success or reason for error if any.
258 int bluetooth_telephony_call_held(unsigned int call_id);
261 * @brief The function bluetooth_telephony_call_retrieved to retrieve call
263 * @param[in] call_id Call Id.
264 * @return int Zero on Success or reason for error if any.
267 int bluetooth_telephony_call_retrieved(unsigned int call_id);
270 * @brief The function bluetooth_telephony_call_swapped to swap call
272 * @param[in] call_list Call info such as id and status.
273 * @param[in] call_count Call count.
274 * @return int Zero on Success or reason for error if any.
277 int bluetooth_telephony_call_swapped(void *call_list,
278 unsigned int call_count);
281 * @brief The function bluetooth_telephony_set_call_status to set call status
283 * @param[in] call_list Call info such as id and status.
284 * @param[in] call_count Call count.
285 * @return int Zero on Success or reason for error if any.
288 int bluetooth_telephony_set_call_status(void *call_list,
289 unsigned int call_count);
292 * @brief The function bluetooth_telephony_indicate_outgoing_call toindicate
295 * @param[in] ph_number Phone number of the outgoing call.
296 * @param[in] call_id Call ID.
297 * @param[in] bt_audio Flag.
298 * @return int Zero on Success or reason for error if any.
301 int bluetooth_telephony_indicate_outgoing_call(
302 const char *ph_number, unsigned int call_id,
303 unsigned int bt_audio);
306 * @brief The function bluetooth_telephony_indicate_incoming_call to indicate
309 * @param[in] call_info Call info such as id and status.
310 * @param[in] call_count Call count.
311 * @return int Zero on Success or reason for error if any.
314 int bluetooth_telephony_indicate_incoming_call(
315 const char *ph_number, unsigned int call_id);
318 * @brief The function bluetooth_telephony_is_sco_connected to check
319 * if SCO channel is connected.
321 * @return gboolean TRUE if headset playing else FALSE.
324 gboolean bluetooth_telephony_is_sco_connected(void);
327 * @brief The function bluetooth_telephony_is_nrec_enabled to check
328 * for noise reduction and echo cancelation(nrec) status
330 * @return int Zero on Success or reason for error if any.
333 int bluetooth_telephony_is_nrec_enabled(gboolean *status);
336 * @brief The function bluetooth_telephony_is_nrec_enabled to check
337 * for wide band speech status
339 * @return int Zero on Success or reason for error if any.
342 int bluetooth_telephony_is_wbs_mode(gboolean *status);
345 * @brief This function send XSAT vendor specific AT command
347 * @return int Zero on Success or reason for error if any.
349 int bluetooth_telephony_send_vendor_cmd(const char *cmd);
353 * @brief This function sends request to enable voice recognition feature
355 * @return int Zero on Success or reason for error if any.
357 int bluetooth_telephony_start_voice_recognition(void);
360 * @brief This function sends request to disable voice recognition feature
362 * @return int Zero on Success or reason for error if any.
364 int bluetooth_telephony_stop_voice_recognition(void);
368 * @brief The function bluetooth_telephony_get_headset_volume is called to get
369 * the changed Volume on AG.
371 * @param[out] speaker_gain Speaker gain.
372 * @return int Zero on Success or reason for error if any.
375 int bluetooth_telephony_get_headset_volume(unsigned int *speaker_gain);
378 * @brief The function bluetooth_telephony_set_speaker_gain is called to indicate
379 * that the Volume on AG is changed.
381 * @param[in] speaker_gain Speaker gain.
382 * @return int Zero on Success or reason for error if any.
385 int bluetooth_telephony_set_speaker_gain(unsigned short speaker_gain);
388 * @brief The function bluetooth_telephony_get_battery_level is called to get
389 * the changed battery level on AG.
391 * @param[in] remote_address Remote Addr.
392 * @param[out] level Battery level.
393 * @return int Zero on Success or reason for error if any.
396 int bluetooth_telephony_get_battery_level(
397 const char *remote_address, unsigned int *level);
400 * @brief The function bluetooth_telephony_is_connected is called to get
401 * the connection state on AG.
403 * @param[in] ag_connnected Connection state.
404 * @return int Zero on Success or reason for error if any.
407 int bluetooth_telephony_is_connected(gboolean *ag_connected);
410 * @brief The function bluetooth_telephony_set_active_headset is called to select
411 * the active headset device for AG role if more than one headset is connected.
413 * @param[in] remote_addr Remote Addr.
414 * @return int Zero on Success or reason for error if any.
417 int bluetooth_telephony_set_active_headset(const char *remote_addr);
421 #endif /*__cplusplus*/
422 #endif/*_BLUETOOTH_TELEPHONY_API_H_*/