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 */
245 BLUETOOTH_EVENT_REMOTE_DEVICE_DISAPPEARED, /**< Bluetooth event remote device disappeared*/
247 BLUETOOTH_EVENT_SERVICE_SEARCHED = BLUETOOTH_EVENT_SDP_BASE,
248 /**< Bluetooth event serice search base id */
249 BLUETOOTH_EVENT_SERVICE_SEARCH_CANCELLED, /**< Bluetooth event service search cancelled */
250 BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED = BLUETOOTH_EVENT_RFCOMM_BASE,
251 /**< RFCOMM data receive event */
252 BLUETOOTH_EVENT_RFCOMM_CONNECTED, /**< Rfcomm server incomming connection */
253 BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, /**< Rfcomm server/client disconnect */
255 BLUETOOTH_EVENT_RFCOMM_AUTHORIZE,
257 BLUETOOTH_EVENT_DEVICE_CONNECTED, /**< Bluetooth event device connected */
258 BLUETOOTH_EVENT_DEVICE_DISCONNECTED, /**< Bluetooth event device disconnected */
260 BLUETOOTH_EVENT_RFCOMM_SERVER_REMOVED,
262 BLUETOOTH_EVENT_NETWORK_SERVER_ACTIVATED = BLUETOOTH_EVENT_NETWORK_BASE,
263 /**< Bluetooth Network event */
264 BLUETOOTH_EVENT_NETWORK_SERVER_DEACTIVATED, /**< Network server deactivated */
265 BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED, /**< Network connected event in server */
266 BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED,
267 /**< Network disconnected evnet in server */
269 BLUETOOTH_EVENT_NETWORK_CONNECTED, /**< Network connected event in client*/
270 BLUETOOTH_EVENT_NETWORK_DISCONNECTED, /**< Network disconnected evnet in client*/
272 BLUETOOTH_EVENT_HDP_CONNECTED
273 = BLUETOOTH_EVENT_HDP_BASE, /**<HDP Connect>*/
274 BLUETOOTH_EVENT_HDP_DISCONNECTED, /**<HDP Disconnect>*/
275 BLUETOOTH_EVENT_HDP_DATA_RECEIVED, /**<HDP Data Indication>*/
277 BLUETOOTH_EVENT_OPC_CONNECTED = BLUETOOTH_EVENT_OPC_BASE,
278 /* OPC Connected event */
279 BLUETOOTH_EVENT_OPC_DISCONNECTED, /* OPC Disonnected event */
280 BLUETOOTH_EVENT_OPC_TRANSFER_STARTED, /* OPC Transfer started event */
281 BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS, /* OPC Transfer progress event */
282 BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE, /* OPC Transfer Complete event */
284 BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE = BLUETOOTH_EVENT_OBEX_SERVER_BASE,
285 /* Obex server authorize event*/
286 BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED, /* Obex Server transfer started event*/
287 BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS,/* Obex Server transfer progress event*/
288 BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED,/* Obex Server transfer complete event*/
289 BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE,
291 BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED = BLUETOOTH_EVENT_GATT_BASE,
292 /**<Discovered GATT service characteristics event*/
293 BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED,
294 /**<Remote GATT charateristic value changed event*/
295 BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID,
297 BLUETOOTH_EVENT_AG_CONNECTED = BLUETOOTH_EVENT_AUDIO_BASE, /**<AG service connected event*/
298 BLUETOOTH_EVENT_AG_DISCONNECTED, /**<AG service disconnected event*/
299 BLUETOOTH_EVENT_AG_SPEAKER_GAIN, /**<Speaker gain request event*/
300 BLUETOOTH_EVENT_AG_MIC_GAIN, /**<Mic gain request event*/
301 BLUETOOTH_EVENT_AG_AUDIO_CONNECTED, /**<AV & AG service connected event*/
302 BLUETOOTH_EVENT_AG_AUDIO_DISCONNECTED, /**<AV & AG service disconnected event*/
303 BLUETOOTH_EVENT_AV_CONNECTED, /**<AV service connected event*/
304 BLUETOOTH_EVENT_AV_DISCONNECTED, /**<AV service disconnected event*/
305 BLUETOOTH_EVENT_AVRCP_CONNECTED, /**<AVRCP service connected event*/
306 BLUETOOTH_EVENT_AVRCP_DISCONNECTED, /**<AVRCP service disconnected event*/
307 BLUETOOTH_EVENT_AVRCP_SETTING_SHUFFLE_STATUS, /**<AVRCP service player suffle status event*/
308 BLUETOOTH_EVENT_AVRCP_SETTING_EQUALIZER_STATUS, /**<AVRCP service player equalizer status event*/
309 BLUETOOTH_EVENT_AVRCP_SETTING_REPEAT_STATUS, /**<AVRCP service player repeat status event*/
310 BLUETOOTH_EVENT_AVRCP_SETTING_SCAN_STATUS, /**<AVRCP service player scan status event*/
312 BLUETOOTH_HID_CONNECTED = BLUETOOTH_EVENT_HID_BASE, /**< Input connectd event*/
313 BLUETOOTH_HID_DISCONNECTED, /**< Input disconnectd event*/
314 BLUETOOTH_EVENT_MAX, /**< Bluetooth event Max value */
315 } bluetooth_event_type_t;
318 * This bt_service_uuid_list_t enum indicates service uuid list .
319 * This values is stored the service_list_array in bt_sdp_info_t and bluetooth_device_info_t.
323 BLUETOOTH_SPP_PROFILE_UUID = ((unsigned short)0x1101), /**<SPP*/
324 BLUETOOTH_LAP_PROFILE_UUID = ((unsigned short)0x1102), /**<LAP*/
325 BLUETOOTH_DUN_PROFILE_UUID = ((unsigned short)0x1103), /**<DUN*/
326 BLUETOOTH_OBEX_IR_MC_SYNC_SERVICE_UUID = ((unsigned short)0x1104), /**<OBEX IR MC SYNC*/
327 BLUETOOTH_OBEX_OBJECT_PUSH_SERVICE_UUID = ((unsigned short)0x1105), /**<OPP*/
328 BLUETOOTH_OBEX_FILE_TRANSFER_UUID = ((unsigned short)0x1106), /**<FTP*/
329 BLUETOOTH_IRMC_SYNC_COMMAND_UUID = ((unsigned short)0x1107), /**<IRMC SYNC COMMAND*/
330 BLUETOOTH_HS_PROFILE_UUID = ((unsigned short)0x1108), /**<HS*/
331 BLUETOOTH_CTP_PROFILE_UUID = ((unsigned short)0x1109), /**<CTP*/
332 BLUETOOTH_AUDIO_SOURCE_UUID = ((unsigned short)0x110A), /**<AUDIO SOURCE*/
333 BLUETOOTH_AUDIO_SINK_UUID = ((unsigned short)0x110B), /**<AUDIO SINK*/
334 BLUETOOTH_AV_REMOTE_CONTROL_TARGET_UUID = ((unsigned short)0x110C), /**<AV REMOTE CONTROL
336 BLUETOOTH_ADVANCED_AUDIO_PROFILE_UUID = ((unsigned short)0x110D), /**<A2DP*/
337 BLUETOOTH_AV_REMOTE_CONTROL_UUID = ((unsigned short)0x110E), /**<AV REMOTE CONTROL UUID*/
338 BLUETOOTH_AV_REMOTE_CONTROL_CONTROLLER_UUID = ((unsigned short)0x110F), /**<AV REMOTE CONTROLLER UUID*/
339 BLUETOOTH_ICP_PROFILE_UUID = ((unsigned short)0x1110), /**<ICP*/
340 BLUETOOTH_FAX_PROFILE_UUID = ((unsigned short)0x1111), /**<FAX*/
341 BLUETOOTH_HEADSET_AG_SERVICE_UUID = ((unsigned short)0x1112), /**<HS AG */
342 BLUETOOTH_PAN_PANU_PROFILE_UUID = ((unsigned short)0x1115), /**<PAN*/
343 BLUETOOTH_PAN_NAP_PROFILE_UUID = ((unsigned short)0x1116), /**<PAN*/
344 BLUETOOTH_PAN_GN_PROFILE_UUID = ((unsigned short)0x1117), /**<PAN*/
345 BLUETOOTH_DIRECT_PRINTING = ((unsigned short)0x1118),
346 BLUETOOTH_OBEX_BPPS_PROFILE_UUID = ((unsigned short)0x1118), /**<OBEX BPPS*/ /* Will be removed */
347 BLUETOOTH_REFERENCE_PRINTING = ((unsigned short)0x1119),
348 BLUETOOTH_OBEX_IMAGING_UUID = ((unsigned short)0x111A), /**<OBEX_IMAGING*/
349 BLUETOOTH_OBEX_IMAGING_RESPONDER_UUID = ((unsigned short)0x111B), /**<OBEX_IMAGING
351 BLUETOOTH_IMAGING_AUTOMATIC_ARCHIVE_UUID = ((unsigned short)0x111C), /**<IMAGING AUTOMATIC ARCHIVE*/
352 BLUETOOTH_IMAGING_REFERENCED_OBJECTS_UUID = ((unsigned short)0x111D), /**<IMAGING REFERENCED OBJECTS*/
353 BLUETOOTH_HF_PROFILE_UUID = ((unsigned short)0x111E), /**<HF*/
354 BLUETOOTH_HFG_PROFILE_UUID = ((unsigned short)0x111F), /**<HFG*/
355 BLUETOOTH_DIRECT_PRINTING_REFERENCE_OBJ_UUID = ((unsigned short)0x1120),
356 /**<DIRECT PRINTING*/
357 BLUETOOTH_REFLECTED_UI = ((unsigned short)0x1121), /**<REFLECTED UI*/
358 BLUETOOTH_BASIC_PRINTING = ((unsigned short)0x1122), /**<BASIC PRINTING*/
359 BLUETOOTH_PRINTING_STATUS = ((unsigned short)0x1123), /**<PRINTING STATUS*/
360 BLUETOOTH_OBEX_PRINTING_STATUS_UUID = ((unsigned short)0x1123), /**<OBEX PRINTING STATUS*/ /* Will be removed */
361 BLUETOOTH_HID_PROFILE_UUID = ((unsigned short)0x1124), /**<HID*/
362 BLUETOOTH_HCR_PROFILE_UUID = ((unsigned short)0x1125), /**<HCRP*/
363 BLUETOOTH_HCR_PRINT_UUID = ((unsigned short)0x1126), /**<HCR PRINT*/
364 BLUETOOTH_HCR_SCAN_UUID = ((unsigned short)0x1127), /**<HCR SCAN*/
365 BLUETOOTH_SIM_ACCESS_PROFILE_UUID = ((unsigned short)0x112D), /**<SIM ACCESS PROFILE*/
366 BLUETOOTH_PBAP_PCE_UUID = ((unsigned short)0x112E), /**<PBAP - PCE*/
367 BLUETOOTH_PBAP_PSE_UUID = ((unsigned short)0x112F), /**<OBEX PBA*/
368 BLUETOOTH_OBEX_PBA_PROFILE_UUID = ((unsigned short)0x112F), /**<OBEX PBA*/ /* Will be removed */
369 BLUETOOTH_OBEX_PBAP_UUID = ((unsigned short)0x1130), /**<OBEX PBA*/
370 BLUETOOTH_HEADSET_HS_UUID = ((unsigned short)0x1131), /**<HEADSET HS*/
371 BLUETOOTH_MESSAGE_ACCESS_SERVER_UUID = ((unsigned short)0x1132),/**<MESSAGE ACCESS SERVER*/
372 BLUETOOTH_MESSAGE_NOTIFICATION_SERVER_UUID = ((unsigned short)0x1133),/**<MESSAGE NOTIFICATION SERVER*/
373 BLUETOOTH_MESSAGE_ACCESS_PROFILE_UUID = ((unsigned short)0x1134),/**<MESSAGE ACCESS PROFILE*/
374 BLUETOOTH_PNP_INFORMATION_UUID = ((unsigned short)0x1200), /**<PNP*/
375 BLUETOOTH_GENERIC_NETWORKING_UUID = ((unsigned short)0x1201), /**<GENERIC NETWORKING*/
376 BLUETOOTH_GENERIC_FILE_TRANSFER_UUID = ((unsigned short)0x1202),/**<GENERIC FILE TRANSFER*/
377 BLUETOOTH_GENERIC_AUDIO_UUID = ((unsigned short)0x1203), /**<GENERIC AUDIO*/
378 BLUETOOTH_GENERIC_TELEPHONY_UUID = ((unsigned short)0x1204), /**<GENERIC TELEPHONY*/
379 BLUETOOTH_VIDEO_SOURCE_UUID = ((unsigned short)0x1303), /**<VEDIO SOURCE*/
380 BLUETOOTH_VIDEO_SINK_UUID = ((unsigned short)0x1304), /**<VEDIO SINK*/
381 BLUETOOTH_VIDEO_DISTRIBUTION_UUID = ((unsigned short)0x1305), /**<VEDIO DISTRIBUTION*/
382 BLUETOOTH_HDP_UUID = ((unsigned short)0x1400), /**<HDP*/
383 BLUETOOTH_HDP_SOURCE_UUID = ((unsigned short)0x1401), /**<HDP SOURCE*/
384 BLUETOOTH_HDP_SINK_UUID = ((unsigned short)0x1402), /**<HDP SINK*/
385 BLUETOOTH_OBEX_SYNCML_TRANSFER_UUID = ((unsigned short)0x0000) /**<OBEX_SYNC*/ /* Will be removed */
386 } bluetooth_service_uuid_list_t;
389 * Service class part of class of device returned from device discovery
392 BLUETOOTH_DEVICE_SERVICE_CLASS_LIMITED_DISCOVERABLE_MODE = 0x002000,
393 BLUETOOTH_DEVICE_SERVICE_CLASS_POSITIONING = 0x010000, /**< */
394 BLUETOOTH_DEVICE_SERVICE_CLASS_NETWORKING = 0x020000, /**< */
395 BLUETOOTH_DEVICE_SERVICE_CLASS_RENDERING = 0x040000, /**< */
396 BLUETOOTH_DEVICE_SERVICE_CLASS_CAPTURING = 0x080000, /**< */
397 BLUETOOTH_DEVICE_SERVICE_CLASS_OBJECT_TRANSFER = 0x100000, /**< */
398 BLUETOOTH_DEVICE_SERVICE_CLASS_AUDIO = 0x200000, /**< */
399 BLUETOOTH_DEVICE_SERVICE_CLASS_TELEPHONY = 0x400000, /**< */
400 BLUETOOTH_DEVICE_SERVICE_CLASS_INFORMATION = 0x800000, /**< */
401 } bluetooth_device_service_class_t;
405 * Major device mask (For device discovery)
408 BLUETOOTH_DEVICE_MAJOR_MASK_MISC = 0x00,
409 BLUETOOTH_DEVICE_MAJOR_MASK_COMPUTER = 0x0001,
410 BLUETOOTH_DEVICE_MAJOR_MASK_PHONE = 0x0002,
411 BLUETOOTH_DEVICE_MAJOR_MASK_LAN_ACCESS_POINT = 0x0004,
412 BLUETOOTH_DEVICE_MAJOR_MASK_AUDIO = 0x0008,
413 BLUETOOTH_DEVICE_MAJOR_MASK_PERIPHERAL = 0x0010,
414 BLUETOOTH_DEVICE_MAJOR_MASK_IMAGING = 0x0020,
415 BLUETOOTH_DEVICE_MAJOR_MASK_WEARABLE = 0x0040,
416 BLUETOOTH_DEVICE_MAJOR_MASK_TOY = 0x0080,
417 BLUETOOTH_DEVICE_MAJOR_MASK_HEALTH = 0x0100,
418 } bluetooth_device_major_mask_t;
422 * Major device class (part of Class of Device)
425 BLUETOOTH_DEVICE_MAJOR_CLASS_MISC = 0x00, /**< Miscellaneous major device class*/
426 BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER = 0x01, /**< Computer major device class*/
427 BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE = 0x02, /**< Phone major device class*/
428 BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT = 0x03, /**< LAN major device class*/
429 BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO = 0x04, /**< AUDIO major device class*/
430 BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL = 0x05, /**< Peripheral major device class*/
431 BLUETOOTH_DEVICE_MAJOR_CLASS_IMAGING = 0x06, /**< Imaging major device class*/
432 BLUETOOTH_DEVICE_MAJOR_CLASS_WEARABLE = 0x07, /**< Wearable device class*/
433 BLUETOOTH_DEVICE_MAJOR_CLASS_TOY = 0x08, /**< Toy device class*/
434 BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH = 0x09, /**< Health device class*/
435 BLUETOOTH_DEVICE_MAJOR_CLASS_UNCLASSIFIED = 0x1F /**< Unknown major device class*/
436 } bluetooth_device_major_class_t;
439 BLUETOOTH_DEVICE_MINOR_CLASS_UNCLASSIFIED = 0x00, /**< unclassified minor class */
441 /* About Computer Major class */
442 BLUETOOTH_DEVICE_MINOR_CLASS_DESKTOP_WORKSTATION = 0x04, /**< desktop workstation
444 BLUETOOTH_DEVICE_MINOR_CLASS_SERVER_CLASS_COMPUTER = 0x08, /**< server minor class */
445 BLUETOOTH_DEVICE_MINOR_CLASS_LAPTOP = 0x0C, /**< laptop minor class */
446 BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_PC_OR_PDA = 0x10, /**< PDA minor class */
447 BLUETOOTH_DEVICE_MINOR_CLASS_PALM_SIZED_PC_OR_PDA = 0x14, /**< PALM minor class */
448 BLUETOOTH_DEVICE_MINOR_CLASS_WEARABLE_COMPUTER = 0x18, /**< Wearable PC minor class */
450 /* About Phone Major class */
451 BLUETOOTH_DEVICE_MINOR_CLASS_CELLULAR = 0x04, /**< Cellular minor class */
452 BLUETOOTH_DEVICE_MINOR_CLASS_CORDLESS = 0x08, /**< cordless minor class */
453 BLUETOOTH_DEVICE_MINOR_CLASS_SMART_PHONE = 0x0C, /**< smart phone minor class */
454 BLUETOOTH_DEVICE_MINOR_CLASS_WIRED_MODEM_OR_VOICE_GATEWAY = 0x10,
455 /**< voice gateway minor class */
456 BLUETOOTH_DEVICE_MINOR_CLASS_COMMON_ISDN_ACCESS = 0x14, /**< ISDN minor class */
458 /* About LAN/Network Access Point Major class */
459 BLUETOOTH_DEVICE_MINOR_CLASS_FULLY_AVAILABLE = 0x04, /**< Fully available minor class */
460 BLUETOOTH_DEVICE_MINOR_CLASS_1_TO_17_PERCENT_UTILIZED = 0x20, /**< 1-17% utilized minor class */
461 BLUETOOTH_DEVICE_MINOR_CLASS_17_TO_33_PERCENT_UTILIZED = 0x40, /**< 17-33% utilized minor class */
462 BLUETOOTH_DEVICE_MINOR_CLASS_33_TO_50_PERCENT_UTILIZED = 0x60, /**< 33-50% utilized minor class */
463 BLUETOOTH_DEVICE_MINOR_CLASS_50_to_67_PERCENT_UTILIZED = 0x80, /**< 50-67% utilized minor class */
464 BLUETOOTH_DEVICE_MINOR_CLASS_67_TO_83_PERCENT_UTILIZED = 0xA0, /**< 67-83% utilized minor class */
465 BLUETOOTH_DEVICE_MINOR_CLASS_83_TO_99_PERCENT_UTILIZED = 0xC0, /**< 83-99% utilized minor class */
466 BLUETOOTH_DEVICE_MINOR_CLASS_NO_SERVICE_AVAILABLE = 0xE0, /**< No service available minor class */
468 /* About Audio/Video Major class */
469 BLUETOOTH_DEVICE_MINOR_CLASS_HEADSET_PROFILE = 0x04, /**< Headset minor class */
470 BLUETOOTH_DEVICE_MINOR_CLASS_HANDSFREE = 0x08, /**< Handsfree minor class*/
472 BLUETOOTH_DEVICE_MINOR_CLASS_MICROPHONE = 0x10, /**< Microphone minor class */
473 BLUETOOTH_DEVICE_MINOR_CLASS_LOUD_SPEAKER = 0x14, /**< Loud Speaker minor class */
474 BLUETOOTH_DEVICE_MINOR_CLASS_HEADPHONES = 0x18, /**< Headphones minor class */
475 BLUETOOTH_DEVICE_MINOR_CLASS_PORTABLE_AUDIO = 0x1C, /**< Portable Audio minor class */
476 BLUETOOTH_DEVICE_MINOR_CLASS_CAR_AUDIO = 0x20, /**< Car Audio minor class */
477 BLUETOOTH_DEVICE_MINOR_CLASS_SET_TOP_BOX = 0x24, /**< Set top box minor class */
478 BLUETOOTH_DEVICE_MINOR_CLASS_HIFI_AUDIO_DEVICE = 0x28, /**< Hifi minor class */
479 BLUETOOTH_DEVICE_MINOR_CLASS_VCR = 0x2C, /**< VCR minor class */
480 BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_CAMERA = 0x30, /**< Video Camera minor class */
481 BLUETOOTH_DEVICE_MINOR_CLASS_CAM_CORDER = 0x34, /**< CAM Corder minor class */
482 BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_MONITOR = 0x38, /**<Video Monitor minor class */
483 BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_DISPLAY_AND_LOUD_SPEAKER = 0x3C,
484 /**< Video Display and Loud
485 Speaker minor class */
486 BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_CONFERENCING = 0x40, /**< Video Conferencing minor
489 BLUETOOTH_DEVICE_MINOR_CLASS_GAMING_OR_TOY = 0x48, /**< Gaming or toy minor class */
491 /* About Peripheral Major class */
492 BLUETOOTH_DEVICE_MINOR_CLASS_KEY_BOARD = 0x40, /**< Key board minor class */
493 BLUETOOTH_DEVICE_MINOR_CLASS_POINTING_DEVICE = 0x80, /**< Pointing Device minor class */
494 BLUETOOTH_DEVICE_MINOR_CLASS_COMBO_KEYBOARD_OR_POINTING_DEVICE = 0xC0,
495 /**< Combo Keyboard or pointing
498 BLUETOOTH_DEVICE_MINOR_CLASS_JOYSTICK = 0x04, /**< JoyStick minor class */
499 BLUETOOTH_DEVICE_MINOR_CLASS_GAME_PAD = 0x08, /**< Game Pad minor class */
500 BLUETOOTH_DEVICE_MINOR_CLASS_REMOTE_CONTROL = 0x0C, /**< Remote Control minor class */
501 BLUETOOTH_DEVICE_MINOR_CLASS_SENSING_DEVICE = 0x10, /**< Sensing Device minor class */
502 BLUETOOTH_DEVICE_MINOR_CLASS_DIGITIZER_TABLET = 0x14, /**< Digitizer minor class */
503 BLUETOOTH_DEVICE_MINOR_CLASS_CARD_READER = 0x18, /**< Card Reader minor class */
504 BLUETOOTH_DEVICE_MINOR_CLASS_DIGITAL_PEN = 0x1C, /**< Digital pen minor class */
505 BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_SCANNER = 0x20, /**< Handheld scanner for bar-codes, RFID minor class */
506 BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_GESTURAL_INPUT_DEVICE = 0x24, /**< Handheld gestural input device minor class */
508 /* About Imaging Major class */
509 BLUETOOTH_DEVICE_MINOR_CLASS_DISPLAY = 0x10, /**< Display minor class */
510 BLUETOOTH_DEVICE_MINOR_CLASS_CAMERA = 0x20, /**< Camera minor class */
511 BLUETOOTH_DEVICE_MINOR_CLASS_SCANNER = 0x40, /**< Scanner minor class */
512 BLUETOOTH_DEVICE_MINOR_CLASS_PRINTER = 0x80, /**< Printer minor class */
514 /* About Wearable Major class */
515 BLUETOOTH_DEVICE_MINOR_CLASS_WRIST_WATCH = 0x04, /**< Wrist watch minor class */
516 BLUETOOTH_DEVICE_MINOR_CLASS_PAGER = 0x08, /**< Pager minor class */
517 BLUETOOTH_DEVICE_MINOR_CLASS_JACKET = 0x0C, /**< Jacket minor class */
518 BLUETOOTH_DEVICE_MINOR_CLASS_HELMET = 0x10, /**< Helmet minor class */
519 BLUETOOTH_DEVICE_MINOR_CLASS_GLASSES = 0x14, /**< Glasses minor class */
521 /* About Toy Major class */
522 BLUETOOTH_DEVICE_MINOR_CLASS_ROBOT = 0x04, /**< Robot minor class */
523 BLUETOOTH_DEVICE_MINOR_CLASS_VEHICLE = 0x08, /**< Vehicle minor class */
524 BLUETOOTH_DEVICE_MINOR_CLASS_DOLL_OR_ACTION = 0x0C, /**< Doll or Action minor class */
525 BLUETOOTH_DEVICE_MINOR_CLASS_CONTROLLER = 0x10, /**< Controller minor class */
526 BLUETOOTH_DEVICE_MINOR_CLASS_GAME = 0x14, /**< Game minor class */
528 /* About Health Major class */
529 BLUETOOTH_DEVICE_MINOR_CLASS_BLOOD_PRESSURE_MONITOR = 0x04, /**< Blood Pressure minor class */
530 BLUETOOTH_DEVICE_MINOR_CLASS_THERMOMETER = 0x08, /**< Thermometer minor class */
531 BLUETOOTH_DEVICE_MINOR_CLASS_WEIGHING_SCALE = 0x0C, /**< Weighing Scale minor class */
532 BLUETOOTH_DEVICE_MINOR_CLASS_GLUCOSE_METER = 0x10, /**< Glucose minor class */
533 BLUETOOTH_DEVICE_MINOR_CLASS_PULSE_OXIMETER = 0x14, /**< Pulse Oximeter minor class */
534 BLUETOOTH_DEVICE_MINOR_CLASS_HEART_OR_PULSE_RATE_MONITOR = 0x18,/**< Heart or pulse rate monitor minor class */
535 BLUETOOTH_DEVICE_MINOR_CLASS_MEDICAL_DATA_DISPLAY = 0x1C, /**< Medical minor class */
536 BLUETOOTH_DEVICE_MINOR_CLASS_STEP_COUNTER = 0x20, /**< Step Counter minor class */
537 BLUETOOTH_DEVICE_MINOR_CLASS_BODY_COMPOSITION_ANALYZER = 0x24, /**< Body composition analyzer minor class */
538 BLUETOOTH_DEVICE_MINOR_CLASS_PEAK_FLOW_MONITOR = 0x28, /**< Peak flow monitor minor class */
539 BLUETOOTH_DEVICE_MINOR_CLASS_MEDICATION_MONITOR = 0x2C, /**< Medication monitor minor class */
540 BLUETOOTH_DEVICE_MINOR_CLASS_KNEE_PROSTHESIS = 0x30, /**< Knee prosthesis minor class */
541 BLUETOOTH_DEVICE_MINOR_CLASS_ANKLE_PROSTHESIS = 0x34, /**< Ankle prosthesis minor class */
542 } bluetooth_device_minor_class_t;
545 * structure to hold the device information
548 bluetooth_device_major_class_t major_class; /**< major device class */
549 bluetooth_device_minor_class_t minor_class; /**< minor device class */
550 bluetooth_device_service_class_t service_class;
551 /**< service device class */
552 } bluetooth_device_class_t;
555 * structure to hold the device information
558 bluetooth_device_address_t device_address; /**< device address */
559 bluetooth_device_name_t device_name; /**< device name */
560 bluetooth_device_class_t device_class; /**< device class */
561 char uuids[BLUETOOTH_MAX_SERVICES_FOR_DEVICE][BLUETOOTH_UUID_STRING_MAX];
562 unsigned int service_list_array[BLUETOOTH_MAX_SERVICES_FOR_DEVICE]; /**< Use enum values in bt_service_uuid_list_t */
564 int rssi; /**< received strength signal*/
565 gboolean paired; /**< paired flag */
566 gboolean connected; /**< connected flag */
567 gboolean trust; /**< connected flag */
568 } bluetooth_device_info_t;
571 * structure to hold the paired device information
574 bluetooth_device_address_t device_address; /**< paired device address */
575 bluetooth_device_name_t device_name; /**< device name */
576 bluetooth_device_class_t device_class; /**< device class */
577 } bluetooth_paired_device_info_t;
580 * structure to hold the paired device information
583 bluetooth_device_address_t device_address;
584 /**< device address */
585 char interface_name[BLUETOOTH_INTERFACE_NAME_LENGTH + 1];
586 /**< network interface name */
587 } bluetooth_network_device_info_t;
590 * Stucture to hold discovery option
593 unsigned short max_response; /**< the number of maximum response */
594 unsigned short discovery_duration;
595 /**< duration of discovery (seconds) */
596 unsigned int classOfDeviceMask; /**< mask for values of class of device. to be used with
597 classOfDevice variable */
598 } bluetooth_discovery_option_t;
601 * Stucture to hold event information
604 int event; /**< event type */
605 int result; /**< Success or error value */
607 /**<parameter data pointer */
609 } bluetooth_event_param_t;
612 bluetooth_device_address_t device_addr;
613 char uuids[BLUETOOTH_MAX_SERVICES_FOR_DEVICE][BLUETOOTH_UUID_STRING_MAX];
614 unsigned int service_list_array[BLUETOOTH_MAX_SERVICES_FOR_DEVICE]; /**< Use enum values in bt_service_uuid_list_t */
615 unsigned int service_name_array[BLUETOOTH_MAX_SERVICES_FOR_DEVICE];
620 * Stucture to rfcomm receive data
625 /**< the socket fd */
626 int buffer_size;/**< the length of the receive buffer */
628 /**< the receive data buffer */
629 } bluetooth_rfcomm_received_data_t;
632 * Stucture to rfcomm connection
637 /**< the socket fd */
638 int device_role;/** < Device role - RFCOMM_ROLE_SERVER or RFCOMM_ROLE_CLIENT */
639 bluetooth_device_address_t device_addr;
640 /**< device address */
641 char uuid[BLUETOOTH_UUID_STRING_MAX];
642 } bluetooth_rfcomm_connection_t;
645 * Stucture to rfcomm disconnection
649 /**< the socket fd */
650 int device_role;/** < Device role - RFCOMM_ROLE_SERVER or RFCOMM_ROLE_CLIENT */
651 bluetooth_device_address_t device_addr;
652 /**< device address */
653 char uuid[BLUETOOTH_UUID_STRING_MAX];
654 } bluetooth_rfcomm_disconnection_t;
658 /**< the socket fd */
659 bluetooth_device_address_t device_addr;
660 /**< device address */
661 } bluetooth_rfcomm_connection_request_t;
676 HDP_ROLE_SOURCE = 0x0,
682 * Stucture to HDP connected
685 const char *app_handle; /**< the application handle */
686 unsigned int channel_id; /**< the channel id */
687 bt_hdp_qos_type_t type; /**< the QOS type */
688 bluetooth_device_address_t device_address; /**< the remote address */
689 } bt_hdp_connected_t;
692 * Stucture to HDP disconnected
695 unsigned int channel_id; /**< the channel id */
696 bluetooth_device_address_t device_address; /**< the remote address */
697 } bt_hdp_disconnected_t;
700 * Stucture to HDP data indication
703 unsigned int channel_id; /**< the channel id */
704 const char *buffer; /**< the RX data buffer */
705 unsigned int size; /**< the RX data size */
709 * Stucture to OPP client transfer information
715 }bt_opc_transfer_info_t;
717 /* Obex Server transfer type */
718 #define TRANSFER_PUT "PUT"
719 #define TRANSFER_GET "GET"
721 * Stucture to OPP/FTP Server authorize information
726 } bt_obex_server_authorize_into_t;
729 * Stucture to OPP/FTP server transfer information
736 unsigned long file_size;
738 } bt_obex_server_transfer_info_t;
741 * Stucture to OOB data
745 unsigned char hash[BLUETOOTH_OOB_DATA_LENGTH];
746 unsigned char randomizer[BLUETOOTH_OOB_DATA_LENGTH];
747 unsigned int hash_len;
748 unsigned int randomizer_len;
752 * Structure to GATT attribute handle data
758 } bt_gatt_handle_info_t;
761 * Structure to GATT Remote service data
767 bt_gatt_handle_info_t handle_info;
768 } bt_gatt_service_property_t;
771 * Structure to GATT Remote characteristic data
775 char *service_handle;
776 bt_gatt_handle_info_t handle_info;
777 } bt_gatt_discovered_char_t;
780 * Structure to format of GATT Characteristic Value
784 unsigned char format;
785 unsigned char exponent;
787 unsigned char name_space;
788 unsigned short description;
789 } bt_gatt_char_format_t;
792 * Structure to GATT Characteristic property
800 bt_gatt_char_format_t format;
802 unsigned int val_len;
803 char *representation;
804 } bt_gatt_char_property_t;
807 * Structure to GATT Characteristic value
814 } bt_gatt_char_value_t;
817 * Callback pointer type
819 typedef void (*bluetooth_cb_func_ptr) (int, bluetooth_event_param_t *, void *);
822 * @fn int bluetooth_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data)
823 * @brief Set the callback function pointer for bluetooth event
826 * This API will register the callback function, when any response and event are received from
827 * bluetooth framework. @n
828 * this registered callback function will be get called with appropriate event and data structures.
829 * This function is a synchronous call. An application developer can call
830 * bluetooth_register_callback() function to register a callback function of bluetooth_cb_func_ptr
831 * type. This registered function will receive events of bluetooth_event_type_t type along with
835 * @param[in] callback_ptr A pointer to the callback function
836 * @param[in] user_data A pointer to user data
837 * @return BLUETOOTH_ERROR_NONE - Success
841 void bt_event_callback(int event, bluetooth_event_param_t *param, void *user_data)
843 GMainLoop *main_loop = (GMainLoop*) user_data;
847 // Code for each event
849 g_main_loop_quit(main_loop);
856 GMainLoop *main_loop = NULL;
859 main_loop = g_main_loop_new(NULL, FALSE);
860 ret = bluetooth_register_callback(bt_event_callback, (void*)main_loop);
861 if (ret >= BLUETOOTH_ERROR_NONE)
863 // bluetooth_register_callback returned Success
867 // bluetooth_register_callback returned failiure
869 g_main_loop_run(main_loop);
873 int bluetooth_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data);
876 * @fn int bluetooth_deregister_callback(bluetooth_cb_func_ptr callback_ptr)
877 * @brief Set the callback function pointer for bluetooth event
880 * This API will register the callback function, when any response and event are received from
881 * bluetooth framework. @n
882 * this registered callback function will be get called with appropriate event and data structures.
883 * This function is a synchronous call. An application developer can call
884 * bluetooth_register_callback() function to register a callback function of bluetooth_cb_func_ptr
885 * type. This registered function will receive events of bluetooth_event_type_t type along with
890 * @return BLUETOOTH_ERROR_NONE - Success
894 void bt_event_callback(int event, bluetooth_event_param_t *param, void *user_data)
896 GMainLoop *main_loop = (GMainLoop*) user_data;
900 // Code for each event
902 g_main_loop_quit(main_loop);
909 GMainLoop *main_loop = NULL;
912 main_loop = g_main_loop_new(NULL, FALSE);
913 ret = bluetooth_register_callback(bt_event_callback, (void*)main_loop);
914 if (ret >= BLUETOOTH_ERROR_NONE)
916 // bluetooth_register_callback returned Success
920 // bluetooth_register_callback returned failiure
922 ret = bluetooth_deregister_callback(void);
923 g_main_loop_run(main_loop);
927 int bluetooth_unregister_callback(void);
930 * @fn int bluetooth_enable_adapter(void)
931 * @brief Enable the Bluetooth H/W
934 * This API can be used to activate Bluetooth. It initializes Bluetooth protocol stack for use and
935 * send request to bluetooth chip for activation.
936 * This function is typically called at startup or when Bluetooth services are required. This
937 * function must be called before calling any other API of Bluetooth operations.
939 * Before performing any operations like Device discover, service search etc.., the adapter must be
942 * This function is a asynchronous call.
943 * If the call is success then the application will receive BLUETOOTH_EVENT_ENABLED event
944 * through registered callback function with appropriate result code
945 * BLUETOOTH_CHANGE_STATUS_TIMEOUT - Timeout has happen \n
946 * BLUETOOTH_ERROR_NONE - Success \n
948 * If the adpter is not enabled with in 30 seconds then BLUETOOTH_EVENT_ENABLED with result code
949 * BLUETOOTH_CHANGE_STATUS_TIMEOUT will come
951 * @return BLUETOOTH_ERROR_NONE - Success\n
952 * BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED - Adapter already enabled\n
953 * BLUETOOTH_ERROR_ACCESS_DENIED - Enabling adapter is not allowed by MDM policy\n
954 * BLUETOOTH_ERROR_IN_PROGRESS - Adapter is activating or deactivating\n
955 * @exception BLUETOOTH_ERROR_INTERNAL - Dbus proxy call is fail
957 * @see bluetooth_check_adapter, bluetooth_disable_adapter
959 void bt_event_callback(int event, bluetooth_event_param_t *param)
963 case BLUETOOTH_EVENT_ENABLED:
964 if (param->result == BLUETOOTH_ERROR_NONE)
966 // Successfully Enabled
979 ret = bluetooth_enable_adapter();
983 int bluetooth_enable_adapter(void);
986 * @fn int bluetooth_disable_adapter(void)
987 * @brief Disable the Bluetooth H/W
990 * This function disables Bluetooth protocol stack and hardware. This function is called when
991 * Bluetooth is no longer used. It will internally free all resources and power off the RF radio.
993 * Bluetooth adapter should be disabled to switch off Bluetooth chip (and thereby saving power).
994 * bluetooth_disable_adapter() API will do that job for you. After switching off Bluetooth,
995 * BLUETOOTH_EVENT_DISABLED will be sent by SDK to application for confirmation with appropriate
997 * The various error codes are BLUETOOTH_ERROR_NONE for success and BLUETOOTH_ERROR_INTERNAL for
1000 * This function is a asynchronous call.
1001 * If this call is success then the applications will receive BLUETOOTH_EVENT_DISABLED event
1002 * through registered callback function.
1005 * @return BLUETOOTH_ERROR_NONE - Success\n
1006 * BLUETOOTH_ERROR_IN_PROGRESS - Adapter is activating or deactivating\n
1007 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Bluetooth adapter is not enabled\n
1008 * @exception BLUETOOTH_ERROR_INTERNAL - Dbus proxy call is fail
1010 * @see bluetooth_check_adapter, bluetooth_enable_adapter
1012 void bt_event_callback(int event, bluetooth_event_param_t *param)
1016 case BLUETOOTH_EVENT_DISABLED:
1017 if (param->result == BLUETOOTH_ERROR_NONE)
1019 // Successfully disabled
1032 ret = bluetooth_disable_adapter();
1035 int bluetooth_disable_adapter(void);
1038 * @fn int bluetooth_reset_adapter(void)
1039 * @brief Reset the Bluetooth H/W and values
1042 * This function resets Bluetooth protocol stack and hardware. This function is called when
1043 * an user want to initialize Bluetooth environment.
1045 * The various error codes are BLUETOOTH_ERROR_NONE for success and BLUETOOTH_ERROR_INTERNAL for
1048 * This function is a synchronous call.
1050 * @return BLUETOOTH_ERROR_NONE - Success\n
1051 * @exception BLUETOOTH_ERROR_INTERNAL - Dbus proxy call is fail
1053 * @see bluetooth_check_adapter, bluetooth_enable_adapter
1058 ret = bluetooth_reset_adapter();
1061 int bluetooth_reset_adapter(void);
1064 * @fn int bluetooth_is_supported(void)
1065 * @brief Check if the bluetooth is supported or not by the current target
1067 * This API checks whether the bluetooth is supported or not.
1068 * This API only run by root permission.
1069 * This API was made for the MDM service.
1071 * This function is a synchronous call.
1073 * @return 0 - if bluetooth is not supported\n
1074 * 1 - if bluetooth is supported\n
1075 * BLUETOOTH_ERROR_INTERNAL - Error in API internal
1080 ret = bluetooth_is_supported();
1083 int bluetooth_is_supported(void);
1087 * @fn int bluetooth_check_adapter(void)
1088 * @brief Check the current status of the Bluetooth adapter
1091 * This API checks whether the Bluetooth adapter is enabled or not. Before performing any operations
1092 * the bluetooth adapter should be enabled. This API helps to find out the current state of the
1093 * bluetooth adapter.
1094 * This API get the adapter internal data structure and check current adapter status.
1096 * This function is a synchronous call.
1099 * @return BLUETOOTH_ADAPTER_DISABLED - if bluetooth adapter is disabled\n
1100 * BLUETOOTH_ADAPTER_ENABLED - if bluetooth adapter is enabled\n
1102 * @see bluetooth_enable_adapter, bluetooth_disable_adapter
1106 ret = bluetooth_check_adapter();
1109 int bluetooth_check_adapter(void);
1112 * @fn int bluetooth_get_local_address(bluetooth_device_address_t *local_address)
1113 * @brief Get the local adapter bluetooth address
1116 * This API is used, get the device address of the local bluetooth adapter. Before calling this API,
1117 * the adapter should be enabled.
1118 * In its output parameter, you can receive bluetooth_device_address_t type of pointer which will
1119 * contain Bluetooth address.
1120 * Since its inconvenient for user to remember the address, Bluetooth provides a method to have a
1121 * friendly name for each device.
1122 * There is no event callback for this API.
1124 * This function is a synchronous call.
1127 * @return BLUETOOTH_ERROR_NONE - Succeess \n
1128 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter (NULL buffer) \n
1129 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
1130 * @param[out] local_address a device address of local bluetooth adapter
1135 bluetooth_device_address_t local_address={0,};
1138 ret = bluetooth_get_local_address(&local_address);
1141 int bluetooth_get_local_address(bluetooth_device_address_t *local_address);
1144 * @fn int bluetooth_get_local_name(bluetooth_device_name_t* local_name)
1145 * @brief Get the local device name
1148 * This function is used, get the local device name. Since its difficult to remember the Adapter
1149 * address, the friendly name can be assigned to the adapter and we can get it using this API. This
1150 * friendly name is retrived by the remote device and displaying.
1151 * Before calling this API, the adapter should be enabled. There is no event callback for this API.
1153 * This function is a synchronous call.
1156 * @return BLUETOOTH_ERROR_NONE - Success \n
1157 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter (NULL buffer)\n
1158 * @param[out] local_name a local device name
1162 bluetooth_device_name_t local_name={0,}
1164 ret = bluetooth_get_local_name (&local_name);
1167 int bluetooth_get_local_name(bluetooth_device_name_t *local_name);
1170 * @fn int bluetooth_set_local_name(const bluetooth_device_name_t *local_name)
1171 * @brief Set the local device name
1174 * This function is used to set the local device name. This is a human friendly name whose
1175 * length can be BLUETOOTH_DEVICE_NAME_LENGTH_MAX maximum
1177 * This function is a synchronous call.
1179 * @param[in] local_name bluetooth device name to set local device
1181 * @return BLUETOOTH_ERROR_NONE - Success \n
1182 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1183 * BLUETOOTH_ERROR_INVALID_PARAM - Bluetooth name parameter is incorrect \n
1184 * BLUETOOTH_ERROR_INVALID_DATA - Device address provided is incorrect \n
1185 * BLUETOOTH_ERROR_NO_RESOURCES - Pre-allocated memory error \n
1186 * BLUETOOTH_ERROR_INTERNAL - The dbus method call is fail \n
1191 bluetooth_device_name_t local_name={0,}
1193 ret = bluetooth_set_local_name (&local_name);
1196 int bluetooth_set_local_name(const bluetooth_device_name_t *local_name);
1200 * @fn int bluetooth_is_service_used(const char *service_uuid, gboolean *used)
1201 * @brief Check if the uuid is used or not
1203 * This function is used to check if the uuid is used or not.
1205 * This function is a synchronous call.
1207 * @param[in] service_uuid service uuid (UUID 128 bit as string)
1208 * @param[out] used if the uuid is used or not
1210 * @return BLUETOOTH_ERROR_NONE - Success \n
1211 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1212 * BLUETOOTH_ERROR_INVALID_PARAM - Bluetooth name parameter is incorrect \n
1213 * BLUETOOTH_ERROR_INTERNAL - The dbus method call is fail \n
1218 gboolean used = FALSE;
1219 const char *uuid ="00001101-0000-1000-8000-00805F9B34FB";
1220 ret = bluetooth_is_service_used(uuid, &used);
1223 int bluetooth_is_service_used(const char *service_uuid, gboolean *used);
1226 * @fn int bluetooth_is_device_connected(const bluetooth_device_address_t *device_address, bluetooth_service_type_t type, gboolean *is_connected)
1227 * @brief Check if the device is connected to the specific service
1229 * This function is used to check if if the device is connected to the specific service.
1231 * This function is a synchronous call.
1233 * @param[in] local_address a device address of remote bluetooth device
1234 * @param[in] type the service type
1235 * @param[out] is_connected if the device is connected or not
1237 * @return BLUETOOTH_ERROR_NONE - Success \n
1238 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1239 * BLUETOOTH_ERROR_INVALID_PARAM - Bluetooth name parameter is incorrect \n
1240 * BLUETOOTH_ERROR_INTERNAL - The dbus method call is fail \n
1245 gboolean is_connected = FALSE;
1246 bluetooth_device_address_t device_address={{0x00,0x0D,0xFD,0x24,0x5E,0xFF}};
1247 ret = bluetooth_is_device_connected(&device_address, BLUETOOTH_HSP_SERVICE, &used);
1250 int bluetooth_is_device_connected(const bluetooth_device_address_t *device_address,
1251 bluetooth_service_type_t type,
1252 gboolean *is_connected);
1255 * @fn int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t *discoverable_mode_ptr)
1256 * @brief Get the visibility mode
1259 * This function is used to get the discoverable mode (Visibility option). Depending upon the
1260 * visibity mode, the property of the device is determined whether it can be discoverable, non
1261 * discoverable, connectable etc. Before calling this API make sure that the adapter is enabled.
1263 * This function is a synchronous call.
1266 * @return BLUETOOTH_ERROR_NONE - Success \n
1267 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1268 * BLUETOOTH_ERROR_INVALID_DATA - Invalid data \n
1269 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1270 * BLUETOOTH_ERROR_INTERNAL - Internal IPC error \n
1271 * @param[out] discoverable_mode current bluetooth discoverable mode
1273 * @see bluetooth_set_discoverable_mode
1275 bluetooth_discoverable_mode_t discoverable_mode_ptr;
1277 ret = bluetooth_get_discoverable_mode (&discoverable_mode_ptr);
1280 int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t *discoverable_mode_ptr);
1283 * @fn int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t discoverable_mode,
1285 * @brief Set the visibility mode
1288 * This function is used to set the discoverable mode (Visibility option).
1290 * Many times user may want to keep his device discoverable so that when peer device is performing
1291 * device search, he/she can find user's device. Application programmer can keep the mode as
1292 * BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE or
1293 * BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE for the same purpose. However, all these
1294 * modes cause bluetooth adapter to consume more battery. Hence developer should generally
1295 * keep discoverable mode as BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE.
1297 * This function is a synchronous call.
1299 * @return BLUETOOTH_ERROR_NONE - Success \n
1300 * BLUETOOTH_ERROR_NOT_SUPPORT - Requested mode is not supported \n
1302 * @param[in] discoverable_mode the bluetooth discoverable mode to set
1303 * @param[in] timeout discoverable time in only limited discoverable mode (second), default: 0
1305 * @see bluetooth_get_discoverable_mode
1309 bluetooth_discoverable_mode_t mode;
1311 mode= BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE;
1312 ret = bluetooth_set_discoverable_mode (mode, 180);
1316 int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t discoverable_mode,
1321 * @fn int bluetooth_get_timeout_value(int *timeout)
1322 * @brief Get the visibility timeout value
1325 * This function is used to get the visibility timeout
1326 * Before calling this API make sure that the adapter is enabled.
1328 * This function is a synchronous call.
1331 * @return BLUETOOTH_ERROR_NONE - Success \n
1332 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1333 * BLUETOOTH_ERROR_INVALID_DATA - Invalid data \n
1334 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1335 * BLUETOOTH_ERROR_INTERNAL - Internal IPC error \n
1336 * @param[out] timeout remain visibility timeout value
1338 * @see bluetooth_set_discoverable_mode
1342 ret = bluetooth_get_timeout_value (&timeout);
1345 int bluetooth_get_timeout_value(int *timeout);
1349 * @fn int bluetooth_start_discovery(unsigned short max_response, unsigned short discovery_duration,
1350 * unsigned int classOfDeviceMask)
1351 * @brief Start the device discovery
1353 * To connect connect to peer bluetooth device, you will need to know its bluetooth address and its
1354 * name. You can search for Bluetooth devices in vicinity by bluetooth_start_discovery() API. It
1355 * first performs an inquiry. For each device found from the inquiry it gets the remote name of the
1356 * device. Bluetooth device address and name are given to Application via
1357 * BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event. In param_data of bluetooth_event_param_t, you will
1358 * receive a pointer to a structure of bluetooth_device_info_t type. you will receive device
1359 * address, device name, device class, rssi (received signal strength indicator). please see
1360 * bluetooth_device_info_t for more details.
1363 * This API provides searching options like max responses, discovery duration in seconds and class
1364 * of device mask to filter device search. some times there may be too many bluetooth devices in
1365 * vicinity of your device.in such scenario, application can request to reduce number of responces
1366 * (BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event) with help of max_response parameter. However if you
1367 * pass zero, bluetooth adapter will not restrict number of responses. you can also specify duration
1368 * of the seach in discovery_duration. bluetooth adapter will automatically stop device search after
1369 * application defined time. please note that discovery_duration should be mentioned in seconds.
1370 * Also note that search will end after 180 seconds automatically if you pass 0 in discovery
1373 * sometimes user may want to search for a perticular kind of device. for ex, mobile or pc. in such
1374 * case, you can use classOfDeviceMask parameter. please see bluetooth_device_service_class_t,
1375 * bluetooth_device_major_class_t and bluetooth_device_minor_class_t enums
1377 * This function is a asynchronous call.
1378 * If the call is success then the application will receive BLUETOOTH_EVENT_DISCOVERY_STARTED event
1379 * through registered callback function.
1381 * The discovery is responded by an BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event for each device it
1382 * finds and an BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED event for each fount device its name
1385 * The completion or cancellation of the discovery is indicated by an
1386 * BLUETOOTH_EVENT_DISCOVERY_FINISHED event.
1388 * The device discovery can be cancelled by calling bluetooth_stop_discovery().
1391 * @return BLUETOOTH_ERROR_NONE - Success \n
1392 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Bluetooth adapter is not enabled \n
1393 * BLUETOOTH_ERROR_DEVICE_BUSY - Bluetooth adapter is busy doing some operation \n
1394 * BLUETOOTH_ERROR_INTERNAL - System error like heap full has occured or bluetooth
1395 agent is not running \n
1397 * @param[in] max_response define the maximum response of the number of founded devices
1399 * @param[in] discovery_duration define bluetooth discovery duration (0 means 180s )
1400 * @param[in] classOfDeviceMask define classes of the device mask which user wants
1401 (refer to class of device)
1403 * @see bluetooth_cancel_discovery, bluetooth_device_info_t
1406 void bt_event_callback(int event, bluetooth_event_param_t *param)
1410 case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
1412 bluetooth_device_info_t *device_info = NULL;
1413 printf("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]",
1415 device_info = (bluetooth_device_info_t *)param->param_data;
1416 memcpy(&searched_device, &device_info->device_address,
1417 sizeof(bluetooth_device_address_t));
1418 printf("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]",
1419 device_info->device_address.addr[0],
1420 device_info->device_address.addr[1],
1421 device_info->device_address.addr[2],
1422 device_info->device_address.addr[3],
1423 device_info->device_address.addr[4],
1424 device_info->device_address.addr[5]);
1427 case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
1429 bluetooth_device_info_t *device_info = NULL;
1430 printf("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]",
1432 device_info = (bluetooth_device_info_t *)param->param_data;
1433 memcpy(&searched_device, &device_info->device_address,
1434 sizeof(bluetooth_device_address_t));
1435 printf("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]",
1436 device_info->device_name.name,
1437 device_info->device_address.addr[0],
1438 device_info->device_address.addr[1],
1439 device_info->device_address.addr[2],
1440 device_info->device_address.addr[3],
1441 device_info->device_address.addr[4],
1442 device_info->device_address.addr[5]);
1446 case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
1447 printf("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result[0x%04x]", param->result);
1452 unsigned short max_response;
1453 unsigned short discovery_duration;
1454 unsigned classOfDeviceMask;
1458 discovery_duration =0;
1459 classOfDeviceMask =0;
1461 ret = bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);
1467 int bluetooth_start_discovery(unsigned short max_response,
1468 unsigned short discovery_duration,
1469 unsigned int classOfDeviceMask);
1472 * @fn int bluetooth_cancel_discovery (void)
1473 * @brief Cancel the on-going device discovery operation
1476 * This function stops the on-going device discovery operation. This API has to be called after the
1477 * bluetooth_start_discovery API and before the BLUETOOTH_EVENT_DISCOVERY_FINISHED event comes of
1478 * the bluetooth_start_discovery API
1480 * Normally the device discovery takes a more time (~10.24 seconds) to get all the devices in its
1481 * vicinity and it recevies as BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event. This API helps us to
1482 * cancel the discover request once the user received the device to which he wish to connect.
1484 * This function is a asynchronous call.
1485 * If the call is success to cancel discovey then the application will receive
1486 * BLUETOOTH_EVENT_DISCOVERY_FINISHED event through registered callback function
1487 * with an error code BLUETOOTH_ERROR_CANCEL. In the case of failure the error code will be
1488 * BLUETOOTH_ERROR_NONE
1491 * @return BLUETOOTH_ERROR_NONE - Success \n
1492 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1493 * BLUETOOTH_ERROR_NOT_IN_OPERATION - No Discovery operation in progess to cancel \n
1494 * BLUETOOTH_ERROR_ACCESS_DENIED - Currently in discovery but it is requested from
1495 other application \n
1496 * BLUETOOTH_ERROR_INTERNAL - Internel IPC error \n
1498 * @see bluetooth_start_discovery
1500 void bt_event_callback(int event, bluetooth_event_param_t *param)
1504 case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
1505 TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result[0x%04x]", param->result);
1514 ret = bluetooth_cancel_discovery();
1517 int bluetooth_cancel_discovery(void);
1520 * @fn int bluetooth_is_discovering(void)
1521 * @brief Check for the device discovery is in-progress or not.
1523 * This API is used to check the current status of the Discovery operation.If discovery is in\
1524 * progress normally other operations are not allowed.
1525 * If a device discovery is in progress, we have to either cancel the discovery operation or wait
1526 * for the BLUETOOTH_EVENT_DISCOVERY_FINISHED
1527 * event before performing other operations. This API is used to get for the current discovery
1528 * operation status and using bluetooth_cancel_discovery()
1529 * we can cancell the ongoing discovery process.
1530 * Before calling this API, make sure that the adapter is enabled. There is no callback event for
1533 * This function checks whether the device discovery is started or not.
1535 * This function is a synchronous call.
1538 * @return BLUETOOTH_ERROR_NONE - Discovery is not in progress \n
1539 * BLUETOOTH_ERROR_NONE+1 - Discovery in progress \n
1540 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1543 * @see bluetooth_start_discovery, bluetooth_cancel_discovery
1547 ret = bluetooth_is_discovering ();
1550 int bluetooth_is_discovering(void);
1553 * @fn int bluetooth_bond_device(const bluetooth_device_address_t *device_address)
1554 * @brief Initiate a bonding process
1557 * This function initiates a bonding procedure with a peer device. The bonding procedure
1558 * enables authentication and optionally encryption on the Bluetooth link.
1560 * Bonding is applied to the discovered device to which we need a secure connection. We cannot
1561 * inititate the bonding request to the devices already in the paired list.
1563 * Usually we call this API after the device discovery.
1564 * This function is a asynchronous call.
1566 * Response will be received through BLUETOOTH_EVENT_BONDING_FINISHED event. It can any of the below
1567 * mentioed result code
1568 * BLUETOOTH_ERROR_PARING_FAILED - Pairing faied \n
1569 * BLUETOOTH_ERROR_ACCESS_DENIED - Authetication rejected \n
1570 * BLUETOOTH_ERROR_CANCEL_BY_USER - Cancelled by the user \n
1571 * BLUETOOTH_ERROR_PARING_FAILED - Pairing failed \n
1572 * BLUETOOTH_ERROR_TIMEOUT - Timeout has haapened \n
1574 * If the remote user is not responding with in a specific time(60 seconds), then a timeout happens
1575 * and BLUETOOTH_EVENT_BONDING_FINISHED callback event is called with and BLUETOOTH_ERROR_TIMEOUT
1578 * The bonding operation can be cancelled by calling bluetooth_cancel_bonding().
1581 * @return BLUETOOTH_ERROR_NONE - Success \n
1582 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
1583 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1584 * BLUETOOTH_ERROR_DEVICE_BUSY - Adapter is busy or Discovery is in Progress \n
1585 * BLUETOOTH_ERROR_INVALID_DATA - Invalid BD address \n
1587 * @param[in] device_address This indicates an address of the device with which the pairing
1588 * should be initiated
1590 * @see bluetooth_cancel_bonding
1592 void bt_event_callback(int event, bluetooth_event_param_t *param)
1596 case BLUETOOTH_EVENT_BONDING_FINISHED:
1598 TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
1599 if (param->result >= BLUETOOTH_ERROR_NONE)
1601 bluetooth_device_info_t *device_info = NULL;
1602 device_info = (bluetooth_device_info_t *)param->param_data;
1603 printf("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]
1604 mjr[%#x] min[%#x] srv[%#x]",
1605 device_info->device_name.name,
1606 device_info->device_address.addr[0],
1607 device_info->device_address.addr[1],
1608 device_info->device_address.addr[2],
1609 device_info->device_address.addr[3],
1610 device_info->device_address.addr[4],
1611 device_info->device_address.addr[5],
1612 device_info->device_class.major_class,
1613 device_info->device_class.minor_class,
1614 device_info->device_class.service_class);
1628 bluetooth_device_address_t device_address={{0}};
1630 ret = bluetooth_bond_device(&device_address);
1634 int bluetooth_bond_device(const bluetooth_device_address_t *device_address);
1637 * @fn int bluetooth_cancel_bonding(void)
1638 * @brief Cancel the on-going bonding process
1640 * This API is called to cancel the on-going bonding procedure. It should be called before the
1641 * BLUETOOTH_EVENT_BONDING_FINISHED event comes.
1642 * This API is useful when the remote device is not responding to the bond request or we wish to
1643 * cancel the bonding request. In this case we need not wait for the timeout to happen.
1645 * This function is a synchronous call.
1647 * @return BLUETOOTH_ERROR_NONE - Success \n
1648 * BLUETOOTH_ERROR_NOT_IN_OPERATION - No bonding request in progress \n
1649 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1652 * @see bluetooth_bond_device
1658 ret = bluetooth_cancel_bonding();
1661 int bluetooth_cancel_bonding(void);
1664 * @fn int bluetooth_unbond_device(const bluetooth_device_address_t *device_address)
1665 * @brief Remove bonding
1668 * To communicate with remote device over bluetooth link, user should bond with peer device.
1669 * After bonding is over, peer device is added to list of bonded devices. bluetooth_unbond_device()
1670 * API is used to remove peer device from the list. Please note that after removing the device
1671 * from bonded device list, you cannot communication with peer device until bonding happens again.
1673 * User can call this function by passing bluetooth device address of any bonded device. Please note
1674 * that after successful return of this function, any bluetooth application running on your device
1675 * will not be able to communicate with unbonded device until bond operation happens again using
1676 * bluetooth_bond_device()
1679 * This function is a asynchronous call. The request to remove the specified device from the bonded
1680 * list is responded by an BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED event. if the operation is success,
1681 * you will receive BLUETOOTH_ERROR_NONE. BLUETOOTH_ERROR_NOT_PAIRED may be received in result code
1682 * in case if there is a problem in locating given bluetooth device address in bonded devices list
1686 * @return BLUETOOTH_ERROR_NONE - Success \n
1687 * BLUETOOTH_ERROR_INVALID_PARAM - Device address is not valid \n
1688 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Bluetooth adapter is not enabled \n
1689 * BLUETOOTH_ERROR_DEVICE_BUSY - Bluetooth adapter is busy doing some operation \n
1690 * BLUETOOTH_ERROR_INVALID_DATA - Device address provided is incorrect \n
1691 * BLUETOOTH_ERROR_INTERNAL - System error like heap full has occured or bluetooth
1692 * agent is not running \n
1693 * BLUETOOTH_ERROR_NOT_PAIRED - Device address mentioned in the argument is not a
1696 * @param[in] device_address This indicates an address of the device to remove bonding
1700 * @see bluetooth_bond_device, bluetooth_cancel_bonding
1703 void bt_event_callback(int event, bluetooth_event_param_t *param)
1706 case BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED: {
1707 bluetooth_device_address_t *dev_addr = NULL;
1709 if (param->result == BLUETOOTH_ERROR_NONE) {
1710 dev_addr = (bluetooth_device_address_t *)param->param_data;
1712 printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
1713 dev_addr->addr[0], dev_addr->addr[1]
1714 dev_addr->addr[2], dev_addr->addr[3]
1715 dev_addr->addr[4], dev_addr->addr[5]
1726 bluetooth_device_address_t *device_address;
1728 // copy valid device address in device_address
1730 ret = bluetooth_unbond_device(device_address);
1733 int bluetooth_unbond_device(const bluetooth_device_address_t *device_address);
1736 * @fn int bluetooth_get_bonded_device_list(GPtrArray **dev_list)
1737 * @brief Get bonded(paired) device list
1740 * This API gets all bonded device list.
1741 * The devices in the bonded device list further can be used to perform the authorization by calling
1742 * bluetooth_authorize_device API.
1744 * This function is a synchronous call.
1745 * Information for bonded devices can be obtained when result code is BLUETOOTH_ERROR_NONE. If not,
1746 * there is no valid information in the dev_list.
1747 * The len field in the dev_list represents the number of bonded devices. The data structure for
1748 * bonded device information is bluetooth_device_info_t.
1751 * @return BLUETOOTH_ERROR_NONE - Success \n
1752 * BLUETOOTH_ERROR_NOT_SUPPORT - Opreation not supported \n
1754 * @see bluetooth_bond_device, bluetooth_unbond_device, bluetooth_authorize_device
1756 void bt_get_bonded_devices(void)
1760 GPtrArray *devinfo = NULL;
1761 bluetooth_device_info_t *ptr;
1763 // allocate the g_pointer_array
1764 devinfo = g_ptr_array_new();
1766 ret = bluetooth_get_bonded_device_list(&devinfo);
1767 if (ret != BLUETOOTH_ERROR_NONE)
1769 printf("bluetooth_get_bonded_device_list failed with [%d]",ret);
1773 printf("g pointer arrary count : [%d]", devinfo->len);
1774 for (i=0; i<devinfo->len; i++)
1776 ptr = g_ptr_array_index(devinfo, i);
1779 printf("Name [%s]\n", ptr->device_name.name);
1780 printf("Major Class [%d]\n", ptr->device_class.major_class);
1781 printf("Minor Class [%d]\n", ptr->device_class.minor_class);
1782 printf("Service Class [%d]\n", ptr->device_class.service_class);
1783 printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
1784 ptr->device_address.addr[0],
1785 ptr->device_address.addr[1], ptr->device_address.addr[2],
1786 ptr->device_address.addr[3],
1787 ptr->device_address.addr[4], ptr->device_address.addr[5]);
1794 // free g_pointer_array
1795 g_ptr_array_free(devinfo, TRUE);
1800 int bluetooth_get_bonded_device_list(GPtrArray **dev_list);
1803 * @fn int bluetooth_get_bonded_device(const bluetooth_device_address_t *device_address,
1804 * bluetooth_device_info_t *dev_info)
1805 * @brief Get a bonded(paired) device
1808 * This API gets a bonded device.
1810 * This function is a synchronous call.
1811 * Information for bonded devices can be obtained when result code is BLUETOOTH_ERROR_NONE. If not,
1812 * there is no valid information in the dev_info.
1813 * The data structure for bonded device information is bluetooth_device_info_t.
1816 * @return BLUETOOTH_ERROR_NONE - Success \n
1817 * BLUETOOTH_ERROR_NOT_SUPPORT - Opreation not supported \n
1819 * @see bluetooth_bond_device, bluetooth_unbond_device, bluetooth_authorize_device
1821 void bt_get_bonded_device(void)
1825 bluetooth_device_info_t devinfo = {0};
1826 bluetooth_device_address_t device_address={{0x00,0x1C,0x43,0x2B,0x1A,0xE5}};
1828 ret = bluetooth_get_bonded_device(&device_address, &devinfo);
1829 if (ret != BLUETOOTH_ERROR_NONE)
1831 printf("bluetooth_get_bonded_device failed with [%d]",ret);
1835 printf("Name [%s]\n", devinfo.device_name.name);
1836 printf("Major Class [%d]\n", devinfo.device_class.major_class);
1837 printf("Minor Class [%d]\n", devinfo.device_class.minor_class);
1838 printf("Service Class [%d]\n", devinfo.device_class.service_class);
1839 printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", devinfo.device_address.addr[0],
1840 devinfo.device_address.addr[1], devinfo.device_address.addr[2],
1841 devinfo.device_address.addr[3], devinfo.device_address.addr[4],
1842 devinfo.device_address.addr[5]);
1851 int bluetooth_get_bonded_device(const bluetooth_device_address_t *device_address,
1852 bluetooth_device_info_t *dev_info);
1855 * @fn int bluetooth_set_alias(const bluetooth_device_address_t *device_address, const char *alias)
1856 * @brief set alias for bonded device
1859 * This function set alias for bonded device.
1861 * This function is a synchronous call.
1864 * @return BLUETOOTH_ERROR_NONE - Success \n
1865 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
1866 * @param[in] device_address This indicates an address of the remote device
1867 * @param[in] alias This indicates an alias to set
1872 ret = bluetooth_set_alias(&remote_address);
1875 int bluetooth_set_alias(const bluetooth_device_address_t *device_address,
1879 * @fn int bluetooth_get_remote_device(const bluetooth_device_address_t *device_address)
1880 * @brief Get remote deivice
1883 * This function gets specific remote device.
1885 * This function is a asynchronous call.
1886 * This API is responded by an BLUETOOTH_EVENT_REMOTE_DEVICE_READ event.
1889 * @return BLUETOOTH_ERROR_NONE - Success \n
1890 * BLUETOOTH_ERROR_NOT_SUPPORT - Operation not supported \n
1891 * @param[in] device_address This indicates an address of the remote device
1896 ret = bluetooth_get_remote_device(&remote_address);
1899 int bluetooth_get_remote_device(const bluetooth_device_address_t *device_address);
1902 * @fn int bluetooth_authorize_device(const bluetooth_device_address_t *device_address,
1903 * gboolean authorized)
1904 * @brief Authorize/Unauthorize a bonded device
1907 * This function authorizes/unauthorize a bonded device. It decides the device to connect
1908 * with/without user confirmation.
1910 * If we select a paired device and make it authorized by calling this API with the authorized
1911 * parameter to TRUE, then it will not ask for the user conformation before connecting. Similarly
1912 * if we unauthorize the paired device by calling this API with the authorized parameter to FALSE,
1913 * then it will ask for the user conformation before the connection.
1915 * This API supposed to be called on the paired devices. Which means we have to use this API only
1916 * after successful pairing.
1918 * This function is a asynchronous call.
1919 * Response will be received through BLUETOOTH_EVENT_DEVICE_AUTHORIZED event.
1921 * @return BLUETOOTH_ERROR_NONE - Success \n
1922 * @exception BLUETOOTH_ERROR_INTERNAL - Cannot get the interal DBUS proxy \n
1923 * @param[in] device_address This indicates an address of the device to authorize \n
1924 * @param[in] authorized TRUE : authorize FALSE: unauthorize
1926 * @see bluetooth_get_bonded_device_list
1928 void bt_event_callback(int event, bluetooth_event_param_t *param)
1932 case BLUETOOTH_EVENT_DEVICE_AUTHORIZED :
1934 if (param->result == BLUETOOTH_ERROR_NONE)
1938 //device authorization failed failure
1946 bluetooth_device_address_t device_address={{0}};
1947 gboolean authorized;
1951 ret = bluetooth_authorize_device(&device_address,authorized);
1954 int bluetooth_authorize_device(const bluetooth_device_address_t *device_address,
1955 gboolean authorized);
1958 * @fn int bluetooth_search_service(const bluetooth_device_address_t *device_address)
1959 * @brief Get all services supported by remote device
1962 * This API call initiates the search for the services supported by the specified device. Normally
1963 * the service search will take a couple of seconds to get it completed. Before calling this API
1964 * make sure that the Adapter is enabled. We have to give the device address of the remote device to
1965 * perform the service search. We can get the device address by doing a device discovery operation.
1968 * This function is a asynchronous call.
1969 * The service search request is responded by BLUETOOTH_EVENT_SERVICE_SEARCHED event.
1971 * There is a timeout associated with the service search. The default time out is 40 seconds. If the
1972 * remove device did not respond with in the time out period the BLUETOOTH_EVENT_SERVICE_SEARCHED
1973 * event is generated with appropriate result code.
1975 * @return BLUETOOTH_ERROR_NONE - Success \n
1976 * BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR - Service search error (NULL device address) \n
1977 * BLUETOOTH_ERROR_INTERNAL - Internal IPC error \n
1978 * @param[in] device_address This indicates an address of the device
1979 * whose services need to be found
1981 * @see bluetooth_cancel_service_search
1983 int bluetooth_search_service(const bluetooth_device_address_t *device_address);
1986 * @fn int bluetooth_cancel_service_search(void)
1987 * @brief Cancel the ongoing service search operation
1990 * This function cancel the ongoing service search operation. This API is usually calling after the
1991 * bluetooth_search_service API.
1992 * Normally service search will take a more time (> 5 seconds) to complete. This API will be called
1993 * if the user wish to cancel the Ongoing service search operation.
1995 * This API should be called just after the bluetooth_search_service API and before the
1996 * BLUETOOTH_EVENT_SERVICE_SEARCHED event
1998 * This function is a synchronous call.
2000 * @return BLUETOOTH_ERROR_NONE - Success \n
2001 * BLUETOOTH_ERROR_CANCEL - Error in service search cancel operation \n
2002 * BLUETOOTH_ERROR_NOT_PAIRED - Not paired device \n
2003 * BLUETOOTH_ERROR_NOT_IN_OPERATION - Searching service is not in operation \n
2006 * @see bluetooth_search_service
2011 ret = bluetooth_cancel_service_search();
2014 int bluetooth_cancel_service_search(void);
2017 * @fn int bluetooth_rfcomm_create_socket(const char *uuid)
2018 * @brief Register rfcomm socket with a specific uuid
2021 * This API register rfcomm socket with the given UUID. The return value of this API is the socket
2022 * descriptor of the server.
2023 * This is the first API which is called to create the server. Once we created the server socket,
2024 * we will listen on that return socket.
2025 * So a bluetooth_rfcomm_listen_and_accept should follow this API call. This is a synchronous call.
2028 * @return socket FD on Success \n
2029 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2030 * BLUETOOTH_ERROR_INTERNAL - Internal error\n
2031 * BLUETOOTH_ERROR_MAX_CONNECTION - Maximum connection reached\n
2032 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2033 * @param[in] UUID (128 bits)
2036 * @see bluetooth_rfcomm_listen_and_accept, bluetooth_rfcomm_remove_socket
2040 const char *rfcomm_test_uuid="00001101-0000-1000-8000-00805F9B34FB";
2041 fd = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
2045 int bluetooth_rfcomm_create_socket(const char *uuid);
2048 * @fn int bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid)
2049 * @brief De-register the rfcomm socket
2052 * This API deregister rfcomm socket with the given socket fd and UUID. If the remote device is
2053 * already connected then we will receive the BLUETOOTH_EVENT_RFCOMM_DISCONNECTED with socket
2054 * descriptor else no event will come. We will call this API only after the
2055 * bluetooth_rfcomm_listen_and_accept.
2056 * This is a synchronous call.
2058 * @return BLUETOOTH_ERROR_NONE - Success \n
2059 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2060 * BLUETOOTH_ERROR_NOT_FOUND - Cannot find the proxy\n
2061 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2062 * @param[in] int socket_fd
2065 * @see bluetooth_rfcomm_create_socket, bluetooth_rfcomm_listen_and_accept
2068 void bt_event_callback(int event, bluetooth_event_param_t *param)
2072 case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED:
2074 bluetooth_rfcomm_connection_t *discon_ind =
2075 (bluetooth_rfcomm_connection_t *)param->param_data;
2077 printf("\nDisconnected from FD %d", discon_ind->socket_fd);
2085 fd = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
2086 ret = bluetooth_rfcomm_listen_and_accept(fd, 1);
2088 ret = bluetooth_rfcomm_remove_socket(fd);
2091 int bluetooth_rfcomm_remove_socket(int socket_fd);
2094 * @fn int bluetooth_rfcomm_server_disconnect(int socket_fd)
2095 * @brief Disconnect rfcomm connection
2098 * Disconnect a specific(device node fd) RFCOMM connection. This is a Synchronous call and there
2099 * is no cabbback events for this API. We have to provice the valid client fd to disconnect from the
2102 * @return BLUETOOTH_ERROR_NONE - Success \n
2103 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2104 * BLUETOOTH_ERROR_NOT_CONNECTED - Not connected \n
2105 * @param[in] int socket_fd the sending socket fd
2111 ret = bluetooth_rfcomm_server_disconnect(g_ret_fd);
2113 printf("Disconnection failed");
2115 printf("Disconnection Success");
2119 int bluetooth_rfcomm_server_disconnect(int socket_fd);
2122 * @fn int bluetooth_rfcomm_listen_and_accept(int socket_fd,int max_pending_connection)
2123 * @brief Rfcomm socket listen
2126 * This API make rfcomm socket listen and accept with socket. We will call this API immediatly
2127 * after the bluetooth_rfcomm_create_socket API.
2128 * This API listen for the incomming connection and once it receives a connection, it will give
2129 * BLUETOOTH_EVENT_RFCOMM_CONNECTED
2130 * event to the application. This is an Asynchronous API call.
2133 * @return BLUETOOTH_ERROR_NONE - Success \n
2134 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2135 * BLUETOOTH_ERROR_CONNECTION_ERROR - Listen failed \n
2137 * @param[in] int socket_fd
2138 * @param[in] max pending connection.
2141 * @see bluetooth_rfcomm_create_socket
2144 void bt_event_callback(int event, bluetooth_event_param_t* param)
2148 case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
2150 bluetooth_rfcomm_connection_t *conn_ind =
2151 (bluetooth_rfcomm_connection_t *)param->param_data;
2153 printf("\nConnected from FD %d", conn_ind->socket_fd);
2161 fd = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
2162 ret = bluetooth_rfcomm_listen_and_accept(fd, 1);
2166 int bluetooth_rfcomm_listen_and_accept(int socket_fd, int max_pending_connection);
2169 * @fn int bluetooth_rfcomm_listen(int socket_fd,int max_pending_connection)
2170 * @brief Rfcomm socket listen
2173 * This API make rfcomm socket listen and accept with socket. We will call this API immediatly
2174 * after the bluetooth_rfcomm_create_socket API.
2175 * This API listen for the incomming connection and once it receives a connection, it will give
2176 * BLUETOOTH_EVENT_RFCOMM_AUTHORIZE
2177 * event to the application. This is an Asynchronous API call.
2180 * @return BLUETOOTH_ERROR_NONE - Success \n
2181 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2182 * BLUETOOTH_ERROR_CONNECTION_ERROR - Listen failed \n
2184 * @param[in] int socket_fd
2185 * @param[in] max pending connection.
2188 * @see bluetooth_rfcomm_create_socket
2191 void bt_event_callback(int event, bluetooth_event_param_t* param)
2195 case BLUETOOTH_EVENT_RFCOMM_AUTHORIZE:
2197 char *name = (char *)param->param_data;
2199 printf("\nConnected from %s", name);
2201 bluetooth_rfcomm_accept_connection();
2209 fd = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
2210 ret = bluetooth_rfcomm_listen(fd, 1);
2214 int bluetooth_rfcomm_listen(int socket_fd, int max_pending_connection);
2217 * @fn int bluetooth_rfcomm_accept_connection()
2218 * @brief Accepts the authorization request indicated by the event
2219 * BLUETOOTH_EVENT_RFCOMM_AUTHORIZE.
2221 * This function is a synchronous call.
2223 * @return BLUETOOTH_ERROR_NONE - Success \n
2224 * BLUETOOTH_ERROR_INTERNAL - Internal error \n
2226 * @param[in] the socket fd of the server
2227 * @param[out] the socket fd of the client
2231 * @see bluetooth_rfcomm_reject_connection
2233 int bluetooth_rfcomm_accept_connection(int server_fd, int *client_fd);
2236 * @fn int bluetooth_rfcomm_reject_connection()
2237 * @brief Rejects the authorization request indicated by the event
2238 * BLUETOOTH_EVENT_RFCOMM_AUTHORIZE.
2240 * This function is a synchronous call.
2242 * @return BLUETOOTH_ERROR_NONE - Success \n
2243 * BLUETOOTH_ERROR_INTERNAL - Internal error \n
2245 * @param[in] the socket fd of the server
2249 * @see bluetooth_rfcomm_accept_connection
2251 int bluetooth_rfcomm_reject_connection(int server_fd);
2254 * @fn gboolean bluetooth_rfcomm_is_server_uuid_available(const char *uuid)
2255 * @brief Informs whether rfcomm server uuid is available or not.
2257 * This function is a synchronous call.
2259 * @return TRUE - RFCOMM uuid is available \n
2260 * FALSE - RFCOMM uuid is not available \n
2262 * @param[in] uuid UUID string
2268 gboolean bluetooth_rfcomm_is_server_uuid_available(const char *uuid);
2271 * @fn int bluetooth_rfcomm_connect(const bluetooth_device_address_t *remote_bt_address,
2272 * const char *remote_uuid)
2273 * @brief Connect to the remote device rfcomm *
2275 * Connect to a specific RFCOMM based service on a remote device UUID. This is a Async call. Once
2276 * the connection is successful callback BLUETOOTH_EVENT_RFCOMM_CONNECTED events is generated,
2277 * which contains the socket_fd, device role (RFCOMM_ROLE_SERVER/RFCOMM_ROLE_CLIENT), device addess
2278 * etc. The socket_fd can be further used to send the data. It better to do a sevice search before
2279 * initiating a connection.
2281 * @return BLUETOOTH_ERROR_NONE - Success \n
2282 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2283 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2284 * BLUETOOTH_ERROR_CONNECTION_BUSY - Connection in progress \n
2285 * BLUETOOTH_ERROR_INTERNAL - Internal Error\n
2286 * @param[in] bluetooth_device_address_t remote bt_address
2287 * @param[in] char remote uuid
2289 * @see bluetooth_rfcomm_disconnect, bluetooth_rfcomm_write, bluetooth_search_service
2293 void bt_event_callback(int event, bluetooth_event_param_t *param)
2297 case BLUETOOTH_EVENT_SERVICE_SEARCHED:
2299 if (param->result >= BLUETOOTH_ERROR_NONE)
2301 bt_sdp_info_t *bt_sdp_info=param->param_data;
2303 printf("Dev add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
2304 bt_sdp_info->device_addr.addr[0],
2305 bt_sdp_info->device_addr.addr[1],
2306 bt_sdp_info->device_addr.addr[2],
2307 bt_sdp_info->device_addr.addr[3],
2308 bt_sdp_info->device_addr.addr[4],
2309 bt_sdp_info->device_addr.addr[5]);
2311 printf("Supported service list:\n");
2312 for(i=0; i<bt_sdp_info->service_index; i++)
2314 bt_sdp_info->service_list_array[i]);
2317 //ret = bluetooth_rfcomm_connect(bt_sdp_info->device_addr,
2318 //rfcomm_test_uuid);
2322 case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
2324 bluetooth_rfcomm_connection_t *conn_ind =
2325 (bluetooth_rfcomm_connection_t *)param->param_data;
2327 printf("\nConnected from FD %d, Role = %s", conn_ind->socket_fd,
2328 (conn_ind->device_role == RFCOMM_ROLE_SERVER) ?
2329 "SERVER" : "CLIENT");
2334 bluetooth_device_address_t remote_address = {{0},};
2335 remote_address.addr[0] = 0x0; remote_address.addr[1] = 0x0A; remote_address.addr[2] = 0x3A;
2336 remote_address.addr[3]= 0x54; remote_address.addr[4] = 0x19; remote_address.addr[5]= 0x36;
2337 ret = bluetooth_search_service(&remote_address);
2339 printf("Seach failed, Reason = %d", ret);
2341 printf("Search Success, Ret = %d", ret);
2343 ret = bluetooth_rfcomm_connect(&remote_address, rfcomm_test_uuid);
2345 printf("Connection failed, Reason = %d", ret);
2347 printf("Connection Success, Ret = %d", ret);
2351 int bluetooth_rfcomm_connect(const bluetooth_device_address_t *remote_bt_address,
2352 const char *remote_uuid);
2355 * @fn int bluetooth_rfcomm_disconnect(int socket_fd)
2356 * @brief Disconnect rfcomm connection
2359 * Disconnect a specific(device node fd) RFCOMM connection. This is a Synchronous call and there
2360 * is no cabbback events for this API. We have to provice the valid client fd to disconnect from the
2363 * @return BLUETOOTH_ERROR_NONE - Success \n
2364 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2365 * BLUETOOTH_ERROR_NOT_CONNECTED - Not connected \n
2366 * @param[in] char remote bt_address
2369 * @see bluetooth_rfcomm_connect
2373 ret = bluetooth_rfcomm_disconnect(g_ret_fd);
2375 printf("Disconnection failed");
2377 printf("Disconnection Success");
2382 int bluetooth_rfcomm_disconnect(int socket_fd);
2385 * @fn int bluetooth_rfcomm_write (int fd, const char *buff, int length)
2386 * @brief Write to rfcomm connection
2389 * This API is used to send the data over the rfcomm connection. This is a synchronous API. The same
2390 * API is used to send the data for server and the client.
2392 * @return BLUETOOTH_ERROR_NONE - Success \n
2393 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2394 * BLUETOOTH_ERROR_NOT_IN_OPERATION - The Fd is currently not in operation\n
2396 * @param[in] const char *buff Data buffer to send
2397 * @param[in] int length Length of the data
2400 * @see bluetooth_rfcomm_connect
2403 char *buff = "Test data 123456789"
2404 ret = bluetooth_rfcomm_write(g_ret_fd, buff, 15);
2406 printf("Send failed");
2408 printf("Send success");
2412 int bluetooth_rfcomm_write(int fd, const char *buf, int length);
2415 * @fn gboolean bluetooth_rfcomm_is_client_connected(void)
2416 * @brief Informs whether rfcomm client is connected.
2418 * This function is a synchronous call.
2420 * @return TRUE - RFCOMM client is connected \n
2421 * FALSE - RFCOMM client is not connected \n
2427 gboolean bluetooth_rfcomm_is_client_connected(void);
2430 * @fn int bluetooth_network_activate_server(void)
2431 * @brief Activate the NAP (Network Access Point) service
2433 * This function is a asynchronous call.
2434 * The activate server request is responded by BLUETOOTH_EVENT_NETWORK_SERVER_ACTIVATED event.
2436 * @return BLUETOOTH_ERROR_NONE - Success \n
2437 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2438 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2439 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2442 * @see bluetooth_network_deactivate_server
2445 int bluetooth_network_activate_server(void);
2448 * @fn int bluetooth_network_deactivate_server(void)
2449 * @brief Deactivate the NAP (Network Access Point) service
2451 * This function is a asynchronous call.
2452 * The deactivate server request is responded by BLUETOOTH_EVENT_NETWORK_SERVER_DEACTIVATED event.
2454 * @return BLUETOOTH_ERROR_NONE - Success \n
2455 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2456 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2457 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2460 * @see bluetooth_network_activate_server
2463 int bluetooth_network_deactivate_server(void);
2466 * @fn int bluetooth_network_connect(const bluetooth_device_address_t *device_address,
2467 * bluetooth_network_role_t role,
2469 * @brief Connect the network server in the peer
2471 * This function is a asynchronous call.
2472 * The network connect request is responded by BLUETOOTH_EVENT_NETWORK_CONNECTED event.
2474 * @return BLUETOOTH_ERROR_NONE - Success \n
2475 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2476 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2477 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2480 * @param[in] device_address This indicates an address of the device with which the pairing
2481 * should be initiated
2482 * @param[in] role The role to connect. PANU / GN / NAP / CUSTOM. If use the CUSTOM value,
2483 * need to use the third parameter.
2484 * @param[in] custom_uuid If use the CUSTOM value in second parameter, use this parameter to
2485 * connect. UUID string
2487 * @see bluetooth_network_disconnect
2489 int bluetooth_network_connect(const bluetooth_device_address_t *device_address,
2490 bluetooth_network_role_t role, char *custom_uuid);
2493 * @fn int bluetooth_network_disconnect(const bluetooth_device_address_t *device_address,
2494 * bluetooth_network_role_t role,
2495 * char *custom_uuid)
2496 * @brief Connect the network server in the peer
2498 * This function is a asynchronous call.
2499 * The network disconnect request is responded by BLUETOOTH_EVENT_NETWORK_CONNECTED event.
2501 * @return BLUETOOTH_ERROR_NONE - Success \n
2502 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2503 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2504 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2507 * @param[in] device_address This indicates an address of the device with which the pairing
2508 * should be initiated
2510 * @see bluetooth_network_connect
2512 int bluetooth_network_disconnect(const bluetooth_device_address_t *device_address);
2517 * @fn int bluetooth_hdp_activate(unsigned short data_type,
2518 * bt_hdp_role_type_t role,
2519 * bt_hdp_qos_type_t channel_type,
2520 * char **app_handle)
2521 * @brief Activate the HDP service for a particular data type
2523 * This function is a synchronous call.
2525 * @return BLUETOOTH_ERROR_NONE - Success \n
2526 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2527 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2528 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2531 * @param[in] data_type The data type against corresponding service
2532 * @param[in] role The role of HDP. HDP_ROLE_SOURCE/HDP_ROLE_SINK.
2533 * @param[in] channel_type The QOS type for the channel.
2534 * HDP_QOS_RELIABLE/HDP_QOS_STREAMING/HDP_QOS_ANY.
2535 * For role = HDP_ROLE_SINK, the channel_type
2536 * should be HDP_QOS_ANY.
2537 * @param[out] app_handle The application handler against corresponding service
2539 * @see bluetooth_hdp_deactivate
2541 int bluetooth_hdp_activate(unsigned short data_type,
2542 bt_hdp_role_type_t role,
2543 bt_hdp_qos_type_t channel_type,
2546 * @fn int bluetooth_hdp_deactivate(const char *app_handle)
2547 * @brief Deactivate the HDP service for a particular service using the handler
2549 * This function is a synchronous call.
2551 * @return BLUETOOTH_ERROR_NONE - Success \n
2552 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2553 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2554 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2557 * @param[in] app_handle The application handler against corresponding service
2559 * @see bluetooth_hdp_deactivate
2561 int bluetooth_hdp_deactivate(const char *app_handle);
2564 * @fn int bluetooth_hdp_send_data(unsigned int channel_id,
2565 * const char *buffer, unsigned int size)
2566 * @brief Send data to the remote HDP device
2568 * This function is a synchronous call.
2570 * @return BLUETOOTH_ERROR_NONE - Success \n
2571 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2572 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2573 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2574 * BLUETOOTH_ERROR_NOT_IN_OPERATION - FD is invalid \n
2577 * @param[in] channel_id The channel id for the connection.
2578 * @param[in] buffer The pdu buffer.
2579 * @param[in] size Size of the buffer.
2581 * @see bluetooth_hdp_connect
2583 int bluetooth_hdp_send_data(unsigned int channel_id,
2584 const char *buffer, unsigned int size);
2586 * @fn int bluetooth_hdp_connect(const char *app_handle,
2587 * bt_hdp_qos_type_t channel_type,
2588 * const bluetooth_device_address_t *device_address)
2589 * @brief Connect to the remote device(Mainly used by source)
2591 * This function is a asynchronous call.
2592 * The HDP activate is responded by BLUETOOTH_EVENT_HDP_CONNECTED event.
2594 * @return BLUETOOTH_ERROR_NONE - Success \n
2595 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2596 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2597 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2598 * BLUETOOTH_ERROR_MEMORY_ALLOCATION -Memory allocation failed \n
2601 * @param[in] app_handle The application handler against corresponding service
2602 * @param[in] channel_type The QOS type for the channel.
2603 * HDP_QOS_RELIABLE/HDP_QOS_STREAMING.
2604 * @param[in] device_address The remote device Bd address.
2607 * @see bluetooth_hdp_disconnect
2609 int bluetooth_hdp_connect(const char *app_handle,
2610 bt_hdp_qos_type_t channel_type,
2611 const bluetooth_device_address_t *device_address);
2613 * @fn int bluetooth_hdp_disconnect(unsigned int channel_id,
2614 * const bluetooth_device_address_t *device_address)
2615 * @brief Disconnect from the remote device(Mainly used by source)
2617 * This function is a asynchronous call.
2618 * The HDP activate is responded by BLUETOOTH_EVENT_HDP_DISCONNECTED event.
2620 * @return BLUETOOTH_ERROR_NONE - Success \n
2621 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2622 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2623 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2624 * BLUETOOTH_ERROR_MEMORY_ALLOCATION -Memory allocation failed \n
2627 * @param[in] channel_id The channel id for the connection.
2628 * @param[in] device_address The remote device Bd address.
2631 * @see bluetooth_hdp_connect
2633 int bluetooth_hdp_disconnect(unsigned int channel_id,
2634 const bluetooth_device_address_t *device_address);
2638 * @fn int bluetooth_opc_init(void)
2639 * @brief Initialize OPP client.
2641 * This function is a synchronous call.
2642 * No event corresponding to this api
2644 * @return BLUETOOTH_ERROR_NONE - Success \n
2645 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2646 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2647 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2648 * BLUETOOTH_ERROR_ACCESS_DENIED -Memory allocation failed \n
2653 * @see bluetooth_opc_deinit
2655 int bluetooth_opc_init(void);
2658 * @fn int bluetooth_opc_deinit(void)
2659 * @brief Deinitialize OPP client.
2661 * This function is a synchronous call.
2662 * No event corresponding to this api
2664 * @return BLUETOOTH_ERROR_NONE - Success \n
2665 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2666 * BLUETOOTH_ERROR_ACCESS_DENIED -Memory allocation failed \n
2671 * @see bluetooth_opc_init
2674 int bluetooth_opc_deinit(void);
2677 * @fn int bluetooth_opc_push_files(bluetooth_device_address_t *remote_address,
2678 char **file_name_array)
2679 * @brief Send multiple files to a remote device.
2681 * This function is a asynchronous call.
2682 * This api is responded by BLUETOOTH_EVENT_OPC_CONNECTED event.
2684 * @return BLUETOOTH_ERROR_NONE - Success \n
2685 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2686 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2687 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2688 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2689 * BLUETOOTH_ERROR_IN_PROGRESS -Already one push in progress \n
2690 * BLUETOOTH_ERROR_ACCESS_DENIED - Not allowed by MDM policy \n
2693 * @param[in] device_address The remote device Bd address.
2694 * @param[in] file_name_array Array of filepaths to be sent.
2697 * @see bluetooth_opc_cancel_push
2700 int bluetooth_opc_push_files(bluetooth_device_address_t *remote_address,
2701 char **file_name_array);
2704 * @fn int bluetooth_opc_cancel_push(void)
2705 * @brief Cancels the ongoing file push.
2707 * This function is a asynchronous call.
2708 * This api is responded with either BLUETOOTH_EVENT_OPC_CONNECTED or
2709 * BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETED event.
2711 * @return BLUETOOTH_ERROR_NONE - Success \n
2712 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2713 * BLUETOOTH_ERROR_ACCESS_DENIED - No push in progress \n
2718 * @see bluetooth_opc_push_files
2721 int bluetooth_opc_cancel_push(void);
2724 * @fn gboolean bluetooth_opc_session_is_exist(void)
2725 * @brief Informs whether opc session exists or not.
2727 * This function is a synchronous call.
2729 * @return TRUE - OPC session exists \n
2730 * FALSE - OPC session does not exist \n
2738 gboolean bluetooth_opc_session_is_exist(void);
2741 * @fn int bluetooth_opc_is_sending(gboolean *is_sending)
2742 * @brief Informs whether opc session exists or not.
2744 * This function is a synchronous call.
2746 * @return BLUETOOTH_ERROR_NONE - Success \n
2747 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2748 * BLUETOOTH_ERROR_INTERNAL \n
2751 * @param[out] is_sending The sending status: (@c TRUE = in sending , @c false = not in sending)
2756 int bluetooth_opc_is_sending(gboolean *is_sending);
2759 * @fn int bluetooth_obex_server_init(const char *dst_path)
2760 * @brief Initialize OPP and FTP server.
2762 * This function is a synchronous call.
2763 * No event corresponding to this api
2765 * @return BLUETOOTH_ERROR_NONE - Success \n
2766 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2767 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2768 * BLUETOOTH_ERROR_AGENT_ALREADY_EXIST - Obex agent already registered \n
2769 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2772 * @param[in] dst_path OPS destination file path.
2774 * @see bluetooth_obex_server_deinit
2776 int bluetooth_obex_server_init(const char *dst_path);
2780 * @fn int bluetooth_obex_server_deinit(void)
2781 * @brief Deinitialize OPP and FTP server.
2783 * This function is a synchronous call.
2784 * No event corresponding to this api
2786 * @return BLUETOOTH_ERROR_NONE - Success \n
2787 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2788 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2793 * @see bluetooth_obex_server_init
2795 int bluetooth_obex_server_deinit(void);
2799 * @fn gboolean bluetooth_obex_server_is_activated(void)
2800 * @brief Informs whether obex server is activated or not.
2802 * This function is a synchronous call.
2804 * @return TRUE - OBEX server is activated \n
2805 * FALSE - OBEX server is not activated \n
2812 gboolean bluetooth_obex_server_is_activated(void);
2816 * @fn int bluetooth_obex_server_init_without_agent(const char *dst_path)
2817 * @brief Initialize OPP and FTP server without the conneciton authorization of the agent
2819 * This function is a synchronous call.
2820 * No event corresponding to this api
2822 * @return BLUETOOTH_ERROR_NONE - Success \n
2823 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2824 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2825 * BLUETOOTH_ERROR_AGENT_ALREADY_EXIST - Obex agent already registered \n
2826 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2830 * @param[in] dst_path OPS destination file path.
2832 * @see bluetooth_obex_server_deinit_without_agent
2834 int bluetooth_obex_server_init_without_agent(const char *dst_path);
2838 * @fn int bluetooth_obex_server_deinit_without_agent(void)
2839 * @brief Deinitialize OPP and FTP server without the conneciton authorization of the agent
2841 * This function is a synchronous call.
2842 * No event corresponding to this api
2844 * @return BLUETOOTH_ERROR_NONE - Success \n
2845 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2846 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2851 * @see bluetooth_obex_server_init_without_agent
2853 int bluetooth_obex_server_deinit_without_agent(void);
2857 * @fn int bluetooth_obex_server_accept_connection(void)
2858 * @brief Accepts the authorization request indicated by the event
2859 * BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE.
2861 * This function is a synchronous call.
2863 * @return BLUETOOTH_ERROR_NONE - Success \n
2864 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2865 * BLUETOOTH_ERROR_INTERNAL - Internal error \n
2869 * @see bluetooth_obex_server_reject_authorize
2871 int bluetooth_obex_server_accept_connection(void);
2875 * @fn int bluetooth_obex_server_reject_connection(void)
2876 * @brief Rejects the authorization request indicated by the event
2877 * BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE.
2879 * This function is a synchronous call.
2881 * @return BLUETOOTH_ERROR_NONE - Success \n
2882 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2883 * BLUETOOTH_ERROR_INTERNAL - Internal error \n
2887 * @see bluetooth_obex_server_reject_authorize
2889 int bluetooth_obex_server_reject_connection(void);
2893 * @fn int bluetooth_obex_server_accept_authorize(const char *filename)
2894 * @brief Accepts the authorization request indicated by the event
2895 * BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE.
2897 * This function is a asynchronous call.
2898 * This api will be responded with the event BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED.
2900 * @return BLUETOOTH_ERROR_NONE - Success \n
2901 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2902 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2903 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2906 * @param[in] filename Authorized filename.
2909 * @see bluetooth_obex_server_reject_authorize
2912 int bluetooth_obex_server_accept_authorize(const char *filename);
2915 * @fn int bluetooth_obex_server_reject_authorize(void)
2916 * @brief Reject the authorization request indicated by the event
2917 * BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE.
2919 * This function is a asynchronous call.
2920 * No event for this api..
2922 * @return BLUETOOTH_ERROR_NONE - Success \n
2923 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2924 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2929 * @see bluetooth_obex_server_accept_authorize
2932 int bluetooth_obex_server_reject_authorize(void);
2935 * @fn int bluetooth_obex_server_set_destination_path(const char *dst_path)
2936 * @brief Set the OPS destination file path..
2938 * This function is a asynchronous call.
2939 * No event for this api..
2941 * @return BLUETOOTH_ERROR_NONE - Success \n
2942 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2943 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2944 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid Param \n
2947 * @param[in] dst_path OPS destination file path.
2953 int bluetooth_obex_server_set_destination_path(const char *dst_path);
2956 * @fn int bluetooth_obex_server_set_root(const char *root)
2957 * @brief Set the FTS root folder..
2959 * This function is a asynchronous call.
2960 * No event for this api..
2962 * @return BLUETOOTH_ERROR_NONE - Success \n
2963 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2964 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2965 * BLUETOOTH_ERROR_ACCESS_DENIED - Operation not allowed \n
2966 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2967 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2970 * @param[in] root FTS root folder.
2976 int bluetooth_obex_server_set_root(const char *root);
2979 * @fn int bluetooth_obex_server_cancel_transfer(int transfer_id)
2980 * @brief Cancel the transfer on server
2982 * This function is an asynchronous call.
2983 * If the function call that cancels transfer is successful, the application would receive
2984 * BLUETOOTH_EVENT_TRANSFER_COMPLETED event through registered callback
2985 * function with an error code BLUETOOTH_ERROR_CANCEL. In the case of failure
2986 * the error code will be BLUETOOTH_ERROR_NONE
2988 * @return BLUETOOTH_ERROR_NONE - Success \n
2989 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2990 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2991 * BLUETOOTH_ERROR_INTERNAL - internal error (proxy does not exist) \n
2992 * BLUETOOTH_ERROR_NOT_FOUND - The transfer is not found \n
2995 * @param[in] transfer_id transfer ID
3000 int bluetooth_obex_server_cancel_transfer(int transfer_id);
3004 * @fn int bluetooth_obex_server_cancel_all_transfers(void)
3005 * @brief Cancel the transfer on server
3007 * This function is an asynchronous call.
3008 * If the function call that cancels transfer is successful, the application would receive
3009 * BLUETOOTH_EVENT_TRANSFER_COMPLETED event through registered callback
3010 * function with an error code BLUETOOTH_ERROR_CANCEL. In the case of failure
3011 * the error code will be BLUETOOTH_ERROR_NONE
3013 * @return BLUETOOTH_ERROR_NONE - Success \n
3014 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
3015 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
3016 * BLUETOOTH_ERROR_INTERNAL - internal error (proxy does not exist) \n
3017 * BLUETOOTH_ERROR_NOT_FOUND - The transfer is not found \n
3024 int bluetooth_obex_server_cancel_all_transfers(void);
3028 * @fn int bluetooth_obex_server_is_receiving(gboolean *is_receiving)
3029 * @brief Informs whether obex server is receiving or not.
3031 * This function is a synchronous call.
3033 * @return BLUETOOTH_ERROR_NONE - Success \n
3034 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
3035 * BLUETOOTH_ERROR_INTERNAL \n
3038 * @param[out] is_receiving The receiving status: (@c TRUE = in receiving , @c false = not in receiving)
3043 int bluetooth_obex_server_is_receiving(gboolean *is_receiving);
3047 * @fn int bluetooth_oob_read_local_data(bt_oob_data_t *local_oob_data)
3048 * @brief Read the local Hash and Randmizer.
3050 * This function is a synchronous call.
3052 * @return BLUETOOTH_ERROR_NONE - Success \n
3053 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3057 * @param[out] local_oob_data - Pointer to the local OOB data
3063 int bluetooth_oob_read_local_data(bt_oob_data_t *local_oob_data);
3067 * @fn int bluetooth_oob_add_remote_data(
3068 * const bluetooth_device_address_t *remote_device_address,
3069 * bt_oob_data_t *oob_data)
3070 * @brief Add/updated the remote device Hash and Randmizer.
3072 * This function is a synchronous call.
3073 * No event for this api..
3075 * @return BLUETOOTH_ERROR_NONE - Success \n
3076 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3079 * @param[in] remote_device_address - Remote device address
3080 * remote_oob_data - Ponter to Hash and Randomizer oob data structure
3086 int bluetooth_oob_add_remote_data(
3087 const bluetooth_device_address_t *remote_device_address,
3088 bt_oob_data_t *remote_oob_data);
3092 * @fn int bluetooth_oob_remove_remote_data(
3093 * const bluetooth_device_address_t *remote_device_address)
3094 * @brief Delete the Hash and Randomizer w.r.t the remote device address.
3096 * This function is a synchronous call.
3097 * No event for this api..
3099 * @return BLUETOOTH_ERROR_NONE - Success \n
3100 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3103 * @param[in] remote_device_address - Remote device address
3109 int bluetooth_oob_remove_remote_data(
3110 const bluetooth_device_address_t *remote_device_address);
3113 * @fn int bluetooth_gatt_get_primary_services(const bluetooth_device_address_t *address,
3114 * bt_gatt_handle_info_t *prim_svc);
3116 * @brief Gets the GATT based primary services handle supported by remote device
3118 * This function is a synchronous call.
3119 * The output parameter needs to be freed by calling bluetooth_gatt_free_primary_services()
3121 * @return BLUETOOTH_ERROR_NONE - Success \n
3122 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3123 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3124 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3127 * @param[in] address - Remote device address
3128 * @param[out] prim_svc - Structure containing remote service count and handle list.
3131 * @see bluetooth_gatt_free_primary_services()
3133 int bluetooth_gatt_get_primary_services(const bluetooth_device_address_t *address,
3134 bt_gatt_handle_info_t *prim_svc);
3137 * @fn int bluetooth_gatt_discover_service_characteristics(const char *service_handle)
3139 * @brief Discovers the characteristics of GATT based service of remote device
3141 * This function is an asynchronous call.
3142 * This API is responded with BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED
3144 * @return BLUETOOTH_ERROR_NONE - Success \n
3145 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3146 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3147 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3150 * @param[in] service_handle - Handle for remote service.
3155 int bluetooth_gatt_discover_service_characteristics(const char *service_handle);
3158 * @fn int bluetooth_gatt_get_service_property(const char *service_handle,
3159 * bt_gatt_service_property_t *service);
3161 * @brief Gets the properties of GATT based service of remote device
3163 * This function is a synchronous call.
3164 * The output parameter needs to be freed by calling bluetooth_gatt_free_primary_services()
3166 * @return BLUETOOTH_ERROR_NONE - Success \n
3167 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3168 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3169 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3172 * @param[in] service_handle - Handle for remote service.
3173 * @param[out] service - Structure containing remote service property.
3176 * @see bluetooth_gatt_free_service_property()
3178 int bluetooth_gatt_get_service_property(const char *service_handle,
3179 bt_gatt_service_property_t *service);
3182 * @fn int bluetooth_gatt_watch_characteristics(const char *service_handle)
3184 * @brief Register to GATT based service to receive value change notification/indication.
3186 * This function is a synchronous call.
3187 * No event for this api.
3189 * @return BLUETOOTH_ERROR_NONE - Success \n
3190 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3191 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3192 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3195 * @param[in] service_handle - Handle for remote service.
3200 int bluetooth_gatt_watch_characteristics(const char *service_handle);
3203 * @fn int bluetooth_gatt_unwatch_characteristics(const char *service_handle)
3205 * @brief Unregister GATT based service to receive value change notification/indication.
3207 * This function is a synchronous call.
3208 * No event for this api.
3210 * @return BLUETOOTH_ERROR_NONE - Success \n
3211 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3212 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3213 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3216 * @param[in] service_handle - Handle for remote service.
3221 int bluetooth_gatt_unwatch_characteristics(const char *service_handle);
3224 * @fn int bluetooth_gatt_get_characteristics_property(const char *char_handle,
3225 * bt_gatt_char_property_t *characteristic);
3227 * @brief Provides characteristic value along with properties.
3229 * This function is a synchronous call.
3230 * The output parameter needs to be freed by calling bluetooth_gatt_free_char_property()
3232 * @return BLUETOOTH_ERROR_NONE - Success \n
3233 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3234 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3235 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3238 * @param[in] char_handle - Handle for Characteristic property.
3239 * @param[out] characteristic - Structure containing remote characteristic property.
3242 * @see bluetooth_gatt_free_char_property()
3244 int bluetooth_gatt_get_characteristics_property(const char *char_handle,
3245 bt_gatt_char_property_t *characteristic);
3248 * @fn int bluetooth_gatt_set_characteristics_value(const char *char_handle,
3249 * const guint8 *value, int length)
3251 * @brief Set characteristic value.
3253 * This function is a synchronous call.
3255 * @return BLUETOOTH_ERROR_NONE - Success \n
3256 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3257 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3258 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3261 * @param[in] char_handle - Handle for Characteristic property.
3262 * @param[in] value - New value to set for characteristic property.
3263 * @param[in] length - Length of the value to be set.
3268 int bluetooth_gatt_set_characteristics_value(const char *char_handle,
3269 const guint8 *value, int length);
3272 * @fn int bluetooth_gatt_get_service_from_uuid(bluetooth_device_address_t *address,
3273 * const char *service_uuid,
3274 * bt_gatt_service_property_t *service)
3276 * @brief Gets the service property from a device based on a particular uuid
3278 * This function is a synchronous call.
3280 * @return BLUETOOTH_ERROR_NONE - Success \n
3281 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3282 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3283 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3286 * @param[in] address - BD address of the remote device
3287 * @param[in] service_uuid - uuid of the service.
3288 * @param[out] service - Structure containing the service property.
3293 int bluetooth_gatt_get_service_from_uuid(bluetooth_device_address_t *address,
3294 const char *service_uuid,
3295 bt_gatt_service_property_t *service);
3298 * @fn int bluetooth_gatt_get_char_from_uuid(const char *service_handle,
3299 * const char *char_uuid)
3301 * @brief Gets the characteristic property from a service based on a particular char uuid
3303 * This function is an asynchronous call.
3304 * This API is responded with BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID
3306 * @return BLUETOOTH_ERROR_NONE - Success \n
3307 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3308 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3309 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3312 * @param[in] service_handle - Service handle.
3313 * @param[in] uuid - Characteristic uuid.
3318 int bluetooth_gatt_get_char_from_uuid(const char *service_handle,
3319 const char *char_uuid);
3322 * @fn int bluetooth_gatt_free_primary_services(bt_gatt_handle_info_t *prim_svc);
3324 * @brief Releases the memory allocated by bluetooth_gatt_get_primary_services()
3326 * This function is a synchronous call.
3327 * The input parameter is obtained by calling bluetooth_gatt_get_primary_services()
3329 * @return BLUETOOTH_ERROR_NONE - Success \n
3330 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3333 * @param[in] prim_svc - GATT handle info structure
3336 * @see bluetooth_gatt_get_primary_services()
3338 int bluetooth_gatt_free_primary_services(bt_gatt_handle_info_t *prim_svc);
3341 * @fn int bluetooth_gatt_free_service_property(bt_gatt_service_property_t *svc_pty);
3343 * @brief Releases the memory allocated by bluetooth_gatt_get_service_property()
3345 * This function is a synchronous call.
3346 * The input parameter is obtained by calling bluetooth_gatt_get_service_property()
3348 * @return BLUETOOTH_ERROR_NONE - Success \n
3349 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3352 * @param[in] svc_pty - GATT service property structure.
3355 * @see bluetooth_gatt_get_service_property()
3357 int bluetooth_gatt_free_service_property(bt_gatt_service_property_t *svc_pty);
3360 * @fn int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *char_pty);
3362 * @brief Provides characteristic value along with properties.
3364 * This function is a synchronous call.
3365 * The input parameter is obtained by calling bluetooth_gatt_get_characteristics_property()
3367 * @return BLUETOOTH_ERROR_NONE - Success \n
3368 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3371 * @param[in] char_pty - GATT characteristics property structure.
3374 * @see bluetooth_gatt_get_characteristics_property()
3376 int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *char_pty);
3384 #endif /* __cplusplus */
3385 #endif /* _BLUETOOTH_API_H_*/