4 * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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.
20 #ifndef _BLUETOOTH_API_H_
21 #define _BLUETOOTH_API_H_
29 #endif /* __cplusplus */
32 * @defgroup BLUETOOTHFW BluetoothFW
34 * A base library for bluetooth framework
36 * @addtogroup BLUETOOTHFW
40 #define BLUETOOTH_ADDRESS_LENGTH 6 /**< This specifies bluetooth device address length */
41 #define BLUETOOTH_INTERFACE_NAME_LENGTH 16
42 #define BLUETOOTH_DEVICE_NAME_LENGTH_MAX 248 /**< This specifies maximum device name length */
44 #define BLUETOOTH_MAX_SERVICES_FOR_DEVICE 40 /**< This specifies maximum number of services
45 a device can support */
47 #define BLUETOOTH_UUID_STRING_MAX 50
49 #define BLUETOOTH_OOB_DATA_LENGTH 16
51 * This is Bluetooth Connected event role
53 #define RFCOMM_ROLE_SERVER 1
54 #define RFCOMM_ROLE_CLIENT 2
57 * This is Bluetooth error code
59 #define BLUETOOTH_ERROR_BASE ((int)0) /**< Error code base */
61 #define BLUETOOTH_ERROR_NONE ((int)0) /**< No error #0 */
62 #define BLUETOOTH_ERROR_CANCEL ((int)BLUETOOTH_ERROR_BASE - 0x01)
64 #define BLUETOOTH_ERROR_INVALID_CALLBACK ((int)BLUETOOTH_ERROR_BASE - 0x02)
65 /**< Callback error */
66 #define BLUETOOTH_ERROR_INVALID_PARAM ((int)BLUETOOTH_ERROR_BASE - 0x03)
67 /**< invalid paramerror */
68 #define BLUETOOTH_ERROR_INVALID_DATA ((int)BLUETOOTH_ERROR_BASE - 0x04)
69 /**< invalid data error */
70 #define BLUETOOTH_ERROR_MEMORY_ALLOCATION ((int)BLUETOOTH_ERROR_BASE - 0x05)
71 /**< Memory allocation error */
72 #define BLUETOOTH_ERROR_OUT_OF_MEMORY ((int)BLUETOOTH_ERROR_BASE - 0x06)
73 /**< out of memory error */
74 #define BLUETOOTH_ERROR_TIMEOUT ((int)BLUETOOTH_ERROR_BASE - 0x07)
76 #define BLUETOOTH_ERROR_NO_RESOURCES ((int)BLUETOOTH_ERROR_BASE - 0x08)
77 /**< No resource error */
78 #define BLUETOOTH_ERROR_INTERNAL ((int)BLUETOOTH_ERROR_BASE - 0x09)
79 /**< internal error */
80 #define BLUETOOTH_ERROR_NOT_SUPPORT ((int)BLUETOOTH_ERROR_BASE - 0x0a)
81 /**< Not supported error */
82 #define BLUETOOTH_ERROR_DEVICE_NOT_ENABLED ((int)BLUETOOTH_ERROR_BASE - 0x0b)
83 /**< Operation is failed because
84 of not enabled BT Adapter */
85 #define BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED ((int)BLUETOOTH_ERROR_BASE - 0x0c)
86 /**< Enabling is failed because of
87 already enabled BT Adapter */
88 #define BLUETOOTH_ERROR_DEVICE_BUSY ((int)BLUETOOTH_ERROR_BASE - 0x0d)
89 /**< Operation is failed because of
90 other on going operation */
91 #define BLUETOOTH_ERROR_ACCESS_DENIED ((int)BLUETOOTH_ERROR_BASE - 0x0e)
92 /**< access denied error */
93 #define BLUETOOTH_ERROR_MAX_CLIENT ((int)BLUETOOTH_ERROR_BASE - 0x0f)
94 /**< max client error */
95 #define BLUETOOTH_ERROR_NOT_FOUND ((int)BLUETOOTH_ERROR_BASE - 0x10)
96 /**< not found error */
97 #define BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR ((int)BLUETOOTH_ERROR_BASE - 0x11)
98 /**< service search fail */
99 #define BLUETOOTH_ERROR_PARING_FAILED ((int)BLUETOOTH_ERROR_BASE - 0x12)
100 /**< pairing failed error */
101 #define BLUETOOTH_ERROR_NOT_PAIRED ((int)BLUETOOTH_ERROR_BASE - 0x13)
102 /**< Not paired error */
103 #define BLUETOOTH_ERROR_SERVICE_NOT_FOUND ((int)BLUETOOTH_ERROR_BASE - 0x14)
104 /**< no service error */
105 #define BLUETOOTH_ERROR_NOT_CONNECTED ((int)BLUETOOTH_ERROR_BASE - 0x15)
106 /**< no connection error */
107 #define BLUETOOTH_ERROR_ALREADY_CONNECT ((int)BLUETOOTH_ERROR_BASE - 0x16)
108 /**< alread connected error */
109 #define BLUETOOTH_ERROR_CONNECTION_BUSY ((int)BLUETOOTH_ERROR_BASE - 0x17)
110 /**< connection busy error */
111 #define BLUETOOTH_ERROR_CONNECTION_ERROR ((int)BLUETOOTH_ERROR_BASE - 0x18)
112 /**< connection error */
113 #define BLUETOOTH_ERROR_MAX_CONNECTION ((int)BLUETOOTH_ERROR_BASE - 0x19)
114 /**< max connection error*/
115 #define BLUETOOTH_ERROR_NOT_IN_OPERATION ((int)BLUETOOTH_ERROR_BASE - 0x1a)
116 /**< Not in operation */
117 #define BLUETOOTH_ERROR_CANCEL_BY_USER ((int)BLUETOOTH_ERROR_BASE - 0x1b)
118 /**< Cancelled by user */
119 #define BLUETOOTH_ERROR_REGISTRATION_FAILED ((int)BLUETOOTH_ERROR_BASE - 0x1c)
120 /**< Service record registration failed */
121 #define BLUETOOTH_ERROR_IN_PROGRESS ((int)BLUETOOTH_ERROR_BASE - 0x1d)
122 /**< Operation in progress */
123 #define BLUETOOTH_ERROR_AUTHENTICATION_FAILED ((int)BLUETOOTH_ERROR_BASE - 0x1e)
124 /**< authentication failed error when paring*/
125 #define BLUETOOTH_ERROR_HOST_DOWN ((int)BLUETOOTH_ERROR_BASE - 0x1f)
126 /**< Remote host is down */
127 #define BLUETOOTH_ERROR_END_OF_DEVICE_LIST ((int)BLUETOOTH_ERROR_BASE - 0x20)
128 /**< End of device list */
130 #define BLUETOOTH_ERROR_AGENT_ALREADY_EXIST ((int)BLUETOOTH_ERROR_BASE - 0x21)
131 /**< Obex agent already exists */
132 #define BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST ((int)BLUETOOTH_ERROR_BASE - 0x22)
133 /**< Obex agent does not exist */
135 #define BLUETOOTH_ERROR_ALREADY_INITIALIZED ((int)BLUETOOTH_ERROR_BASE - 0x23)
136 /**< Already initialized */
140 * This is Bluetooth device address type, fixed to 6 bytes ##:##:##:##:##:##
143 unsigned char addr[BLUETOOTH_ADDRESS_LENGTH];
144 } bluetooth_device_address_t;
147 * This is Bluetooth device name type, maximum size of Bluetooth device name is 248 bytes
150 char name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX + 1];
151 } bluetooth_device_name_t;
157 BLUETOOTH_ADAPTER_DISABLED, /**< Bluetooth adapter is disabled */
158 BLUETOOTH_ADAPTER_ENABLED, /**< Bluetooth adapter is enabled */
159 BLUETOOTH_ADAPTER_CHANGING_ENABLE, /**< Bluetooth adapter is currently enabling */
160 BLUETOOTH_ADAPTER_CHANGING_DISABLE, /**< Bluetooth adapter is currently disabling */
161 } bluetooth_adapter_state_t;
167 BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, /**< Non discoverable mode */
168 /*Changed the order to make it compatable with old method */
169 BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE,/**< Discoverable mode */
170 BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE,
171 /**< Discoverable mode with time limit
172 After specific timeout, it is changed
173 to non discoverable mode */
174 } bluetooth_discoverable_mode_t;
177 * Network connect mode
180 BLUETOOTH_NETWORK_PANU_ROLE,
182 BLUETOOTH_NETWORK_NAP_ROLE,/**< Network Access Point */
183 BLUETOOTH_NETWORK_GN_ROLE, /**< Group ad-hoc Network */
184 BLUETOOTH_NETWORK_CUSTOM_UUID, /**< Custom role */
185 } bluetooth_network_role_t;
191 BLUETOOTH_RFCOMM_SERVICE = 0x01,
192 BLUETOOTH_A2DP_SERVICE = 0x02,
193 BLUETOOTH_HSP_SERVICE = 0x04,
194 BLUETOOTH_HID_SERVICE = 0x08,
195 } bluetooth_service_type_t;
197 #define BLUETOOTH_EVENT_BASE ((int)(0x0000)) /**< No event */
198 #define BLUETOOTH_EVENT_GAP_BASE ((int)(BLUETOOTH_EVENT_BASE + 0x0010))
199 /**< Base ID for GAP Event */
200 #define BLUETOOTH_EVENT_SDP_BASE ((int)(BLUETOOTH_EVENT_GAP_BASE + 0x0020))
201 /**< Base ID for SDP events */
202 #define BLUETOOTH_EVENT_RFCOMM_BASE ((int)(BLUETOOTH_EVENT_SDP_BASE + 0x0020))
203 /**< Base ID for RFCOMM events */
204 #define BLUETOOTH_EVENT_NETWORK_BASE ((int)(BLUETOOTH_EVENT_RFCOMM_BASE + 0x0020))
205 /**< Base ID for NETWORK events */
206 #define BLUETOOTH_EVENT_HDP_BASE ((int)(BLUETOOTH_EVENT_NETWORK_BASE + 0x0020))
207 /**< Base ID for HDP events */
208 #define BLUETOOTH_EVENT_OPC_BASE ((int)(BLUETOOTH_EVENT_HDP_BASE + 0x0020))
209 /**< Base ID for OPC events */
210 #define BLUETOOTH_EVENT_OBEX_SERVER_BASE ((int)(BLUETOOTH_EVENT_OPC_BASE + 0x0020))
211 /**< Base ID for Obex Server events */
212 #define BLUETOOTH_EVENT_GATT_BASE ((int)(BLUETOOTH_EVENT_OBEX_SERVER_BASE + 0x0020))
213 /**< Base ID for GATT events */
215 #define BLUETOOTH_EVENT_AUDIO_BASE ((int)(BLUETOOTH_EVENT_GATT_BASE + 0x0020))
216 /**< Base ID for Audio events */
217 #define BLUETOOTH_EVENT_HID_BASE ((int)(BLUETOOTH_EVENT_AUDIO_BASE + 0x0020))
218 /**< Base ID for HID events */
221 * Bluetooth event type
224 BLUETOOTH_EVENT_NONE = BLUETOOTH_EVENT_BASE,/**< No event */
226 BLUETOOTH_EVENT_ENABLED, /**< Bluetooth event adpater enabled */
227 BLUETOOTH_EVENT_DISABLED, /**< Bluetooth event adpater disabled */
228 BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, /**< Bluetooth event local name changed*/
229 BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_REQUESTED,
230 /**< Bluetooth event Discoverable timeout requested*/
231 BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED, /**< Bluetooth event mode changed */
232 BLUETOOTH_EVENT_DISCOVERY_OPTION_REQUESTED, /**< Bluetooth event discovery option */
233 BLUETOOTH_EVENT_DISCOVERY_STARTED, /**< Bluetooth event discovery started */
234 BLUETOOTH_EVENT_DISCOVERY_FINISHED, /**< Bluetooth event discovery finished */
236 BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, /**< Bluetooth event remote deice found */
237 BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED,/**< Bluetooth event remote device name updated*/
238 BLUETOOTH_EVENT_BONDING_FINISHED, /**< Bluetooth event bonding completed */
239 BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED, /**< Bluetooth event bonding removed */
240 BLUETOOTH_EVENT_BONDED_DEVICE_FOUND, /**< Bluetooth event paired device found */
241 BLUETOOTH_EVENT_REMOTE_DEVICE_READ, /**< Bluetooth event read remote device */
242 BLUETOOTH_EVENT_DEVICE_AUTHORIZED, /**< Bluetooth event authorize device */
243 BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED, /**< Bluetooth event unauthorize device */
244 BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_CHANGED, /**< Bluetooth event mode changed */
246 BLUETOOTH_EVENT_SERVICE_SEARCHED = BLUETOOTH_EVENT_SDP_BASE,
247 /**< Bluetooth event serice search base id */
248 BLUETOOTH_EVENT_SERVICE_SEARCH_CANCELLED, /**< Bluetooth event service search cancelled */
249 BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED = BLUETOOTH_EVENT_RFCOMM_BASE,
250 /**< RFCOMM data receive event */
251 BLUETOOTH_EVENT_RFCOMM_CONNECTED, /**< Rfcomm server incomming connection */
252 BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, /**< Rfcomm server/client disconnect */
254 BLUETOOTH_EVENT_RFCOMM_AUTHORIZE,
256 BLUETOOTH_EVENT_DEVICE_CONNECTED, /**< Bluetooth event device connected */
257 BLUETOOTH_EVENT_DEVICE_DISCONNECTED, /**< Bluetooth event device disconnected */
259 BLUETOOTH_EVENT_RFCOMM_SERVER_REMOVED,
261 BLUETOOTH_EVENT_NETWORK_SERVER_ACTIVATED = BLUETOOTH_EVENT_NETWORK_BASE,
262 /**< Bluetooth Network event */
263 BLUETOOTH_EVENT_NETWORK_SERVER_DEACTIVATED, /**< Network server deactivated */
264 BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED, /**< Network connected event in server */
265 BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED,
266 /**< Network disconnected evnet in server */
268 BLUETOOTH_EVENT_NETWORK_CONNECTED, /**< Network connected event in client*/
269 BLUETOOTH_EVENT_NETWORK_DISCONNECTED, /**< Network disconnected evnet in client*/
271 BLUETOOTH_EVENT_HDP_CONNECTED
272 = BLUETOOTH_EVENT_HDP_BASE, /**<HDP Connect>*/
273 BLUETOOTH_EVENT_HDP_DISCONNECTED, /**<HDP Disconnect>*/
274 BLUETOOTH_EVENT_HDP_DATA_RECEIVED, /**<HDP Data Indication>*/
276 BLUETOOTH_EVENT_OPC_CONNECTED = BLUETOOTH_EVENT_OPC_BASE,
277 /* OPC Connected event */
278 BLUETOOTH_EVENT_OPC_DISCONNECTED, /* OPC Disonnected event */
279 BLUETOOTH_EVENT_OPC_TRANSFER_STARTED, /* OPC Transfer started event */
280 BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS, /* OPC Transfer progress event */
281 BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE, /* OPC Transfer Complete event */
283 BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE = BLUETOOTH_EVENT_OBEX_SERVER_BASE,
284 /* Obex server authorize event*/
285 BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED, /* Obex Server transfer started event*/
286 BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS,/* Obex Server transfer progress event*/
287 BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED,/* Obex Server transfer complete event*/
288 BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE,
290 BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED = BLUETOOTH_EVENT_GATT_BASE,
291 /**<Discovered GATT service characteristics event*/
292 BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED,
293 /**<Remote GATT charateristic value changed event*/
294 BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID,
296 BLUETOOTH_EVENT_AG_CONNECTED = BLUETOOTH_EVENT_AUDIO_BASE, /**<AG service connected event*/
297 BLUETOOTH_EVENT_AG_DISCONNECTED, /**<AG service disconnected event*/
298 BLUETOOTH_EVENT_AG_SPEAKER_GAIN, /**<Speaker gain request event*/
299 BLUETOOTH_EVENT_AG_MIC_GAIN, /**<Mic gain request event*/
300 BLUETOOTH_EVENT_AG_AUDIO_CONNECTED, /**<AV & AG service connected event*/
301 BLUETOOTH_EVENT_AG_AUDIO_DISCONNECTED, /**<AV & AG service disconnected event*/
302 BLUETOOTH_EVENT_AV_CONNECTED, /**<AV service connected event*/
303 BLUETOOTH_EVENT_AV_DISCONNECTED, /**<AV service disconnected event*/
304 BLUETOOTH_EVENT_AVRCP_CONNECTED, /**<AVRCP service connected event*/
305 BLUETOOTH_EVENT_AVRCP_DISCONNECTED, /**<AVRCP service disconnected event*/
306 BLUETOOTH_EVENT_AVRCP_SETTING_SHUFFLE_STATUS, /**<AVRCP service player suffle status event*/
307 BLUETOOTH_EVENT_AVRCP_SETTING_EQUALIZER_STATUS, /**<AVRCP service player equalizer status event*/
308 BLUETOOTH_EVENT_AVRCP_SETTING_REPEAT_STATUS, /**<AVRCP service player repeat status event*/
309 BLUETOOTH_EVENT_AVRCP_SETTING_SCAN_STATUS, /**<AVRCP service player scan status event*/
311 BLUETOOTH_HID_CONNECTED = BLUETOOTH_EVENT_HID_BASE, /**< Input connectd event*/
312 BLUETOOTH_HID_DISCONNECTED, /**< Input disconnectd event*/
313 BLUETOOTH_EVENT_MAX, /**< Bluetooth event Max value */
314 } bluetooth_event_type_t;
317 * This bt_service_uuid_list_t enum indicates service uuid list .
318 * This values is stored the service_list_array in bt_sdp_info_t and bluetooth_device_info_t.
322 BLUETOOTH_SPP_PROFILE_UUID = ((unsigned short)0x1101), /**<SPP*/
323 BLUETOOTH_LAP_PROFILE_UUID = ((unsigned short)0x1102), /**<LAP*/
324 BLUETOOTH_DUN_PROFILE_UUID = ((unsigned short)0x1103), /**<DUN*/
325 BLUETOOTH_OBEX_IR_MC_SYNC_SERVICE_UUID = ((unsigned short)0x1104), /**<OBEX IR MC SYNC*/
326 BLUETOOTH_OBEX_OBJECT_PUSH_SERVICE_UUID = ((unsigned short)0x1105), /**<OPP*/
327 BLUETOOTH_OBEX_FILE_TRANSFER_UUID = ((unsigned short)0x1106), /**<FTP*/
328 BLUETOOTH_IRMC_SYNC_COMMAND_UUID = ((unsigned short)0x1107), /**<IRMC SYNC COMMAND*/
329 BLUETOOTH_HS_PROFILE_UUID = ((unsigned short)0x1108), /**<HS*/
330 BLUETOOTH_CTP_PROFILE_UUID = ((unsigned short)0x1109), /**<CTP*/
331 BLUETOOTH_AUDIO_SOURCE_UUID = ((unsigned short)0x110A), /**<AUDIO SOURCE*/
332 BLUETOOTH_AUDIO_SINK_UUID = ((unsigned short)0x110B), /**<AUDIO SINK*/
333 BLUETOOTH_AV_REMOTE_CONTROL_TARGET_UUID = ((unsigned short)0x110C), /**<AV REMOTE CONTROL
335 BLUETOOTH_ADVANCED_AUDIO_PROFILE_UUID = ((unsigned short)0x110D), /**<A2DP*/
336 BLUETOOTH_AV_REMOTE_CONTROL_UUID = ((unsigned short)0x110E), /**<AV REMOTE CONTROL UUID*/
337 BLUETOOTH_AV_REMOTE_CONTROL_CONTROLLER_UUID = ((unsigned short)0x110F), /**<AV REMOTE CONTROLLER UUID*/
338 BLUETOOTH_ICP_PROFILE_UUID = ((unsigned short)0x1110), /**<ICP*/
339 BLUETOOTH_FAX_PROFILE_UUID = ((unsigned short)0x1111), /**<FAX*/
340 BLUETOOTH_HEADSET_AG_SERVICE_UUID = ((unsigned short)0x1112), /**<HS AG */
341 BLUETOOTH_PAN_PANU_PROFILE_UUID = ((unsigned short)0x1115), /**<PAN*/
342 BLUETOOTH_PAN_NAP_PROFILE_UUID = ((unsigned short)0x1116), /**<PAN*/
343 BLUETOOTH_PAN_GN_PROFILE_UUID = ((unsigned short)0x1117), /**<PAN*/
344 BLUETOOTH_DIRECT_PRINTING = ((unsigned short)0x1118),
345 BLUETOOTH_OBEX_BPPS_PROFILE_UUID = ((unsigned short)0x1118), /**<OBEX BPPS*/ /* Will be removed */
346 BLUETOOTH_REFERENCE_PRINTING = ((unsigned short)0x1119),
347 BLUETOOTH_OBEX_IMAGING_UUID = ((unsigned short)0x111A), /**<OBEX_IMAGING*/
348 BLUETOOTH_OBEX_IMAGING_RESPONDER_UUID = ((unsigned short)0x111B), /**<OBEX_IMAGING
350 BLUETOOTH_IMAGING_AUTOMATIC_ARCHIVE_UUID = ((unsigned short)0x111C), /**<IMAGING AUTOMATIC ARCHIVE*/
351 BLUETOOTH_IMAGING_REFERENCED_OBJECTS_UUID = ((unsigned short)0x111D), /**<IMAGING REFERENCED OBJECTS*/
352 BLUETOOTH_HF_PROFILE_UUID = ((unsigned short)0x111E), /**<HF*/
353 BLUETOOTH_HFG_PROFILE_UUID = ((unsigned short)0x111F), /**<HFG*/
354 BLUETOOTH_DIRECT_PRINTING_REFERENCE_OBJ_UUID = ((unsigned short)0x1120),
355 /**<DIRECT PRINTING*/
356 BLUETOOTH_REFLECTED_UI = ((unsigned short)0x1121), /**<REFLECTED UI*/
357 BLUETOOTH_BASIC_PRINTING = ((unsigned short)0x1122), /**<BASIC PRINTING*/
358 BLUETOOTH_PRINTING_STATUS = ((unsigned short)0x1123), /**<PRINTING STATUS*/
359 BLUETOOTH_OBEX_PRINTING_STATUS_UUID = ((unsigned short)0x1123), /**<OBEX PRINTING STATUS*/ /* Will be removed */
360 BLUETOOTH_HID_PROFILE_UUID = ((unsigned short)0x1124), /**<HID*/
361 BLUETOOTH_HCR_PROFILE_UUID = ((unsigned short)0x1125), /**<HCRP*/
362 BLUETOOTH_HCR_PRINT_UUID = ((unsigned short)0x1126), /**<HCR PRINT*/
363 BLUETOOTH_HCR_SCAN_UUID = ((unsigned short)0x1127), /**<HCR SCAN*/
364 BLUETOOTH_SIM_ACCESS_PROFILE_UUID = ((unsigned short)0x112D), /**<SIM ACCESS PROFILE*/
365 BLUETOOTH_PBAP_PCE_UUID = ((unsigned short)0x112E), /**<PBAP - PCE*/
366 BLUETOOTH_PBAP_PSE_UUID = ((unsigned short)0x112F), /**<OBEX PBA*/
367 BLUETOOTH_OBEX_PBA_PROFILE_UUID = ((unsigned short)0x112F), /**<OBEX PBA*/ /* Will be removed */
368 BLUETOOTH_OBEX_PBAP_UUID = ((unsigned short)0x1130), /**<OBEX PBA*/
369 BLUETOOTH_HEADSET_HS_UUID = ((unsigned short)0x1131), /**<HEADSET HS*/
370 BLUETOOTH_MESSAGE_ACCESS_SERVER_UUID = ((unsigned short)0x1132),/**<MESSAGE ACCESS SERVER*/
371 BLUETOOTH_MESSAGE_NOTIFICATION_SERVER_UUID = ((unsigned short)0x1133),/**<MESSAGE NOTIFICATION SERVER*/
372 BLUETOOTH_MESSAGE_ACCESS_PROFILE_UUID = ((unsigned short)0x1134),/**<MESSAGE ACCESS PROFILE*/
373 BLUETOOTH_PNP_INFORMATION_UUID = ((unsigned short)0x1200), /**<PNP*/
374 BLUETOOTH_GENERIC_NETWORKING_UUID = ((unsigned short)0x1201), /**<GENERIC NETWORKING*/
375 BLUETOOTH_GENERIC_FILE_TRANSFER_UUID = ((unsigned short)0x1202),/**<GENERIC FILE TRANSFER*/
376 BLUETOOTH_GENERIC_AUDIO_UUID = ((unsigned short)0x1203), /**<GENERIC AUDIO*/
377 BLUETOOTH_GENERIC_TELEPHONY_UUID = ((unsigned short)0x1204), /**<GENERIC TELEPHONY*/
378 BLUETOOTH_VIDEO_SOURCE_UUID = ((unsigned short)0x1303), /**<VEDIO SOURCE*/
379 BLUETOOTH_VIDEO_SINK_UUID = ((unsigned short)0x1304), /**<VEDIO SINK*/
380 BLUETOOTH_VIDEO_DISTRIBUTION_UUID = ((unsigned short)0x1305), /**<VEDIO DISTRIBUTION*/
381 BLUETOOTH_HDP_UUID = ((unsigned short)0x1400), /**<HDP*/
382 BLUETOOTH_HDP_SOURCE_UUID = ((unsigned short)0x1401), /**<HDP SOURCE*/
383 BLUETOOTH_HDP_SINK_UUID = ((unsigned short)0x1402), /**<HDP SINK*/
384 BLUETOOTH_OBEX_SYNCML_TRANSFER_UUID = ((unsigned short)0x0000) /**<OBEX_SYNC*/ /* Will be removed */
385 } bluetooth_service_uuid_list_t;
388 * Service class part of class of device returned from device discovery
391 BLUETOOTH_DEVICE_SERVICE_CLASS_LIMITED_DISCOVERABLE_MODE = 0x002000,
392 BLUETOOTH_DEVICE_SERVICE_CLASS_POSITIONING = 0x010000, /**< */
393 BLUETOOTH_DEVICE_SERVICE_CLASS_NETWORKING = 0x020000, /**< */
394 BLUETOOTH_DEVICE_SERVICE_CLASS_RENDERING = 0x040000, /**< */
395 BLUETOOTH_DEVICE_SERVICE_CLASS_CAPTURING = 0x080000, /**< */
396 BLUETOOTH_DEVICE_SERVICE_CLASS_OBJECT_TRANSFER = 0x100000, /**< */
397 BLUETOOTH_DEVICE_SERVICE_CLASS_AUDIO = 0x200000, /**< */
398 BLUETOOTH_DEVICE_SERVICE_CLASS_TELEPHONY = 0x400000, /**< */
399 BLUETOOTH_DEVICE_SERVICE_CLASS_INFORMATION = 0x800000, /**< */
400 } bluetooth_device_service_class_t;
404 * Major device mask (For device discovery)
407 BLUETOOTH_DEVICE_MAJOR_MASK_MISC = 0x00,
408 BLUETOOTH_DEVICE_MAJOR_MASK_COMPUTER = 0x0001,
409 BLUETOOTH_DEVICE_MAJOR_MASK_PHONE = 0x0002,
410 BLUETOOTH_DEVICE_MAJOR_MASK_LAN_ACCESS_POINT = 0x0004,
411 BLUETOOTH_DEVICE_MAJOR_MASK_AUDIO = 0x0008,
412 BLUETOOTH_DEVICE_MAJOR_MASK_PERIPHERAL = 0x0010,
413 BLUETOOTH_DEVICE_MAJOR_MASK_IMAGING = 0x0020,
414 BLUETOOTH_DEVICE_MAJOR_MASK_WEARABLE = 0x0040,
415 BLUETOOTH_DEVICE_MAJOR_MASK_TOY = 0x0080,
416 BLUETOOTH_DEVICE_MAJOR_MASK_HEALTH = 0x0100,
417 } bluetooth_device_major_mask_t;
421 * Major device class (part of Class of Device)
424 BLUETOOTH_DEVICE_MAJOR_CLASS_MISC = 0x00, /**< Miscellaneous major device class*/
425 BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER = 0x01, /**< Computer major device class*/
426 BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE = 0x02, /**< Phone major device class*/
427 BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT = 0x03, /**< LAN major device class*/
428 BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO = 0x04, /**< AUDIO major device class*/
429 BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL = 0x05, /**< Peripheral major device class*/
430 BLUETOOTH_DEVICE_MAJOR_CLASS_IMAGING = 0x06, /**< Imaging major device class*/
431 BLUETOOTH_DEVICE_MAJOR_CLASS_WEARABLE = 0x07, /**< Wearable device class*/
432 BLUETOOTH_DEVICE_MAJOR_CLASS_TOY = 0x08, /**< Toy device class*/
433 BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH = 0x09, /**< Health device class*/
434 BLUETOOTH_DEVICE_MAJOR_CLASS_UNCLASSIFIED = 0x1F /**< Unknown major device class*/
435 } bluetooth_device_major_class_t;
438 BLUETOOTH_DEVICE_MINOR_CLASS_UNCLASSIFIED = 0x00, /**< unclassified minor class */
440 /* About Computer Major class */
441 BLUETOOTH_DEVICE_MINOR_CLASS_DESKTOP_WORKSTATION = 0x04, /**< desktop workstation
443 BLUETOOTH_DEVICE_MINOR_CLASS_SERVER_CLASS_COMPUTER = 0x08, /**< server minor class */
444 BLUETOOTH_DEVICE_MINOR_CLASS_LAPTOP = 0x0C, /**< laptop minor class */
445 BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_PC_OR_PDA = 0x10, /**< PDA minor class */
446 BLUETOOTH_DEVICE_MINOR_CLASS_PALM_SIZED_PC_OR_PDA = 0x14, /**< PALM minor class */
447 BLUETOOTH_DEVICE_MINOR_CLASS_WEARABLE_COMPUTER = 0x18, /**< Wearable PC minor class */
449 /* About Phone Major class */
450 BLUETOOTH_DEVICE_MINOR_CLASS_CELLULAR = 0x04, /**< Cellular minor class */
451 BLUETOOTH_DEVICE_MINOR_CLASS_CORDLESS = 0x08, /**< cordless minor class */
452 BLUETOOTH_DEVICE_MINOR_CLASS_SMART_PHONE = 0x0C, /**< smart phone minor class */
453 BLUETOOTH_DEVICE_MINOR_CLASS_WIRED_MODEM_OR_VOICE_GATEWAY = 0x10,
454 /**< voice gateway minor class */
455 BLUETOOTH_DEVICE_MINOR_CLASS_COMMON_ISDN_ACCESS = 0x14, /**< ISDN minor class */
457 /* About LAN/Network Access Point Major class */
458 BLUETOOTH_DEVICE_MINOR_CLASS_FULLY_AVAILABLE = 0x04, /**< Fully available minor class */
459 BLUETOOTH_DEVICE_MINOR_CLASS_1_TO_17_PERCENT_UTILIZED = 0x20, /**< 1-17% utilized minor class */
460 BLUETOOTH_DEVICE_MINOR_CLASS_17_TO_33_PERCENT_UTILIZED = 0x40, /**< 17-33% utilized minor class */
461 BLUETOOTH_DEVICE_MINOR_CLASS_33_TO_50_PERCENT_UTILIZED = 0x60, /**< 33-50% utilized minor class */
462 BLUETOOTH_DEVICE_MINOR_CLASS_50_to_67_PERCENT_UTILIZED = 0x80, /**< 50-67% utilized minor class */
463 BLUETOOTH_DEVICE_MINOR_CLASS_67_TO_83_PERCENT_UTILIZED = 0xA0, /**< 67-83% utilized minor class */
464 BLUETOOTH_DEVICE_MINOR_CLASS_83_TO_99_PERCENT_UTILIZED = 0xC0, /**< 83-99% utilized minor class */
465 BLUETOOTH_DEVICE_MINOR_CLASS_NO_SERVICE_AVAILABLE = 0xE0, /**< No service available minor class */
467 /* About Audio/Video Major class */
468 BLUETOOTH_DEVICE_MINOR_CLASS_HEADSET_PROFILE = 0x04, /**< Headset minor class */
469 BLUETOOTH_DEVICE_MINOR_CLASS_HANDSFREE = 0x08, /**< Handsfree minor class*/
471 BLUETOOTH_DEVICE_MINOR_CLASS_MICROPHONE = 0x10, /**< Microphone minor class */
472 BLUETOOTH_DEVICE_MINOR_CLASS_LOUD_SPEAKER = 0x14, /**< Loud Speaker minor class */
473 BLUETOOTH_DEVICE_MINOR_CLASS_HEADPHONES = 0x18, /**< Headphones minor class */
474 BLUETOOTH_DEVICE_MINOR_CLASS_PORTABLE_AUDIO = 0x1C, /**< Portable Audio minor class */
475 BLUETOOTH_DEVICE_MINOR_CLASS_CAR_AUDIO = 0x20, /**< Car Audio minor class */
476 BLUETOOTH_DEVICE_MINOR_CLASS_SET_TOP_BOX = 0x24, /**< Set top box minor class */
477 BLUETOOTH_DEVICE_MINOR_CLASS_HIFI_AUDIO_DEVICE = 0x28, /**< Hifi minor class */
478 BLUETOOTH_DEVICE_MINOR_CLASS_VCR = 0x2C, /**< VCR minor class */
479 BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_CAMERA = 0x30, /**< Video Camera minor class */
480 BLUETOOTH_DEVICE_MINOR_CLASS_CAM_CORDER = 0x34, /**< CAM Corder minor class */
481 BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_MONITOR = 0x38, /**<Video Monitor minor class */
482 BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_DISPLAY_AND_LOUD_SPEAKER = 0x3C,
483 /**< Video Display and Loud
484 Speaker minor class */
485 BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_CONFERENCING = 0x40, /**< Video Conferencing minor
488 BLUETOOTH_DEVICE_MINOR_CLASS_GAMING_OR_TOY = 0x48, /**< Gaming or toy minor class */
490 /* About Peripheral Major class */
491 BLUETOOTH_DEVICE_MINOR_CLASS_KEY_BOARD = 0x40, /**< Key board minor class */
492 BLUETOOTH_DEVICE_MINOR_CLASS_POINTING_DEVICE = 0x80, /**< Pointing Device minor class */
493 BLUETOOTH_DEVICE_MINOR_CLASS_COMBO_KEYBOARD_OR_POINTING_DEVICE = 0xC0,
494 /**< Combo Keyboard or pointing
497 BLUETOOTH_DEVICE_MINOR_CLASS_JOYSTICK = 0x04, /**< JoyStick minor class */
498 BLUETOOTH_DEVICE_MINOR_CLASS_GAME_PAD = 0x08, /**< Game Pad minor class */
499 BLUETOOTH_DEVICE_MINOR_CLASS_REMOTE_CONTROL = 0x0C, /**< Remote Control minor class */
500 BLUETOOTH_DEVICE_MINOR_CLASS_SENSING_DEVICE = 0x10, /**< Sensing Device minor class */
501 BLUETOOTH_DEVICE_MINOR_CLASS_DIGITIZER_TABLET = 0x14, /**< Digitizer minor class */
502 BLUETOOTH_DEVICE_MINOR_CLASS_CARD_READER = 0x18, /**< Card Reader minor class */
503 BLUETOOTH_DEVICE_MINOR_CLASS_DIGITAL_PEN = 0x1C, /**< Digital pen minor class */
504 BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_SCANNER = 0x20, /**< Handheld scanner for bar-codes, RFID minor class */
505 BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_GESTURAL_INPUT_DEVICE = 0x24, /**< Handheld gestural input device minor class */
507 /* About Imaging Major class */
508 BLUETOOTH_DEVICE_MINOR_CLASS_DISPLAY = 0x10, /**< Display minor class */
509 BLUETOOTH_DEVICE_MINOR_CLASS_CAMERA = 0x20, /**< Camera minor class */
510 BLUETOOTH_DEVICE_MINOR_CLASS_SCANNER = 0x40, /**< Scanner minor class */
511 BLUETOOTH_DEVICE_MINOR_CLASS_PRINTER = 0x80, /**< Printer minor class */
513 /* About Wearable Major class */
514 BLUETOOTH_DEVICE_MINOR_CLASS_WRIST_WATCH = 0x04, /**< Wrist watch minor class */
515 BLUETOOTH_DEVICE_MINOR_CLASS_PAGER = 0x08, /**< Pager minor class */
516 BLUETOOTH_DEVICE_MINOR_CLASS_JACKET = 0x0C, /**< Jacket minor class */
517 BLUETOOTH_DEVICE_MINOR_CLASS_HELMET = 0x10, /**< Helmet minor class */
518 BLUETOOTH_DEVICE_MINOR_CLASS_GLASSES = 0x14, /**< Glasses minor class */
520 /* About Toy Major class */
521 BLUETOOTH_DEVICE_MINOR_CLASS_ROBOT = 0x04, /**< Robot minor class */
522 BLUETOOTH_DEVICE_MINOR_CLASS_VEHICLE = 0x08, /**< Vehicle minor class */
523 BLUETOOTH_DEVICE_MINOR_CLASS_DOLL_OR_ACTION = 0x0C, /**< Doll or Action minor class */
524 BLUETOOTH_DEVICE_MINOR_CLASS_CONTROLLER = 0x10, /**< Controller minor class */
525 BLUETOOTH_DEVICE_MINOR_CLASS_GAME = 0x14, /**< Game minor class */
527 /* About Health Major class */
528 BLUETOOTH_DEVICE_MINOR_CLASS_BLOOD_PRESSURE_MONITOR = 0x04, /**< Blood Pressure minor class */
529 BLUETOOTH_DEVICE_MINOR_CLASS_THERMOMETER = 0x08, /**< Thermometer minor class */
530 BLUETOOTH_DEVICE_MINOR_CLASS_WEIGHING_SCALE = 0x0C, /**< Weighing Scale minor class */
531 BLUETOOTH_DEVICE_MINOR_CLASS_GLUCOSE_METER = 0x10, /**< Glucose minor class */
532 BLUETOOTH_DEVICE_MINOR_CLASS_PULSE_OXIMETER = 0x14, /**< Pulse Oximeter minor class */
533 BLUETOOTH_DEVICE_MINOR_CLASS_HEART_OR_PULSE_RATE_MONITOR = 0x18,/**< Heart or pulse rate monitor minor class */
534 BLUETOOTH_DEVICE_MINOR_CLASS_MEDICAL_DATA_DISPLAY = 0x1C, /**< Medical minor class */
535 BLUETOOTH_DEVICE_MINOR_CLASS_STEP_COUNTER = 0x20, /**< Step Counter minor class */
536 BLUETOOTH_DEVICE_MINOR_CLASS_BODY_COMPOSITION_ANALYZER = 0x24, /**< Body composition analyzer minor class */
537 BLUETOOTH_DEVICE_MINOR_CLASS_PEAK_FLOW_MONITOR = 0x28, /**< Peak flow monitor minor class */
538 BLUETOOTH_DEVICE_MINOR_CLASS_MEDICATION_MONITOR = 0x2C, /**< Medication monitor minor class */
539 BLUETOOTH_DEVICE_MINOR_CLASS_KNEE_PROSTHESIS = 0x30, /**< Knee prosthesis minor class */
540 BLUETOOTH_DEVICE_MINOR_CLASS_ANKLE_PROSTHESIS = 0x34, /**< Ankle prosthesis minor class */
541 } bluetooth_device_minor_class_t;
544 * structure to hold the device information
547 bluetooth_device_major_class_t major_class; /**< major device class */
548 bluetooth_device_minor_class_t minor_class; /**< minor device class */
549 bluetooth_device_service_class_t service_class;
550 /**< service device class */
551 } bluetooth_device_class_t;
554 * structure to hold the device information
557 bluetooth_device_address_t device_address; /**< device address */
558 bluetooth_device_name_t device_name; /**< device name */
559 bluetooth_device_class_t device_class; /**< device class */
560 char uuids[BLUETOOTH_MAX_SERVICES_FOR_DEVICE][BLUETOOTH_UUID_STRING_MAX];
561 unsigned int service_list_array[BLUETOOTH_MAX_SERVICES_FOR_DEVICE]; /**< Use enum values in bt_service_uuid_list_t */
563 int rssi; /**< received strength signal*/
564 gboolean paired; /**< paired flag */
565 gboolean connected; /**< connected flag */
566 gboolean trust; /**< connected flag */
567 } bluetooth_device_info_t;
570 * structure to hold the paired device information
573 bluetooth_device_address_t device_address; /**< paired device address */
574 bluetooth_device_name_t device_name; /**< device name */
575 bluetooth_device_class_t device_class; /**< device class */
576 } bluetooth_paired_device_info_t;
579 * structure to hold the paired device information
582 bluetooth_device_address_t device_address;
583 /**< device address */
584 char interface_name[BLUETOOTH_INTERFACE_NAME_LENGTH + 1];
585 /**< network interface name */
586 } bluetooth_network_device_info_t;
589 * Stucture to hold discovery option
592 unsigned short max_response; /**< the number of maximum response */
593 unsigned short discovery_duration;
594 /**< duration of discovery (seconds) */
595 unsigned int classOfDeviceMask; /**< mask for values of class of device. to be used with
596 classOfDevice variable */
597 } bluetooth_discovery_option_t;
600 * Stucture to hold event information
603 int event; /**< event type */
604 int result; /**< Success or error value */
606 /**<parameter data pointer */
608 } bluetooth_event_param_t;
611 bluetooth_device_address_t device_addr;
612 char uuids[BLUETOOTH_MAX_SERVICES_FOR_DEVICE][BLUETOOTH_UUID_STRING_MAX];
613 unsigned int service_list_array[BLUETOOTH_MAX_SERVICES_FOR_DEVICE]; /**< Use enum values in bt_service_uuid_list_t */
614 unsigned int service_name_array[BLUETOOTH_MAX_SERVICES_FOR_DEVICE];
619 * Stucture to rfcomm receive data
624 /**< the socket fd */
625 int buffer_size;/**< the length of the receive buffer */
627 /**< the receive data buffer */
628 } bluetooth_rfcomm_received_data_t;
631 * Stucture to rfcomm connection
636 /**< the socket fd */
637 int device_role;/** < Device role - RFCOMM_ROLE_SERVER or RFCOMM_ROLE_CLIENT */
638 bluetooth_device_address_t device_addr;
639 /**< device address */
640 char uuid[BLUETOOTH_UUID_STRING_MAX];
641 } bluetooth_rfcomm_connection_t;
644 * Stucture to rfcomm disconnection
648 /**< the socket fd */
649 int device_role;/** < Device role - RFCOMM_ROLE_SERVER or RFCOMM_ROLE_CLIENT */
650 bluetooth_device_address_t device_addr;
651 /**< device address */
652 char uuid[BLUETOOTH_UUID_STRING_MAX];
653 } bluetooth_rfcomm_disconnection_t;
657 /**< the socket fd */
658 bluetooth_device_address_t device_addr;
659 /**< device address */
660 } bluetooth_rfcomm_connection_request_t;
675 HDP_ROLE_SOURCE = 0x0,
681 * Stucture to HDP connected
684 const char *app_handle; /**< the application handle */
685 unsigned int channel_id; /**< the channel id */
686 bt_hdp_qos_type_t type; /**< the QOS type */
687 bluetooth_device_address_t device_address; /**< the remote address */
688 } bt_hdp_connected_t;
691 * Stucture to HDP disconnected
694 unsigned int channel_id; /**< the channel id */
695 bluetooth_device_address_t device_address; /**< the remote address */
696 } bt_hdp_disconnected_t;
699 * Stucture to HDP data indication
702 unsigned int channel_id; /**< the channel id */
703 const char *buffer; /**< the RX data buffer */
704 unsigned int size; /**< the RX data size */
708 * Stucture to OPP client transfer information
714 }bt_opc_transfer_info_t;
716 /* Obex Server transfer type */
717 #define TRANSFER_PUT "PUT"
718 #define TRANSFER_GET "GET"
720 * Stucture to OPP/FTP Server authorize information
725 } bt_obex_server_authorize_into_t;
728 * Stucture to OPP/FTP server transfer information
735 unsigned long file_size;
737 } bt_obex_server_transfer_info_t;
740 * Stucture to OOB data
744 unsigned char hash[BLUETOOTH_OOB_DATA_LENGTH];
745 unsigned char randomizer[BLUETOOTH_OOB_DATA_LENGTH];
746 unsigned int hash_len;
747 unsigned int randomizer_len;
751 * Structure to GATT attribute handle data
757 } bt_gatt_handle_info_t;
760 * Structure to GATT Remote service data
766 bt_gatt_handle_info_t handle_info;
767 } bt_gatt_service_property_t;
770 * Structure to GATT Remote characteristic data
774 char *service_handle;
775 bt_gatt_handle_info_t handle_info;
776 } bt_gatt_discovered_char_t;
779 * Structure to format of GATT Characteristic Value
783 unsigned char format;
784 unsigned char exponent;
786 unsigned char name_space;
787 unsigned short description;
788 } bt_gatt_char_format_t;
791 * Structure to GATT Characteristic property
799 bt_gatt_char_format_t format;
801 unsigned int val_len;
802 char *representation;
803 } bt_gatt_char_property_t;
806 * Structure to GATT Characteristic value
813 } bt_gatt_char_value_t;
816 * Callback pointer type
818 typedef void (*bluetooth_cb_func_ptr) (int, bluetooth_event_param_t *, void *);
821 * @fn int bluetooth_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data)
822 * @brief Set the callback function pointer for bluetooth event
825 * This API will register the callback function, when any response and event are received from
826 * bluetooth framework. @n
827 * this registered callback function will be get called with appropriate event and data structures.
828 * This function is a synchronous call. An application developer can call
829 * bluetooth_register_callback() function to register a callback function of bluetooth_cb_func_ptr
830 * type. This registered function will receive events of bluetooth_event_type_t type along with
834 * @param[in] callback_ptr A pointer to the callback function
835 * @param[in] user_data A pointer to user data
836 * @return BLUETOOTH_ERROR_NONE - Success
840 void bt_event_callback(int event, bluetooth_event_param_t *param, void *user_data)
842 GMainLoop *main_loop = (GMainLoop*) user_data;
846 // Code for each event
848 g_main_loop_quit(main_loop);
855 GMainLoop *main_loop = NULL;
858 main_loop = g_main_loop_new(NULL, FALSE);
859 ret = bluetooth_register_callback(bt_event_callback, (void*)main_loop);
860 if (ret >= BLUETOOTH_ERROR_NONE)
862 // bluetooth_register_callback returned Success
866 // bluetooth_register_callback returned failiure
868 g_main_loop_run(main_loop);
872 int bluetooth_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data);
875 * @fn int bluetooth_deregister_callback(bluetooth_cb_func_ptr callback_ptr)
876 * @brief Set the callback function pointer for bluetooth event
879 * This API will register the callback function, when any response and event are received from
880 * bluetooth framework. @n
881 * this registered callback function will be get called with appropriate event and data structures.
882 * This function is a synchronous call. An application developer can call
883 * bluetooth_register_callback() function to register a callback function of bluetooth_cb_func_ptr
884 * type. This registered function will receive events of bluetooth_event_type_t type along with
889 * @return BLUETOOTH_ERROR_NONE - Success
893 void bt_event_callback(int event, bluetooth_event_param_t *param, void *user_data)
895 GMainLoop *main_loop = (GMainLoop*) user_data;
899 // Code for each event
901 g_main_loop_quit(main_loop);
908 GMainLoop *main_loop = NULL;
911 main_loop = g_main_loop_new(NULL, FALSE);
912 ret = bluetooth_register_callback(bt_event_callback, (void*)main_loop);
913 if (ret >= BLUETOOTH_ERROR_NONE)
915 // bluetooth_register_callback returned Success
919 // bluetooth_register_callback returned failiure
921 ret = bluetooth_deregister_callback(void);
922 g_main_loop_run(main_loop);
926 int bluetooth_unregister_callback(void);
929 * @fn int bluetooth_enable_adapter(void)
930 * @brief Enable the Bluetooth H/W
933 * This API can be used to activate Bluetooth. It initializes Bluetooth protocol stack for use and
934 * send request to bluetooth chip for activation.
935 * This function is typically called at startup or when Bluetooth services are required. This
936 * function must be called before calling any other API of Bluetooth operations.
938 * Before performing any operations like Device discover, service search etc.., the adapter must be
941 * This function is a asynchronous call.
942 * If the call is success then the application will receive BLUETOOTH_EVENT_ENABLED event
943 * through registered callback function with appropriate result code
944 * BLUETOOTH_CHANGE_STATUS_TIMEOUT - Timeout has happen \n
945 * BLUETOOTH_ERROR_NONE - Success \n
947 * If the adpter is not enabled with in 30 seconds then BLUETOOTH_EVENT_ENABLED with result code
948 * BLUETOOTH_CHANGE_STATUS_TIMEOUT will come
950 * @return BLUETOOTH_ERROR_NONE - Success\n
951 * BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED - Adapter already enabled\n
952 * BLUETOOTH_ERROR_ACCESS_DENIED - Enabling adapter is not allowed by MDM policy\n
953 * BLUETOOTH_ERROR_IN_PROGRESS - Adapter is activating or deactivating\n
954 * @exception BLUETOOTH_ERROR_INTERNAL - Dbus proxy call is fail
956 * @see bluetooth_check_adapter, bluetooth_disable_adapter
958 void bt_event_callback(int event, bluetooth_event_param_t *param)
962 case BLUETOOTH_EVENT_ENABLED:
963 if (param->result == BLUETOOTH_ERROR_NONE)
965 // Successfully Enabled
978 ret = bluetooth_enable_adapter();
982 int bluetooth_enable_adapter(void);
985 * @fn int bluetooth_disable_adapter(void)
986 * @brief Disable the Bluetooth H/W
989 * This function disables Bluetooth protocol stack and hardware. This function is called when
990 * Bluetooth is no longer used. It will internally free all resources and power off the RF radio.
992 * Bluetooth adapter should be disabled to switch off Bluetooth chip (and thereby saving power).
993 * bluetooth_disable_adapter() API will do that job for you. After switching off Bluetooth,
994 * BLUETOOTH_EVENT_DISABLED will be sent by SDK to application for confirmation with appropriate
996 * The various error codes are BLUETOOTH_ERROR_NONE for success and BLUETOOTH_ERROR_INTERNAL for
999 * This function is a asynchronous call.
1000 * If this call is success then the applications will receive BLUETOOTH_EVENT_DISABLED event
1001 * through registered callback function.
1004 * @return BLUETOOTH_ERROR_NONE - Success\n
1005 * BLUETOOTH_ERROR_IN_PROGRESS - Adapter is activating or deactivating\n
1006 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Bluetooth adapter is not enabled\n
1007 * @exception BLUETOOTH_ERROR_INTERNAL - Dbus proxy call is fail
1009 * @see bluetooth_check_adapter, bluetooth_enable_adapter
1011 void bt_event_callback(int event, bluetooth_event_param_t *param)
1015 case BLUETOOTH_EVENT_DISABLED:
1016 if (param->result == BLUETOOTH_ERROR_NONE)
1018 // Successfully disabled
1031 ret = bluetooth_disable_adapter();
1034 int bluetooth_disable_adapter(void);
1037 * @fn int bluetooth_reset_adapter(void)
1038 * @brief Reset the Bluetooth H/W and values
1041 * This function resets Bluetooth protocol stack and hardware. This function is called when
1042 * an user want to initialize Bluetooth environment.
1044 * The various error codes are BLUETOOTH_ERROR_NONE for success and BLUETOOTH_ERROR_INTERNAL for
1047 * This function is a synchronous call.
1049 * @return BLUETOOTH_ERROR_NONE - Success\n
1050 * @exception BLUETOOTH_ERROR_INTERNAL - Dbus proxy call is fail
1052 * @see bluetooth_check_adapter, bluetooth_enable_adapter
1057 ret = bluetooth_reset_adapter();
1060 int bluetooth_reset_adapter(void);
1063 * @fn int bluetooth_is_supported(void)
1064 * @brief Check if the bluetooth is supported or not by the current target
1066 * This API checks whether the bluetooth is supported or not.
1067 * This API only run by root permission.
1068 * This API was made for the MDM service.
1070 * This function is a synchronous call.
1072 * @return 0 - if bluetooth is not supported\n
1073 * 1 - if bluetooth is supported\n
1074 * BLUETOOTH_ERROR_INTERNAL - Error in API internal
1079 ret = bluetooth_is_supported();
1082 int bluetooth_is_supported(void);
1086 * @fn int bluetooth_check_adapter(void)
1087 * @brief Check the current status of the Bluetooth adapter
1090 * This API checks whether the Bluetooth adapter is enabled or not. Before performing any operations
1091 * the bluetooth adapter should be enabled. This API helps to find out the current state of the
1092 * bluetooth adapter.
1093 * This API get the adapter internal data structure and check current adapter status.
1095 * This function is a synchronous call.
1098 * @return BLUETOOTH_ADAPTER_DISABLED - if bluetooth adapter is disabled\n
1099 * BLUETOOTH_ADAPTER_ENABLED - if bluetooth adapter is enabled\n
1101 * @see bluetooth_enable_adapter, bluetooth_disable_adapter
1105 ret = bluetooth_check_adapter();
1108 int bluetooth_check_adapter(void);
1111 * @fn int bluetooth_get_local_address(bluetooth_device_address_t *local_address)
1112 * @brief Get the local adapter bluetooth address
1115 * This API is used, get the device address of the local bluetooth adapter. Before calling this API,
1116 * the adapter should be enabled.
1117 * In its output parameter, you can receive bluetooth_device_address_t type of pointer which will
1118 * contain Bluetooth address.
1119 * Since its inconvenient for user to remember the address, Bluetooth provides a method to have a
1120 * friendly name for each device.
1121 * There is no event callback for this API.
1123 * This function is a synchronous call.
1126 * @return BLUETOOTH_ERROR_NONE - Succeess \n
1127 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter (NULL buffer) \n
1128 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
1129 * @param[out] local_address a device address of local bluetooth adapter
1134 bluetooth_device_address_t local_address={0,};
1137 ret = bluetooth_get_local_address(&local_address);
1140 int bluetooth_get_local_address(bluetooth_device_address_t *local_address);
1143 * @fn int bluetooth_get_local_name(bluetooth_device_name_t* local_name)
1144 * @brief Get the local device name
1147 * This function is used, get the local device name. Since its difficult to remember the Adapter
1148 * address, the friendly name can be assigned to the adapter and we can get it using this API. This
1149 * friendly name is retrived by the remote device and displaying.
1150 * Before calling this API, the adapter should be enabled. There is no event callback for this API.
1152 * This function is a synchronous call.
1155 * @return BLUETOOTH_ERROR_NONE - Success \n
1156 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter (NULL buffer)\n
1157 * @param[out] local_name a local device name
1161 bluetooth_device_name_t local_name={0,}
1163 ret = bluetooth_get_local_name (&local_name);
1166 int bluetooth_get_local_name(bluetooth_device_name_t *local_name);
1169 * @fn int bluetooth_set_local_name(const bluetooth_device_name_t *local_name)
1170 * @brief Set the local device name
1173 * This function is used to set the local device name. This is a human friendly name whose
1174 * length can be BLUETOOTH_DEVICE_NAME_LENGTH_MAX maximum
1176 * This function is a synchronous call.
1178 * @param[in] local_name bluetooth device name to set local device
1180 * @return BLUETOOTH_ERROR_NONE - Success \n
1181 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1182 * BLUETOOTH_ERROR_INVALID_PARAM - Bluetooth name parameter is incorrect \n
1183 * BLUETOOTH_ERROR_INVALID_DATA - Device address provided is incorrect \n
1184 * BLUETOOTH_ERROR_NO_RESOURCES - Pre-allocated memory error \n
1185 * BLUETOOTH_ERROR_INTERNAL - The dbus method call is fail \n
1190 bluetooth_device_name_t local_name={0,}
1192 ret = bluetooth_set_local_name (&local_name);
1195 int bluetooth_set_local_name(const bluetooth_device_name_t *local_name);
1199 * @fn int bluetooth_is_service_used(const char *service_uuid, gboolean *used)
1200 * @brief Check if the uuid is used or not
1202 * This function is used to check if the uuid is used or not.
1204 * This function is a synchronous call.
1206 * @param[in] service_uuid service uuid (UUID 128 bit as string)
1207 * @param[out] used if the uuid is used or not
1209 * @return BLUETOOTH_ERROR_NONE - Success \n
1210 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1211 * BLUETOOTH_ERROR_INVALID_PARAM - Bluetooth name parameter is incorrect \n
1212 * BLUETOOTH_ERROR_INTERNAL - The dbus method call is fail \n
1217 gboolean used = FALSE;
1218 const char *uuid ="00001101-0000-1000-8000-00805F9B34FB";
1219 ret = bluetooth_is_service_used(uuid, &used);
1222 int bluetooth_is_service_used(const char *service_uuid, gboolean *used);
1225 * @fn int bluetooth_is_device_connected(const bluetooth_device_address_t *device_address, bluetooth_service_type_t type, gboolean *is_connected)
1226 * @brief Check if the device is connected to the specific service
1228 * This function is used to check if if the device is connected to the specific service.
1230 * This function is a synchronous call.
1232 * @param[in] local_address a device address of remote bluetooth device
1233 * @param[in] type the service type
1234 * @param[out] is_connected if the device is connected or not
1236 * @return BLUETOOTH_ERROR_NONE - Success \n
1237 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1238 * BLUETOOTH_ERROR_INVALID_PARAM - Bluetooth name parameter is incorrect \n
1239 * BLUETOOTH_ERROR_INTERNAL - The dbus method call is fail \n
1244 gboolean is_connected = FALSE;
1245 bluetooth_device_address_t device_address={{0x00,0x0D,0xFD,0x24,0x5E,0xFF}};
1246 ret = bluetooth_is_device_connected(&device_address, BLUETOOTH_HSP_SERVICE, &used);
1249 int bluetooth_is_device_connected(const bluetooth_device_address_t *device_address,
1250 bluetooth_service_type_t type,
1251 gboolean *is_connected);
1254 * @fn int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t *discoverable_mode_ptr)
1255 * @brief Get the visibility mode
1258 * This function is used to get the discoverable mode (Visibility option). Depending upon the
1259 * visibity mode, the property of the device is determined whether it can be discoverable, non
1260 * discoverable, connectable etc. Before calling this API make sure that the adapter is enabled.
1262 * This function is a synchronous call.
1265 * @return BLUETOOTH_ERROR_NONE - Success \n
1266 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1267 * BLUETOOTH_ERROR_INVALID_DATA - Invalid data \n
1268 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1269 * BLUETOOTH_ERROR_INTERNAL - Internal IPC error \n
1270 * @param[out] discoverable_mode current bluetooth discoverable mode
1272 * @see bluetooth_set_discoverable_mode
1274 bluetooth_discoverable_mode_t discoverable_mode_ptr;
1276 ret = bluetooth_get_discoverable_mode (&discoverable_mode_ptr);
1279 int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t *discoverable_mode_ptr);
1282 * @fn int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t discoverable_mode,
1284 * @brief Set the visibility mode
1287 * This function is used to set the discoverable mode (Visibility option).
1289 * Many times user may want to keep his device discoverable so that when peer device is performing
1290 * device search, he/she can find user's device. Application programmer can keep the mode as
1291 * BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE or
1292 * BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE for the same purpose. However, all these
1293 * modes cause bluetooth adapter to consume more battery. Hence developer should generally
1294 * keep discoverable mode as BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE.
1296 * This function is a synchronous call.
1298 * @return BLUETOOTH_ERROR_NONE - Success \n
1299 * BLUETOOTH_ERROR_NOT_SUPPORT - Requested mode is not supported \n
1301 * @param[in] discoverable_mode the bluetooth discoverable mode to set
1302 * @param[in] timeout discoverable time in only limited discoverable mode (second), default: 0
1304 * @see bluetooth_get_discoverable_mode
1308 bluetooth_discoverable_mode_t mode;
1310 mode= BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE;
1311 ret = bluetooth_set_discoverable_mode (mode, 180);
1315 int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t discoverable_mode,
1320 * @fn int bluetooth_get_timeout_value(int *timeout)
1321 * @brief Get the visibility timeout value
1324 * This function is used to get the visibility timeout
1325 * Before calling this API make sure that the adapter is enabled.
1327 * This function is a synchronous call.
1330 * @return BLUETOOTH_ERROR_NONE - Success \n
1331 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1332 * BLUETOOTH_ERROR_INVALID_DATA - Invalid data \n
1333 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1334 * BLUETOOTH_ERROR_INTERNAL - Internal IPC error \n
1335 * @param[out] timeout remain visibility timeout value
1337 * @see bluetooth_set_discoverable_mode
1341 ret = bluetooth_get_timeout_value (&timeout);
1344 int bluetooth_get_timeout_value(int *timeout);
1348 * @fn int bluetooth_start_discovery(unsigned short max_response, unsigned short discovery_duration,
1349 * unsigned int classOfDeviceMask)
1350 * @brief Start the device discovery
1352 * To connect connect to peer bluetooth device, you will need to know its bluetooth address and its
1353 * name. You can search for Bluetooth devices in vicinity by bluetooth_start_discovery() API. It
1354 * first performs an inquiry. For each device found from the inquiry it gets the remote name of the
1355 * device. Bluetooth device address and name are given to Application via
1356 * BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event. In param_data of bluetooth_event_param_t, you will
1357 * receive a pointer to a structure of bluetooth_device_info_t type. you will receive device
1358 * address, device name, device class, rssi (received signal strength indicator). please see
1359 * bluetooth_device_info_t for more details.
1362 * This API provides searching options like max responses, discovery duration in seconds and class
1363 * of device mask to filter device search. some times there may be too many bluetooth devices in
1364 * vicinity of your device.in such scenario, application can request to reduce number of responces
1365 * (BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event) with help of max_response parameter. However if you
1366 * pass zero, bluetooth adapter will not restrict number of responses. you can also specify duration
1367 * of the seach in discovery_duration. bluetooth adapter will automatically stop device search after
1368 * application defined time. please note that discovery_duration should be mentioned in seconds.
1369 * Also note that search will end after 180 seconds automatically if you pass 0 in discovery
1372 * sometimes user may want to search for a perticular kind of device. for ex, mobile or pc. in such
1373 * case, you can use classOfDeviceMask parameter. please see bluetooth_device_service_class_t,
1374 * bluetooth_device_major_class_t and bluetooth_device_minor_class_t enums
1376 * This function is a asynchronous call.
1377 * If the call is success then the application will receive BLUETOOTH_EVENT_DISCOVERY_STARTED event
1378 * through registered callback function.
1380 * The discovery is responded by an BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event for each device it
1381 * finds and an BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED event for each fount device its name
1384 * The completion or cancellation of the discovery is indicated by an
1385 * BLUETOOTH_EVENT_DISCOVERY_FINISHED event.
1387 * The device discovery can be cancelled by calling bluetooth_stop_discovery().
1390 * @return BLUETOOTH_ERROR_NONE - Success \n
1391 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Bluetooth adapter is not enabled \n
1392 * BLUETOOTH_ERROR_DEVICE_BUSY - Bluetooth adapter is busy doing some operation \n
1393 * BLUETOOTH_ERROR_INTERNAL - System error like heap full has occured or bluetooth
1394 agent is not running \n
1396 * @param[in] max_response define the maximum response of the number of founded devices
1398 * @param[in] discovery_duration define bluetooth discovery duration (0 means 180s )
1399 * @param[in] classOfDeviceMask define classes of the device mask which user wants
1400 (refer to class of device)
1402 * @see bluetooth_cancel_discovery, bluetooth_device_info_t
1405 void bt_event_callback(int event, bluetooth_event_param_t *param)
1409 case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
1411 bluetooth_device_info_t *device_info = NULL;
1412 printf("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]",
1414 device_info = (bluetooth_device_info_t *)param->param_data;
1415 memcpy(&searched_device, &device_info->device_address,
1416 sizeof(bluetooth_device_address_t));
1417 printf("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]",
1418 device_info->device_address.addr[0],
1419 device_info->device_address.addr[1],
1420 device_info->device_address.addr[2],
1421 device_info->device_address.addr[3],
1422 device_info->device_address.addr[4],
1423 device_info->device_address.addr[5]);
1426 case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
1428 bluetooth_device_info_t *device_info = NULL;
1429 printf("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]",
1431 device_info = (bluetooth_device_info_t *)param->param_data;
1432 memcpy(&searched_device, &device_info->device_address,
1433 sizeof(bluetooth_device_address_t));
1434 printf("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]",
1435 device_info->device_name.name,
1436 device_info->device_address.addr[0],
1437 device_info->device_address.addr[1],
1438 device_info->device_address.addr[2],
1439 device_info->device_address.addr[3],
1440 device_info->device_address.addr[4],
1441 device_info->device_address.addr[5]);
1445 case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
1446 printf("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result[0x%04x]", param->result);
1451 unsigned short max_response;
1452 unsigned short discovery_duration;
1453 unsigned classOfDeviceMask;
1457 discovery_duration =0;
1458 classOfDeviceMask =0;
1460 ret = bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);
1466 int bluetooth_start_discovery(unsigned short max_response,
1467 unsigned short discovery_duration,
1468 unsigned int classOfDeviceMask);
1471 * @fn int bluetooth_cancel_discovery (void)
1472 * @brief Cancel the on-going device discovery operation
1475 * This function stops the on-going device discovery operation. This API has to be called after the
1476 * bluetooth_start_discovery API and before the BLUETOOTH_EVENT_DISCOVERY_FINISHED event comes of
1477 * the bluetooth_start_discovery API
1479 * Normally the device discovery takes a more time (~10.24 seconds) to get all the devices in its
1480 * vicinity and it recevies as BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event. This API helps us to
1481 * cancel the discover request once the user received the device to which he wish to connect.
1483 * This function is a asynchronous call.
1484 * If the call is success to cancel discovey then the application will receive
1485 * BLUETOOTH_EVENT_DISCOVERY_FINISHED event through registered callback function
1486 * with an error code BLUETOOTH_ERROR_CANCEL. In the case of failure the error code will be
1487 * BLUETOOTH_ERROR_NONE
1490 * @return BLUETOOTH_ERROR_NONE - Success \n
1491 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1492 * BLUETOOTH_ERROR_NOT_IN_OPERATION - No Discovery operation in progess to cancel \n
1493 * BLUETOOTH_ERROR_ACCESS_DENIED - Currently in discovery but it is requested from
1494 other application \n
1495 * BLUETOOTH_ERROR_INTERNAL - Internel IPC error \n
1497 * @see bluetooth_start_discovery
1499 void bt_event_callback(int event, bluetooth_event_param_t *param)
1503 case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
1504 TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result[0x%04x]", param->result);
1513 ret = bluetooth_cancel_discovery();
1516 int bluetooth_cancel_discovery(void);
1519 * @fn int bluetooth_is_discovering(void)
1520 * @brief Check for the device discovery is in-progress or not.
1522 * This API is used to check the current status of the Discovery operation.If discovery is in\
1523 * progress normally other operations are not allowed.
1524 * If a device discovery is in progress, we have to either cancel the discovery operation or wait
1525 * for the BLUETOOTH_EVENT_DISCOVERY_FINISHED
1526 * event before performing other operations. This API is used to get for the current discovery
1527 * operation status and using bluetooth_cancel_discovery()
1528 * we can cancell the ongoing discovery process.
1529 * Before calling this API, make sure that the adapter is enabled. There is no callback event for
1532 * This function checks whether the device discovery is started or not.
1534 * This function is a synchronous call.
1537 * @return BLUETOOTH_ERROR_NONE - Discovery is not in progress \n
1538 * BLUETOOTH_ERROR_NONE+1 - Discovery in progress \n
1539 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1542 * @see bluetooth_start_discovery, bluetooth_cancel_discovery
1546 ret = bluetooth_is_discovering ();
1549 int bluetooth_is_discovering(void);
1552 * @fn int bluetooth_bond_device(const bluetooth_device_address_t *device_address)
1553 * @brief Initiate a bonding process
1556 * This function initiates a bonding procedure with a peer device. The bonding procedure
1557 * enables authentication and optionally encryption on the Bluetooth link.
1559 * Bonding is applied to the discovered device to which we need a secure connection. We cannot
1560 * inititate the bonding request to the devices already in the paired list.
1562 * Usually we call this API after the device discovery.
1563 * This function is a asynchronous call.
1565 * Response will be received through BLUETOOTH_EVENT_BONDING_FINISHED event. It can any of the below
1566 * mentioed result code
1567 * BLUETOOTH_ERROR_PARING_FAILED - Pairing faied \n
1568 * BLUETOOTH_ERROR_ACCESS_DENIED - Authetication rejected \n
1569 * BLUETOOTH_ERROR_CANCEL_BY_USER - Cancelled by the user \n
1570 * BLUETOOTH_ERROR_PARING_FAILED - Pairing failed \n
1571 * BLUETOOTH_ERROR_TIMEOUT - Timeout has haapened \n
1573 * If the remote user is not responding with in a specific time(60 seconds), then a timeout happens
1574 * and BLUETOOTH_EVENT_BONDING_FINISHED callback event is called with and BLUETOOTH_ERROR_TIMEOUT
1577 * The bonding operation can be cancelled by calling bluetooth_cancel_bonding().
1580 * @return BLUETOOTH_ERROR_NONE - Success \n
1581 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
1582 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1583 * BLUETOOTH_ERROR_DEVICE_BUSY - Adapter is busy or Discovery is in Progress \n
1584 * BLUETOOTH_ERROR_INVALID_DATA - Invalid BD address \n
1586 * @param[in] device_address This indicates an address of the device with which the pairing
1587 * should be initiated
1589 * @see bluetooth_cancel_bonding
1591 void bt_event_callback(int event, bluetooth_event_param_t *param)
1595 case BLUETOOTH_EVENT_BONDING_FINISHED:
1597 TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
1598 if (param->result >= BLUETOOTH_ERROR_NONE)
1600 bluetooth_device_info_t *device_info = NULL;
1601 device_info = (bluetooth_device_info_t *)param->param_data;
1602 printf("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]
1603 mjr[%#x] min[%#x] srv[%#x]",
1604 device_info->device_name.name,
1605 device_info->device_address.addr[0],
1606 device_info->device_address.addr[1],
1607 device_info->device_address.addr[2],
1608 device_info->device_address.addr[3],
1609 device_info->device_address.addr[4],
1610 device_info->device_address.addr[5],
1611 device_info->device_class.major_class,
1612 device_info->device_class.minor_class,
1613 device_info->device_class.service_class);
1627 bluetooth_device_address_t device_address={{0}};
1629 ret = bluetooth_bond_device(&device_address);
1633 int bluetooth_bond_device(const bluetooth_device_address_t *device_address);
1636 * @fn int bluetooth_cancel_bonding(void)
1637 * @brief Cancel the on-going bonding process
1639 * This API is called to cancel the on-going bonding procedure. It should be called before the
1640 * BLUETOOTH_EVENT_BONDING_FINISHED event comes.
1641 * This API is useful when the remote device is not responding to the bond request or we wish to
1642 * cancel the bonding request. In this case we need not wait for the timeout to happen.
1644 * This function is a synchronous call.
1646 * @return BLUETOOTH_ERROR_NONE - Success \n
1647 * BLUETOOTH_ERROR_NOT_IN_OPERATION - No bonding request in progress \n
1648 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1651 * @see bluetooth_bond_device
1657 ret = bluetooth_cancel_bonding();
1660 int bluetooth_cancel_bonding(void);
1663 * @fn int bluetooth_unbond_device(const bluetooth_device_address_t *device_address)
1664 * @brief Remove bonding
1667 * To communicate with remote device over bluetooth link, user should bond with peer device.
1668 * After bonding is over, peer device is added to list of bonded devices. bluetooth_unbond_device()
1669 * API is used to remove peer device from the list. Please note that after removing the device
1670 * from bonded device list, you cannot communication with peer device until bonding happens again.
1672 * User can call this function by passing bluetooth device address of any bonded device. Please note
1673 * that after successful return of this function, any bluetooth application running on your device
1674 * will not be able to communicate with unbonded device until bond operation happens again using
1675 * bluetooth_bond_device()
1678 * This function is a asynchronous call. The request to remove the specified device from the bonded
1679 * list is responded by an BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED event. if the operation is success,
1680 * you will receive BLUETOOTH_ERROR_NONE. BLUETOOTH_ERROR_NOT_PAIRED may be received in result code
1681 * in case if there is a problem in locating given bluetooth device address in bonded devices list
1685 * @return BLUETOOTH_ERROR_NONE - Success \n
1686 * BLUETOOTH_ERROR_INVALID_PARAM - Device address is not valid \n
1687 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Bluetooth adapter is not enabled \n
1688 * BLUETOOTH_ERROR_DEVICE_BUSY - Bluetooth adapter is busy doing some operation \n
1689 * BLUETOOTH_ERROR_INVALID_DATA - Device address provided is incorrect \n
1690 * BLUETOOTH_ERROR_INTERNAL - System error like heap full has occured or bluetooth
1691 * agent is not running \n
1692 * BLUETOOTH_ERROR_NOT_PAIRED - Device address mentioned in the argument is not a
1695 * @param[in] device_address This indicates an address of the device to remove bonding
1699 * @see bluetooth_bond_device, bluetooth_cancel_bonding
1702 void bt_event_callback(int event, bluetooth_event_param_t *param)
1705 case BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED: {
1706 bluetooth_device_address_t *dev_addr = NULL;
1708 if (param->result == BLUETOOTH_ERROR_NONE) {
1709 dev_addr = (bluetooth_device_address_t *)param->param_data;
1711 printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
1712 dev_addr->addr[0], dev_addr->addr[1]
1713 dev_addr->addr[2], dev_addr->addr[3]
1714 dev_addr->addr[4], dev_addr->addr[5]
1725 bluetooth_device_address_t *device_address;
1727 // copy valid device address in device_address
1729 ret = bluetooth_unbond_device(device_address);
1732 int bluetooth_unbond_device(const bluetooth_device_address_t *device_address);
1735 * @fn int bluetooth_get_bonded_device_list(GPtrArray **dev_list)
1736 * @brief Get bonded(paired) device list
1739 * This API gets all bonded device list.
1740 * The devices in the bonded device list further can be used to perform the authorization by calling
1741 * bluetooth_authorize_device API.
1743 * This function is a synchronous call.
1744 * Information for bonded devices can be obtained when result code is BLUETOOTH_ERROR_NONE. If not,
1745 * there is no valid information in the dev_list.
1746 * The len field in the dev_list represents the number of bonded devices. The data structure for
1747 * bonded device information is bluetooth_device_info_t.
1750 * @return BLUETOOTH_ERROR_NONE - Success \n
1751 * BLUETOOTH_ERROR_NOT_SUPPORT - Opreation not supported \n
1753 * @see bluetooth_bond_device, bluetooth_unbond_device, bluetooth_authorize_device
1755 void bt_get_bonded_devices(void)
1759 GPtrArray *devinfo = NULL;
1760 bluetooth_device_info_t *ptr;
1762 // allocate the g_pointer_array
1763 devinfo = g_ptr_array_new();
1765 ret = bluetooth_get_bonded_device_list(&devinfo);
1766 if (ret != BLUETOOTH_ERROR_NONE)
1768 printf("bluetooth_get_bonded_device_list failed with [%d]",ret);
1772 printf("g pointer arrary count : [%d]", devinfo->len);
1773 for (i=0; i<devinfo->len; i++)
1775 ptr = g_ptr_array_index(devinfo, i);
1778 printf("Name [%s]\n", ptr->device_name.name);
1779 printf("Major Class [%d]\n", ptr->device_class.major_class);
1780 printf("Minor Class [%d]\n", ptr->device_class.minor_class);
1781 printf("Service Class [%d]\n", ptr->device_class.service_class);
1782 printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
1783 ptr->device_address.addr[0],
1784 ptr->device_address.addr[1], ptr->device_address.addr[2],
1785 ptr->device_address.addr[3],
1786 ptr->device_address.addr[4], ptr->device_address.addr[5]);
1793 // free g_pointer_array
1794 g_ptr_array_free(devinfo, TRUE);
1799 int bluetooth_get_bonded_device_list(GPtrArray **dev_list);
1802 * @fn int bluetooth_get_bonded_device(const bluetooth_device_address_t *device_address,
1803 * bluetooth_device_info_t *dev_info)
1804 * @brief Get a bonded(paired) device
1807 * This API gets a bonded device.
1809 * This function is a synchronous call.
1810 * Information for bonded devices can be obtained when result code is BLUETOOTH_ERROR_NONE. If not,
1811 * there is no valid information in the dev_info.
1812 * The data structure for bonded device information is bluetooth_device_info_t.
1815 * @return BLUETOOTH_ERROR_NONE - Success \n
1816 * BLUETOOTH_ERROR_NOT_SUPPORT - Opreation not supported \n
1818 * @see bluetooth_bond_device, bluetooth_unbond_device, bluetooth_authorize_device
1820 void bt_get_bonded_device(void)
1824 bluetooth_device_info_t devinfo = {0};
1825 bluetooth_device_address_t device_address={{0x00,0x1C,0x43,0x2B,0x1A,0xE5}};
1827 ret = bluetooth_get_bonded_device(&device_address, &devinfo);
1828 if (ret != BLUETOOTH_ERROR_NONE)
1830 printf("bluetooth_get_bonded_device failed with [%d]",ret);
1834 printf("Name [%s]\n", devinfo.device_name.name);
1835 printf("Major Class [%d]\n", devinfo.device_class.major_class);
1836 printf("Minor Class [%d]\n", devinfo.device_class.minor_class);
1837 printf("Service Class [%d]\n", devinfo.device_class.service_class);
1838 printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", devinfo.device_address.addr[0],
1839 devinfo.device_address.addr[1], devinfo.device_address.addr[2],
1840 devinfo.device_address.addr[3], devinfo.device_address.addr[4],
1841 devinfo.device_address.addr[5]);
1850 int bluetooth_get_bonded_device(const bluetooth_device_address_t *device_address,
1851 bluetooth_device_info_t *dev_info);
1854 * @fn int bluetooth_set_alias(const bluetooth_device_address_t *device_address, const char *alias)
1855 * @brief set alias for bonded device
1858 * This function set alias for bonded device.
1860 * This function is a synchronous call.
1863 * @return BLUETOOTH_ERROR_NONE - Success \n
1864 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
1865 * @param[in] device_address This indicates an address of the remote device
1866 * @param[in] alias This indicates an alias to set
1871 ret = bluetooth_set_alias(&remote_address);
1874 int bluetooth_set_alias(const bluetooth_device_address_t *device_address,
1878 * @fn int bluetooth_get_remote_device(const bluetooth_device_address_t *device_address)
1879 * @brief Get remote deivice
1882 * This function gets specific remote device.
1884 * This function is a asynchronous call.
1885 * This API is responded by an BLUETOOTH_EVENT_REMOTE_DEVICE_READ event.
1888 * @return BLUETOOTH_ERROR_NONE - Success \n
1889 * BLUETOOTH_ERROR_NOT_SUPPORT - Operation not supported \n
1890 * @param[in] device_address This indicates an address of the remote device
1895 ret = bluetooth_get_remote_device(&remote_address);
1898 int bluetooth_get_remote_device(const bluetooth_device_address_t *device_address);
1901 * @fn int bluetooth_authorize_device(const bluetooth_device_address_t *device_address,
1902 * gboolean authorized)
1903 * @brief Authorize/Unauthorize a bonded device
1906 * This function authorizes/unauthorize a bonded device. It decides the device to connect
1907 * with/without user confirmation.
1909 * If we select a paired device and make it authorized by calling this API with the authorized
1910 * parameter to TRUE, then it will not ask for the user conformation before connecting. Similarly
1911 * if we unauthorize the paired device by calling this API with the authorized parameter to FALSE,
1912 * then it will ask for the user conformation before the connection.
1914 * This API supposed to be called on the paired devices. Which means we have to use this API only
1915 * after successful pairing.
1917 * This function is a asynchronous call.
1918 * Response will be received through BLUETOOTH_EVENT_DEVICE_AUTHORIZED event.
1920 * @return BLUETOOTH_ERROR_NONE - Success \n
1921 * @exception BLUETOOTH_ERROR_INTERNAL - Cannot get the interal DBUS proxy \n
1922 * @param[in] device_address This indicates an address of the device to authorize \n
1923 * @param[in] authorized TRUE : authorize FALSE: unauthorize
1925 * @see bluetooth_get_bonded_device_list
1927 void bt_event_callback(int event, bluetooth_event_param_t *param)
1931 case BLUETOOTH_EVENT_DEVICE_AUTHORIZED :
1933 if (param->result == BLUETOOTH_ERROR_NONE)
1937 //device authorization failed failure
1945 bluetooth_device_address_t device_address={{0}};
1946 gboolean authorized;
1950 ret = bluetooth_authorize_device(&device_address,authorized);
1953 int bluetooth_authorize_device(const bluetooth_device_address_t *device_address,
1954 gboolean authorized);
1957 * @fn int bluetooth_search_service(const bluetooth_device_address_t *device_address)
1958 * @brief Get all services supported by remote device
1961 * This API call initiates the search for the services supported by the specified device. Normally
1962 * the service search will take a couple of seconds to get it completed. Before calling this API
1963 * make sure that the Adapter is enabled. We have to give the device address of the remote device to
1964 * perform the service search. We can get the device address by doing a device discovery operation.
1967 * This function is a asynchronous call.
1968 * The service search request is responded by BLUETOOTH_EVENT_SERVICE_SEARCHED event.
1970 * There is a timeout associated with the service search. The default time out is 40 seconds. If the
1971 * remove device did not respond with in the time out period the BLUETOOTH_EVENT_SERVICE_SEARCHED
1972 * event is generated with appropriate result code.
1974 * @return BLUETOOTH_ERROR_NONE - Success \n
1975 * BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR - Service search error (NULL device address) \n
1976 * BLUETOOTH_ERROR_INTERNAL - Internal IPC error \n
1977 * @param[in] device_address This indicates an address of the device
1978 * whose services need to be found
1980 * @see bluetooth_cancel_service_search
1982 int bluetooth_search_service(const bluetooth_device_address_t *device_address);
1985 * @fn int bluetooth_cancel_service_search(void)
1986 * @brief Cancel the ongoing service search operation
1989 * This function cancel the ongoing service search operation. This API is usually calling after the
1990 * bluetooth_search_service API.
1991 * Normally service search will take a more time (> 5 seconds) to complete. This API will be called
1992 * if the user wish to cancel the Ongoing service search operation.
1994 * This API should be called just after the bluetooth_search_service API and before the
1995 * BLUETOOTH_EVENT_SERVICE_SEARCHED event
1997 * This function is a synchronous call.
1999 * @return BLUETOOTH_ERROR_NONE - Success \n
2000 * BLUETOOTH_ERROR_CANCEL - Error in service search cancel operation \n
2001 * BLUETOOTH_ERROR_NOT_PAIRED - Not paired device \n
2002 * BLUETOOTH_ERROR_NOT_IN_OPERATION - Searching service is not in operation \n
2005 * @see bluetooth_search_service
2010 ret = bluetooth_cancel_service_search();
2013 int bluetooth_cancel_service_search(void);
2016 * @fn int bluetooth_rfcomm_create_socket(const char *uuid)
2017 * @brief Register rfcomm socket with a specific uuid
2020 * This API register rfcomm socket with the given UUID. The return value of this API is the socket
2021 * descriptor of the server.
2022 * This is the first API which is called to create the server. Once we created the server socket,
2023 * we will listen on that return socket.
2024 * So a bluetooth_rfcomm_listen_and_accept should follow this API call. This is a synchronous call.
2027 * @return socket FD on Success \n
2028 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2029 * BLUETOOTH_ERROR_INTERNAL - Internal error\n
2030 * BLUETOOTH_ERROR_MAX_CONNECTION - Maximum connection reached\n
2031 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2032 * @param[in] UUID (128 bits)
2035 * @see bluetooth_rfcomm_listen_and_accept, bluetooth_rfcomm_remove_socket
2039 const char *rfcomm_test_uuid="00001101-0000-1000-8000-00805F9B34FB";
2040 fd = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
2044 int bluetooth_rfcomm_create_socket(const char *uuid);
2047 * @fn int bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid)
2048 * @brief De-register the rfcomm socket
2051 * This API deregister rfcomm socket with the given socket fd and UUID. If the remote device is
2052 * already connected then we will receive the BLUETOOTH_EVENT_RFCOMM_DISCONNECTED with socket
2053 * descriptor else no event will come. We will call this API only after the
2054 * bluetooth_rfcomm_listen_and_accept.
2055 * This is a synchronous call.
2057 * @return BLUETOOTH_ERROR_NONE - Success \n
2058 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2059 * BLUETOOTH_ERROR_NOT_FOUND - Cannot find the proxy\n
2060 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2061 * @param[in] int socket_fd
2064 * @see bluetooth_rfcomm_create_socket, bluetooth_rfcomm_listen_and_accept
2067 void bt_event_callback(int event, bluetooth_event_param_t *param)
2071 case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED:
2073 bluetooth_rfcomm_connection_t *discon_ind =
2074 (bluetooth_rfcomm_connection_t *)param->param_data;
2076 printf("\nDisconnected from FD %d", discon_ind->socket_fd);
2084 fd = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
2085 ret = bluetooth_rfcomm_listen_and_accept(fd, 1);
2087 ret = bluetooth_rfcomm_remove_socket(fd);
2090 int bluetooth_rfcomm_remove_socket(int socket_fd);
2093 * @fn int bluetooth_rfcomm_server_disconnect(int socket_fd)
2094 * @brief Disconnect rfcomm connection
2097 * Disconnect a specific(device node fd) RFCOMM connection. This is a Synchronous call and there
2098 * is no cabbback events for this API. We have to provice the valid client fd to disconnect from the
2101 * @return BLUETOOTH_ERROR_NONE - Success \n
2102 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2103 * BLUETOOTH_ERROR_NOT_CONNECTED - Not connected \n
2104 * @param[in] int socket_fd the sending socket fd
2110 ret = bluetooth_rfcomm_server_disconnect(g_ret_fd);
2112 printf("Disconnection failed");
2114 printf("Disconnection Success");
2118 int bluetooth_rfcomm_server_disconnect(int socket_fd);
2121 * @fn int bluetooth_rfcomm_listen_and_accept(int socket_fd,int max_pending_connection)
2122 * @brief Rfcomm socket listen
2125 * This API make rfcomm socket listen and accept with socket. We will call this API immediatly
2126 * after the bluetooth_rfcomm_create_socket API.
2127 * This API listen for the incomming connection and once it receives a connection, it will give
2128 * BLUETOOTH_EVENT_RFCOMM_CONNECTED
2129 * event to the application. This is an Asynchronous API call.
2132 * @return BLUETOOTH_ERROR_NONE - Success \n
2133 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2134 * BLUETOOTH_ERROR_CONNECTION_ERROR - Listen failed \n
2136 * @param[in] int socket_fd
2137 * @param[in] max pending connection.
2140 * @see bluetooth_rfcomm_create_socket
2143 void bt_event_callback(int event, bluetooth_event_param_t* param)
2147 case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
2149 bluetooth_rfcomm_connection_t *conn_ind =
2150 (bluetooth_rfcomm_connection_t *)param->param_data;
2152 printf("\nConnected from FD %d", conn_ind->socket_fd);
2160 fd = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
2161 ret = bluetooth_rfcomm_listen_and_accept(fd, 1);
2165 int bluetooth_rfcomm_listen_and_accept(int socket_fd, int max_pending_connection);
2168 * @fn int bluetooth_rfcomm_listen(int socket_fd,int max_pending_connection)
2169 * @brief Rfcomm socket listen
2172 * This API make rfcomm socket listen and accept with socket. We will call this API immediatly
2173 * after the bluetooth_rfcomm_create_socket API.
2174 * This API listen for the incomming connection and once it receives a connection, it will give
2175 * BLUETOOTH_EVENT_RFCOMM_AUTHORIZE
2176 * event to the application. This is an Asynchronous API call.
2179 * @return BLUETOOTH_ERROR_NONE - Success \n
2180 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2181 * BLUETOOTH_ERROR_CONNECTION_ERROR - Listen failed \n
2183 * @param[in] int socket_fd
2184 * @param[in] max pending connection.
2187 * @see bluetooth_rfcomm_create_socket
2190 void bt_event_callback(int event, bluetooth_event_param_t* param)
2194 case BLUETOOTH_EVENT_RFCOMM_AUTHORIZE:
2196 char *name = (char *)param->param_data;
2198 printf("\nConnected from %s", name);
2200 bluetooth_rfcomm_accept_connection();
2208 fd = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
2209 ret = bluetooth_rfcomm_listen(fd, 1);
2213 int bluetooth_rfcomm_listen(int socket_fd, int max_pending_connection);
2216 * @fn int bluetooth_rfcomm_accept_connection()
2217 * @brief Accepts the authorization request indicated by the event
2218 * BLUETOOTH_EVENT_RFCOMM_AUTHORIZE.
2220 * This function is a synchronous call.
2222 * @return BLUETOOTH_ERROR_NONE - Success \n
2223 * BLUETOOTH_ERROR_INTERNAL - Internal error \n
2225 * @param[in] the socket fd of the server
2226 * @param[out] the socket fd of the client
2230 * @see bluetooth_rfcomm_reject_connection
2232 int bluetooth_rfcomm_accept_connection(int server_fd, int *client_fd);
2235 * @fn int bluetooth_rfcomm_reject_connection()
2236 * @brief Rejects the authorization request indicated by the event
2237 * BLUETOOTH_EVENT_RFCOMM_AUTHORIZE.
2239 * This function is a synchronous call.
2241 * @return BLUETOOTH_ERROR_NONE - Success \n
2242 * BLUETOOTH_ERROR_INTERNAL - Internal error \n
2244 * @param[in] the socket fd of the server
2248 * @see bluetooth_rfcomm_accept_connection
2250 int bluetooth_rfcomm_reject_connection(int server_fd);
2253 * @fn gboolean bluetooth_rfcomm_is_server_uuid_available(const char *uuid)
2254 * @brief Informs whether rfcomm server uuid is available or not.
2256 * This function is a synchronous call.
2258 * @return TRUE - RFCOMM uuid is available \n
2259 * FALSE - RFCOMM uuid is not available \n
2261 * @param[in] uuid UUID string
2267 gboolean bluetooth_rfcomm_is_server_uuid_available(const char *uuid);
2270 * @fn int bluetooth_rfcomm_connect(const bluetooth_device_address_t *remote_bt_address,
2271 * const char *remote_uuid)
2272 * @brief Connect to the remote device rfcomm *
2274 * Connect to a specific RFCOMM based service on a remote device UUID. This is a Async call. Once
2275 * the connection is successful callback BLUETOOTH_EVENT_RFCOMM_CONNECTED events is generated,
2276 * which contains the socket_fd, device role (RFCOMM_ROLE_SERVER/RFCOMM_ROLE_CLIENT), device addess
2277 * etc. The socket_fd can be further used to send the data. It better to do a sevice search before
2278 * initiating a connection.
2280 * @return BLUETOOTH_ERROR_NONE - Success \n
2281 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2282 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2283 * BLUETOOTH_ERROR_CONNECTION_BUSY - Connection in progress \n
2284 * BLUETOOTH_ERROR_INTERNAL - Internal Error\n
2285 * @param[in] bluetooth_device_address_t remote bt_address
2286 * @param[in] char remote uuid
2288 * @see bluetooth_rfcomm_disconnect, bluetooth_rfcomm_write, bluetooth_search_service
2292 void bt_event_callback(int event, bluetooth_event_param_t *param)
2296 case BLUETOOTH_EVENT_SERVICE_SEARCHED:
2298 if (param->result >= BLUETOOTH_ERROR_NONE)
2300 bt_sdp_info_t *bt_sdp_info=param->param_data;
2302 printf("Dev add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
2303 bt_sdp_info->device_addr.addr[0],
2304 bt_sdp_info->device_addr.addr[1],
2305 bt_sdp_info->device_addr.addr[2],
2306 bt_sdp_info->device_addr.addr[3],
2307 bt_sdp_info->device_addr.addr[4],
2308 bt_sdp_info->device_addr.addr[5]);
2310 printf("Supported service list:\n");
2311 for(i=0; i<bt_sdp_info->service_index; i++)
2313 bt_sdp_info->service_list_array[i]);
2316 //ret = bluetooth_rfcomm_connect(bt_sdp_info->device_addr,
2317 //rfcomm_test_uuid);
2321 case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
2323 bluetooth_rfcomm_connection_t *conn_ind =
2324 (bluetooth_rfcomm_connection_t *)param->param_data;
2326 printf("\nConnected from FD %d, Role = %s", conn_ind->socket_fd,
2327 (conn_ind->device_role == RFCOMM_ROLE_SERVER) ?
2328 "SERVER" : "CLIENT");
2333 bluetooth_device_address_t remote_address = {{0},};
2334 remote_address.addr[0] = 0x0; remote_address.addr[1] = 0x0A; remote_address.addr[2] = 0x3A;
2335 remote_address.addr[3]= 0x54; remote_address.addr[4] = 0x19; remote_address.addr[5]= 0x36;
2336 ret = bluetooth_search_service(&remote_address);
2338 printf("Seach failed, Reason = %d", ret);
2340 printf("Search Success, Ret = %d", ret);
2342 ret = bluetooth_rfcomm_connect(&remote_address, rfcomm_test_uuid);
2344 printf("Connection failed, Reason = %d", ret);
2346 printf("Connection Success, Ret = %d", ret);
2350 int bluetooth_rfcomm_connect(const bluetooth_device_address_t *remote_bt_address,
2351 const char *remote_uuid);
2354 * @fn int bluetooth_rfcomm_disconnect(int socket_fd)
2355 * @brief Disconnect rfcomm connection
2358 * Disconnect a specific(device node fd) RFCOMM connection. This is a Synchronous call and there
2359 * is no cabbback events for this API. We have to provice the valid client fd to disconnect from the
2362 * @return BLUETOOTH_ERROR_NONE - Success \n
2363 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2364 * BLUETOOTH_ERROR_NOT_CONNECTED - Not connected \n
2365 * @param[in] char remote bt_address
2368 * @see bluetooth_rfcomm_connect
2372 ret = bluetooth_rfcomm_disconnect(g_ret_fd);
2374 printf("Disconnection failed");
2376 printf("Disconnection Success");
2381 int bluetooth_rfcomm_disconnect(int socket_fd);
2384 * @fn int bluetooth_rfcomm_write (int fd, const char *buff, int length)
2385 * @brief Write to rfcomm connection
2388 * This API is used to send the data over the rfcomm connection. This is a synchronous API. The same
2389 * API is used to send the data for server and the client.
2391 * @return BLUETOOTH_ERROR_NONE - Success \n
2392 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2393 * BLUETOOTH_ERROR_NOT_IN_OPERATION - The Fd is currently not in operation\n
2395 * @param[in] const char *buff Data buffer to send
2396 * @param[in] int length Length of the data
2399 * @see bluetooth_rfcomm_connect
2402 char *buff = "Test data 123456789"
2403 ret = bluetooth_rfcomm_write(g_ret_fd, buff, 15);
2405 printf("Send failed");
2407 printf("Send success");
2411 int bluetooth_rfcomm_write(int fd, const char *buf, int length);
2414 * @fn gboolean bluetooth_rfcomm_is_client_connected(void)
2415 * @brief Informs whether rfcomm client is connected.
2417 * This function is a synchronous call.
2419 * @return TRUE - RFCOMM client is connected \n
2420 * FALSE - RFCOMM client is not connected \n
2426 gboolean bluetooth_rfcomm_is_client_connected(void);
2429 * @fn int bluetooth_network_activate_server(void)
2430 * @brief Activate the NAP (Network Access Point) service
2432 * This function is a asynchronous call.
2433 * The activate server request is responded by BLUETOOTH_EVENT_NETWORK_SERVER_ACTIVATED event.
2435 * @return BLUETOOTH_ERROR_NONE - Success \n
2436 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2437 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2438 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2441 * @see bluetooth_network_deactivate_server
2444 int bluetooth_network_activate_server(void);
2447 * @fn int bluetooth_network_deactivate_server(void)
2448 * @brief Deactivate the NAP (Network Access Point) service
2450 * This function is a asynchronous call.
2451 * The deactivate server request is responded by BLUETOOTH_EVENT_NETWORK_SERVER_DEACTIVATED event.
2453 * @return BLUETOOTH_ERROR_NONE - Success \n
2454 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2455 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2456 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2459 * @see bluetooth_network_activate_server
2462 int bluetooth_network_deactivate_server(void);
2465 * @fn int bluetooth_network_connect(const bluetooth_device_address_t *device_address,
2466 * bluetooth_network_role_t role,
2468 * @brief Connect the network server in the peer
2470 * This function is a asynchronous call.
2471 * The network connect request is responded by BLUETOOTH_EVENT_NETWORK_CONNECTED event.
2473 * @return BLUETOOTH_ERROR_NONE - Success \n
2474 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2475 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2476 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2479 * @param[in] device_address This indicates an address of the device with which the pairing
2480 * should be initiated
2481 * @param[in] role The role to connect. PANU / GN / NAP / CUSTOM. If use the CUSTOM value,
2482 * need to use the third parameter.
2483 * @param[in] custom_uuid If use the CUSTOM value in second parameter, use this parameter to
2484 * connect. UUID string
2486 * @see bluetooth_network_disconnect
2488 int bluetooth_network_connect(const bluetooth_device_address_t *device_address,
2489 bluetooth_network_role_t role, char *custom_uuid);
2492 * @fn int bluetooth_network_disconnect(const bluetooth_device_address_t *device_address,
2493 * bluetooth_network_role_t role,
2494 * char *custom_uuid)
2495 * @brief Connect the network server in the peer
2497 * This function is a asynchronous call.
2498 * The network disconnect request is responded by BLUETOOTH_EVENT_NETWORK_CONNECTED event.
2500 * @return BLUETOOTH_ERROR_NONE - Success \n
2501 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2502 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2503 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2506 * @param[in] device_address This indicates an address of the device with which the pairing
2507 * should be initiated
2509 * @see bluetooth_network_connect
2511 int bluetooth_network_disconnect(const bluetooth_device_address_t *device_address);
2516 * @fn int bluetooth_hdp_activate(unsigned short data_type,
2517 * bt_hdp_role_type_t role,
2518 * bt_hdp_qos_type_t channel_type,
2519 * char **app_handle)
2520 * @brief Activate the HDP service for a particular data type
2522 * This function is a synchronous call.
2524 * @return BLUETOOTH_ERROR_NONE - Success \n
2525 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2526 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2527 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2530 * @param[in] data_type The data type against corresponding service
2531 * @param[in] role The role of HDP. HDP_ROLE_SOURCE/HDP_ROLE_SINK.
2532 * @param[in] channel_type The QOS type for the channel.
2533 * HDP_QOS_RELIABLE/HDP_QOS_STREAMING/HDP_QOS_ANY.
2534 * For role = HDP_ROLE_SINK, the channel_type
2535 * should be HDP_QOS_ANY.
2536 * @param[out] app_handle The application handler against corresponding service
2538 * @see bluetooth_hdp_deactivate
2540 int bluetooth_hdp_activate(unsigned short data_type,
2541 bt_hdp_role_type_t role,
2542 bt_hdp_qos_type_t channel_type,
2545 * @fn int bluetooth_hdp_deactivate(const char *app_handle)
2546 * @brief Deactivate the HDP service for a particular service using the handler
2548 * This function is a synchronous call.
2550 * @return BLUETOOTH_ERROR_NONE - Success \n
2551 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2552 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2553 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2556 * @param[in] app_handle The application handler against corresponding service
2558 * @see bluetooth_hdp_deactivate
2560 int bluetooth_hdp_deactivate(const char *app_handle);
2563 * @fn int bluetooth_hdp_send_data(unsigned int channel_id,
2564 * const char *buffer, unsigned int size)
2565 * @brief Send data to the remote HDP device
2567 * This function is a synchronous call.
2569 * @return BLUETOOTH_ERROR_NONE - Success \n
2570 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2571 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2572 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2573 * BLUETOOTH_ERROR_NOT_IN_OPERATION - FD is invalid \n
2576 * @param[in] channel_id The channel id for the connection.
2577 * @param[in] buffer The pdu buffer.
2578 * @param[in] size Size of the buffer.
2580 * @see bluetooth_hdp_connect
2582 int bluetooth_hdp_send_data(unsigned int channel_id,
2583 const char *buffer, unsigned int size);
2585 * @fn int bluetooth_hdp_connect(const char *app_handle,
2586 * bt_hdp_qos_type_t channel_type,
2587 * const bluetooth_device_address_t *device_address)
2588 * @brief Connect to the remote device(Mainly used by source)
2590 * This function is a asynchronous call.
2591 * The HDP activate is responded by BLUETOOTH_EVENT_HDP_CONNECTED event.
2593 * @return BLUETOOTH_ERROR_NONE - Success \n
2594 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2595 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2596 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2597 * BLUETOOTH_ERROR_MEMORY_ALLOCATION -Memory allocation failed \n
2600 * @param[in] app_handle The application handler against corresponding service
2601 * @param[in] channel_type The QOS type for the channel.
2602 * HDP_QOS_RELIABLE/HDP_QOS_STREAMING.
2603 * @param[in] device_address The remote device Bd address.
2606 * @see bluetooth_hdp_disconnect
2608 int bluetooth_hdp_connect(const char *app_handle,
2609 bt_hdp_qos_type_t channel_type,
2610 const bluetooth_device_address_t *device_address);
2612 * @fn int bluetooth_hdp_disconnect(unsigned int channel_id,
2613 * const bluetooth_device_address_t *device_address)
2614 * @brief Disconnect from the remote device(Mainly used by source)
2616 * This function is a asynchronous call.
2617 * The HDP activate is responded by BLUETOOTH_EVENT_HDP_DISCONNECTED event.
2619 * @return BLUETOOTH_ERROR_NONE - Success \n
2620 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2621 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2622 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2623 * BLUETOOTH_ERROR_MEMORY_ALLOCATION -Memory allocation failed \n
2626 * @param[in] channel_id The channel id for the connection.
2627 * @param[in] device_address The remote device Bd address.
2630 * @see bluetooth_hdp_connect
2632 int bluetooth_hdp_disconnect(unsigned int channel_id,
2633 const bluetooth_device_address_t *device_address);
2637 * @fn int bluetooth_opc_init(void)
2638 * @brief Initialize OPP client.
2640 * This function is a synchronous call.
2641 * No event corresponding to this api
2643 * @return BLUETOOTH_ERROR_NONE - Success \n
2644 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2645 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2646 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2647 * BLUETOOTH_ERROR_ACCESS_DENIED -Memory allocation failed \n
2652 * @see bluetooth_opc_deinit
2654 int bluetooth_opc_init(void);
2657 * @fn int bluetooth_opc_deinit(void)
2658 * @brief Deinitialize OPP client.
2660 * This function is a synchronous call.
2661 * No event corresponding to this api
2663 * @return BLUETOOTH_ERROR_NONE - Success \n
2664 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2665 * BLUETOOTH_ERROR_ACCESS_DENIED -Memory allocation failed \n
2670 * @see bluetooth_opc_init
2673 int bluetooth_opc_deinit(void);
2676 * @fn int bluetooth_opc_push_files(bluetooth_device_address_t *remote_address,
2677 char **file_name_array)
2678 * @brief Send multiple files to a remote device.
2680 * This function is a asynchronous call.
2681 * This api is responded by BLUETOOTH_EVENT_OPC_CONNECTED event.
2683 * @return BLUETOOTH_ERROR_NONE - Success \n
2684 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2685 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2686 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2687 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2688 * BLUETOOTH_ERROR_IN_PROGRESS -Already one push in progress \n
2689 * BLUETOOTH_ERROR_ACCESS_DENIED - Not allowed by MDM policy \n
2692 * @param[in] device_address The remote device Bd address.
2693 * @param[in] file_name_array Array of filepaths to be sent.
2696 * @see bluetooth_opc_cancel_push
2699 int bluetooth_opc_push_files(bluetooth_device_address_t *remote_address,
2700 char **file_name_array);
2703 * @fn int bluetooth_opc_cancel_push(void)
2704 * @brief Cancels the ongoing file push.
2706 * This function is a asynchronous call.
2707 * This api is responded with either BLUETOOTH_EVENT_OPC_CONNECTED or
2708 * BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETED event.
2710 * @return BLUETOOTH_ERROR_NONE - Success \n
2711 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2712 * BLUETOOTH_ERROR_ACCESS_DENIED - No push in progress \n
2717 * @see bluetooth_opc_push_files
2720 int bluetooth_opc_cancel_push(void);
2723 * @fn gboolean bluetooth_opc_session_is_exist(void)
2724 * @brief Informs whether opc session exists or not.
2726 * This function is a synchronous call.
2728 * @return TRUE - OPC session exists \n
2729 * FALSE - OPC session does not exist \n
2737 gboolean bluetooth_opc_session_is_exist(void);
2740 * @fn int bluetooth_opc_is_sending(gboolean *is_sending)
2741 * @brief Informs whether opc session exists or not.
2743 * This function is a synchronous call.
2745 * @return BLUETOOTH_ERROR_NONE - Success \n
2746 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2747 * BLUETOOTH_ERROR_INTERNAL \n
2750 * @param[out] is_sending The sending status: (@c TRUE = in sending , @c false = not in sending)
2755 int bluetooth_opc_is_sending(gboolean *is_sending);
2758 * @fn int bluetooth_obex_server_init(const char *dst_path)
2759 * @brief Initialize OPP and FTP server.
2761 * This function is a synchronous call.
2762 * No event corresponding to this api
2764 * @return BLUETOOTH_ERROR_NONE - Success \n
2765 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2766 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2767 * BLUETOOTH_ERROR_AGENT_ALREADY_EXIST - Obex agent already registered \n
2768 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2771 * @param[in] dst_path OPS destination file path.
2773 * @see bluetooth_obex_server_deinit
2775 int bluetooth_obex_server_init(const char *dst_path);
2779 * @fn int bluetooth_obex_server_deinit(void)
2780 * @brief Deinitialize OPP and FTP server.
2782 * This function is a synchronous call.
2783 * No event corresponding to this api
2785 * @return BLUETOOTH_ERROR_NONE - Success \n
2786 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2787 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2792 * @see bluetooth_obex_server_init
2794 int bluetooth_obex_server_deinit(void);
2798 * @fn gboolean bluetooth_obex_server_is_activated(void)
2799 * @brief Informs whether obex server is activated or not.
2801 * This function is a synchronous call.
2803 * @return TRUE - OBEX server is activated \n
2804 * FALSE - OBEX server is not activated \n
2811 gboolean bluetooth_obex_server_is_activated(void);
2815 * @fn int bluetooth_obex_server_init_without_agent(const char *dst_path)
2816 * @brief Initialize OPP and FTP server without the conneciton authorization of the agent
2818 * This function is a synchronous call.
2819 * No event corresponding to this api
2821 * @return BLUETOOTH_ERROR_NONE - Success \n
2822 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2823 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2824 * BLUETOOTH_ERROR_AGENT_ALREADY_EXIST - Obex agent already registered \n
2825 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2829 * @param[in] dst_path OPS destination file path.
2831 * @see bluetooth_obex_server_deinit_without_agent
2833 int bluetooth_obex_server_init_without_agent(const char *dst_path);
2837 * @fn int bluetooth_obex_server_deinit_without_agent(void)
2838 * @brief Deinitialize OPP and FTP server without the conneciton authorization of the agent
2840 * This function is a synchronous call.
2841 * No event corresponding to this api
2843 * @return BLUETOOTH_ERROR_NONE - Success \n
2844 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2845 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2850 * @see bluetooth_obex_server_init_without_agent
2852 int bluetooth_obex_server_deinit_without_agent(void);
2856 * @fn int bluetooth_obex_server_accept_connection(void)
2857 * @brief Accepts the authorization request indicated by the event
2858 * BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE.
2860 * This function is a synchronous call.
2862 * @return BLUETOOTH_ERROR_NONE - Success \n
2863 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2864 * BLUETOOTH_ERROR_INTERNAL - Internal error \n
2868 * @see bluetooth_obex_server_reject_authorize
2870 int bluetooth_obex_server_accept_connection(void);
2874 * @fn int bluetooth_obex_server_reject_connection(void)
2875 * @brief Rejects the authorization request indicated by the event
2876 * BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE.
2878 * This function is a synchronous call.
2880 * @return BLUETOOTH_ERROR_NONE - Success \n
2881 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2882 * BLUETOOTH_ERROR_INTERNAL - Internal error \n
2886 * @see bluetooth_obex_server_reject_authorize
2888 int bluetooth_obex_server_reject_connection(void);
2892 * @fn int bluetooth_obex_server_accept_authorize(const char *filename)
2893 * @brief Accepts the authorization request indicated by the event
2894 * BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE.
2896 * This function is a asynchronous call.
2897 * This api will be responded with the event BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED.
2899 * @return BLUETOOTH_ERROR_NONE - Success \n
2900 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2901 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2902 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2905 * @param[in] filename Authorized filename.
2908 * @see bluetooth_obex_server_reject_authorize
2911 int bluetooth_obex_server_accept_authorize(const char *filename);
2914 * @fn int bluetooth_obex_server_reject_authorize(void)
2915 * @brief Reject the authorization request indicated by the event
2916 * BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE.
2918 * This function is a asynchronous call.
2919 * No event for this api..
2921 * @return BLUETOOTH_ERROR_NONE - Success \n
2922 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2923 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2928 * @see bluetooth_obex_server_accept_authorize
2931 int bluetooth_obex_server_reject_authorize(void);
2934 * @fn int bluetooth_obex_server_set_destination_path(const char *dst_path)
2935 * @brief Set the OPS destination file path..
2937 * This function is a asynchronous call.
2938 * No event for this api..
2940 * @return BLUETOOTH_ERROR_NONE - Success \n
2941 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2942 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2943 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid Param \n
2946 * @param[in] dst_path OPS destination file path.
2952 int bluetooth_obex_server_set_destination_path(const char *dst_path);
2955 * @fn int bluetooth_obex_server_set_root(const char *root)
2956 * @brief Set the FTS root folder..
2958 * This function is a asynchronous call.
2959 * No event for this api..
2961 * @return BLUETOOTH_ERROR_NONE - Success \n
2962 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2963 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2964 * BLUETOOTH_ERROR_ACCESS_DENIED - Operation not allowed \n
2965 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2966 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2969 * @param[in] root FTS root folder.
2975 int bluetooth_obex_server_set_root(const char *root);
2978 * @fn int bluetooth_obex_server_cancel_transfer(int transfer_id)
2979 * @brief Cancel the transfer on server
2981 * This function is an asynchronous call.
2982 * If the function call that cancels transfer is successful, the application would receive
2983 * BLUETOOTH_EVENT_TRANSFER_COMPLETED event through registered callback
2984 * function with an error code BLUETOOTH_ERROR_CANCEL. In the case of failure
2985 * the error code will be BLUETOOTH_ERROR_NONE
2987 * @return BLUETOOTH_ERROR_NONE - Success \n
2988 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2989 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2990 * BLUETOOTH_ERROR_INTERNAL - internal error (proxy does not exist) \n
2991 * BLUETOOTH_ERROR_NOT_FOUND - The transfer is not found \n
2994 * @param[in] transfer_id transfer ID
2999 int bluetooth_obex_server_cancel_transfer(int transfer_id);
3003 * @fn int bluetooth_obex_server_cancel_all_transfers(void)
3004 * @brief Cancel the transfer on server
3006 * This function is an asynchronous call.
3007 * If the function call that cancels transfer is successful, the application would receive
3008 * BLUETOOTH_EVENT_TRANSFER_COMPLETED event through registered callback
3009 * function with an error code BLUETOOTH_ERROR_CANCEL. In the case of failure
3010 * the error code will be BLUETOOTH_ERROR_NONE
3012 * @return BLUETOOTH_ERROR_NONE - Success \n
3013 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
3014 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
3015 * BLUETOOTH_ERROR_INTERNAL - internal error (proxy does not exist) \n
3016 * BLUETOOTH_ERROR_NOT_FOUND - The transfer is not found \n
3023 int bluetooth_obex_server_cancel_all_transfers(void);
3027 * @fn int bluetooth_obex_server_is_receiving(gboolean *is_receiving)
3028 * @brief Informs whether obex server is receiving or not.
3030 * This function is a synchronous call.
3032 * @return BLUETOOTH_ERROR_NONE - Success \n
3033 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
3034 * BLUETOOTH_ERROR_INTERNAL \n
3037 * @param[out] is_receiving The receiving status: (@c TRUE = in receiving , @c false = not in receiving)
3042 int bluetooth_obex_server_is_receiving(gboolean *is_receiving);
3046 * @fn int bluetooth_oob_read_local_data(bt_oob_data_t *local_oob_data)
3047 * @brief Read the local Hash and Randmizer.
3049 * This function is a synchronous call.
3051 * @return BLUETOOTH_ERROR_NONE - Success \n
3052 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3056 * @param[out] local_oob_data - Pointer to the local OOB data
3062 int bluetooth_oob_read_local_data(bt_oob_data_t *local_oob_data);
3066 * @fn int bluetooth_oob_add_remote_data(
3067 * const bluetooth_device_address_t *remote_device_address,
3068 * bt_oob_data_t *oob_data)
3069 * @brief Add/updated the remote device Hash and Randmizer.
3071 * This function is a synchronous call.
3072 * No event for this api..
3074 * @return BLUETOOTH_ERROR_NONE - Success \n
3075 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3078 * @param[in] remote_device_address - Remote device address
3079 * remote_oob_data - Ponter to Hash and Randomizer oob data structure
3085 int bluetooth_oob_add_remote_data(
3086 const bluetooth_device_address_t *remote_device_address,
3087 bt_oob_data_t *remote_oob_data);
3091 * @fn int bluetooth_oob_remove_remote_data(
3092 * const bluetooth_device_address_t *remote_device_address)
3093 * @brief Delete the Hash and Randomizer w.r.t the remote device address.
3095 * This function is a synchronous call.
3096 * No event for this api..
3098 * @return BLUETOOTH_ERROR_NONE - Success \n
3099 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3102 * @param[in] remote_device_address - Remote device address
3108 int bluetooth_oob_remove_remote_data(
3109 const bluetooth_device_address_t *remote_device_address);
3112 * @fn int bluetooth_gatt_get_primary_services(const bluetooth_device_address_t *address,
3113 * bt_gatt_handle_info_t *prim_svc);
3115 * @brief Gets the GATT based primary services handle supported by remote device
3117 * This function is a synchronous call.
3118 * The output parameter needs to be freed by calling bluetooth_gatt_free_primary_services()
3120 * @return BLUETOOTH_ERROR_NONE - Success \n
3121 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3122 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3123 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3126 * @param[in] address - Remote device address
3127 * @param[out] prim_svc - Structure containing remote service count and handle list.
3130 * @see bluetooth_gatt_free_primary_services()
3132 int bluetooth_gatt_get_primary_services(const bluetooth_device_address_t *address,
3133 bt_gatt_handle_info_t *prim_svc);
3136 * @fn int bluetooth_gatt_discover_service_characteristics(const char *service_handle)
3138 * @brief Discovers the characteristics of GATT based service of remote device
3140 * This function is an asynchronous call.
3141 * This API is responded with BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED
3143 * @return BLUETOOTH_ERROR_NONE - Success \n
3144 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3145 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3146 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3149 * @param[in] service_handle - Handle for remote service.
3154 int bluetooth_gatt_discover_service_characteristics(const char *service_handle);
3157 * @fn int bluetooth_gatt_get_service_property(const char *service_handle,
3158 * bt_gatt_service_property_t *service);
3160 * @brief Gets the properties of GATT based service of remote device
3162 * This function is a synchronous call.
3163 * The output parameter needs to be freed by calling bluetooth_gatt_free_primary_services()
3165 * @return BLUETOOTH_ERROR_NONE - Success \n
3166 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3167 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3168 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3171 * @param[in] service_handle - Handle for remote service.
3172 * @param[out] service - Structure containing remote service property.
3175 * @see bluetooth_gatt_free_service_property()
3177 int bluetooth_gatt_get_service_property(const char *service_handle,
3178 bt_gatt_service_property_t *service);
3181 * @fn int bluetooth_gatt_watch_characteristics(const char *service_handle)
3183 * @brief Register to GATT based service to receive value change notification/indication.
3185 * This function is a synchronous call.
3186 * No event for this api.
3188 * @return BLUETOOTH_ERROR_NONE - Success \n
3189 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3190 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3191 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3194 * @param[in] service_handle - Handle for remote service.
3199 int bluetooth_gatt_watch_characteristics(const char *service_handle);
3202 * @fn int bluetooth_gatt_unwatch_characteristics(const char *service_handle)
3204 * @brief Unregister GATT based service to receive value change notification/indication.
3206 * This function is a synchronous call.
3207 * No event for this api.
3209 * @return BLUETOOTH_ERROR_NONE - Success \n
3210 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3211 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3212 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3215 * @param[in] service_handle - Handle for remote service.
3220 int bluetooth_gatt_unwatch_characteristics(const char *service_handle);
3223 * @fn int bluetooth_gatt_get_characteristics_property(const char *char_handle,
3224 * bt_gatt_char_property_t *characteristic);
3226 * @brief Provides characteristic value along with properties.
3228 * This function is a synchronous call.
3229 * The output parameter needs to be freed by calling bluetooth_gatt_free_char_property()
3231 * @return BLUETOOTH_ERROR_NONE - Success \n
3232 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3233 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3234 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3237 * @param[in] char_handle - Handle for Characteristic property.
3238 * @param[out] characteristic - Structure containing remote characteristic property.
3241 * @see bluetooth_gatt_free_char_property()
3243 int bluetooth_gatt_get_characteristics_property(const char *char_handle,
3244 bt_gatt_char_property_t *characteristic);
3247 * @fn int bluetooth_gatt_set_characteristics_value(const char *char_handle,
3248 * const guint8 *value, int length)
3250 * @brief Set characteristic value.
3252 * This function is a synchronous call.
3254 * @return BLUETOOTH_ERROR_NONE - Success \n
3255 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3256 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3257 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3260 * @param[in] char_handle - Handle for Characteristic property.
3261 * @param[in] value - New value to set for characteristic property.
3262 * @param[in] length - Length of the value to be set.
3267 int bluetooth_gatt_set_characteristics_value(const char *char_handle,
3268 const guint8 *value, int length);
3271 * @fn int bluetooth_gatt_get_service_from_uuid(bluetooth_device_address_t *address,
3272 * const char *service_uuid,
3273 * bt_gatt_service_property_t *service)
3275 * @brief Gets the service property from a device based on a particular uuid
3277 * This function is a synchronous call.
3279 * @return BLUETOOTH_ERROR_NONE - Success \n
3280 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3281 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3282 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3285 * @param[in] address - BD address of the remote device
3286 * @param[in] service_uuid - uuid of the service.
3287 * @param[out] service - Structure containing the service property.
3292 int bluetooth_gatt_get_service_from_uuid(bluetooth_device_address_t *address,
3293 const char *service_uuid,
3294 bt_gatt_service_property_t *service);
3297 * @fn int bluetooth_gatt_get_char_from_uuid(const char *service_handle,
3298 * const char *char_uuid)
3300 * @brief Gets the characteristic property from a service based on a particular char uuid
3302 * This function is an asynchronous call.
3303 * This API is responded with BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID
3305 * @return BLUETOOTH_ERROR_NONE - Success \n
3306 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3307 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3308 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3311 * @param[in] service_handle - Service handle.
3312 * @param[in] uuid - Characteristic uuid.
3317 int bluetooth_gatt_get_char_from_uuid(const char *service_handle,
3318 const char *char_uuid);
3321 * @fn int bluetooth_gatt_free_primary_services(bt_gatt_handle_info_t *prim_svc);
3323 * @brief Releases the memory allocated by bluetooth_gatt_get_primary_services()
3325 * This function is a synchronous call.
3326 * The input parameter is obtained by calling bluetooth_gatt_get_primary_services()
3328 * @return BLUETOOTH_ERROR_NONE - Success \n
3329 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3332 * @param[in] prim_svc - GATT handle info structure
3335 * @see bluetooth_gatt_get_primary_services()
3337 int bluetooth_gatt_free_primary_services(bt_gatt_handle_info_t *prim_svc);
3340 * @fn int bluetooth_gatt_free_service_property(bt_gatt_service_property_t *svc_pty);
3342 * @brief Releases the memory allocated by bluetooth_gatt_get_service_property()
3344 * This function is a synchronous call.
3345 * The input parameter is obtained by calling bluetooth_gatt_get_service_property()
3347 * @return BLUETOOTH_ERROR_NONE - Success \n
3348 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3351 * @param[in] svc_pty - GATT service property structure.
3354 * @see bluetooth_gatt_get_service_property()
3356 int bluetooth_gatt_free_service_property(bt_gatt_service_property_t *svc_pty);
3359 * @fn int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *char_pty);
3361 * @brief Provides characteristic value along with properties.
3363 * This function is a synchronous call.
3364 * The input parameter is obtained by calling bluetooth_gatt_get_characteristics_property()
3366 * @return BLUETOOTH_ERROR_NONE - Success \n
3367 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3370 * @param[in] char_pty - GATT characteristics property structure.
3373 * @see bluetooth_gatt_get_characteristics_property()
3375 int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *char_pty);
3383 #endif /* __cplusplus */
3384 #endif /* _BLUETOOTH_API_H_*/