4 * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #ifndef _BLUETOOTH_API_H_
21 #define _BLUETOOTH_API_H_
29 #endif /* __cplusplus */
32 * @defgroup BLUETOOTHFW BluetoothFW
34 * A base library for bluetooth framework
36 * @addtogroup BLUETOOTHFW
40 #define BLUETOOTH_ADDRESS_LENGTH 6 /**< This specifies bluetooth device address length */
41 #define BLUETOOTH_INTERFACE_NAME_LENGTH 16
42 #define BLUETOOTH_DEVICE_NAME_LENGTH_MAX 248 /**< This specifies maximum device name length */
44 #define BLUETOOTH_MAX_SERVICES_FOR_DEVICE 40 /**< This specifies maximum number of services
45 a device can support */
47 #define BLUETOOTH_UUID_STRING_MAX 50
49 #define BLUETOOTH_OOB_DATA_LENGTH 16
51 * This is Bluetooth Connected event role
53 #define RFCOMM_ROLE_SERVER 1
54 #define RFCOMM_ROLE_CLIENT 2
57 * This is Bluetooth error code
59 #define BLUETOOTH_ERROR_BASE ((int)0) /**< Error code base */
61 #define BLUETOOTH_ERROR_NONE ((int)0) /**< No error #0 */
62 #define BLUETOOTH_ERROR_CANCEL ((int)BLUETOOTH_ERROR_BASE - 0x01)
64 #define BLUETOOTH_ERROR_INVALID_CALLBACK ((int)BLUETOOTH_ERROR_BASE - 0x02)
65 /**< Callback error */
66 #define BLUETOOTH_ERROR_INVALID_PARAM ((int)BLUETOOTH_ERROR_BASE - 0x03)
67 /**< invalid paramerror */
68 #define BLUETOOTH_ERROR_INVALID_DATA ((int)BLUETOOTH_ERROR_BASE - 0x04)
69 /**< invalid data error */
70 #define BLUETOOTH_ERROR_MEMORY_ALLOCATION ((int)BLUETOOTH_ERROR_BASE - 0x05)
71 /**< Memory allocation error */
72 #define BLUETOOTH_ERROR_OUT_OF_MEMORY ((int)BLUETOOTH_ERROR_BASE - 0x06)
73 /**< out of memory error */
74 #define BLUETOOTH_ERROR_TIMEOUT ((int)BLUETOOTH_ERROR_BASE - 0x07)
76 #define BLUETOOTH_ERROR_NO_RESOURCES ((int)BLUETOOTH_ERROR_BASE - 0x08)
77 /**< No resource error */
78 #define BLUETOOTH_ERROR_INTERNAL ((int)BLUETOOTH_ERROR_BASE - 0x09)
79 /**< internal error */
80 #define BLUETOOTH_ERROR_NOT_SUPPORT ((int)BLUETOOTH_ERROR_BASE - 0x0a)
81 /**< Not supported error */
82 #define BLUETOOTH_ERROR_DEVICE_NOT_ENABLED ((int)BLUETOOTH_ERROR_BASE - 0x0b)
83 /**< Operation is failed because
84 of not enabled BT Adapter */
85 #define BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED ((int)BLUETOOTH_ERROR_BASE - 0x0c)
86 /**< Enabling is failed because of
87 already enabled BT Adapter */
88 #define BLUETOOTH_ERROR_DEVICE_BUSY ((int)BLUETOOTH_ERROR_BASE - 0x0d)
89 /**< Operation is failed because of
90 other on going operation */
91 #define BLUETOOTH_ERROR_ACCESS_DENIED ((int)BLUETOOTH_ERROR_BASE - 0x0e)
92 /**< access denied error */
93 #define BLUETOOTH_ERROR_MAX_CLIENT ((int)BLUETOOTH_ERROR_BASE - 0x0f)
94 /**< max client error */
95 #define BLUETOOTH_ERROR_NOT_FOUND ((int)BLUETOOTH_ERROR_BASE - 0x10)
96 /**< not found error */
97 #define BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR ((int)BLUETOOTH_ERROR_BASE - 0x11)
98 /**< service search fail */
99 #define BLUETOOTH_ERROR_PARING_FAILED ((int)BLUETOOTH_ERROR_BASE - 0x12)
100 /**< pairing failed error */
101 #define BLUETOOTH_ERROR_NOT_PAIRED ((int)BLUETOOTH_ERROR_BASE - 0x13)
102 /**< Not paired error */
103 #define BLUETOOTH_ERROR_SERVICE_NOT_FOUND ((int)BLUETOOTH_ERROR_BASE - 0x14)
104 /**< no service error */
105 #define BLUETOOTH_ERROR_NOT_CONNECTED ((int)BLUETOOTH_ERROR_BASE - 0x15)
106 /**< no connection error */
107 #define BLUETOOTH_ERROR_ALREADY_CONNECT ((int)BLUETOOTH_ERROR_BASE - 0x16)
108 /**< alread connected error */
109 #define BLUETOOTH_ERROR_CONNECTION_BUSY ((int)BLUETOOTH_ERROR_BASE - 0x17)
110 /**< connection busy error */
111 #define BLUETOOTH_ERROR_CONNECTION_ERROR ((int)BLUETOOTH_ERROR_BASE - 0x18)
112 /**< connection error */
113 #define BLUETOOTH_ERROR_MAX_CONNECTION ((int)BLUETOOTH_ERROR_BASE - 0x19)
114 /**< max connection error*/
115 #define BLUETOOTH_ERROR_NOT_IN_OPERATION ((int)BLUETOOTH_ERROR_BASE - 0x1a)
116 /**< Not in operation */
117 #define BLUETOOTH_ERROR_CANCEL_BY_USER ((int)BLUETOOTH_ERROR_BASE - 0x1b)
118 /**< Cancelled by user */
119 #define BLUETOOTH_ERROR_REGISTRATION_FAILED ((int)BLUETOOTH_ERROR_BASE - 0x1c)
120 /**< Service record registration failed */
121 #define BLUETOOTH_ERROR_IN_PROGRESS ((int)BLUETOOTH_ERROR_BASE - 0x1d)
122 /**< Operation in progress */
123 #define BLUETOOTH_ERROR_AUTHENTICATION_FAILED ((int)BLUETOOTH_ERROR_BASE - 0x1e)
124 /**< authentication failed error when paring*/
125 #define BLUETOOTH_ERROR_HOST_DOWN ((int)BLUETOOTH_ERROR_BASE - 0x1f)
126 /**< Remote host is down */
127 #define BLUETOOTH_ERROR_END_OF_DEVICE_LIST ((int)BLUETOOTH_ERROR_BASE - 0x20)
128 /**< End of device list */
130 #define BLUETOOTH_ERROR_AGENT_ALREADY_EXIST ((int)BLUETOOTH_ERROR_BASE - 0x21)
131 /**< Obex agent already exists */
132 #define BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST ((int)BLUETOOTH_ERROR_BASE - 0x22)
133 /**< Obex agent does not exist */
135 #define BLUETOOTH_ERROR_ALREADY_INITIALIZED ((int)BLUETOOTH_ERROR_BASE - 0x23)
136 /**< Already initialized */
140 * This is Bluetooth device address type, fixed to 6 bytes ##:##:##:##:##:##
143 unsigned char addr[BLUETOOTH_ADDRESS_LENGTH];
144 } bluetooth_device_address_t;
147 * This is Bluetooth device name type, maximum size of Bluetooth device name is 248 bytes
150 char name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX + 1];
151 } bluetooth_device_name_t;
157 BLUETOOTH_ADAPTER_DISABLED, /**< Bluetooth adapter is disabled */
158 BLUETOOTH_ADAPTER_ENABLED, /**< Bluetooth adapter is enabled */
159 BLUETOOTH_ADAPTER_CHANGING_ENABLE, /**< Bluetooth adapter is currently enabling */
160 BLUETOOTH_ADAPTER_CHANGING_DISABLE, /**< Bluetooth adapter is currently disabling */
161 } bluetooth_adapter_state_t;
167 BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, /**< Non discoverable mode */
168 /*Changed the order to make it compatable with old method */
169 BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE,/**< Discoverable mode */
170 BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE,
171 /**< Discoverable mode with time limit
172 After specific timeout, it is changed
173 to non discoverable mode */
174 } bluetooth_discoverable_mode_t;
177 * Network connect mode
180 BLUETOOTH_NETWORK_PANU_ROLE,
182 BLUETOOTH_NETWORK_NAP_ROLE,/**< Network Access Point */
183 BLUETOOTH_NETWORK_GN_ROLE, /**< Group ad-hoc Network */
184 BLUETOOTH_NETWORK_CUSTOM_UUID, /**< Custom role */
185 } bluetooth_network_role_t;
191 BLUETOOTH_RFCOMM_SERVICE = 0x01,
192 BLUETOOTH_A2DP_SERVICE = 0x02,
193 BLUETOOTH_HSP_SERVICE = 0x04,
194 BLUETOOTH_HID_SERVICE = 0x08,
195 } bluetooth_service_type_t;
197 #define BLUETOOTH_EVENT_BASE ((int)(0x0000)) /**< No event */
198 #define BLUETOOTH_EVENT_GAP_BASE ((int)(BLUETOOTH_EVENT_BASE + 0x0010))
199 /**< Base ID for GAP Event */
200 #define BLUETOOTH_EVENT_SDP_BASE ((int)(BLUETOOTH_EVENT_GAP_BASE + 0x0020))
201 /**< Base ID for SDP events */
202 #define BLUETOOTH_EVENT_RFCOMM_BASE ((int)(BLUETOOTH_EVENT_SDP_BASE + 0x0020))
203 /**< Base ID for RFCOMM events */
204 #define BLUETOOTH_EVENT_NETWORK_BASE ((int)(BLUETOOTH_EVENT_RFCOMM_BASE + 0x0020))
205 /**< Base ID for NETWORK events */
206 #define BLUETOOTH_EVENT_HDP_BASE ((int)(BLUETOOTH_EVENT_NETWORK_BASE + 0x0020))
207 /**< Base ID for HDP events */
208 #define BLUETOOTH_EVENT_OPC_BASE ((int)(BLUETOOTH_EVENT_HDP_BASE + 0x0020))
209 /**< Base ID for OPC events */
210 #define BLUETOOTH_EVENT_OBEX_SERVER_BASE ((int)(BLUETOOTH_EVENT_OPC_BASE + 0x0020))
211 /**< Base ID for Obex Server events */
212 #define BLUETOOTH_EVENT_GATT_BASE ((int)(BLUETOOTH_EVENT_OBEX_SERVER_BASE + 0x0020))
213 /**< Base ID for GATT events */
215 #define BLUETOOTH_EVENT_AUDIO_BASE ((int)(BLUETOOTH_EVENT_GATT_BASE + 0x0020))
216 /**< Base ID for Audio events */
217 #define BLUETOOTH_EVENT_HID_BASE ((int)(BLUETOOTH_EVENT_AUDIO_BASE + 0x0020))
218 /**< Base ID for HID events */
221 * Bluetooth event type
224 BLUETOOTH_EVENT_NONE = BLUETOOTH_EVENT_BASE,/**< No event */
226 BLUETOOTH_EVENT_ENABLED, /**< Bluetooth event adpater enabled */
227 BLUETOOTH_EVENT_DISABLED, /**< Bluetooth event adpater disabled */
228 BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, /**< Bluetooth event local name changed*/
229 BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_REQUESTED,
230 /**< Bluetooth event Discoverable timeout requested*/
231 BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED, /**< Bluetooth event mode changed */
232 BLUETOOTH_EVENT_DISCOVERY_OPTION_REQUESTED, /**< Bluetooth event discovery option */
233 BLUETOOTH_EVENT_DISCOVERY_STARTED, /**< Bluetooth event discovery started */
234 BLUETOOTH_EVENT_DISCOVERY_FINISHED, /**< Bluetooth event discovery finished */
236 BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, /**< Bluetooth event remote deice found */
237 BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED,/**< Bluetooth event remote device name updated*/
238 BLUETOOTH_EVENT_BONDING_FINISHED, /**< Bluetooth event bonding completed */
239 BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED, /**< Bluetooth event bonding removed */
240 BLUETOOTH_EVENT_BONDED_DEVICE_FOUND, /**< Bluetooth event paired device found */
241 BLUETOOTH_EVENT_REMOTE_DEVICE_READ, /**< Bluetooth event read remote device */
242 BLUETOOTH_EVENT_DEVICE_AUTHORIZED, /**< Bluetooth event authorize device */
243 BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED, /**< Bluetooth event unauthorize device */
244 BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_CHANGED, /**< Bluetooth event mode changed */
246 BLUETOOTH_EVENT_SERVICE_SEARCHED = BLUETOOTH_EVENT_SDP_BASE,
247 /**< Bluetooth event serice search base id */
248 BLUETOOTH_EVENT_SERVICE_SEARCH_CANCELLED, /**< Bluetooth event service search cancelled */
249 BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED = BLUETOOTH_EVENT_RFCOMM_BASE,
250 /**< RFCOMM data receive event */
251 BLUETOOTH_EVENT_RFCOMM_CONNECTED, /**< Rfcomm server incomming connection */
252 BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, /**< Rfcomm server/client disconnect */
254 BLUETOOTH_EVENT_RFCOMM_AUTHORIZE,
256 BLUETOOTH_EVENT_DEVICE_CONNECTED, /**< Bluetooth event device connected */
257 BLUETOOTH_EVENT_DEVICE_DISCONNECTED, /**< Bluetooth event device disconnected */
259 BLUETOOTH_EVENT_RFCOMM_SERVER_REMOVED,
261 BLUETOOTH_EVENT_NETWORK_SERVER_ACTIVATED = BLUETOOTH_EVENT_NETWORK_BASE,
262 /**< Bluetooth Network event */
263 BLUETOOTH_EVENT_NETWORK_SERVER_DEACTIVATED, /**< Network server deactivated */
264 BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED, /**< Network connected event in server */
265 BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED,
266 /**< Network disconnected evnet in server */
268 BLUETOOTH_EVENT_NETWORK_CONNECTED, /**< Network connected event in client*/
269 BLUETOOTH_EVENT_NETWORK_DISCONNECTED, /**< Network disconnected evnet in client*/
271 BLUETOOTH_EVENT_HDP_CONNECTED
272 = BLUETOOTH_EVENT_HDP_BASE, /**<HDP Connect>*/
273 BLUETOOTH_EVENT_HDP_DISCONNECTED, /**<HDP Disconnect>*/
274 BLUETOOTH_EVENT_HDP_DATA_RECEIVED, /**<HDP Data Indication>*/
276 BLUETOOTH_EVENT_OPC_CONNECTED = BLUETOOTH_EVENT_OPC_BASE,
277 /* OPC Connected event */
278 BLUETOOTH_EVENT_OPC_DISCONNECTED, /* OPC Disonnected event */
279 BLUETOOTH_EVENT_OPC_TRANSFER_STARTED, /* OPC Transfer started event */
280 BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS, /* OPC Transfer progress event */
281 BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE, /* OPC Transfer Complete event */
283 BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE = BLUETOOTH_EVENT_OBEX_SERVER_BASE,
284 /* Obex server authorize event*/
285 BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED, /* Obex Server transfer started event*/
286 BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS,/* Obex Server transfer progress event*/
287 BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED,/* Obex Server transfer complete event*/
288 BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE,
290 BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED = BLUETOOTH_EVENT_GATT_BASE,
291 /**<Discovered GATT service characteristics event*/
292 BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED,
293 /**<Remote GATT charateristic value changed event*/
295 BLUETOOTH_EVENT_AG_CONNECTED = BLUETOOTH_EVENT_AUDIO_BASE, /**<AG service connected event*/
296 BLUETOOTH_EVENT_AG_DISCONNECTED, /**<AG service disconnected event*/
297 BLUETOOTH_EVENT_AG_SPEAKER_GAIN, /**<Speaker gain request event*/
298 BLUETOOTH_EVENT_AG_MIC_GAIN, /**<Mic gain request event*/
299 BLUETOOTH_EVENT_AG_AUDIO_CONNECTED, /**<AV & AG service connected event*/
300 BLUETOOTH_EVENT_AG_AUDIO_DISCONNECTED, /**<AV & AG service disconnected event*/
301 BLUETOOTH_EVENT_AV_CONNECTED, /**<AV service connected event*/
302 BLUETOOTH_EVENT_AV_DISCONNECTED, /**<AV service disconnected event*/
303 BLUETOOTH_EVENT_AVRCP_CONNECTED, /**<AVRCP service connected event*/
304 BLUETOOTH_EVENT_AVRCP_DISCONNECTED, /**<AVRCP service disconnected event*/
305 BLUETOOTH_EVENT_AVRCP_SETTING_SHUFFLE_STATUS, /**<AVRCP service player suffle status event*/
306 BLUETOOTH_EVENT_AVRCP_SETTING_EQUALIZER_STATUS, /**<AVRCP service player equalizer status event*/
307 BLUETOOTH_EVENT_AVRCP_SETTING_REPEAT_STATUS, /**<AVRCP service player repeat status event*/
308 BLUETOOTH_EVENT_AVRCP_SETTING_SCAN_STATUS, /**<AVRCP service player scan status event*/
310 BLUETOOTH_HID_CONNECTED = BLUETOOTH_EVENT_HID_BASE, /**< Input connectd event*/
311 BLUETOOTH_HID_DISCONNECTED, /**< Input disconnectd event*/
312 BLUETOOTH_EVENT_MAX, /**< Bluetooth event Max value */
313 } bluetooth_event_type_t;
316 * This bt_service_uuid_list_t enum indicates service uuid list .
317 * This values is stored the service_list_array in bt_sdp_info_t and bluetooth_device_info_t.
321 BLUETOOTH_SPP_PROFILE_UUID = ((unsigned short)0x1101), /**<SPP*/
322 BLUETOOTH_LAP_PROFILE_UUID = ((unsigned short)0x1102), /**<LAP*/
323 BLUETOOTH_DUN_PROFILE_UUID = ((unsigned short)0x1103), /**<DUN*/
324 BLUETOOTH_OBEX_IR_MC_SYNC_SERVICE_UUID = ((unsigned short)0x1104), /**<OBEX IR MC SYNC*/
325 BLUETOOTH_OBEX_OBJECT_PUSH_SERVICE_UUID = ((unsigned short)0x1105), /**<OPP*/
326 BLUETOOTH_OBEX_FILE_TRANSFER_UUID = ((unsigned short)0x1106), /**<FTP*/
327 BLUETOOTH_IRMC_SYNC_COMMAND_UUID = ((unsigned short)0x1107), /**<IRMC SYNC COMMAND*/
328 BLUETOOTH_HS_PROFILE_UUID = ((unsigned short)0x1108), /**<HS*/
329 BLUETOOTH_CTP_PROFILE_UUID = ((unsigned short)0x1109), /**<CTP*/
330 BLUETOOTH_AUDIO_SOURCE_UUID = ((unsigned short)0x110A), /**<AUDIO SOURCE*/
331 BLUETOOTH_AUDIO_SINK_UUID = ((unsigned short)0x110B), /**<AUDIO SINK*/
332 BLUETOOTH_AV_REMOTE_CONTROL_TARGET_UUID = ((unsigned short)0x110C), /**<AV REMOTE CONTROL
334 BLUETOOTH_ADVANCED_AUDIO_PROFILE_UUID = ((unsigned short)0x110D), /**<A2DP*/
335 BLUETOOTH_AV_REMOTE_CONTROL_UUID = ((unsigned short)0x110E), /**<AV REMOTE CONTROL UUID*/
336 BLUETOOTH_AV_REMOTE_CONTROL_CONTROLLER_UUID = ((unsigned short)0x110F), /**<AV REMOTE CONTROLLER UUID*/
337 BLUETOOTH_ICP_PROFILE_UUID = ((unsigned short)0x1110), /**<ICP*/
338 BLUETOOTH_FAX_PROFILE_UUID = ((unsigned short)0x1111), /**<FAX*/
339 BLUETOOTH_HEADSET_AG_SERVICE_UUID = ((unsigned short)0x1112), /**<HS AG */
340 BLUETOOTH_PAN_PANU_PROFILE_UUID = ((unsigned short)0x1115), /**<PAN*/
341 BLUETOOTH_PAN_NAP_PROFILE_UUID = ((unsigned short)0x1116), /**<PAN*/
342 BLUETOOTH_PAN_GN_PROFILE_UUID = ((unsigned short)0x1117), /**<PAN*/
343 BLUETOOTH_DIRECT_PRINTING = ((unsigned short)0x1118),
344 BLUETOOTH_OBEX_BPPS_PROFILE_UUID = ((unsigned short)0x1118), /**<OBEX BPPS*/ /* Will be removed */
345 BLUETOOTH_REFERENCE_PRINTING = ((unsigned short)0x1119),
346 BLUETOOTH_OBEX_IMAGING_UUID = ((unsigned short)0x111A), /**<OBEX_IMAGING*/
347 BLUETOOTH_OBEX_IMAGING_RESPONDER_UUID = ((unsigned short)0x111B), /**<OBEX_IMAGING
349 BLUETOOTH_IMAGING_AUTOMATIC_ARCHIVE_UUID = ((unsigned short)0x111C), /**<IMAGING AUTOMATIC ARCHIVE*/
350 BLUETOOTH_IMAGING_REFERENCED_OBJECTS_UUID = ((unsigned short)0x111D), /**<IMAGING REFERENCED OBJECTS*/
351 BLUETOOTH_HF_PROFILE_UUID = ((unsigned short)0x111E), /**<HF*/
352 BLUETOOTH_HFG_PROFILE_UUID = ((unsigned short)0x111F), /**<HFG*/
353 BLUETOOTH_DIRECT_PRINTING_REFERENCE_OBJ_UUID = ((unsigned short)0x1120),
354 /**<DIRECT PRINTING*/
355 BLUETOOTH_REFLECTED_UI = ((unsigned short)0x1121), /**<REFLECTED UI*/
356 BLUETOOTH_BASIC_PRINTING = ((unsigned short)0x1122), /**<BASIC PRINTING*/
357 BLUETOOTH_PRINTING_STATUS = ((unsigned short)0x1123), /**<PRINTING STATUS*/
358 BLUETOOTH_OBEX_PRINTING_STATUS_UUID = ((unsigned short)0x1123), /**<OBEX PRINTING STATUS*/ /* Will be removed */
359 BLUETOOTH_HID_PROFILE_UUID = ((unsigned short)0x1124), /**<HID*/
360 BLUETOOTH_HCR_PROFILE_UUID = ((unsigned short)0x1125), /**<HCRP*/
361 BLUETOOTH_HCR_PRINT_UUID = ((unsigned short)0x1126), /**<HCR PRINT*/
362 BLUETOOTH_HCR_SCAN_UUID = ((unsigned short)0x1127), /**<HCR SCAN*/
363 BLUETOOTH_SIM_ACCESS_PROFILE_UUID = ((unsigned short)0x112D), /**<SIM ACCESS PROFILE*/
364 BLUETOOTH_PBAP_PCE_UUID = ((unsigned short)0x112E), /**<PBAP - PCE*/
365 BLUETOOTH_PBAP_PSE_UUID = ((unsigned short)0x112F), /**<OBEX PBA*/
366 BLUETOOTH_OBEX_PBA_PROFILE_UUID = ((unsigned short)0x112F), /**<OBEX PBA*/ /* Will be removed */
367 BLUETOOTH_OBEX_PBAP_UUID = ((unsigned short)0x1130), /**<OBEX PBA*/
368 BLUETOOTH_HEADSET_HS_UUID = ((unsigned short)0x1131), /**<HEADSET HS*/
369 BLUETOOTH_MESSAGE_ACCESS_SERVER_UUID = ((unsigned short)0x1132),/**<MESSAGE ACCESS SERVER*/
370 BLUETOOTH_MESSAGE_NOTIFICATION_SERVER_UUID = ((unsigned short)0x1133),/**<MESSAGE NOTIFICATION SERVER*/
371 BLUETOOTH_MESSAGE_ACCESS_PROFILE_UUID = ((unsigned short)0x1134),/**<MESSAGE ACCESS PROFILE*/
372 BLUETOOTH_PNP_INFORMATION_UUID = ((unsigned short)0x1200), /**<PNP*/
373 BLUETOOTH_GENERIC_NETWORKING_UUID = ((unsigned short)0x1201), /**<GENERIC NETWORKING*/
374 BLUETOOTH_GENERIC_FILE_TRANSFER_UUID = ((unsigned short)0x1202),/**<GENERIC FILE TRANSFER*/
375 BLUETOOTH_GENERIC_AUDIO_UUID = ((unsigned short)0x1203), /**<GENERIC AUDIO*/
376 BLUETOOTH_GENERIC_TELEPHONY_UUID = ((unsigned short)0x1204), /**<GENERIC TELEPHONY*/
377 BLUETOOTH_VIDEO_SOURCE_UUID = ((unsigned short)0x1303), /**<VEDIO SOURCE*/
378 BLUETOOTH_VIDEO_SINK_UUID = ((unsigned short)0x1304), /**<VEDIO SINK*/
379 BLUETOOTH_VIDEO_DISTRIBUTION_UUID = ((unsigned short)0x1305), /**<VEDIO DISTRIBUTION*/
380 BLUETOOTH_HDP_UUID = ((unsigned short)0x1400), /**<HDP*/
381 BLUETOOTH_HDP_SOURCE_UUID = ((unsigned short)0x1401), /**<HDP SOURCE*/
382 BLUETOOTH_HDP_SINK_UUID = ((unsigned short)0x1402), /**<HDP SINK*/
383 BLUETOOTH_OBEX_SYNCML_TRANSFER_UUID = ((unsigned short)0x0000) /**<OBEX_SYNC*/ /* Will be removed */
384 } bluetooth_service_uuid_list_t;
387 * Service class part of class of device returned from device discovery
390 BLUETOOTH_DEVICE_SERVICE_CLASS_LIMITED_DISCOVERABLE_MODE = 0x002000,
391 BLUETOOTH_DEVICE_SERVICE_CLASS_POSITIONING = 0x010000, /**< */
392 BLUETOOTH_DEVICE_SERVICE_CLASS_NETWORKING = 0x020000, /**< */
393 BLUETOOTH_DEVICE_SERVICE_CLASS_RENDERING = 0x040000, /**< */
394 BLUETOOTH_DEVICE_SERVICE_CLASS_CAPTURING = 0x080000, /**< */
395 BLUETOOTH_DEVICE_SERVICE_CLASS_OBJECT_TRANSFER = 0x100000, /**< */
396 BLUETOOTH_DEVICE_SERVICE_CLASS_AUDIO = 0x200000, /**< */
397 BLUETOOTH_DEVICE_SERVICE_CLASS_TELEPHONY = 0x400000, /**< */
398 BLUETOOTH_DEVICE_SERVICE_CLASS_INFORMATION = 0x800000, /**< */
399 } bluetooth_device_service_class_t;
403 * Major device mask (For device discovery)
406 BLUETOOTH_DEVICE_MAJOR_MASK_MISC = 0x00,
407 BLUETOOTH_DEVICE_MAJOR_MASK_COMPUTER = 0x0001,
408 BLUETOOTH_DEVICE_MAJOR_MASK_PHONE = 0x0002,
409 BLUETOOTH_DEVICE_MAJOR_MASK_LAN_ACCESS_POINT = 0x0004,
410 BLUETOOTH_DEVICE_MAJOR_MASK_AUDIO = 0x0008,
411 BLUETOOTH_DEVICE_MAJOR_MASK_PERIPHERAL = 0x0010,
412 BLUETOOTH_DEVICE_MAJOR_MASK_IMAGING = 0x0020,
413 BLUETOOTH_DEVICE_MAJOR_MASK_WEARABLE = 0x0040,
414 BLUETOOTH_DEVICE_MAJOR_MASK_TOY = 0x0080,
415 BLUETOOTH_DEVICE_MAJOR_MASK_HEALTH = 0x0100,
416 } bluetooth_device_major_mask_t;
420 * Major device class (part of Class of Device)
423 BLUETOOTH_DEVICE_MAJOR_CLASS_MISC = 0x00, /**< Miscellaneous major device class*/
424 BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER = 0x01, /**< Computer major device class*/
425 BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE = 0x02, /**< Phone major device class*/
426 BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT = 0x03, /**< LAN major device class*/
427 BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO = 0x04, /**< AUDIO major device class*/
428 BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL = 0x05, /**< Peripheral major device class*/
429 BLUETOOTH_DEVICE_MAJOR_CLASS_IMAGING = 0x06, /**< Imaging major device class*/
430 BLUETOOTH_DEVICE_MAJOR_CLASS_WEARABLE = 0x07, /**< Wearable device class*/
431 BLUETOOTH_DEVICE_MAJOR_CLASS_TOY = 0x08, /**< Toy device class*/
432 BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH = 0x09, /**< Health device class*/
433 BLUETOOTH_DEVICE_MAJOR_CLASS_UNCLASSIFIED = 0x1F /**< Unknown major device class*/
434 } bluetooth_device_major_class_t;
437 BLUETOOTH_DEVICE_MINOR_CLASS_UNCLASSIFIED = 0x00, /**< unclassified minor class */
439 /* About Computer Major class */
440 BLUETOOTH_DEVICE_MINOR_CLASS_DESKTOP_WORKSTATION = 0x04, /**< desktop workstation
442 BLUETOOTH_DEVICE_MINOR_CLASS_SERVER_CLASS_COMPUTER = 0x08, /**< server minor class */
443 BLUETOOTH_DEVICE_MINOR_CLASS_LAPTOP = 0x0C, /**< laptop minor class */
444 BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_PC_OR_PDA = 0x10, /**< PDA minor class */
445 BLUETOOTH_DEVICE_MINOR_CLASS_PALM_SIZED_PC_OR_PDA = 0x14, /**< PALM minor class */
446 BLUETOOTH_DEVICE_MINOR_CLASS_WEARABLE_COMPUTER = 0x18, /**< Wearable PC minor class */
448 /* About Phone Major class */
449 BLUETOOTH_DEVICE_MINOR_CLASS_CELLULAR = 0x04, /**< Cellular minor class */
450 BLUETOOTH_DEVICE_MINOR_CLASS_CORDLESS = 0x08, /**< cordless minor class */
451 BLUETOOTH_DEVICE_MINOR_CLASS_SMART_PHONE = 0x0C, /**< smart phone minor class */
452 BLUETOOTH_DEVICE_MINOR_CLASS_WIRED_MODEM_OR_VOICE_GATEWAY = 0x10,
453 /**< voice gateway minor class */
454 BLUETOOTH_DEVICE_MINOR_CLASS_COMMON_ISDN_ACCESS = 0x14, /**< ISDN minor class */
456 /* About LAN/Network Access Point Major class */
457 BLUETOOTH_DEVICE_MINOR_CLASS_FULLY_AVAILABLE = 0x04, /**< Fully available minor class */
458 BLUETOOTH_DEVICE_MINOR_CLASS_1_TO_17_PERCENT_UTILIZED = 0x20, /**< 1-17% utilized minor class */
459 BLUETOOTH_DEVICE_MINOR_CLASS_17_TO_33_PERCENT_UTILIZED = 0x40, /**< 17-33% utilized minor class */
460 BLUETOOTH_DEVICE_MINOR_CLASS_33_TO_50_PERCENT_UTILIZED = 0x60, /**< 33-50% utilized minor class */
461 BLUETOOTH_DEVICE_MINOR_CLASS_50_to_67_PERCENT_UTILIZED = 0x80, /**< 50-67% utilized minor class */
462 BLUETOOTH_DEVICE_MINOR_CLASS_67_TO_83_PERCENT_UTILIZED = 0xA0, /**< 67-83% utilized minor class */
463 BLUETOOTH_DEVICE_MINOR_CLASS_83_TO_99_PERCENT_UTILIZED = 0xC0, /**< 83-99% utilized minor class */
464 BLUETOOTH_DEVICE_MINOR_CLASS_NO_SERVICE_AVAILABLE = 0xE0, /**< No service available minor class */
466 /* About Audio/Video Major class */
467 BLUETOOTH_DEVICE_MINOR_CLASS_HEADSET_PROFILE = 0x04, /**< Headset minor class */
468 BLUETOOTH_DEVICE_MINOR_CLASS_HANDSFREE = 0x08, /**< Handsfree minor class*/
470 BLUETOOTH_DEVICE_MINOR_CLASS_MICROPHONE = 0x10, /**< Microphone minor class */
471 BLUETOOTH_DEVICE_MINOR_CLASS_LOUD_SPEAKER = 0x14, /**< Loud Speaker minor class */
472 BLUETOOTH_DEVICE_MINOR_CLASS_HEADPHONES = 0x18, /**< Headphones minor class */
473 BLUETOOTH_DEVICE_MINOR_CLASS_PORTABLE_AUDIO = 0x1C, /**< Portable Audio minor class */
474 BLUETOOTH_DEVICE_MINOR_CLASS_CAR_AUDIO = 0x20, /**< Car Audio minor class */
475 BLUETOOTH_DEVICE_MINOR_CLASS_SET_TOP_BOX = 0x24, /**< Set top box minor class */
476 BLUETOOTH_DEVICE_MINOR_CLASS_HIFI_AUDIO_DEVICE = 0x28, /**< Hifi minor class */
477 BLUETOOTH_DEVICE_MINOR_CLASS_VCR = 0x2C, /**< VCR minor class */
478 BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_CAMERA = 0x30, /**< Video Camera minor class */
479 BLUETOOTH_DEVICE_MINOR_CLASS_CAM_CORDER = 0x34, /**< CAM Corder minor class */
480 BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_MONITOR = 0x38, /**<Video Monitor minor class */
481 BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_DISPLAY_AND_LOUD_SPEAKER = 0x3C,
482 /**< Video Display and Loud
483 Speaker minor class */
484 BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_CONFERENCING = 0x40, /**< Video Conferencing minor
487 BLUETOOTH_DEVICE_MINOR_CLASS_GAMING_OR_TOY = 0x48, /**< Gaming or toy minor class */
489 /* About Peripheral Major class */
490 BLUETOOTH_DEVICE_MINOR_CLASS_KEY_BOARD = 0x40, /**< Key board minor class */
491 BLUETOOTH_DEVICE_MINOR_CLASS_POINTING_DEVICE = 0x80, /**< Pointing Device minor class */
492 BLUETOOTH_DEVICE_MINOR_CLASS_COMBO_KEYBOARD_OR_POINTING_DEVICE = 0xC0,
493 /**< Combo Keyboard or pointing
496 BLUETOOTH_DEVICE_MINOR_CLASS_JOYSTICK = 0x04, /**< JoyStick minor class */
497 BLUETOOTH_DEVICE_MINOR_CLASS_GAME_PAD = 0x08, /**< Game Pad minor class */
498 BLUETOOTH_DEVICE_MINOR_CLASS_REMOTE_CONTROL = 0x0C, /**< Remote Control minor class */
499 BLUETOOTH_DEVICE_MINOR_CLASS_SENSING_DEVICE = 0x10, /**< Sensing Device minor class */
500 BLUETOOTH_DEVICE_MINOR_CLASS_DIGITIZER_TABLET = 0x14, /**< Digitizer minor class */
501 BLUETOOTH_DEVICE_MINOR_CLASS_CARD_READER = 0x18, /**< Card Reader minor class */
502 BLUETOOTH_DEVICE_MINOR_CLASS_DIGITAL_PEN = 0x1C, /**< Digital pen minor class */
503 BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_SCANNER = 0x20, /**< Handheld scanner for bar-codes, RFID minor class */
504 BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_GESTURAL_INPUT_DEVICE = 0x24, /**< Handheld gestural input device minor class */
506 /* About Imaging Major class */
507 BLUETOOTH_DEVICE_MINOR_CLASS_DISPLAY = 0x10, /**< Display minor class */
508 BLUETOOTH_DEVICE_MINOR_CLASS_CAMERA = 0x20, /**< Camera minor class */
509 BLUETOOTH_DEVICE_MINOR_CLASS_SCANNER = 0x40, /**< Scanner minor class */
510 BLUETOOTH_DEVICE_MINOR_CLASS_PRINTER = 0x80, /**< Printer minor class */
512 /* About Wearable Major class */
513 BLUETOOTH_DEVICE_MINOR_CLASS_WRIST_WATCH = 0x04, /**< Wrist watch minor class */
514 BLUETOOTH_DEVICE_MINOR_CLASS_PAGER = 0x08, /**< Pager minor class */
515 BLUETOOTH_DEVICE_MINOR_CLASS_JACKET = 0x0C, /**< Jacket minor class */
516 BLUETOOTH_DEVICE_MINOR_CLASS_HELMET = 0x10, /**< Helmet minor class */
517 BLUETOOTH_DEVICE_MINOR_CLASS_GLASSES = 0x14, /**< Glasses minor class */
519 /* About Toy Major class */
520 BLUETOOTH_DEVICE_MINOR_CLASS_ROBOT = 0x04, /**< Robot minor class */
521 BLUETOOTH_DEVICE_MINOR_CLASS_VEHICLE = 0x08, /**< Vehicle minor class */
522 BLUETOOTH_DEVICE_MINOR_CLASS_DOLL_OR_ACTION = 0x0C, /**< Doll or Action minor class */
523 BLUETOOTH_DEVICE_MINOR_CLASS_CONTROLLER = 0x10, /**< Controller minor class */
524 BLUETOOTH_DEVICE_MINOR_CLASS_GAME = 0x14, /**< Game minor class */
526 /* About Health Major class */
527 BLUETOOTH_DEVICE_MINOR_CLASS_BLOOD_PRESSURE_MONITOR = 0x04, /**< Blood Pressure minor class */
528 BLUETOOTH_DEVICE_MINOR_CLASS_THERMOMETER = 0x08, /**< Thermometer minor class */
529 BLUETOOTH_DEVICE_MINOR_CLASS_WEIGHING_SCALE = 0x0C, /**< Weighing Scale minor class */
530 BLUETOOTH_DEVICE_MINOR_CLASS_GLUCOSE_METER = 0x10, /**< Glucose minor class */
531 BLUETOOTH_DEVICE_MINOR_CLASS_PULSE_OXIMETER = 0x14, /**< Pulse Oximeter minor class */
532 BLUETOOTH_DEVICE_MINOR_CLASS_HEART_OR_PULSE_RATE_MONITOR = 0x18,/**< Heart or pulse rate monitor minor class */
533 BLUETOOTH_DEVICE_MINOR_CLASS_MEDICAL_DATA_DISPLAY = 0x1C, /**< Medical minor class */
534 BLUETOOTH_DEVICE_MINOR_CLASS_STEP_COUNTER = 0x20, /**< Step Counter minor class */
535 BLUETOOTH_DEVICE_MINOR_CLASS_BODY_COMPOSITION_ANALYZER = 0x24, /**< Body composition analyzer minor class */
536 BLUETOOTH_DEVICE_MINOR_CLASS_PEAK_FLOW_MONITOR = 0x28, /**< Peak flow monitor minor class */
537 BLUETOOTH_DEVICE_MINOR_CLASS_MEDICATION_MONITOR = 0x2C, /**< Medication monitor minor class */
538 BLUETOOTH_DEVICE_MINOR_CLASS_KNEE_PROSTHESIS = 0x30, /**< Knee prosthesis minor class */
539 BLUETOOTH_DEVICE_MINOR_CLASS_ANKLE_PROSTHESIS = 0x34, /**< Ankle prosthesis minor class */
540 } bluetooth_device_minor_class_t;
543 * structure to hold the device information
546 bluetooth_device_major_class_t major_class; /**< major device class */
547 bluetooth_device_minor_class_t minor_class; /**< minor device class */
548 bluetooth_device_service_class_t service_class;
549 /**< service device class */
550 } bluetooth_device_class_t;
553 * structure to hold the device information
556 bluetooth_device_address_t device_address; /**< device address */
557 bluetooth_device_name_t device_name; /**< device name */
558 bluetooth_device_class_t device_class; /**< device class */
559 char uuids[BLUETOOTH_MAX_SERVICES_FOR_DEVICE][BLUETOOTH_UUID_STRING_MAX];
560 unsigned int service_list_array[BLUETOOTH_MAX_SERVICES_FOR_DEVICE]; /**< Use enum values in bt_service_uuid_list_t */
562 int rssi; /**< received strength signal*/
563 gboolean paired; /**< paired flag */
564 gboolean connected; /**< connected flag */
565 gboolean trust; /**< connected flag */
566 } bluetooth_device_info_t;
569 * structure to hold the paired device information
572 bluetooth_device_address_t device_address; /**< paired device address */
573 bluetooth_device_name_t device_name; /**< device name */
574 bluetooth_device_class_t device_class; /**< device class */
575 } bluetooth_paired_device_info_t;
578 * structure to hold the paired device information
581 bluetooth_device_address_t device_address;
582 /**< device address */
583 char interface_name[BLUETOOTH_INTERFACE_NAME_LENGTH + 1];
584 /**< network interface name */
585 } bluetooth_network_device_info_t;
588 * Stucture to hold discovery option
591 unsigned short max_response; /**< the number of maximum response */
592 unsigned short discovery_duration;
593 /**< duration of discovery (seconds) */
594 unsigned int classOfDeviceMask; /**< mask for values of class of device. to be used with
595 classOfDevice variable */
596 } bluetooth_discovery_option_t;
599 * Stucture to hold event information
602 int event; /**< event type */
603 int result; /**< Success or error value */
605 /**<parameter data pointer */
607 } bluetooth_event_param_t;
610 bluetooth_device_address_t device_addr;
611 char uuids[BLUETOOTH_MAX_SERVICES_FOR_DEVICE][BLUETOOTH_UUID_STRING_MAX];
612 unsigned int service_list_array[BLUETOOTH_MAX_SERVICES_FOR_DEVICE]; /**< Use enum values in bt_service_uuid_list_t */
613 unsigned int service_name_array[BLUETOOTH_MAX_SERVICES_FOR_DEVICE];
618 * Stucture to rfcomm receive data
623 /**< the socket fd */
624 int buffer_size;/**< the length of the receive buffer */
626 /**< the receive data buffer */
627 } bluetooth_rfcomm_received_data_t;
630 * Stucture to rfcomm connection
635 /**< the socket fd */
636 int device_role;/** < Device role - RFCOMM_ROLE_SERVER or RFCOMM_ROLE_CLIENT */
637 bluetooth_device_address_t device_addr;
638 /**< device address */
639 char uuid[BLUETOOTH_UUID_STRING_MAX];
640 } bluetooth_rfcomm_connection_t;
643 * Stucture to rfcomm disconnection
647 /**< the socket fd */
648 int device_role;/** < Device role - RFCOMM_ROLE_SERVER or RFCOMM_ROLE_CLIENT */
649 bluetooth_device_address_t device_addr;
650 /**< device address */
651 char uuid[BLUETOOTH_UUID_STRING_MAX];
652 } bluetooth_rfcomm_disconnection_t;
656 /**< the socket fd */
657 bluetooth_device_address_t device_addr;
658 /**< device address */
659 } bluetooth_rfcomm_connection_request_t;
674 HDP_ROLE_SOURCE = 0x0,
680 * Stucture to HDP connected
683 const char *app_handle; /**< the application handle */
684 unsigned int channel_id; /**< the channel id */
685 bt_hdp_qos_type_t type; /**< the QOS type */
686 bluetooth_device_address_t device_address; /**< the remote address */
687 } bt_hdp_connected_t;
690 * Stucture to HDP disconnected
693 unsigned int channel_id; /**< the channel id */
694 bluetooth_device_address_t device_address; /**< the remote address */
695 } bt_hdp_disconnected_t;
698 * Stucture to HDP data indication
701 unsigned int channel_id; /**< the channel id */
702 const char *buffer; /**< the RX data buffer */
703 unsigned int size; /**< the RX data size */
707 * Stucture to OPP client transfer information
713 }bt_opc_transfer_info_t;
715 /* Obex Server transfer type */
716 #define TRANSFER_PUT "PUT"
717 #define TRANSFER_GET "GET"
719 * Stucture to OPP/FTP Server authorize information
724 } bt_obex_server_authorize_into_t;
727 * Stucture to OPP/FTP server transfer information
734 unsigned long file_size;
736 } bt_obex_server_transfer_info_t;
739 * Stucture to OOB data
743 unsigned char hash[BLUETOOTH_OOB_DATA_LENGTH];
744 unsigned char randomizer[BLUETOOTH_OOB_DATA_LENGTH];
745 unsigned int hash_len;
746 unsigned int randomizer_len;
750 * Structure to GATT attribute handle data
756 } bt_gatt_handle_info_t;
759 * Structure to GATT Remote service data
764 bt_gatt_handle_info_t handle_info;
765 } bt_gatt_service_property_t;
768 * Structure to GATT Remote characteristic data
772 char *service_handle;
773 bt_gatt_handle_info_t handle_info;
774 } bt_gatt_discovered_char_t;
777 * Structure to format of GATT Characteristic Value
781 unsigned char format;
782 unsigned char exponent;
784 unsigned char name_space;
785 unsigned short description;
786 } bt_gatt_char_format_t;
789 * Structure to GATT Characteristic property
796 bt_gatt_char_format_t format;
798 unsigned int val_len;
799 char *representation;
800 } bt_gatt_char_property_t;
803 * Structure to GATT Characteristic value
810 } bt_gatt_char_value_t;
813 * Callback pointer type
815 typedef void (*bluetooth_cb_func_ptr) (int, bluetooth_event_param_t *, void *);
818 * @fn int bluetooth_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data)
819 * @brief Set the callback function pointer for bluetooth event
822 * This API will register the callback function, when any response and event are received from
823 * bluetooth framework. @n
824 * this registered callback function will be get called with appropriate event and data structures.
825 * This function is a synchronous call. An application developer can call
826 * bluetooth_register_callback() function to register a callback function of bluetooth_cb_func_ptr
827 * type. This registered function will receive events of bluetooth_event_type_t type along with
831 * @param[in] callback_ptr A pointer to the callback function
832 * @param[in] user_data A pointer to user data
833 * @return BLUETOOTH_ERROR_NONE - Success
837 void bt_event_callback(int event, bluetooth_event_param_t *param, void *user_data)
839 GMainLoop *main_loop = (GMainLoop*) user_data;
843 // Code for each event
845 g_main_loop_quit(main_loop);
852 GMainLoop *main_loop = NULL;
855 main_loop = g_main_loop_new(NULL, FALSE);
856 ret = bluetooth_register_callback(bt_event_callback, (void*)main_loop);
857 if (ret >= BLUETOOTH_ERROR_NONE)
859 // bluetooth_register_callback returned Success
863 // bluetooth_register_callback returned failiure
865 g_main_loop_run(main_loop);
869 int bluetooth_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data);
872 * @fn int bluetooth_deregister_callback(bluetooth_cb_func_ptr callback_ptr)
873 * @brief Set the callback function pointer for bluetooth event
876 * This API will register the callback function, when any response and event are received from
877 * bluetooth framework. @n
878 * this registered callback function will be get called with appropriate event and data structures.
879 * This function is a synchronous call. An application developer can call
880 * bluetooth_register_callback() function to register a callback function of bluetooth_cb_func_ptr
881 * type. This registered function will receive events of bluetooth_event_type_t type along with
886 * @return BLUETOOTH_ERROR_NONE - Success
890 void bt_event_callback(int event, bluetooth_event_param_t *param, void *user_data)
892 GMainLoop *main_loop = (GMainLoop*) user_data;
896 // Code for each event
898 g_main_loop_quit(main_loop);
905 GMainLoop *main_loop = NULL;
908 main_loop = g_main_loop_new(NULL, FALSE);
909 ret = bluetooth_register_callback(bt_event_callback, (void*)main_loop);
910 if (ret >= BLUETOOTH_ERROR_NONE)
912 // bluetooth_register_callback returned Success
916 // bluetooth_register_callback returned failiure
918 ret = bluetooth_deregister_callback(void);
919 g_main_loop_run(main_loop);
923 int bluetooth_unregister_callback(void);
926 * @fn int bluetooth_enable_adapter(void)
927 * @brief Enable the Bluetooth H/W
930 * This API can be used to activate Bluetooth. It initializes Bluetooth protocol stack for use and
931 * send request to bluetooth chip for activation.
932 * This function is typically called at startup or when Bluetooth services are required. This
933 * function must be called before calling any other API of Bluetooth operations.
935 * Before performing any operations like Device discover, service search etc.., the adapter must be
938 * This function is a asynchronous call.
939 * If the call is success then the application will receive BLUETOOTH_EVENT_ENABLED event
940 * through registered callback function with appropriate result code
941 * BLUETOOTH_CHANGE_STATUS_TIMEOUT - Timeout has happen \n
942 * BLUETOOTH_ERROR_NONE - Success \n
944 * If the adpter is not enabled with in 30 seconds then BLUETOOTH_EVENT_ENABLED with result code
945 * BLUETOOTH_CHANGE_STATUS_TIMEOUT will come
947 * @return BLUETOOTH_ERROR_NONE - Success\n
948 * BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED - Adapter already enabled\n
949 * BLUETOOTH_ERROR_ACCESS_DENIED - Enabling adapter is not allowed by MDM policy\n
950 * BLUETOOTH_ERROR_IN_PROGRESS - Adapter is activating or deactivating\n
951 * @exception BLUETOOTH_ERROR_INTERNAL - Dbus proxy call is fail
953 * @see bluetooth_check_adapter, bluetooth_disable_adapter
955 void bt_event_callback(int event, bluetooth_event_param_t *param)
959 case BLUETOOTH_EVENT_ENABLED:
960 if (param->result == BLUETOOTH_ERROR_NONE)
962 // Successfully Enabled
975 ret = bluetooth_enable_adapter();
979 int bluetooth_enable_adapter(void);
982 * @fn int bluetooth_disable_adapter(void)
983 * @brief Disable the Bluetooth H/W
986 * This function disables Bluetooth protocol stack and hardware. This function is called when
987 * Bluetooth is no longer used. It will internally free all resources and power off the RF radio.
989 * Bluetooth adapter should be disabled to switch off Bluetooth chip (and thereby saving power).
990 * bluetooth_disable_adapter() API will do that job for you. After switching off Bluetooth,
991 * BLUETOOTH_EVENT_DISABLED will be sent by SDK to application for confirmation with appropriate
993 * The various error codes are BLUETOOTH_ERROR_NONE for success and BLUETOOTH_ERROR_INTERNAL for
996 * This function is a asynchronous call.
997 * If this call is success then the applications will receive BLUETOOTH_EVENT_DISABLED event
998 * through registered callback function.
1001 * @return BLUETOOTH_ERROR_NONE - Success\n
1002 * BLUETOOTH_ERROR_IN_PROGRESS - Adapter is activating or deactivating\n
1003 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Bluetooth adapter is not enabled\n
1004 * @exception BLUETOOTH_ERROR_INTERNAL - Dbus proxy call is fail
1006 * @see bluetooth_check_adapter, bluetooth_enable_adapter
1008 void bt_event_callback(int event, bluetooth_event_param_t *param)
1012 case BLUETOOTH_EVENT_DISABLED:
1013 if (param->result == BLUETOOTH_ERROR_NONE)
1015 // Successfully disabled
1028 ret = bluetooth_disable_adapter();
1031 int bluetooth_disable_adapter(void);
1035 * @fn int bluetooth_is_supported(void)
1036 * @brief Check if the bluetooth is supported or not by the current target
1038 * This API checks whether the bluetooth is supported or not.
1039 * This API only run by root permission.
1040 * This API was made for the MDM service.
1042 * This function is a synchronous call.
1044 * @return 0 - if bluetooth is not supported\n
1045 * 1 - if bluetooth is supported\n
1046 * BLUETOOTH_ERROR_INTERNAL - Error in API internal
1051 ret = bluetooth_is_supported();
1054 int bluetooth_is_supported(void);
1058 * @fn int bluetooth_check_adapter(void)
1059 * @brief Check the current status of the Bluetooth adapter
1062 * This API checks whether the Bluetooth adapter is enabled or not. Before performing any operations
1063 * the bluetooth adapter should be enabled. This API helps to find out the current state of the
1064 * bluetooth adapter.
1065 * This API get the adapter internal data structure and check current adapter status.
1067 * This function is a synchronous call.
1070 * @return BLUETOOTH_ADAPTER_DISABLED - if bluetooth adapter is disabled\n
1071 * BLUETOOTH_ADAPTER_ENABLED - if bluetooth adapter is enabled\n
1073 * @see bluetooth_enable_adapter, bluetooth_disable_adapter
1077 ret = bluetooth_check_adapter();
1080 int bluetooth_check_adapter(void);
1083 * @fn int bluetooth_get_local_address(bluetooth_device_address_t *local_address)
1084 * @brief Get the local adapter bluetooth address
1087 * This API is used, get the device address of the local bluetooth adapter. Before calling this API,
1088 * the adapter should be enabled.
1089 * In its output parameter, you can receive bluetooth_device_address_t type of pointer which will
1090 * contain Bluetooth address.
1091 * Since its inconvenient for user to remember the address, Bluetooth provides a method to have a
1092 * friendly name for each device.
1093 * There is no event callback for this API.
1095 * This function is a synchronous call.
1098 * @return BLUETOOTH_ERROR_NONE - Succeess \n
1099 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter (NULL buffer) \n
1100 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
1101 * @param[out] local_address a device address of local bluetooth adapter
1106 bluetooth_device_address_t local_address={0,};
1109 ret = bluetooth_get_local_address(&local_address);
1112 int bluetooth_get_local_address(bluetooth_device_address_t *local_address);
1115 * @fn int bluetooth_get_local_name(bluetooth_device_name_t* local_name)
1116 * @brief Get the local device name
1119 * This function is used, get the local device name. Since its difficult to remember the Adapter
1120 * address, the friendly name can be assigned to the adapter and we can get it using this API. This
1121 * friendly name is retrived by the remote device and displaying.
1122 * Before calling this API, the adapter should be enabled. There is no event callback for this API.
1124 * This function is a synchronous call.
1127 * @return BLUETOOTH_ERROR_NONE - Success \n
1128 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter (NULL buffer)\n
1129 * @param[out] local_name a local device name
1133 bluetooth_device_name_t local_name={0,}
1135 ret = bluetooth_get_local_name (&local_name);
1138 int bluetooth_get_local_name(bluetooth_device_name_t *local_name);
1141 * @fn int bluetooth_set_local_name(const bluetooth_device_name_t *local_name)
1142 * @brief Set the local device name
1145 * This function is used to set the local device name. This is a human friendly name whose
1146 * length can be BLUETOOTH_DEVICE_NAME_LENGTH_MAX maximum
1148 * This function is a synchronous call.
1150 * @param[in] local_name bluetooth device name to set local device
1152 * @return BLUETOOTH_ERROR_NONE - Success \n
1153 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1154 * BLUETOOTH_ERROR_INVALID_PARAM - Bluetooth name parameter is incorrect \n
1155 * BLUETOOTH_ERROR_INVALID_DATA - Device address provided is incorrect \n
1156 * BLUETOOTH_ERROR_NO_RESOURCES - Pre-allocated memory error \n
1157 * BLUETOOTH_ERROR_INTERNAL - The dbus method call is fail \n
1162 bluetooth_device_name_t local_name={0,}
1164 ret = bluetooth_set_local_name (&local_name);
1167 int bluetooth_set_local_name(const bluetooth_device_name_t *local_name);
1171 * @fn int bluetooth_is_service_used(const char *service_uuid, gboolean *used)
1172 * @brief Check if the uuid is used or not
1174 * This function is used to check if the uuid is used or not.
1176 * This function is a synchronous call.
1178 * @param[in] service_uuid service uuid (UUID 128 bit as string)
1179 * @param[out] used if the uuid is used or not
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_INTERNAL - The dbus method call is fail \n
1189 gboolean used = FALSE;
1190 const char *uuid ="00001101-0000-1000-8000-00805F9B34FB";
1191 ret = bluetooth_is_service_used(uuid, &used);
1194 int bluetooth_is_service_used(const char *service_uuid, gboolean *used);
1197 * @fn int bluetooth_is_device_connected(const bluetooth_device_address_t *device_address, bluetooth_service_type_t type, gboolean *is_connected)
1198 * @brief Check if the device is connected to the specific service
1200 * This function is used to check if if the device is connected to the specific service.
1202 * This function is a synchronous call.
1204 * @param[in] local_address a device address of remote bluetooth device
1205 * @param[in] type the service type
1206 * @param[out] is_connected if the device is connected or not
1208 * @return BLUETOOTH_ERROR_NONE - Success \n
1209 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1210 * BLUETOOTH_ERROR_INVALID_PARAM - Bluetooth name parameter is incorrect \n
1211 * BLUETOOTH_ERROR_INTERNAL - The dbus method call is fail \n
1216 gboolean is_connected = FALSE;
1217 bluetooth_device_address_t device_address={{0x00,0x0D,0xFD,0x24,0x5E,0xFF}};
1218 ret = bluetooth_is_device_connected(&device_address, BLUETOOTH_HSP_SERVICE, &used);
1221 int bluetooth_is_device_connected(const bluetooth_device_address_t *device_address,
1222 bluetooth_service_type_t type,
1223 gboolean *is_connected);
1226 * @fn int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t *discoverable_mode_ptr)
1227 * @brief Get the visibility mode
1230 * This function is used to get the discoverable mode (Visibility option). Depending upon the
1231 * visibity mode, the property of the device is determined whether it can be discoverable, non
1232 * discoverable, connectable etc. Before calling this API make sure that the adapter is enabled.
1234 * This function is a synchronous call.
1237 * @return BLUETOOTH_ERROR_NONE - Success \n
1238 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1239 * BLUETOOTH_ERROR_INVALID_DATA - Invalid data \n
1240 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1241 * BLUETOOTH_ERROR_INTERNAL - Internal IPC error \n
1242 * @param[out] discoverable_mode current bluetooth discoverable mode
1244 * @see bluetooth_set_discoverable_mode
1246 bluetooth_discoverable_mode_t discoverable_mode_ptr;
1248 ret = bluetooth_get_discoverable_mode (&discoverable_mode_ptr);
1251 int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t *discoverable_mode_ptr);
1254 * @fn int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t discoverable_mode,
1256 * @brief Set the visibility mode
1259 * This function is used to set the discoverable mode (Visibility option).
1261 * Many times user may want to keep his device discoverable so that when peer device is performing
1262 * device search, he/she can find user's device. Application programmer can keep the mode as
1263 * BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE or
1264 * BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE for the same purpose. However, all these
1265 * modes cause bluetooth adapter to consume more battery. Hence developer should generally
1266 * keep discoverable mode as BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE.
1268 * This function is a synchronous call.
1270 * @return BLUETOOTH_ERROR_NONE - Success \n
1271 * BLUETOOTH_ERROR_NOT_SUPPORT - Requested mode is not supported \n
1273 * @param[in] discoverable_mode the bluetooth discoverable mode to set
1274 * @param[in] timeout discoverable time in only limited discoverable mode (second), default: 0
1276 * @see bluetooth_get_discoverable_mode
1280 bluetooth_discoverable_mode_t mode;
1282 mode= BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE;
1283 ret = bluetooth_set_discoverable_mode (mode, 180);
1287 int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t discoverable_mode,
1292 * @fn int bluetooth_get_timeout_value(int *timeout)
1293 * @brief Get the visibility timeout value
1296 * This function is used to get the visibility timeout
1297 * Before calling this API make sure that the adapter is enabled.
1299 * This function is a synchronous call.
1302 * @return BLUETOOTH_ERROR_NONE - Success \n
1303 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1304 * BLUETOOTH_ERROR_INVALID_DATA - Invalid data \n
1305 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1306 * BLUETOOTH_ERROR_INTERNAL - Internal IPC error \n
1307 * @param[out] timeout remain visibility timeout value
1309 * @see bluetooth_set_discoverable_mode
1313 ret = bluetooth_get_timeout_value (&timeout);
1316 int bluetooth_get_timeout_value(int *timeout);
1320 * @fn int bluetooth_start_discovery(unsigned short max_response, unsigned short discovery_duration,
1321 * unsigned int classOfDeviceMask)
1322 * @brief Start the device discovery
1324 * To connect connect to peer bluetooth device, you will need to know its bluetooth address and its
1325 * name. You can search for Bluetooth devices in vicinity by bluetooth_start_discovery() API. It
1326 * first performs an inquiry. For each device found from the inquiry it gets the remote name of the
1327 * device. Bluetooth device address and name are given to Application via
1328 * BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event. In param_data of bluetooth_event_param_t, you will
1329 * receive a pointer to a structure of bluetooth_device_info_t type. you will receive device
1330 * address, device name, device class, rssi (received signal strength indicator). please see
1331 * bluetooth_device_info_t for more details.
1334 * This API provides searching options like max responses, discovery duration in seconds and class
1335 * of device mask to filter device search. some times there may be too many bluetooth devices in
1336 * vicinity of your device.in such scenario, application can request to reduce number of responces
1337 * (BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event) with help of max_response parameter. However if you
1338 * pass zero, bluetooth adapter will not restrict number of responses. you can also specify duration
1339 * of the seach in discovery_duration. bluetooth adapter will automatically stop device search after
1340 * application defined time. please note that discovery_duration should be mentioned in seconds.
1341 * Also note that search will end after 180 seconds automatically if you pass 0 in discovery
1344 * sometimes user may want to search for a perticular kind of device. for ex, mobile or pc. in such
1345 * case, you can use classOfDeviceMask parameter. please see bluetooth_device_service_class_t,
1346 * bluetooth_device_major_class_t and bluetooth_device_minor_class_t enums
1348 * This function is a asynchronous call.
1349 * If the call is success then the application will receive BLUETOOTH_EVENT_DISCOVERY_STARTED event
1350 * through registered callback function.
1352 * The discovery is responded by an BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event for each device it
1353 * finds and an BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED event for each fount device its name
1356 * The completion or cancellation of the discovery is indicated by an
1357 * BLUETOOTH_EVENT_DISCOVERY_FINISHED event.
1359 * The device discovery can be cancelled by calling bluetooth_stop_discovery().
1362 * @return BLUETOOTH_ERROR_NONE - Success \n
1363 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Bluetooth adapter is not enabled \n
1364 * BLUETOOTH_ERROR_DEVICE_BUSY - Bluetooth adapter is busy doing some operation \n
1365 * BLUETOOTH_ERROR_INTERNAL - System error like heap full has occured or bluetooth
1366 agent is not running \n
1368 * @param[in] max_response define the maximum response of the number of founded devices
1370 * @param[in] discovery_duration define bluetooth discovery duration (0 means 180s )
1371 * @param[in] classOfDeviceMask define classes of the device mask which user wants
1372 (refer to class of device)
1374 * @see bluetooth_cancel_discovery, bluetooth_device_info_t
1377 void bt_event_callback(int event, bluetooth_event_param_t *param)
1381 case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
1383 bluetooth_device_info_t *device_info = NULL;
1384 printf("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]",
1386 device_info = (bluetooth_device_info_t *)param->param_data;
1387 memcpy(&searched_device, &device_info->device_address,
1388 sizeof(bluetooth_device_address_t));
1389 printf("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]",
1390 device_info->device_address.addr[0],
1391 device_info->device_address.addr[1],
1392 device_info->device_address.addr[2],
1393 device_info->device_address.addr[3],
1394 device_info->device_address.addr[4],
1395 device_info->device_address.addr[5]);
1398 case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
1400 bluetooth_device_info_t *device_info = NULL;
1401 printf("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]",
1403 device_info = (bluetooth_device_info_t *)param->param_data;
1404 memcpy(&searched_device, &device_info->device_address,
1405 sizeof(bluetooth_device_address_t));
1406 printf("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]",
1407 device_info->device_name.name,
1408 device_info->device_address.addr[0],
1409 device_info->device_address.addr[1],
1410 device_info->device_address.addr[2],
1411 device_info->device_address.addr[3],
1412 device_info->device_address.addr[4],
1413 device_info->device_address.addr[5]);
1417 case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
1418 printf("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result[0x%04x]", param->result);
1423 unsigned short max_response;
1424 unsigned short discovery_duration;
1425 unsigned classOfDeviceMask;
1429 discovery_duration =0;
1430 classOfDeviceMask =0;
1432 ret = bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);
1438 int bluetooth_start_discovery(unsigned short max_response,
1439 unsigned short discovery_duration,
1440 unsigned int classOfDeviceMask);
1443 * @fn int bluetooth_cancel_discovery (void)
1444 * @brief Cancel the on-going device discovery operation
1447 * This function stops the on-going device discovery operation. This API has to be called after the
1448 * bluetooth_start_discovery API and before the BLUETOOTH_EVENT_DISCOVERY_FINISHED event comes of
1449 * the bluetooth_start_discovery API
1451 * Normally the device discovery takes a more time (~10.24 seconds) to get all the devices in its
1452 * vicinity and it recevies as BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event. This API helps us to
1453 * cancel the discover request once the user received the device to which he wish to connect.
1455 * This function is a asynchronous call.
1456 * If the call is success to cancel discovey then the application will receive
1457 * BLUETOOTH_EVENT_DISCOVERY_FINISHED event through registered callback function
1458 * with an error code BLUETOOTH_ERROR_CANCEL. In the case of failure the error code will be
1459 * BLUETOOTH_ERROR_NONE
1462 * @return BLUETOOTH_ERROR_NONE - Success \n
1463 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1464 * BLUETOOTH_ERROR_NOT_IN_OPERATION - No Discovery operation in progess to cancel \n
1465 * BLUETOOTH_ERROR_ACCESS_DENIED - Currently in discovery but it is requested from
1466 other application \n
1467 * BLUETOOTH_ERROR_INTERNAL - Internel IPC error \n
1469 * @see bluetooth_start_discovery
1471 void bt_event_callback(int event, bluetooth_event_param_t *param)
1475 case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
1476 TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result[0x%04x]", param->result);
1485 ret = bluetooth_cancel_discovery();
1488 int bluetooth_cancel_discovery(void);
1491 * @fn int bluetooth_is_discovering(void)
1492 * @brief Check for the device discovery is in-progress or not.
1494 * This API is used to check the current status of the Discovery operation.If discovery is in\
1495 * progress normally other operations are not allowed.
1496 * If a device discovery is in progress, we have to either cancel the discovery operation or wait
1497 * for the BLUETOOTH_EVENT_DISCOVERY_FINISHED
1498 * event before performing other operations. This API is used to get for the current discovery
1499 * operation status and using bluetooth_cancel_discovery()
1500 * we can cancell the ongoing discovery process.
1501 * Before calling this API, make sure that the adapter is enabled. There is no callback event for
1504 * This function checks whether the device discovery is started or not.
1506 * This function is a synchronous call.
1509 * @return BLUETOOTH_ERROR_NONE - Discovery is not in progress \n
1510 * BLUETOOTH_ERROR_NONE+1 - Discovery in progress \n
1511 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1514 * @see bluetooth_start_discovery, bluetooth_cancel_discovery
1518 ret = bluetooth_is_discovering ();
1521 int bluetooth_is_discovering(void);
1524 * @fn int bluetooth_bond_device(const bluetooth_device_address_t *device_address)
1525 * @brief Initiate a bonding process
1528 * This function initiates a bonding procedure with a peer device. The bonding procedure
1529 * enables authentication and optionally encryption on the Bluetooth link.
1531 * Bonding is applied to the discovered device to which we need a secure connection. We cannot
1532 * inititate the bonding request to the devices already in the paired list.
1534 * Usually we call this API after the device discovery.
1535 * This function is a asynchronous call.
1537 * Response will be received through BLUETOOTH_EVENT_BONDING_FINISHED event. It can any of the below
1538 * mentioed result code
1539 * BLUETOOTH_ERROR_PARING_FAILED - Pairing faied \n
1540 * BLUETOOTH_ERROR_ACCESS_DENIED - Authetication rejected \n
1541 * BLUETOOTH_ERROR_CANCEL_BY_USER - Cancelled by the user \n
1542 * BLUETOOTH_ERROR_PARING_FAILED - Pairing failed \n
1543 * BLUETOOTH_ERROR_TIMEOUT - Timeout has haapened \n
1545 * If the remote user is not responding with in a specific time(60 seconds), then a timeout happens
1546 * and BLUETOOTH_EVENT_BONDING_FINISHED callback event is called with and BLUETOOTH_ERROR_TIMEOUT
1549 * The bonding operation can be cancelled by calling bluetooth_cancel_bonding().
1552 * @return BLUETOOTH_ERROR_NONE - Success \n
1553 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
1554 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1555 * BLUETOOTH_ERROR_DEVICE_BUSY - Adapter is busy or Discovery is in Progress \n
1556 * BLUETOOTH_ERROR_INVALID_DATA - Invalid BD address \n
1558 * @param[in] device_address This indicates an address of the device with which the pairing
1559 * should be initiated
1561 * @see bluetooth_cancel_bonding
1563 void bt_event_callback(int event, bluetooth_event_param_t *param)
1567 case BLUETOOTH_EVENT_BONDING_FINISHED:
1569 TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
1570 if (param->result >= BLUETOOTH_ERROR_NONE)
1572 bluetooth_device_info_t *device_info = NULL;
1573 device_info = (bluetooth_device_info_t *)param->param_data;
1574 printf("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]
1575 mjr[%#x] min[%#x] srv[%#x]",
1576 device_info->device_name.name,
1577 device_info->device_address.addr[0],
1578 device_info->device_address.addr[1],
1579 device_info->device_address.addr[2],
1580 device_info->device_address.addr[3],
1581 device_info->device_address.addr[4],
1582 device_info->device_address.addr[5],
1583 device_info->device_class.major_class,
1584 device_info->device_class.minor_class,
1585 device_info->device_class.service_class);
1599 bluetooth_device_address_t device_address={{0}};
1601 ret = bluetooth_bond_device(&device_address);
1605 int bluetooth_bond_device(const bluetooth_device_address_t *device_address);
1608 * @fn int bluetooth_cancel_bonding(void)
1609 * @brief Cancel the on-going bonding process
1611 * This API is called to cancel the on-going bonding procedure. It should be called before the
1612 * BLUETOOTH_EVENT_BONDING_FINISHED event comes.
1613 * This API is useful when the remote device is not responding to the bond request or we wish to
1614 * cancel the bonding request. In this case we need not wait for the timeout to happen.
1616 * This function is a synchronous call.
1618 * @return BLUETOOTH_ERROR_NONE - Success \n
1619 * BLUETOOTH_ERROR_NOT_IN_OPERATION - No bonding request in progress \n
1620 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
1623 * @see bluetooth_bond_device
1629 ret = bluetooth_cancel_bonding();
1632 int bluetooth_cancel_bonding(void);
1635 * @fn int bluetooth_unbond_device(const bluetooth_device_address_t *device_address)
1636 * @brief Remove bonding
1639 * To communicate with remote device over bluetooth link, user should bond with peer device.
1640 * After bonding is over, peer device is added to list of bonded devices. bluetooth_unbond_device()
1641 * API is used to remove peer device from the list. Please note that after removing the device
1642 * from bonded device list, you cannot communication with peer device until bonding happens again.
1644 * User can call this function by passing bluetooth device address of any bonded device. Please note
1645 * that after successful return of this function, any bluetooth application running on your device
1646 * will not be able to communicate with unbonded device until bond operation happens again using
1647 * bluetooth_bond_device()
1650 * This function is a asynchronous call. The request to remove the specified device from the bonded
1651 * list is responded by an BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED event. if the operation is success,
1652 * you will receive BLUETOOTH_ERROR_NONE. BLUETOOTH_ERROR_NOT_PAIRED may be received in result code
1653 * in case if there is a problem in locating given bluetooth device address in bonded devices list
1657 * @return BLUETOOTH_ERROR_NONE - Success \n
1658 * BLUETOOTH_ERROR_INVALID_PARAM - Device address is not valid \n
1659 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Bluetooth adapter is not enabled \n
1660 * BLUETOOTH_ERROR_DEVICE_BUSY - Bluetooth adapter is busy doing some operation \n
1661 * BLUETOOTH_ERROR_INVALID_DATA - Device address provided is incorrect \n
1662 * BLUETOOTH_ERROR_INTERNAL - System error like heap full has occured or bluetooth
1663 * agent is not running \n
1664 * BLUETOOTH_ERROR_NOT_PAIRED - Device address mentioned in the argument is not a
1667 * @param[in] device_address This indicates an address of the device to remove bonding
1671 * @see bluetooth_bond_device, bluetooth_cancel_bonding
1674 void bt_event_callback(int event, bluetooth_event_param_t *param)
1677 case BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED: {
1678 bluetooth_device_address_t *dev_addr = NULL;
1680 if (param->result == BLUETOOTH_ERROR_NONE) {
1681 dev_addr = (bluetooth_device_address_t *)param->param_data;
1683 printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
1684 dev_addr->addr[0], dev_addr->addr[1]
1685 dev_addr->addr[2], dev_addr->addr[3]
1686 dev_addr->addr[4], dev_addr->addr[5]
1697 bluetooth_device_address_t *device_address;
1699 // copy valid device address in device_address
1701 ret = bluetooth_unbond_device(device_address);
1704 int bluetooth_unbond_device(const bluetooth_device_address_t *device_address);
1707 * @fn int bluetooth_get_bonded_device_list(GPtrArray **dev_list)
1708 * @brief Get bonded(paired) device list
1711 * This API gets all bonded device list.
1712 * The devices in the bonded device list further can be used to perform the authorization by calling
1713 * bluetooth_authorize_device API.
1715 * This function is a synchronous call.
1716 * Information for bonded devices can be obtained when result code is BLUETOOTH_ERROR_NONE. If not,
1717 * there is no valid information in the dev_list.
1718 * The len field in the dev_list represents the number of bonded devices. The data structure for
1719 * bonded device information is bluetooth_device_info_t.
1722 * @return BLUETOOTH_ERROR_NONE - Success \n
1723 * BLUETOOTH_ERROR_NOT_SUPPORT - Opreation not supported \n
1725 * @see bluetooth_bond_device, bluetooth_unbond_device, bluetooth_authorize_device
1727 void bt_get_bonded_devices(void)
1731 GPtrArray *devinfo = NULL;
1732 bluetooth_device_info_t *ptr;
1734 // allocate the g_pointer_array
1735 devinfo = g_ptr_array_new();
1737 ret = bluetooth_get_bonded_device_list(&devinfo);
1738 if (ret != BLUETOOTH_ERROR_NONE)
1740 printf("bluetooth_get_bonded_device_list failed with [%d]",ret);
1744 printf("g pointer arrary count : [%d]", devinfo->len);
1745 for (i=0; i<devinfo->len; i++)
1747 ptr = g_ptr_array_index(devinfo, i);
1750 printf("Name [%s]\n", ptr->device_name.name);
1751 printf("Major Class [%d]\n", ptr->device_class.major_class);
1752 printf("Minor Class [%d]\n", ptr->device_class.minor_class);
1753 printf("Service Class [%d]\n", ptr->device_class.service_class);
1754 printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
1755 ptr->device_address.addr[0],
1756 ptr->device_address.addr[1], ptr->device_address.addr[2],
1757 ptr->device_address.addr[3],
1758 ptr->device_address.addr[4], ptr->device_address.addr[5]);
1765 // free g_pointer_array
1766 g_ptr_array_free(devinfo, TRUE);
1771 int bluetooth_get_bonded_device_list(GPtrArray **dev_list);
1774 * @fn int bluetooth_get_bonded_device(const bluetooth_device_address_t *device_address,
1775 * bluetooth_device_info_t *dev_info)
1776 * @brief Get a bonded(paired) device
1779 * This API gets a bonded device.
1781 * This function is a synchronous call.
1782 * Information for bonded devices can be obtained when result code is BLUETOOTH_ERROR_NONE. If not,
1783 * there is no valid information in the dev_info.
1784 * The data structure for bonded device information is bluetooth_device_info_t.
1787 * @return BLUETOOTH_ERROR_NONE - Success \n
1788 * BLUETOOTH_ERROR_NOT_SUPPORT - Opreation not supported \n
1790 * @see bluetooth_bond_device, bluetooth_unbond_device, bluetooth_authorize_device
1792 void bt_get_bonded_device(void)
1796 bluetooth_device_info_t devinfo = {0};
1797 bluetooth_device_address_t device_address={{0x00,0x1C,0x43,0x2B,0x1A,0xE5}};
1799 ret = bluetooth_get_bonded_device(&device_address, &devinfo);
1800 if (ret != BLUETOOTH_ERROR_NONE)
1802 printf("bluetooth_get_bonded_device failed with [%d]",ret);
1806 printf("Name [%s]\n", devinfo.device_name.name);
1807 printf("Major Class [%d]\n", devinfo.device_class.major_class);
1808 printf("Minor Class [%d]\n", devinfo.device_class.minor_class);
1809 printf("Service Class [%d]\n", devinfo.device_class.service_class);
1810 printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", devinfo.device_address.addr[0],
1811 devinfo.device_address.addr[1], devinfo.device_address.addr[2],
1812 devinfo.device_address.addr[3], devinfo.device_address.addr[4],
1813 devinfo.device_address.addr[5]);
1822 int bluetooth_get_bonded_device(const bluetooth_device_address_t *device_address,
1823 bluetooth_device_info_t *dev_info);
1826 * @fn int bluetooth_set_alias(const bluetooth_device_address_t *device_address, const char *alias)
1827 * @brief set alias for bonded device
1830 * This function set alias for bonded device.
1832 * This function is a synchronous call.
1835 * @return BLUETOOTH_ERROR_NONE - Success \n
1836 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
1837 * @param[in] device_address This indicates an address of the remote device
1838 * @param[in] alias This indicates an alias to set
1843 ret = bluetooth_set_alias(&remote_address);
1846 int bluetooth_set_alias(const bluetooth_device_address_t *device_address,
1850 * @fn int bluetooth_get_remote_device(const bluetooth_device_address_t *device_address)
1851 * @brief Get remote deivice
1854 * This function gets specific remote device.
1856 * This function is a asynchronous call.
1857 * This API is responded by an BLUETOOTH_EVENT_REMOTE_DEVICE_READ event.
1860 * @return BLUETOOTH_ERROR_NONE - Success \n
1861 * BLUETOOTH_ERROR_NOT_SUPPORT - Operation not supported \n
1862 * @param[in] device_address This indicates an address of the remote device
1867 ret = bluetooth_get_remote_device(&remote_address);
1870 int bluetooth_get_remote_device(const bluetooth_device_address_t *device_address);
1873 * @fn int bluetooth_authorize_device(const bluetooth_device_address_t *device_address,
1874 * gboolean authorized)
1875 * @brief Authorize/Unauthorize a bonded device
1878 * This function authorizes/unauthorize a bonded device. It decides the device to connect
1879 * with/without user confirmation.
1881 * If we select a paired device and make it authorized by calling this API with the authorized
1882 * parameter to TRUE, then it will not ask for the user conformation before connecting. Similarly
1883 * if we unauthorize the paired device by calling this API with the authorized parameter to FALSE,
1884 * then it will ask for the user conformation before the connection.
1886 * This API supposed to be called on the paired devices. Which means we have to use this API only
1887 * after successful pairing.
1889 * This function is a asynchronous call.
1890 * Response will be received through BLUETOOTH_EVENT_DEVICE_AUTHORIZED event.
1892 * @return BLUETOOTH_ERROR_NONE - Success \n
1893 * @exception BLUETOOTH_ERROR_INTERNAL - Cannot get the interal DBUS proxy \n
1894 * @param[in] device_address This indicates an address of the device to authorize \n
1895 * @param[in] authorized TRUE : authorize FALSE: unauthorize
1897 * @see bluetooth_get_bonded_device_list
1899 void bt_event_callback(int event, bluetooth_event_param_t *param)
1903 case BLUETOOTH_EVENT_DEVICE_AUTHORIZED :
1905 if (param->result == BLUETOOTH_ERROR_NONE)
1909 //device authorization failed failure
1917 bluetooth_device_address_t device_address={{0}};
1918 gboolean authorized;
1922 ret = bluetooth_authorize_device(&device_address,authorized);
1925 int bluetooth_authorize_device(const bluetooth_device_address_t *device_address,
1926 gboolean authorized);
1929 * @fn int bluetooth_search_service(const bluetooth_device_address_t *device_address)
1930 * @brief Get all services supported by remote device
1933 * This API call initiates the search for the services supported by the specified device. Normally
1934 * the service search will take a couple of seconds to get it completed. Before calling this API
1935 * make sure that the Adapter is enabled. We have to give the device address of the remote device to
1936 * perform the service search. We can get the device address by doing a device discovery operation.
1939 * This function is a asynchronous call.
1940 * The service search request is responded by BLUETOOTH_EVENT_SERVICE_SEARCHED event.
1942 * There is a timeout associated with the service search. The default time out is 40 seconds. If the
1943 * remove device did not respond with in the time out period the BLUETOOTH_EVENT_SERVICE_SEARCHED
1944 * event is generated with appropriate result code.
1946 * @return BLUETOOTH_ERROR_NONE - Success \n
1947 * BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR - Service search error (NULL device address) \n
1948 * BLUETOOTH_ERROR_INTERNAL - Internal IPC error \n
1949 * @param[in] device_address This indicates an address of the device
1950 * whose services need to be found
1952 * @see bluetooth_cancel_service_search
1954 int bluetooth_search_service(const bluetooth_device_address_t *device_address);
1957 * @fn int bluetooth_cancel_service_search(void)
1958 * @brief Cancel the ongoing service search operation
1961 * This function cancel the ongoing service search operation. This API is usually calling after the
1962 * bluetooth_search_service API.
1963 * Normally service search will take a more time (> 5 seconds) to complete. This API will be called
1964 * if the user wish to cancel the Ongoing service search operation.
1966 * This API should be called just after the bluetooth_search_service API and before the
1967 * BLUETOOTH_EVENT_SERVICE_SEARCHED event
1969 * This function is a synchronous call.
1971 * @return BLUETOOTH_ERROR_NONE - Success \n
1972 * BLUETOOTH_ERROR_CANCEL - Error in service search cancel operation \n
1973 * BLUETOOTH_ERROR_NOT_PAIRED - Not paired device \n
1974 * BLUETOOTH_ERROR_NOT_IN_OPERATION - Searching service is not in operation \n
1977 * @see bluetooth_search_service
1982 ret = bluetooth_cancel_service_search();
1985 int bluetooth_cancel_service_search(void);
1988 * @fn int bluetooth_rfcomm_create_socket(const char *uuid)
1989 * @brief Register rfcomm socket with a specific uuid
1992 * This API register rfcomm socket with the given UUID. The return value of this API is the socket
1993 * descriptor of the server.
1994 * This is the first API which is called to create the server. Once we created the server socket,
1995 * we will listen on that return socket.
1996 * So a bluetooth_rfcomm_listen_and_accept should follow this API call. This is a synchronous call.
1999 * @return socket FD on Success \n
2000 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2001 * BLUETOOTH_ERROR_INTERNAL - Internal error\n
2002 * BLUETOOTH_ERROR_MAX_CONNECTION - Maximum connection reached\n
2003 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2004 * @param[in] UUID (128 bits)
2007 * @see bluetooth_rfcomm_listen_and_accept, bluetooth_rfcomm_remove_socket
2011 const char *rfcomm_test_uuid="00001101-0000-1000-8000-00805F9B34FB";
2012 fd = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
2016 int bluetooth_rfcomm_create_socket(const char *uuid);
2019 * @fn int bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid)
2020 * @brief De-register the rfcomm socket
2023 * This API deregister rfcomm socket with the given socket fd and UUID. If the remote device is
2024 * already connected then we will receive the BLUETOOTH_EVENT_RFCOMM_DISCONNECTED with socket
2025 * descriptor else no event will come. We will call this API only after the
2026 * bluetooth_rfcomm_listen_and_accept.
2027 * This is a synchronous call.
2029 * @return BLUETOOTH_ERROR_NONE - Success \n
2030 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2031 * BLUETOOTH_ERROR_NOT_FOUND - Cannot find the proxy\n
2032 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2033 * @param[in] int socket_fd
2036 * @see bluetooth_rfcomm_create_socket, bluetooth_rfcomm_listen_and_accept
2039 void bt_event_callback(int event, bluetooth_event_param_t *param)
2043 case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED:
2045 bluetooth_rfcomm_connection_t *discon_ind =
2046 (bluetooth_rfcomm_connection_t *)param->param_data;
2048 printf("\nDisconnected from FD %d", discon_ind->socket_fd);
2056 fd = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
2057 ret = bluetooth_rfcomm_listen_and_accept(fd, 1);
2059 ret = bluetooth_rfcomm_remove_socket(fd);
2062 int bluetooth_rfcomm_remove_socket(int socket_fd);
2065 * @fn int bluetooth_rfcomm_server_disconnect(int socket_fd)
2066 * @brief Disconnect rfcomm connection
2069 * Disconnect a specific(device node fd) RFCOMM connection. This is a Synchronous call and there
2070 * is no cabbback events for this API. We have to provice the valid client fd to disconnect from the
2073 * @return BLUETOOTH_ERROR_NONE - Success \n
2074 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2075 * BLUETOOTH_ERROR_NOT_CONNECTED - Not connected \n
2076 * @param[in] int socket_fd the sending socket fd
2082 ret = bluetooth_rfcomm_server_disconnect(g_ret_fd);
2084 printf("Disconnection failed");
2086 printf("Disconnection Success");
2090 int bluetooth_rfcomm_server_disconnect(int socket_fd);
2093 * @fn int bluetooth_rfcomm_listen_and_accept(int socket_fd,int max_pending_connection)
2094 * @brief Rfcomm socket listen
2097 * This API make rfcomm socket listen and accept with socket. We will call this API immediatly
2098 * after the bluetooth_rfcomm_create_socket API.
2099 * This API listen for the incomming connection and once it receives a connection, it will give
2100 * BLUETOOTH_EVENT_RFCOMM_CONNECTED
2101 * event to the application. This is an Asynchronous API call.
2104 * @return BLUETOOTH_ERROR_NONE - Success \n
2105 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2106 * BLUETOOTH_ERROR_CONNECTION_ERROR - Listen failed \n
2108 * @param[in] int socket_fd
2109 * @param[in] max pending connection.
2112 * @see bluetooth_rfcomm_create_socket
2115 void bt_event_callback(int event, bluetooth_event_param_t* param)
2119 case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
2121 bluetooth_rfcomm_connection_t *conn_ind =
2122 (bluetooth_rfcomm_connection_t *)param->param_data;
2124 printf("\nConnected from FD %d", conn_ind->socket_fd);
2132 fd = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
2133 ret = bluetooth_rfcomm_listen_and_accept(fd, 1);
2137 int bluetooth_rfcomm_listen_and_accept(int socket_fd, int max_pending_connection);
2140 * @fn int bluetooth_rfcomm_listen(int socket_fd,int max_pending_connection)
2141 * @brief Rfcomm socket listen
2144 * This API make rfcomm socket listen and accept with socket. We will call this API immediatly
2145 * after the bluetooth_rfcomm_create_socket API.
2146 * This API listen for the incomming connection and once it receives a connection, it will give
2147 * BLUETOOTH_EVENT_RFCOMM_AUTHORIZE
2148 * event to the application. This is an Asynchronous API call.
2151 * @return BLUETOOTH_ERROR_NONE - Success \n
2152 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2153 * BLUETOOTH_ERROR_CONNECTION_ERROR - Listen failed \n
2155 * @param[in] int socket_fd
2156 * @param[in] max pending connection.
2159 * @see bluetooth_rfcomm_create_socket
2162 void bt_event_callback(int event, bluetooth_event_param_t* param)
2166 case BLUETOOTH_EVENT_RFCOMM_AUTHORIZE:
2168 char *name = (char *)param->param_data;
2170 printf("\nConnected from %s", name);
2172 bluetooth_rfcomm_accept_connection();
2180 fd = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
2181 ret = bluetooth_rfcomm_listen(fd, 1);
2185 int bluetooth_rfcomm_listen(int socket_fd, int max_pending_connection);
2188 * @fn int bluetooth_rfcomm_accept_connection()
2189 * @brief Accepts the authorization request indicated by the event
2190 * BLUETOOTH_EVENT_RFCOMM_AUTHORIZE.
2192 * This function is a synchronous call.
2194 * @return BLUETOOTH_ERROR_NONE - Success \n
2195 * BLUETOOTH_ERROR_INTERNAL - Internal error \n
2197 * @param[in] the socket fd of the server
2198 * @param[out] the socket fd of the client
2202 * @see bluetooth_rfcomm_reject_connection
2204 int bluetooth_rfcomm_accept_connection(int server_fd, int *client_fd);
2207 * @fn int bluetooth_rfcomm_reject_connection()
2208 * @brief Rejects the authorization request indicated by the event
2209 * BLUETOOTH_EVENT_RFCOMM_AUTHORIZE.
2211 * This function is a synchronous call.
2213 * @return BLUETOOTH_ERROR_NONE - Success \n
2214 * BLUETOOTH_ERROR_INTERNAL - Internal error \n
2216 * @param[in] the socket fd of the server
2220 * @see bluetooth_rfcomm_accept_connection
2222 int bluetooth_rfcomm_reject_connection(int server_fd);
2225 * @fn gboolean bluetooth_rfcomm_is_server_uuid_available(const char *uuid)
2226 * @brief Informs whether rfcomm server uuid is available or not.
2228 * This function is a synchronous call.
2230 * @return TRUE - RFCOMM uuid is available \n
2231 * FALSE - RFCOMM uuid is not available \n
2233 * @param[in] uuid UUID string
2239 gboolean bluetooth_rfcomm_is_server_uuid_available(const char *uuid);
2242 * @fn int bluetooth_rfcomm_connect(const bluetooth_device_address_t *remote_bt_address,
2243 * const char *remote_uuid)
2244 * @brief Connect to the remote device rfcomm *
2246 * Connect to a specific RFCOMM based service on a remote device UUID. This is a Async call. Once
2247 * the connection is successful callback BLUETOOTH_EVENT_RFCOMM_CONNECTED events is generated,
2248 * which contains the socket_fd, device role (RFCOMM_ROLE_SERVER/RFCOMM_ROLE_CLIENT), device addess
2249 * etc. The socket_fd can be further used to send the data. It better to do a sevice search before
2250 * initiating a connection.
2252 * @return BLUETOOTH_ERROR_NONE - Success \n
2253 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2254 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2255 * BLUETOOTH_ERROR_CONNECTION_BUSY - Connection in progress \n
2256 * BLUETOOTH_ERROR_INTERNAL - Internal Error\n
2257 * @param[in] bluetooth_device_address_t remote bt_address
2258 * @param[in] char remote uuid
2260 * @see bluetooth_rfcomm_disconnect, bluetooth_rfcomm_write, bluetooth_search_service
2264 void bt_event_callback(int event, bluetooth_event_param_t *param)
2268 case BLUETOOTH_EVENT_SERVICE_SEARCHED:
2270 if (param->result >= BLUETOOTH_ERROR_NONE)
2272 bt_sdp_info_t *bt_sdp_info=param->param_data;
2274 printf("Dev add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
2275 bt_sdp_info->device_addr.addr[0],
2276 bt_sdp_info->device_addr.addr[1],
2277 bt_sdp_info->device_addr.addr[2],
2278 bt_sdp_info->device_addr.addr[3],
2279 bt_sdp_info->device_addr.addr[4],
2280 bt_sdp_info->device_addr.addr[5]);
2282 printf("Supported service list:\n");
2283 for(i=0; i<bt_sdp_info->service_index; i++)
2285 bt_sdp_info->service_list_array[i]);
2288 //ret = bluetooth_rfcomm_connect(bt_sdp_info->device_addr,
2289 //rfcomm_test_uuid);
2293 case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
2295 bluetooth_rfcomm_connection_t *conn_ind =
2296 (bluetooth_rfcomm_connection_t *)param->param_data;
2298 printf("\nConnected from FD %d, Role = %s", conn_ind->socket_fd,
2299 (conn_ind->device_role == RFCOMM_ROLE_SERVER) ?
2300 "SERVER" : "CLIENT");
2305 bluetooth_device_address_t remote_address = {{0},};
2306 remote_address.addr[0] = 0x0; remote_address.addr[1] = 0x0A; remote_address.addr[2] = 0x3A;
2307 remote_address.addr[3]= 0x54; remote_address.addr[4] = 0x19; remote_address.addr[5]= 0x36;
2308 ret = bluetooth_search_service(&remote_address);
2310 printf("Seach failed, Reason = %d", ret);
2312 printf("Search Success, Ret = %d", ret);
2314 ret = bluetooth_rfcomm_connect(&remote_address, rfcomm_test_uuid);
2316 printf("Connection failed, Reason = %d", ret);
2318 printf("Connection Success, Ret = %d", ret);
2322 int bluetooth_rfcomm_connect(const bluetooth_device_address_t *remote_bt_address,
2323 const char *remote_uuid);
2326 * @fn int bluetooth_rfcomm_disconnect(int socket_fd)
2327 * @brief Disconnect rfcomm connection
2330 * Disconnect a specific(device node fd) RFCOMM connection. This is a Synchronous call and there
2331 * is no cabbback events for this API. We have to provice the valid client fd to disconnect from the
2334 * @return BLUETOOTH_ERROR_NONE - Success \n
2335 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2336 * BLUETOOTH_ERROR_NOT_CONNECTED - Not connected \n
2337 * @param[in] char remote bt_address
2340 * @see bluetooth_rfcomm_connect
2344 ret = bluetooth_rfcomm_disconnect(g_ret_fd);
2346 printf("Disconnection failed");
2348 printf("Disconnection Success");
2353 int bluetooth_rfcomm_disconnect(int socket_fd);
2356 * @fn int bluetooth_rfcomm_write (int fd, const char *buff, int length)
2357 * @brief Write to rfcomm connection
2360 * This API is used to send the data over the rfcomm connection. This is a synchronous API. The same
2361 * API is used to send the data for server and the client.
2363 * @return BLUETOOTH_ERROR_NONE - Success \n
2364 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2365 * BLUETOOTH_ERROR_NOT_IN_OPERATION - The Fd is currently not in operation\n
2367 * @param[in] const char *buff Data buffer to send
2368 * @param[in] int length Length of the data
2371 * @see bluetooth_rfcomm_connect
2374 char *buff = "Test data 123456789"
2375 ret = bluetooth_rfcomm_write(g_ret_fd, buff, 15);
2377 printf("Send failed");
2379 printf("Send success");
2383 int bluetooth_rfcomm_write(int fd, const char *buf, int length);
2386 * @fn gboolean bluetooth_rfcomm_is_client_connected(void)
2387 * @brief Informs whether rfcomm client is connected.
2389 * This function is a synchronous call.
2391 * @return TRUE - RFCOMM client is connected \n
2392 * FALSE - RFCOMM client is not connected \n
2398 gboolean bluetooth_rfcomm_is_client_connected(void);
2401 * @fn int bluetooth_network_activate_server(void)
2402 * @brief Activate the NAP (Network Access Point) service
2404 * This function is a asynchronous call.
2405 * The activate server request is responded by BLUETOOTH_EVENT_NETWORK_SERVER_ACTIVATED event.
2407 * @return BLUETOOTH_ERROR_NONE - Success \n
2408 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2409 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2410 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2413 * @see bluetooth_network_deactivate_server
2416 int bluetooth_network_activate_server(void);
2419 * @fn int bluetooth_network_deactivate_server(void)
2420 * @brief Deactivate the NAP (Network Access Point) service
2422 * This function is a asynchronous call.
2423 * The deactivate server request is responded by BLUETOOTH_EVENT_NETWORK_SERVER_DEACTIVATED event.
2425 * @return BLUETOOTH_ERROR_NONE - Success \n
2426 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2427 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2428 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2431 * @see bluetooth_network_activate_server
2434 int bluetooth_network_deactivate_server(void);
2437 * @fn int bluetooth_network_connect(const bluetooth_device_address_t *device_address,
2438 * bluetooth_network_role_t role,
2440 * @brief Connect the network server in the peer
2442 * This function is a asynchronous call.
2443 * The network connect request is responded by BLUETOOTH_EVENT_NETWORK_CONNECTED event.
2445 * @return BLUETOOTH_ERROR_NONE - Success \n
2446 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2447 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2448 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2451 * @param[in] device_address This indicates an address of the device with which the pairing
2452 * should be initiated
2453 * @param[in] role The role to connect. PANU / GN / NAP / CUSTOM. If use the CUSTOM value,
2454 * need to use the third parameter.
2455 * @param[in] custom_uuid If use the CUSTOM value in second parameter, use this parameter to
2456 * connect. UUID string
2458 * @see bluetooth_network_disconnect
2460 int bluetooth_network_connect(const bluetooth_device_address_t *device_address,
2461 bluetooth_network_role_t role, char *custom_uuid);
2464 * @fn int bluetooth_network_disconnect(const bluetooth_device_address_t *device_address,
2465 * bluetooth_network_role_t role,
2466 * char *custom_uuid)
2467 * @brief Connect the network server in the peer
2469 * This function is a asynchronous call.
2470 * The network disconnect request is responded by BLUETOOTH_EVENT_NETWORK_CONNECTED event.
2472 * @return BLUETOOTH_ERROR_NONE - Success \n
2473 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2474 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2475 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2478 * @param[in] device_address This indicates an address of the device with which the pairing
2479 * should be initiated
2481 * @see bluetooth_network_connect
2483 int bluetooth_network_disconnect(const bluetooth_device_address_t *device_address);
2488 * @fn int bluetooth_hdp_activate(unsigned short data_type,
2489 * bt_hdp_role_type_t role,
2490 * bt_hdp_qos_type_t channel_type,
2491 * char **app_handle)
2492 * @brief Activate the HDP service for a particular data type
2494 * This function is a synchronous call.
2496 * @return BLUETOOTH_ERROR_NONE - Success \n
2497 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2498 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2499 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2502 * @param[in] data_type The data type against corresponding service
2503 * @param[in] role The role of HDP. HDP_ROLE_SOURCE/HDP_ROLE_SINK.
2504 * @param[in] channel_type The QOS type for the channel.
2505 * HDP_QOS_RELIABLE/HDP_QOS_STREAMING/HDP_QOS_ANY.
2506 * For role = HDP_ROLE_SINK, the channel_type
2507 * should be HDP_QOS_ANY.
2508 * @param[out] app_handle The application handler against corresponding service
2510 * @see bluetooth_hdp_deactivate
2512 int bluetooth_hdp_activate(unsigned short data_type,
2513 bt_hdp_role_type_t role,
2514 bt_hdp_qos_type_t channel_type,
2517 * @fn int bluetooth_hdp_deactivate(const char *app_handle)
2518 * @brief Deactivate the HDP service for a particular service using the handler
2520 * This function is a synchronous call.
2522 * @return BLUETOOTH_ERROR_NONE - Success \n
2523 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2524 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2525 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2528 * @param[in] app_handle The application handler against corresponding service
2530 * @see bluetooth_hdp_deactivate
2532 int bluetooth_hdp_deactivate(const char *app_handle);
2535 * @fn int bluetooth_hdp_send_data(unsigned int channel_id,
2536 * const char *buffer, unsigned int size)
2537 * @brief Send data to the remote HDP device
2539 * This function is a synchronous call.
2541 * @return BLUETOOTH_ERROR_NONE - Success \n
2542 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2543 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2544 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2545 * BLUETOOTH_ERROR_NOT_IN_OPERATION - FD is invalid \n
2548 * @param[in] channel_id The channel id for the connection.
2549 * @param[in] buffer The pdu buffer.
2550 * @param[in] size Size of the buffer.
2552 * @see bluetooth_hdp_connect
2554 int bluetooth_hdp_send_data(unsigned int channel_id,
2555 const char *buffer, unsigned int size);
2557 * @fn int bluetooth_hdp_connect(const char *app_handle,
2558 * bt_hdp_qos_type_t channel_type,
2559 * const bluetooth_device_address_t *device_address)
2560 * @brief Connect to the remote device(Mainly used by source)
2562 * This function is a asynchronous call.
2563 * The HDP activate is responded by BLUETOOTH_EVENT_HDP_CONNECTED event.
2565 * @return BLUETOOTH_ERROR_NONE - Success \n
2566 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2567 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2568 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2569 * BLUETOOTH_ERROR_MEMORY_ALLOCATION -Memory allocation failed \n
2572 * @param[in] app_handle The application handler against corresponding service
2573 * @param[in] channel_type The QOS type for the channel.
2574 * HDP_QOS_RELIABLE/HDP_QOS_STREAMING.
2575 * @param[in] device_address The remote device Bd address.
2578 * @see bluetooth_hdp_disconnect
2580 int bluetooth_hdp_connect(const char *app_handle,
2581 bt_hdp_qos_type_t channel_type,
2582 const bluetooth_device_address_t *device_address);
2584 * @fn int bluetooth_hdp_disconnect(unsigned int channel_id,
2585 * const bluetooth_device_address_t *device_address)
2586 * @brief Disconnect from the remote device(Mainly used by source)
2588 * This function is a asynchronous call.
2589 * The HDP activate is responded by BLUETOOTH_EVENT_HDP_DISCONNECTED event.
2591 * @return BLUETOOTH_ERROR_NONE - Success \n
2592 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2593 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2594 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2595 * BLUETOOTH_ERROR_MEMORY_ALLOCATION -Memory allocation failed \n
2598 * @param[in] channel_id The channel id for the connection.
2599 * @param[in] device_address The remote device Bd address.
2602 * @see bluetooth_hdp_connect
2604 int bluetooth_hdp_disconnect(unsigned int channel_id,
2605 const bluetooth_device_address_t *device_address);
2609 * @fn int bluetooth_opc_init(void)
2610 * @brief Initialize OPP client.
2612 * This function is a synchronous call.
2613 * No event corresponding to this api
2615 * @return BLUETOOTH_ERROR_NONE - Success \n
2616 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2617 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2618 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2619 * BLUETOOTH_ERROR_ACCESS_DENIED -Memory allocation failed \n
2624 * @see bluetooth_opc_deinit
2626 int bluetooth_opc_init(void);
2629 * @fn int bluetooth_opc_deinit(void)
2630 * @brief Deinitialize OPP client.
2632 * This function is a synchronous call.
2633 * No event corresponding to this api
2635 * @return BLUETOOTH_ERROR_NONE - Success \n
2636 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2637 * BLUETOOTH_ERROR_ACCESS_DENIED -Memory allocation failed \n
2642 * @see bluetooth_opc_init
2645 int bluetooth_opc_deinit(void);
2648 * @fn int bluetooth_opc_push_files(bluetooth_device_address_t *remote_address,
2649 char **file_name_array)
2650 * @brief Send multiple files to a remote device.
2652 * This function is a asynchronous call.
2653 * This api is responded by BLUETOOTH_EVENT_OPC_CONNECTED event.
2655 * @return BLUETOOTH_ERROR_NONE - Success \n
2656 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2657 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2658 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2659 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2660 * BLUETOOTH_ERROR_IN_PROGRESS -Already one push in progress \n
2661 * BLUETOOTH_ERROR_ACCESS_DENIED - Not allowed by MDM policy \n
2664 * @param[in] device_address The remote device Bd address.
2665 * @param[in] file_name_array Array of filepaths to be sent.
2668 * @see bluetooth_opc_cancel_push
2671 int bluetooth_opc_push_files(bluetooth_device_address_t *remote_address,
2672 char **file_name_array);
2675 * @fn int bluetooth_opc_cancel_push(void)
2676 * @brief Cancels the ongoing file push.
2678 * This function is a asynchronous call.
2679 * This api is responded with either BLUETOOTH_EVENT_OPC_CONNECTED or
2680 * BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETED event.
2682 * @return BLUETOOTH_ERROR_NONE - Success \n
2683 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2684 * BLUETOOTH_ERROR_ACCESS_DENIED - No push in progress \n
2689 * @see bluetooth_opc_push_files
2692 int bluetooth_opc_cancel_push(void);
2695 * @fn gboolean bluetooth_opc_session_is_exist(void)
2696 * @brief Informs whether opc session exists or not.
2698 * This function is a synchronous call.
2700 * @return TRUE - OPC session exists \n
2701 * FALSE - OPC session does not exist \n
2709 gboolean bluetooth_opc_session_is_exist(void);
2713 * @fn int bluetooth_obex_server_init(const char *dst_path)
2714 * @brief Initialize OPP and FTP server.
2716 * This function is a synchronous call.
2717 * No event corresponding to this api
2719 * @return BLUETOOTH_ERROR_NONE - Success \n
2720 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2721 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2722 * BLUETOOTH_ERROR_AGENT_ALREADY_EXIST - Obex agent already registered \n
2723 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2726 * @param[in] dst_path OPS destination file path.
2728 * @see bluetooth_obex_server_deinit
2730 int bluetooth_obex_server_init(const char *dst_path);
2734 * @fn int bluetooth_obex_server_deinit(void)
2735 * @brief Deinitialize OPP and FTP server.
2737 * This function is a synchronous call.
2738 * No event corresponding to this api
2740 * @return BLUETOOTH_ERROR_NONE - Success \n
2741 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2742 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2747 * @see bluetooth_obex_server_init
2749 int bluetooth_obex_server_deinit(void);
2753 * @fn gboolean bluetooth_obex_server_is_activated(void)
2754 * @brief Informs whether obex server is activated or not.
2756 * This function is a synchronous call.
2758 * @return TRUE - OBEX server is activated \n
2759 * FALSE - OBEX server is not activated \n
2766 gboolean bluetooth_obex_server_is_activated(void);
2770 * @fn int bluetooth_obex_server_init_without_agent(const char *dst_path)
2771 * @brief Initialize OPP and FTP server without the conneciton authorization of the agent
2773 * This function is a synchronous call.
2774 * No event corresponding to this api
2776 * @return BLUETOOTH_ERROR_NONE - Success \n
2777 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2778 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2779 * BLUETOOTH_ERROR_AGENT_ALREADY_EXIST - Obex agent already registered \n
2780 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2784 * @param[in] dst_path OPS destination file path.
2786 * @see bluetooth_obex_server_deinit_without_agent
2788 int bluetooth_obex_server_init_without_agent(const char *dst_path);
2792 * @fn int bluetooth_obex_server_deinit_without_agent(void)
2793 * @brief Deinitialize OPP and FTP server without the conneciton authorization of the agent
2795 * This function is a synchronous call.
2796 * No event corresponding to this api
2798 * @return BLUETOOTH_ERROR_NONE - Success \n
2799 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2800 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2805 * @see bluetooth_obex_server_init_without_agent
2807 int bluetooth_obex_server_deinit_without_agent(void);
2811 * @fn int bluetooth_obex_server_accept_connection(void)
2812 * @brief Accepts the authorization request indicated by the event
2813 * BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE.
2815 * This function is a synchronous call.
2817 * @return BLUETOOTH_ERROR_NONE - Success \n
2818 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2819 * BLUETOOTH_ERROR_INTERNAL - Internal error \n
2823 * @see bluetooth_obex_server_reject_authorize
2825 int bluetooth_obex_server_accept_connection(void);
2829 * @fn int bluetooth_obex_server_reject_connection(void)
2830 * @brief Rejects the authorization request indicated by the event
2831 * BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE.
2833 * This function is a synchronous call.
2835 * @return BLUETOOTH_ERROR_NONE - Success \n
2836 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2837 * BLUETOOTH_ERROR_INTERNAL - Internal error \n
2841 * @see bluetooth_obex_server_reject_authorize
2843 int bluetooth_obex_server_reject_connection(void);
2847 * @fn int bluetooth_obex_server_accept_authorize(const char *filename)
2848 * @brief Accepts the authorization request indicated by the event
2849 * BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE.
2851 * This function is a asynchronous call.
2852 * This api will be responded with the event BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED.
2854 * @return BLUETOOTH_ERROR_NONE - Success \n
2855 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2856 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2857 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2860 * @param[in] filename Authorized filename.
2863 * @see bluetooth_obex_server_reject_authorize
2866 int bluetooth_obex_server_accept_authorize(const char *filename);
2869 * @fn int bluetooth_obex_server_reject_authorize(void)
2870 * @brief Reject the authorization request indicated by the event
2871 * BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE.
2873 * This function is a asynchronous call.
2874 * No event for this api..
2876 * @return BLUETOOTH_ERROR_NONE - Success \n
2877 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2878 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2883 * @see bluetooth_obex_server_accept_authorize
2886 int bluetooth_obex_server_reject_authorize(void);
2889 * @fn int bluetooth_obex_server_set_destination_path(const char *dst_path)
2890 * @brief Set the OPS destination file path..
2892 * This function is a asynchronous call.
2893 * No event for this api..
2895 * @return BLUETOOTH_ERROR_NONE - Success \n
2896 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2897 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2898 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid Param \n
2901 * @param[in] dst_path OPS destination file path.
2907 int bluetooth_obex_server_set_destination_path(const char *dst_path);
2910 * @fn int bluetooth_obex_server_set_root(const char *root)
2911 * @brief Set the FTS root folder..
2913 * This function is a asynchronous call.
2914 * No event for this api..
2916 * @return BLUETOOTH_ERROR_NONE - Success \n
2917 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
2918 * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
2919 * BLUETOOTH_ERROR_ACCESS_DENIED - Operation not allowed \n
2920 * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
2921 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2924 * @param[in] root FTS root folder.
2930 int bluetooth_obex_server_set_root(const char *root);
2933 * @fn int bluetooth_obex_server_cancel_transfer(int transfer_id)
2934 * @brief Cancel the transfer on server
2936 * This function is an asynchronous call.
2937 * If the function call that cancels transfer is successful, the application would receive
2938 * BLUETOOTH_EVENT_TRANSFER_COMPLETED event through registered callback
2939 * function with an error code BLUETOOTH_ERROR_CANCEL. In the case of failure
2940 * the error code will be BLUETOOTH_ERROR_NONE
2942 * @return BLUETOOTH_ERROR_NONE - Success \n
2943 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2944 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2945 * BLUETOOTH_ERROR_INTERNAL - internal error (proxy does not exist) \n
2946 * BLUETOOTH_ERROR_NOT_FOUND - The transfer is not found \n
2949 * @param[in] transfer_id transfer ID
2954 int bluetooth_obex_server_cancel_transfer(int transfer_id);
2958 * @fn int bluetooth_obex_server_cancel_all_transfers(void)
2959 * @brief Cancel the transfer on server
2961 * This function is an asynchronous call.
2962 * If the function call that cancels transfer is successful, the application would receive
2963 * BLUETOOTH_EVENT_TRANSFER_COMPLETED event through registered callback
2964 * function with an error code BLUETOOTH_ERROR_CANCEL. In the case of failure
2965 * the error code will be BLUETOOTH_ERROR_NONE
2967 * @return BLUETOOTH_ERROR_NONE - Success \n
2968 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
2969 * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
2970 * BLUETOOTH_ERROR_INTERNAL - internal error (proxy does not exist) \n
2971 * BLUETOOTH_ERROR_NOT_FOUND - The transfer is not found \n
2978 int bluetooth_obex_server_cancel_all_transfers(void);
2982 * @fn int bluetooth_oob_read_local_data(bt_oob_data_t *local_oob_data)
2983 * @brief Read the local Hash and Randmizer.
2985 * This function is a synchronous call.
2987 * @return BLUETOOTH_ERROR_NONE - Success \n
2988 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
2992 * @param[out] local_oob_data - Pointer to the local OOB data
2998 int bluetooth_oob_read_local_data(bt_oob_data_t *local_oob_data);
3002 * @fn int bluetooth_oob_add_remote_data(
3003 * const bluetooth_device_address_t *remote_device_address,
3004 * bt_oob_data_t *oob_data)
3005 * @brief Add/updated the remote device Hash and Randmizer.
3007 * This function is a synchronous call.
3008 * No event for this api..
3010 * @return BLUETOOTH_ERROR_NONE - Success \n
3011 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3014 * @param[in] remote_device_address - Remote device address
3015 * remote_oob_data - Ponter to Hash and Randomizer oob data structure
3021 int bluetooth_oob_add_remote_data(
3022 const bluetooth_device_address_t *remote_device_address,
3023 bt_oob_data_t *remote_oob_data);
3027 * @fn int bluetooth_oob_remove_remote_data(
3028 * const bluetooth_device_address_t *remote_device_address)
3029 * @brief Delete the Hash and Randomizer w.r.t the remote device address.
3031 * This function is a synchronous call.
3032 * No event for this api..
3034 * @return BLUETOOTH_ERROR_NONE - Success \n
3035 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3038 * @param[in] remote_device_address - Remote device address
3044 int bluetooth_oob_remove_remote_data(
3045 const bluetooth_device_address_t *remote_device_address);
3048 * @fn int bluetooth_gatt_get_primary_services(const bluetooth_device_address_t *address,
3049 * bt_gatt_handle_info_t *prim_svc);
3051 * @brief Gets the GATT based primary services handle supported by remote device
3053 * This function is a synchronous call.
3054 * The output parameter needs to be freed by calling bluetooth_gatt_free_primary_services()
3056 * @return BLUETOOTH_ERROR_NONE - Success \n
3057 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3058 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3059 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3062 * @param[in] address - Remote device address
3063 * @param[out] prim_svc - Structure containing remote service count and handle list.
3066 * @see bluetooth_gatt_free_primary_services()
3068 int bluetooth_gatt_get_primary_services(const bluetooth_device_address_t *address,
3069 bt_gatt_handle_info_t *prim_svc);
3072 * @fn int bluetooth_gatt_discover_service_characteristics(const char *service_handle)
3074 * @brief Discovers the characteristics of GATT based service of remote device
3076 * This function is an asynchronous call.
3077 * This API is responded with BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED
3079 * @return BLUETOOTH_ERROR_NONE - Success \n
3080 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3081 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3082 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3085 * @param[in] service_handle - Handle for remote service.
3090 int bluetooth_gatt_discover_service_characteristics(const char *service_handle);
3093 * @fn int bluetooth_gatt_get_service_property(const char *service_handle,
3094 * bt_gatt_service_property_t *service);
3096 * @brief Gets the properties of GATT based service of remote device
3098 * This function is a synchronous call.
3099 * The output parameter needs to be freed by calling bluetooth_gatt_free_primary_services()
3101 * @return BLUETOOTH_ERROR_NONE - Success \n
3102 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3103 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3104 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3107 * @param[in] service_handle - Handle for remote service.
3108 * @param[out] service - Structure containing remote service property.
3111 * @see bluetooth_gatt_free_service_property()
3113 int bluetooth_gatt_get_service_property(const char *service_handle,
3114 bt_gatt_service_property_t *service);
3117 * @fn int bluetooth_gatt_watch_characteristics(const char *service_handle)
3119 * @brief Register to GATT based service to receive value change notification/indication.
3121 * This function is a synchronous call.
3122 * No event for this api.
3124 * @return BLUETOOTH_ERROR_NONE - Success \n
3125 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3126 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3127 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3130 * @param[in] service_handle - Handle for remote service.
3135 int bluetooth_gatt_watch_characteristics(const char *service_handle);
3138 * @fn int bluetooth_gatt_unwatch_characteristics(const char *service_handle)
3140 * @brief Unregister GATT based service to receive value change notification/indication.
3142 * This function is a synchronous call.
3143 * No event for this api.
3145 * @return BLUETOOTH_ERROR_NONE - Success \n
3146 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3147 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3148 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3151 * @param[in] service_handle - Handle for remote service.
3156 int bluetooth_gatt_unwatch_characteristics(const char *service_handle);
3159 * @fn int bluetooth_gatt_get_characteristics_property(const char *char_handle,
3160 * bt_gatt_char_property_t *characteristic);
3162 * @brief Provides characteristic value along with properties.
3164 * This function is a synchronous call.
3165 * The output parameter needs to be freed by calling bluetooth_gatt_free_char_property()
3167 * @return BLUETOOTH_ERROR_NONE - Success \n
3168 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3169 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3170 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3173 * @param[in] char_handle - Handle for Characteristic property.
3174 * @param[out] characteristic - Structure containing remote characteristic property.
3177 * @see bluetooth_gatt_free_char_property()
3179 int bluetooth_gatt_get_characteristics_property(const char *char_handle,
3180 bt_gatt_char_property_t *characteristic);
3183 * @fn int bluetooth_gatt_set_characteristics_value(const char *char_handle,
3184 * const guint8 *value, int length)
3186 * @brief Set characteristic value.
3188 * This function is a synchronous call.
3190 * @return BLUETOOTH_ERROR_NONE - Success \n
3191 * BLUETOOTH_ERROR_INTERNAL - Internal Error \n
3192 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3193 * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
3196 * @param[in] char_handle - Handle for Characteristic property.
3197 * @param[in] value - New value to set for characteristic property.
3198 * @param[in] length - Length of the value to be set.
3203 int bluetooth_gatt_set_characteristics_value(const char *char_handle,
3204 const guint8 *value, int length);
3207 * @fn int bluetooth_gatt_free_primary_services(bt_gatt_handle_info_t *prim_svc);
3209 * @brief Releases the memory allocated by bluetooth_gatt_get_primary_services()
3211 * This function is a synchronous call.
3212 * The input parameter is obtained by calling bluetooth_gatt_get_primary_services()
3214 * @return BLUETOOTH_ERROR_NONE - Success \n
3215 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3218 * @param[in] prim_svc - GATT handle info structure
3221 * @see bluetooth_gatt_get_primary_services()
3223 int bluetooth_gatt_free_primary_services(bt_gatt_handle_info_t *prim_svc);
3226 * @fn int bluetooth_gatt_free_service_property(bt_gatt_service_property_t *svc_pty);
3228 * @brief Releases the memory allocated by bluetooth_gatt_get_service_property()
3230 * This function is a synchronous call.
3231 * The input parameter is obtained by calling bluetooth_gatt_get_service_property()
3233 * @return BLUETOOTH_ERROR_NONE - Success \n
3234 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3237 * @param[in] svc_pty - GATT service property structure.
3240 * @see bluetooth_gatt_get_service_property()
3242 int bluetooth_gatt_free_service_property(bt_gatt_service_property_t *svc_pty);
3245 * @fn int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *char_pty);
3247 * @brief Provides characteristic value along with properties.
3249 * This function is a synchronous call.
3250 * The input parameter is obtained by calling bluetooth_gatt_get_characteristics_property()
3252 * @return BLUETOOTH_ERROR_NONE - Success \n
3253 * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
3256 * @param[in] char_pty - GATT characteristics property structure.
3259 * @see bluetooth_gatt_get_characteristics_property()
3261 int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *char_pty);
3269 #endif /* __cplusplus */
3270 #endif /* _BLUETOOTH_API_H_*/