Git init
[framework/api/bluetooth.git] / include / bluetooth.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16  
17
18 #ifndef __TIZEN_NETWORK_BLUETOOTH_H__
19 #define __TIZEN_NETWORK_BLUETOOTH_H__
20
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <stdbool.h>
24 #include <tizen_error.h>
25
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif /* __cplusplus */
30
31 /**
32  * @file        bluetooth.h
33  * @brief       API to control the Bluetooth adapter and devices and communications.
34  * @ingroup     CAPI_NETWORK_BLUETOOTH_MODULE
35  */
36
37
38 /**
39  * @addtogroup CAPI_NETWORK_BLUETOOTH_MODULE
40  * @{
41  */
42
43 /**
44  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
45  * @brief  Enumerations of connected Bluetooth device event role.
46  */
47 typedef enum
48 {
49         BT_SOCKET_UNKNOWN = 0x00, /**< Unknown role*/
50         BT_SOCKET_SERVER , /**< Server role*/
51         BT_SOCKET_CLIENT, /**< Client role*/
52 } bt_socket_role_e;
53
54 /**
55  * @ingroup CAPI_NETWORK_BLUETOOTH_MODULE
56  * @brief Enumerations of Bluetooth error codes.
57  */
58 typedef enum
59 {
60         BT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful*/
61         BT_ERROR_CANCELLED = TIZEN_ERROR_CANCELED, /**< Operation cancelled */
62         BT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
63         BT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
64         BT_ERROR_RESOURCE_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Device or resource busy */
65         BT_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< Timeout error */
66         BT_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /**< Operation now in progress */
67         BT_ERROR_NOT_INITIALIZED = TIZEN_ERROR_NETWORK_CLASS|0x0101, /**< Local adapter not initialized */
68         BT_ERROR_NOT_ENABLED = TIZEN_ERROR_NETWORK_CLASS|0x0102, /**< Local adapter not enabled */
69         BT_ERROR_ALREADY_DONE = TIZEN_ERROR_NETWORK_CLASS|0x0103, /**< Operation already done  */
70         BT_ERROR_OPERATION_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x0104, /**< Operation failed */
71         BT_ERROR_NOT_IN_PROGRESS = TIZEN_ERROR_NETWORK_CLASS|0x0105, /**< Operation not in progress */
72         BT_ERROR_REMOTE_DEVICE_NOT_BONDED = TIZEN_ERROR_NETWORK_CLASS|0x0106, /**< Remote device not bonded */
73         BT_ERROR_AUTH_REJECTED = TIZEN_ERROR_NETWORK_CLASS|0x0107, /**< Authentication rejected */
74         BT_ERROR_AUTH_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x0108, /**< Authentication failed */
75         BT_ERROR_REMOTE_DEVICE_NOT_FOUND = TIZEN_ERROR_NETWORK_CLASS|0x0109, /**< Remote device not found */
76         BT_ERROR_SERVICE_SEARCH_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x010A, /**< Service search failed */
77 } bt_error_e;
78
79 /**
80  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
81  * @brief  Enumerations of the Bluetooth adapter state.
82  */
83 typedef enum
84 {
85         BT_ADAPTER_DISABLED = 0x00, /**< Bluetooth adapter is disabled */
86         BT_ADAPTER_ENABLED, /**< Bluetooth adapter is enabled */
87 } bt_adapter_state_e;
88
89 /**
90  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
91  * @brief Enumerations of the Bluetooth visibility mode.
92  */
93 typedef enum
94 {
95         BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE = 0x00,  /**< Other devices cannot find your device via discovery */
96         BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE,  /**< Discoverable mode */
97         BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE,  /**< Discoverable mode with time limit. After specific period, 
98                                                             it is changed to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE.*/
99 } bt_adapter_visibility_mode_e;
100
101 /**
102  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
103  * @brief Enumerations of the discovery state of Bluetooth device.
104  *
105  */
106 typedef enum
107 {
108         BT_ADAPTER_DEVICE_DISCOVERY_STARTED, /**< Device discovery is started */
109         BT_ADAPTER_DEVICE_DISCOVERY_FINISHED, /**< Device discovery is finished */
110         BT_ADAPTER_DEVICE_DISCOVERY_FOUND, /**< The remote Bluetooth device is found */
111 } bt_adapter_device_discovery_state_e;
112
113 /**
114  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
115  * @brief Enumerations of device authorization state.
116  */
117 typedef enum
118 {
119         BT_DEVICE_AUTHORIZED, /**< The remote Bluetooth device is authorized */
120         BT_DEVICE_UNAUTHORIZED, /**< The remote Bluetooth device is unauthorized */
121 } bt_device_authorization_e;
122
123 /**
124  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
125  * @brief  Enumerations of Bluetooth socket connection state.
126  */
127 typedef enum
128 {
129         BT_SOCKET_CONNECTED, /**< Socket is connected */
130         BT_SOCKET_DISCONNECTED, /**< Socket is disconnected */
131 } bt_socket_connection_state_e;
132
133 /**
134  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
135  * @brief  Enumerations of major service class.
136  */
137 typedef enum
138 {
139         BT_MAJOR_SERVICE_CLASS_LIMITED_DISCOVERABLE_MODE  = 0x002000, /**< Limited discoverable mode */
140         BT_MAJOR_SERVICE_CLASS_POSITIONING                = 0x010000, /**< Positioning class */
141         BT_MAJOR_SERVICE_CLASS_NETWORKING                 = 0x020000, /**< Networking class */
142         BT_MAJOR_SERVICE_CLASS_RENDERING                  = 0x040000, /**< Rendering class */
143         BT_MAJOR_SERVICE_CLASS_CAPTURING                  = 0x080000, /**< Capturing class */
144         BT_MAJOR_SERVICE_CLASS_OBJECT_TRANSFER            = 0x100000, /**< Object transferring class */
145         BT_MAJOR_SERVICE_CLASS_AUDIO                      = 0x200000, /**< Audio class*/
146         BT_MAJOR_SERVICE_CLASS_TELEPHONY                  = 0x400000, /**< Telephony class */
147         BT_MAJOR_SERVICE_CLASS_INFORMATION                = 0x800000, /**< Information class */
148 } bt_major_service_class_e;
149
150 /**
151  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
152  * @brief  Enumerations of major device class.
153  */
154 typedef enum
155 {
156         BT_MAJOR_DEVICE_CLASS_MISC = 0x00, /**< Miscellaneous major device class*/
157         BT_MAJOR_DEVICE_CLASS_COMPUTER = 0x01, /**< Computer major device class */
158         BT_MAJOR_DEVICE_CLASS_PHONE = 0x02, /**< Phone major device class */
159         BT_MAJOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT = 0x03, /**< LAN/Network access point major device class */
160         BT_MAJOR_DEVICE_CLASS_AUDIO_VIDEO = 0x04, /**< Audio/Video major device class */
161         BT_MAJOR_DEVICE_CLASS_PERIPHERAL = 0x05, /**< Peripheral major device class */
162         BT_MAJOR_DEVICE_CLASS_IMAGING = 0x06, /**< Imaging major device class */
163         BT_MAJOR_DEVICE_CLASS_WEARABLE = 0x07, /**< Wearable device class */
164         BT_MAJOR_DEVICE_CLASS_TOY = 0x08, /**< Toy device class */
165         BT_MAJOR_DEVICE_CLASS_HEALTH = 0x09, /**< Health device class */
166         BT_MAJOR_DEVICE_CLASS_UNCATEGORIZED = 0x1F, /**< Uncategorized major device class */
167 } bt_major_device_class_e;
168
169 /**
170  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
171  * @brief  Enumerations of minor device class.
172  */
173 typedef enum
174 {
175         BT_MINOR_DEVICE_CLASS_COMPUTER_UNCATEGORIZED = 0x00, /**< Uncategorized minor device class of computer */
176         BT_MINOR_DEVICE_CLASS_COMPUTER_DESKTOP_WORKSTATION = 0x04, /**< Desktop workstation minor device class of computer */
177         BT_MINOR_DEVICE_CLASS_COMPUTER_SERVER_CLASS = 0x08, /**< Server minor device class of computer */
178         BT_MINOR_DEVICE_CLASS_COMPUTER_LAPTOP = 0x0C, /**< Laptop minor device class of computer */
179         BT_MINOR_DEVICE_CLASS_COMPUTER_HANDHELD_PC_OR_PDA = 0x10, /**< Handheld PC/PDA minor device class of computer */
180         BT_MINOR_DEVICE_CLASS_COMPUTER_PALM_SIZED_PC_OR_PDA = 0x14, /**< Palm sized PC/PDA minor device class of computer */
181         BT_MINOR_DEVICE_CLASS_COMPUTER_WEARABLE_COMPUTER = 0x18, /**< Wearable(watch sized) minor device class of computer */
182
183         BT_MINOR_DEVICE_CLASS_PHONE_UNCATEGORIZED = 0x00, /**< Uncategorized minor device class of phone */
184         BT_MINOR_DEVICE_CLASS_PHONE_CELLULAR = 0x04, /**< Cellular minor device class of phone */
185         BT_MINOR_DEVICE_CLASS_PHONE_CORDLESS = 0x08, /**< Cordless minor device class of phone */
186         BT_MINOR_DEVICE_CLASS_PHONE_SMART_PHONE = 0x0C, /**< Smart phone minor device class of phone */
187         BT_MINOR_DEVICE_CLASS_PHONE_WIRED_MODEM_OR_VOICE_GATEWAY = 0x10, /**< Wired modem or voice gateway minor device class of phone */
188         BT_MINOR_DEVICE_CLASS_PHONE_COMMON_ISDN_ACCESS = 0x14, /**< Common ISDN minor device class of phone */
189
190         BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_FULLY_AVAILABLE = 0x04, /**< Fully available minor device class of LAN/Network access point */
191         BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_1_TO_17_PERCENT_UTILIZED = 0x20, /**< 1-17% utilized minor device class of LAN/Network access point */
192         BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_17_TO_33_PERCENT_UTILIZED = 0x40, /**< 17-33% utilized minor device class of LAN/Network access point */
193         BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_33_TO_50_PERCENT_UTILIZED = 0x60, /**< 33-50% utilized minor device class of LAN/Network access point */
194         BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_50_to_67_PERCENT_UTILIZED = 0x80, /**< 50-67% utilized minor device class of LAN/Network access point */
195         BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_67_TO_83_PERCENT_UTILIZED = 0xA0, /**< 67-83% utilized minor device class of LAN/Network access point */
196         BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_83_TO_99_PERCENT_UTILIZED = 0xC0, /**< 83-99% utilized minor device class of LAN/Network access point */
197         BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_NO_SERVICE_AVAILABLE = 0xE0, /**< No service available minor device class of LAN/Network access point */
198
199         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_UNCATEGORIZED = 0x00, /**< Uncategorized minor device class of audio/video */
200         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_WEARABLE_HEADSET = 0x04, /**< Wearable headset minor device class of audio/video */
201         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_HANDS_FREE = 0x08, /**< Hands-free minor device class of audio/video */
202         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_MICROPHONE = 0x10, /**< Microphone minor device class of audio/video */
203         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_LOUDSPEAKER = 0x14, /**< Loudspeaker minor device class of audio/video */
204         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_HEADPHONES = 0x18, /**< Headphones minor device class of audio/video */
205         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_PORTABLE_AUDIO = 0x1C, /**< Portable audio minor device class of audio/video */
206         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_CAR_AUDIO = 0x20, /**< Car audio minor device class of audio/video */
207         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_SET_TOP_BOX = 0x24, /**< Set-top box minor device class of audio/video */
208         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_HIFI_AUDIO_DEVICE = 0x28, /**< Hifi audio minor device class of audio/video */
209         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VCR = 0x2C, /**< VCR minor device class of audio/video */
210         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_CAMERA = 0x30, /**< Video camera minor device class of audio/video */
211         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_CAMCORDER = 0x34, /**< Camcorder minor device class of audio/video */
212         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_MONITOR = 0x38, /**< Video monitor minor device class of audio/video */
213         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_DISPLAY_LOUDSPEAKER = 0x3C, /**< Video display and loudspeaker minor device class of audio/video */
214         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_CONFERENCING = 0x40, /**< Video conferencing minor device class of audio/video */
215         BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_GAMING_TOY = 0x48, /**< Gaming/toy minor device class of audio/video */
216
217         BT_MINOR_DEVICE_CLASS_PERIPHERA_UNCATEGORIZED = 0x00, /**< Uncategorized minor device class of peripheral */
218         BT_MINOR_DEVICE_CLASS_PERIPHERAL_KEY_BOARD = 0x40, /**< Key board minor device class of peripheral */
219         BT_MINOR_DEVICE_CLASS_PERIPHERAL_POINTING_DEVICE = 0x80, /**< Pointing device minor device class of peripheral */
220         BT_MINOR_DEVICE_CLASS_PERIPHERAL_COMBO_KEYBOARD_POINTING_DEVICE = 0xC0, /**< Combo keyboard or pointing device minor device class of peripheral */
221         BT_MINOR_DEVICE_CLASS_PERIPHERAL_JOYSTICK = 0x04, /**< Joystick minor device class of peripheral */
222         BT_MINOR_DEVICE_CLASS_PERIPHERAL_GAME_PAD = 0x08, /**< Game pad minor device class of peripheral */
223         BT_MINOR_DEVICE_CLASS_PERIPHERAL_REMOTE_CONTROL = 0x0C, /**< Remote control minor device class of peripheral */
224         BT_MINOR_DEVICE_CLASS_PERIPHERAL_SENSING_DEVICE = 0x10, /**< Sensing device minor device class of peripheral */
225         BT_MINOR_DEVICE_CLASS_PERIPHERAL_DIGITIZER_TABLET = 0x14, /**< Digitizer minor device class of peripheral */
226         BT_MINOR_DEVICE_CLASS_PERIPHERAL_CARD_READER = 0x18, /**< Card reader minor device class of peripheral */
227         BT_MINOR_DEVICE_CLASS_PERIPHERAL_DIGITAL_PEN = 0x1C, /**< Digital pen minor device class of peripheral */
228         BT_MINOR_DEVICE_CLASS_PERIPHERAL_HANDHELD_SCANNER = 0x20, /**< Handheld scanner minor device class of peripheral */
229         BT_MINOR_DEVICE_CLASS_PERIPHERAL_HANDHELD_GESTURAL_INPUT_DEVICE = 0x24, /**< Handheld gestural input device minor device class of peripheral */
230
231         BT_MINOR_DEVICE_CLASS_IMAGING_DISPLAY = 0x10, /**< Display minor device class of imaging */
232         BT_MINOR_DEVICE_CLASS_IMAGING_CAMERA = 0x20, /**< Camera minor device class of imaging */
233         BT_MINOR_DEVICE_CLASS_IMAGING_SCANNER = 0x40, /**< Scanner minor device class of imaging */
234         BT_MINOR_DEVICE_CLASS_IMAGING_PRINTER = 0x80, /**< Printer minor device class of imaging */
235
236         BT_MINOR_DEVICE_CLASS_WEARABLE_WRIST_WATCH = 0x04, /**< Wrist watch minor device class of wearable */
237         BT_MINOR_DEVICE_CLASS_WEARABLE_PAGER = 0x08, /**< Pager minor device class of wearable */
238         BT_MINOR_DEVICE_CLASS_WEARABLE_JACKET = 0x0C, /**< Jacket minor device class of wearable */
239         BT_MINOR_DEVICE_CLASS_WEARABLE_HELMET = 0x10, /**< Helmet minor device class of wearable */
240         BT_MINOR_DEVICE_CLASS_WEARABLE_GLASSES = 0x14, /**< Glasses minor device class of wearable */
241
242         BT_MINOR_DEVICE_CLASS_TOY_ROBOT = 0x04, /**< Robot minor device class of toy */
243         BT_MINOR_DEVICE_CLASS_TOY_VEHICLE = 0x08, /**< Vehicle minor device class of toy */
244         BT_MINOR_DEVICE_CLASS_TOY_DOLL_ACTION = 0x0C, /**< Doll/Action minor device class of toy */
245         BT_MINOR_DEVICE_CLASS_TOY_CONTROLLER = 0x10, /**< Controller minor device class of toy */
246         BT_MINOR_DEVICE_CLASS_TOY_GAME = 0x14, /**< Game minor device class of toy */
247
248         BT_MINOR_DEVICE_CLASS_HEATH_UNCATEGORIZED = 0x00, /**< Uncategorized minor device class of health */
249         BT_MINOR_DEVICE_CLASS_HEATH_BLOOD_PRESSURE_MONITOR = 0x04, /**< Blood pressure monitor minor device class of health */
250         BT_MINOR_DEVICE_CLASS_HEATH_THERMOMETER = 0x08, /**< Thermometer minor device class of health */
251         BT_MINOR_DEVICE_CLASS_HEATH_WEIGHING_SCALE = 0x0C, /**< Weighing scale minor device class of health */
252         BT_MINOR_DEVICE_CLASS_HEATH_GLUCOSE_METER = 0x10, /**< Glucose minor device class of health */
253         BT_MINOR_DEVICE_CLASS_HEATH_PULSE_OXIMETER = 0x14, /**< Pulse oximeter minor device class of health */
254         BT_MINOR_DEVICE_CLASS_HEATH_HEART_PULSE_RATE_MONITOR = 0x18, /**< Heart/Pulse rate monitor minor device class of health */
255         BT_MINOR_DEVICE_CLASS_HEATH_DATA_DISPLAY = 0x1C, /**< Health data display minor device class of health */
256         BT_MINOR_DEVICE_CLASS_HEATH_STEP_COUNTER = 0x20, /**< Step counter minor device class of health */    
257         BT_MINOR_DEVICE_CLASS_HEATH_BODY_COMPOSITION_ANALYZER = 0x24, /**< Body composition analyzer minor device class of health */    
258         BT_MINOR_DEVICE_CLASS_HEATH_PEAK_FLOW_MONITOR = 0x28, /**< Peak flow monitor minor device class of health */    
259         BT_MINOR_DEVICE_CLASS_HEATH_MEDICATION_MONITOR = 0x2C, /**< Medication monitor minor device class of health */    
260         BT_MINOR_DEVICE_CLASS_HEATH_KNEE_PROSTHESIS = 0x30, /**< Knee prosthesis minor device class of health */    
261         BT_MINOR_DEVICE_CLASS_HEATH_ANKLE_PROSTHESIS = 0x34, /**< Ankle prosthesis minor device class of health */    
262 } bt_minor_device_class_e;
263
264 /**
265  * @}
266  */
267
268 /**
269  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
270  * @brief Class structure of device and service.
271  *
272  * @see #bt_device_info_s
273  * @see #bt_adapter_device_discovery_info_s
274  * @see bt_device_bond_created_cb()
275  * @see bt_adapter_device_discovery_state_changed_cb()
276  */
277 typedef struct
278 {
279         bt_major_device_class_e major_device_class;     /**< Major device class. */
280         bt_minor_device_class_e minor_device_class;     /**< Minor device class. */
281         int major_service_class_mask;   /**< Major service class mask. 
282         This value can be a combination of #bt_major_service_class_e like #BT_MAJOR_SERVICE_CLASS_RENDERING | #BT_MAJOR_SERVICE_CLASS_AUDIO */
283 } bt_class_s;
284
285 /**
286  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
287  * @brief Structure of device discovery information.
288  *
289  * @see #bt_class_s
290  * @see bt_adapter_device_discovery_state_changed_cb()
291  */
292 typedef struct
293 {
294         char* remote_address;   /**< The address of remote device */
295         char* remote_name;      /**< The name of remote device */
296         bt_class_s bt_class;    /**< The Bluetooth classes */
297         int rssi;       /**< The strength indicator of received signal  */
298         bool is_bonded; /**< The bonding state */
299 } bt_adapter_device_discovery_info_s;
300
301 /**
302  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
303  * @brief Device information structure used for identifying pear device.
304  *
305  * @see #bt_class_s
306  * @see bt_device_bond_created_cb()
307  */
308 typedef struct
309 {
310         char* remote_address;   /**< The address of remote device */
311         char* remote_name;      /**< The name of remote device */
312         bt_class_s bt_class;    /**< The Bluetooth classes */
313         char** service_uuid;  /**< The UUID list of service */
314         int service_count;      /**< The number of services */     
315         bool is_bonded; /**< The bonding state */
316         bool is_connected;      /**< The connection state */
317         bool is_authorized;     /**< The authorization state */
318 } bt_device_info_s;
319
320 /**
321  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
322  * @brief Service Discovery Protocol (SDP) data structure.
323  *
324  * @details This protocol is used for discovering available services or pear device,
325  * and finding one to connect with. 
326  *
327  * @see bt_device_service_searched_cb()
328  */
329 typedef struct
330 {
331         char* remote_address;   /**< The address of remote device */
332         char** service_uuid;  /**< The UUID list of service */
333         int service_count;    /**< The number of services. */
334 } bt_device_sdp_info_s;
335
336 /**
337  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
338  *
339  * @brief Rfcomm connection data used for exchanging data between Bluetooth devices.
340  *
341  * @see bt_socket_connection_state_changed_cb()
342  */
343 typedef struct
344 {
345         int socket_fd;  /**< The socket fd */
346         bt_socket_role_e local_role;    /**< The local device role in this connection */
347         char* remote_address;   /**< The remote device address. */
348 } bt_socket_connection_s;
349
350 /**
351  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
352  *
353  * @brief Structure of RFCOMM received data.
354  *
355  * @remarks User can use standard linux functions for reading/writing
356  * data from/to sockets.
357  *
358  * @see bt_socket_data_received_cb()
359  */
360 typedef struct
361 {
362         int socket_fd;  /**< The socket fd */
363         int data_size;  /**< The length of the received data */
364         char* data;     /**< The received data */
365 } bt_socket_received_data_s;
366
367 /**
368  * @addtogroup CAPI_NETWORK_BLUETOOTH_MODULE
369  * @{
370  */
371
372 /**
373  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
374  * @brief  Called when the Bluetooth adapter state changes. 
375  * @param[in]   result  The result of the adapter state changing
376  * @param[in]   adapter_state  The adapter state to be changed
377  * @param[in]   user_data  The user data passed from the callback registration function
378  * @pre Either bt_adapter_enable() or bt_adapter_disable() will invoke this callback if you register this callback using bt_adapter_set_state_changed_cb().
379  * @see bt_adapter_enable()
380  * @see bt_adapter_disable()
381  * @see bt_adapter_set_state_changed_cb()
382  * @see bt_adapter_unset_state_changed_cb() 
383  */
384 typedef void (*bt_adapter_state_changed_cb)(int result, bt_adapter_state_e adapter_state, void *user_data);
385
386 /**
387  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
388  * @brief  Called when adapter name changes. 
389  * @param[in]   device_name     The name of the Bluetooth device to be changed
390  * @param[in]   user_data       The user data passed from the callback registration function
391  * @pre This function will be invoked when the name of Bluetooth adapter changes
392  * if you register this callback using bt_adapter_set_name_changed_cb().
393  * @see bt_adapter_set_name()
394  * @see bt_adapter_set_name_changed_cb()
395  * @see bt_adapter_unset_name_changed_cb()
396  */
397 typedef void (*bt_adapter_name_changed_cb)(char *device_name, void *user_data);
398
399 /**
400  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
401  * @brief  Called when the visibility mode changes. 
402  * @param[in] result The result of the visibility mode changing
403  * @param[in] visibility_mode The visibility mode to be changed
404  * @param[in] user_data The user data passed from the callback registration function
405  * 
406  * @pre This function will be invoked when the visibility of Bluetooth adapter changes
407  * if you register this callback using bt_adapter_set_visibility_mode_changed_cb().
408  * 
409  * @see bt_adapter_set_visibility()
410  * @see bt_adapter_set_visibility_mode_changed_cb()
411  * @see bt_adapter_unset_visibility_mode_changed_cb()
412  */
413 typedef void (*bt_adapter_visibility_mode_changed_cb)
414         (int result, bt_adapter_visibility_mode_e visibility_mode, void *user_data);
415
416 /**
417  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
418  * @brief  Called when the state of device discovery changes. 
419  *
420  * @remarks If \a discovery_state is #BT_ADAPTER_DEVICE_DISCOVERY_FOUND, 
421  * then you can get some information, such as remote device address, remote device name, rssi, and bonding state.
422  *
423  * @param[in] result The result of the device discovery
424  * @param[in] discovery_state The discovery state to be changed
425  * @param[in] device_info The information of the discovered device \n
426  *                                      If \a discovery_state is #BT_ADAPTER_DEVICE_DISCOVERY_STARTED or 
427  * #BT_ADAPTER_DEVICE_DISCOVERY_FINISHED, then \a device_info is NULL.
428  * @param[in] user_data The user data passed from the callback registration function
429  * 
430  * @pre Either bt_adapter_start_device_discovery() or bt_adapter_stop_device_discovery() will invoke this function 
431  * if you register this callback using bt_adapter_set_device_discovery_state_changed_cb().
432  *
433  * @see bt_adapter_start_device_discovery() 
434  * @see bt_adapter_stop_device_discovery()
435  * @see bt_adapter_set_device_discovery_state_changed_cb()
436  * @see bt_adapter_unset_device_discovery_state_changed_cb()
437  * 
438  */
439 typedef void (*bt_adapter_device_discovery_state_changed_cb)
440         (int result, bt_adapter_device_discovery_state_e discovery_state, bt_adapter_device_discovery_info_s *discovery_info, void *user_data);
441
442 /**
443  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
444  * @brief  Called when you get bonded devices repeatedly.
445  *
446  * @param[in] device_info The bonded device information
447  * @param[in] user_data The user data passed from the foreach function
448  * @return @c true to continue with the next iteration of the loop, 
449  * \n @c false to break out of the loop.
450  * @pre bt_adapter_foreach_bonded_device() will invoke this function.
451  * 
452  * @see bt_adapter_foreach_bonded_device()
453  * 
454  */
455 typedef bool (*bt_adapter_bonded_device_cb)(bt_device_info_s* device_info, void *user_data);
456
457 /**
458  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
459  * @brief Called when the process of creating bond finishes.
460  * @remarks If the remote user does not respond within 60 seconds, a time out will happen with #BT_ERROR_TIMED_OUT result code.\n
461  * If bt_device_cancel_bonding() is called and it returns #BT_ERROR_NONE, then this callback function will be called 
462  * with #BT_ERROR_CANCELLED result. \n
463  * If creating a bond succeeds but service search fails, then this callback will be called with #BT_ERROR_SERVICE_SEARCH_FAILED.
464  * In this case, you should try service search again by bt_device_start_service_search() to get the supported service list.
465  *
466  * @param[in] result The result of the bonding device
467  * @param[in] device_info The device information which you creates bond with
468  * @param[in] user_data The user data passed from the callback registration function
469  * 
470  * @pre Either bt_device_create_bond() will invoke this function 
471  * if you register this callback using bt_device_set_bond_created_cb().
472  *
473  * @see bt_device_create_bond() 
474  * @see bt_device_cancel_bonding()
475  * @see bt_device_set_bond_created_cb()
476  * @see bt_device_unset_bond_created_cb()
477  */
478 typedef void (*bt_device_bond_created_cb)(int result, bt_device_info_s *device_info, void *user_data);
479
480 /**
481  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
482  * @brief  Called when the bond destroys. 
483  * @param[in] result The result that a bond is destroyed
484  * @param[in] remote_address The address of the remote Bluetooth device to destroy bond with
485  * @param[in] user_data The user data passed from the callback registration function
486  * @pre bt_device_destroy_bond() will invoke this function
487  * if you register this callback using bt_device_set_bond_destroyed_cb().
488  * 
489  * @see bt_device_destroy_bond()
490  * @see bt_device_set_bond_destroyed_cb()
491  * @see bt_device_unset_bond_destroyed_cb()
492  */
493 typedef void (*bt_device_bond_destroyed_cb)(int result, char *remote_address, void *user_data);
494
495 /**
496  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
497  * @brief  Called when the authorization of device changes. 
498  * @param[in] authorization The authorization of device
499  * @param[in] remote_address The address of the remote Bluetooth device which is (un)authorized
500  * @param[in] user_data The user data passed from the callback registration function
501  * @pre bt_device_set_authorization() will invoke this function if you register this callback using bt_device_set_authorization_changed_cb().
502  *
503  * @see bt_device_set_authorization()
504  * @see #bt_device_set_authorization_changed_cb() 
505  * @see #bt_device_unset_authorization_changed_cb()
506  */
507 typedef void (*bt_device_authorization_changed_cb)
508         (bt_device_authorization_e authorization, char *remote_address, void *user_data);
509
510 /**
511  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
512  * @brief  Called when the process of service search finishes. 
513  * @remark If bt_device_cancel_service_search() is called and it returns #BT_ERROR_NONE, 
514  * then this callback function will be called with #BT_ERROR_CANCELLED result.
515  *
516  * @param[in] result The result of the service searching
517  * @param[in] sdp_info The structure of service lists found on a device
518  * @param[in] user_data The user data passed from the callback registration function
519  * @pre Either bt_device_start_service_search() will invoke this function 
520  * if you register this callback using  bt_device_set_service_searched_cb().
521  *
522  * @see bt_device_start_service_search()
523  * @see bt_device_cancel_service_search()
524  * @see bt_device_set_service_searched_cb()
525  * @see bt_device_unset_service_searched_cb()
526  *
527  */
528 typedef void (*bt_device_service_searched_cb)(int result, bt_device_sdp_info_s *sdp_info, void *user_data);
529
530 /** 
531  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
532  * @brief Called when you receive data. 
533  *
534  * @param[in] data The received data from the remote device
535  * @param[in] user_data The user data passed from the callback registration function
536  *
537  * @pre When the connected remote Bluetooth device invokes bt_socket_send_data(),
538  *              this function will be invoked if you register this function using bt_socket_set_data_received_cb(). 
539  *
540  * @see bt_socket_set_data_received_cb()
541  * @see bt_socket_unset_data_received_cb()
542  * @see bt_socket_send_data()
543  */
544 typedef void (*bt_socket_data_received_cb)(bt_socket_received_data_s *data, void *user_data);
545
546 /**
547  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
548  * @brief  Called when the socket connection state changes.
549  * @remarks  This function won't be invoked when you call bt_socket_disconnect_rfcomm(), which is synchronous function.
550  *
551  * @param[in] result The result of connection state changing
552  * @param[in] connection_state The connection state
553  * @param[in] connection The connection information which is established or disconnected
554  * @param[in] user_data The user data passed from the callback registration function
555  * @pre Either bt_socket_listen_and_accept_rfcomm() or bt_socket_connect_rfcomm() will invoke this function 
556  * if you register this callback using bt_socket_set_connection_state_changed_cb(). \n
557  * If the remote Bluetooth device is connected when bt_socket_destroy_rfcomm() is called, then bt_socket_connection_state_changed_cb() will be invoked.
558  *
559  * @see bt_socket_listen_and_accept_rfcomm()
560  * @see bt_socket_connect_rfcomm()
561  * @see bt_socket_set_connection_state_changed_cb()
562  * @see bt_socket_unset_connection_state_changed_cb()
563  */
564 typedef void (*bt_socket_connection_state_changed_cb)
565         (int result, bt_socket_connection_state_e connection_state, bt_socket_connection_s *connection, void *user_data);
566
567
568 /**
569  * @ingroup CAPI_NETWORK_BLUETOOTH_MODULE
570  * @brief Initializes the Bluetooth API.
571  *
572  * @remarks This function must be called before Bluetooth API starts. \n
573  * You must free all resources of the Bluetooth service by calling bt_deinitialize() if Bluetooth service is no longer needed.
574  *
575  * @return 0 on success, otherwise a negative error value.
576  * @retval #BT_ERROR_NONE  Successful
577  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
578  *
579  * @see  bt_deinitialize()
580  */
581 int bt_initialize(void);
582
583
584 /**
585  * @ingroup CAPI_NETWORK_BLUETOOTH_MODULE
586  * @brief Releases all resources of the Bluetooth API.
587  *
588  * @remarks This function must be called if Bluetooth API is no longer needed. 
589  *
590  * @return 0 on success, otherwise a negative error value.
591  * @retval #BT_ERROR_NONE  Successful
592  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
593  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
594  *
595  * @pre Bluetooth API must be initialized with bt_initialize().
596  *
597  * @see bt_initialize()
598  */
599 int bt_deinitialize(void);
600
601
602 /**
603  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
604  * @brief Enables the local Bluetooth adapter, asynchronously.
605  *
606  * @details This function enables Bluetooth protocol stack and hardware. 
607  *
608  * @return 0 on success, otherwise a negative error value.
609  * @retval #BT_ERROR_NONE  Successful
610  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
611  * @retval #BT_ERROR_ALREADY_DONE  Already enabled
612  * @retval #BT_ERROR_NOW_IN_PROGRESS  Operation now in progress
613  *
614  * @pre Bluetooth service must be initialized with bt_initialize().
615  * @post This function invokes bt_adapter_state_changed_cb().
616  *
617  * @see bt_initialize()
618  * @see bt_adapter_get_state()
619  * @see bt_adapter_disable()
620  * @see bt_adapter_set_state_changed_cb()
621  * @see bt_adapter_unset_state_changed_cb() 
622  * @see bt_adapter_state_changed_cb()
623  *
624  */
625 int bt_adapter_enable(void);
626
627 /**
628  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
629  * @brief Disables the local Bluetooth adapter, asynchronously. 
630  *
631  * @details This function disables Bluetooth protocol stack and hardware. 
632  *
633  * @remarks You should disable Bluetooth adapter to switch off Bluetooth chip, which is helpful for saving power.
634  *
635  * @return 0 on success, otherwise a negative error value.
636  * @retval #BT_ERROR_NONE  Successful
637  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
638  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
639  * @retval #BT_ERROR_NOW_IN_PROGRESS  Operation now in progress
640  *
641  * @pre Bluetooth API must be enabled with bt_adapter_enable().
642  * @post This function invokes bt_adapter_state_changed_cb().
643  *
644  * @see bt_adapter_get_state()
645  * @see bt_adapter_enable()
646  * @see bt_adapter_state_changed_cb()
647  * @see bt_adapter_set_state_changed_cb()
648  * @see bt_adapter_unset_state_changed_cb ()
649  *
650  */
651 int bt_adapter_disable(void);
652
653 /**
654  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
655  * @brief Gets the current state of local Bluetooth adapter.
656  *
657  * @param[out] adapter_state The current adapter state
658  *
659  * @return 0 on success, otherwise a negative error value.
660  * @retval #BT_ERROR_NONE  Successful
661  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
662  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
663  *
664  * @pre Bluetooth service must be initialized with bt_initialize().
665  *
666  * @see bt_initialize() 
667  * @see bt_adapter_enable()
668  * @see bt_adapter_disable()
669  */
670 int bt_adapter_get_state(bt_adapter_state_e *adapter_state);
671
672 /**
673  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
674  * @brief Gets the address of local Bluetooth adapter.
675  *
676  * @remarks The @a local_address must be released with free() by you.
677  *
678  * @param[out] local_address The device address of local Bluetooth adapter
679  *
680  * @return 0 on success, otherwise a negative error value.
681  * @retval #BT_ERROR_NONE Successful
682  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
683  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter 
684  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
685  * @retval #BT_ERROR_OUT_OF_MEMORY  Out of memory
686  * @retval #BT_ERROR_OPERATION_FAILED Operation failed 
687  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable().
688  * @see bt_adapter_enable()
689  * @see bt_adapter_get_name()  
690  */
691 int bt_adapter_get_address(char **local_address);
692
693 /**
694  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
695  * @brief Gets the name of local Bluetooth adapter.
696  *
697  * @details Use this function to get the friendly name associated with Bluetooth 
698  * device, retrieved by the remote Bluetooth devices.
699  *
700  * @remarks The @a local_name must be released with free() by you.
701  *
702  * @param[out] local_name  The local device name
703  *
704  * @return 0 on success, otherwise a negative error value.
705  * @retval #BT_ERROR_NONE  Successful
706  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
707  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
708  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
709  * @retval #BT_ERROR_OUT_OF_MEMORY  Out of memory
710  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed 
711  *
712  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable().
713  * 
714  * @see bt_adapter_enable() 
715  * @see bt_adapter_set_name() 
716  */
717 int bt_adapter_get_name(char **local_name);
718
719 /**
720  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
721  * @brief Sets the name of local Bluetooth adapter. 
722  *
723  * @param[in] local_name The name of the Bluetooth device. \n
724  *                              The maximum length is 248 characters.
725  *
726  * @return 0 on success, otherwise a negative error value.
727  * @retval #BT_ERROR_NONE  Successful
728  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
729  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
730  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
731  * @retval #BT_ERROR_OPERATION_FAILED Operation failed
732  *
733  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable().
734  * @post bt_adapter_name_changed_cb() will be invoked if this function returns #BT_ERROR_NONE.
735  * 
736  * @see bt_adapter_enable()
737  * @see bt_adapter_get_name()
738  * @see bt_adapter_name_changed_cb()
739  * @see bt_adapter_set_name_changed_cb()
740  * @see bt_adapter_unset_name_changed_cb() 
741  */
742 int bt_adapter_set_name(const char *local_name);
743
744 /**
745  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
746  * @brief Gets the visibility mode of local Bluetooth adapter.
747  *
748  * @param[out] mode     The visibility mode of the Bluetooth device
749  *
750  * @return 0 on success, otherwise a negative error value.
751  * @retval #BT_ERROR_NONE  Successful
752  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
753  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
754  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
755  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
756  *
757  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). 
758  *
759  * @see bt_adapter_enable() 
760  * @see bt_adapter_set_visibility()
761  */
762 int bt_adapter_get_visibility(bt_adapter_visibility_mode_e *mode);
763
764 /**
765  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
766  * @brief Sets the visibility mode. 
767  *
768  * @remarks #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE will change to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE 
769  * after the given @a timeout_sec goes.
770  *
771  * @param[in] discoverable_mode The Bluetooth discoverable mode to set
772  * @param[in] timeout_sec The discoverable time duration (in seconds)
773  *                                      @a timeout_sec is used only for #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE mode.
774  *
775  * @return 0 on success, otherwise a negative error value.
776  * @retval #BT_ERROR_NONE  Successful
777  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
778  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
779  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
780  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
781  *
782  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). 
783  * @post bt_adapter_visibility_mode_changed_cb() will be invoked if this function returns #BT_ERROR_NONE. 
784  *
785  * @see bt_adapter_enable()
786  * @see bt_adapter_get_visibility()
787  * @see bt_adapter_visibility_mode_changed_cb()
788  * @see bt_adapter_set_visibility_mode_changed_cb()
789  * @see bt_adapter_unset_visibility_mode_changed_cb() 
790  */
791 int bt_adapter_set_visibility(bt_adapter_visibility_mode_e discoverable_mode, int timeout_sec);
792
793 /**
794  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
795  * @brief Starts the device discovery, asynchronously. 
796  *
797  * @details If a device is discovered, bt_adapter_device_discovery_state_changed_cb() will be invoked 
798  * with #BT_ADAPTER_DEVICE_DISCOVERY_FOUND, and then bt_adapter_device_discovery_state_changed_cb()
799  * will be called with #BT_ADAPTER_DEVICE_DISCOVERY_FINISHED in case of the completion or cancellation of the discovery.
800  *
801  * @remarks To connect to peer Bluetooth device, you need to know its Bluetooth address. \n
802  * The device discovery can be stopped by bt_adapter_stop_device_discovery().
803  *
804  * @return 0 on success, otherwise a negative error value.
805  * @retval #BT_ERROR_NONE  Successful
806  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
807  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
808  * @retval #BT_ERROR_NOW_IN_PROGRESS  Operation is now in progress 
809  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
810  *
811  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). 
812  * @post This function invokes bt_adapter_device_discovery_state_changed_cb().
813  *
814  * @see bt_adapter_enable()
815  * @see bt_adapter_is_discovering()
816  * @see bt_adapter_stop_device_discovery()
817  * @see bt_adapter_device_discovery_state_changed_cb()
818  * @see bt_adapter_set_device_discovery_state_changed_cb()
819  * @see bt_adapter_unset_device_discovery_state_changed_cb() 
820  */
821 int bt_adapter_start_device_discovery(void);
822
823 /**
824  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
825  * @brief Stops the device discovery, asynchronously. 
826  * @remarks The device discovery process will take 10 ~ 20 seconds to get all the devices in vicinity. 
827  * 
828  * @return 0 on success, otherwise a negative error value.
829  * @retval #BT_ERROR_NONE  Successful
830  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
831  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
832  * @retval #BT_ERROR_NOT_IN_PROGRESS  Operation is not in progress
833  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
834  *
835  * @pre The device discovery must be in progress with bt_adapter_start_device_discovery(). 
836  * @post This function invokes bt_adapter_device_discovery_state_changed_cb().
837  *
838  * @see bt_adapter_is_discovering() 
839  * @see bt_adapter_start_device_discovery()
840  * @see bt_adapter_set_device_discovery_state_changed_cb()
841  * @see bt_adapter_unset_device_discovery_state_changed_cb()
842  * @see bt_adapter_device_discovery_state_changed_cb()
843  */
844 int bt_adapter_stop_device_discovery(void);
845
846 /**
847  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
848  * @brief Checks for the device discovery is in progress or not.
849  *
850  * @remarks If Bluetooth discovery is in progress, other operations are not allowed and 
851  * you have to either stop the discovery operation, or wait for it to be finished, 
852  * before performing other operations.
853
854  * @param[out] is_discovering The discovering status: (@c true = in progress , @c  false = not in progress )
855  *
856  * @return 0 on success, otherwise a negative error value.
857  * @retval #BT_ERROR_NONE  Successful
858  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
859  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
860  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
861  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
862  *
863  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). 
864  * 
865  * @see bt_adapter_enable()
866  * @see bt_adapter_start_device_discovery()
867  * @see bt_adapter_stop_device_discovery()
868  */
869 int bt_adapter_is_discovering(bool* is_discovering);
870
871 /**
872  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
873  * @brief Retrieves the device information of all bonded devices. 
874  * 
875  * @param [in] callback The callback function to invoke
876  * @param [in] user_data The user data passed from the foreach function
877  *
878  * @return 0 on success, otherwise a negative error value.
879  * @retval #BT_ERROR_NONE  Successful
880  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
881  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
882  * @retval #BT_ERROR_OUT_OF_MEMORY  Out of memory 
883  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
884  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
885  *
886  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). 
887  * @post This function invokes bt_adapter_bonded_device_cb().
888  *
889  * @see bt_adapter_bonded_device_cb()
890  * @see bt_adapter_enable()
891  */
892 int bt_adapter_foreach_bonded_device(bt_adapter_bonded_device_cb callback, void *user_data);
893
894 /**
895  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
896  * @brief  Registers a callback function to be invoked when the Bluetooth adapter state changes.
897  *
898  * @param[in] callback  The callback function to invoke
899  * @param[in] user_data The user data to be passed to the callback function
900  *
901  * @return   0 on success, otherwise a negative error value.
902  * @retval #BT_ERROR_NONE  Successful
903  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
904  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
905  *
906  * @pre The Bluetooth service must be initialized with bt_initialize(). 
907  * @post bt_adapter_state_changed_cb() will be invoked.
908  *
909  * @see bt_initialize()
910  * @see bt_adapter_state_changed_cb()
911  * @see bt_adapter_set_state_changed_cb()
912  * @see bt_adapter_unset_state_changed_cb()
913  */
914 int bt_adapter_set_state_changed_cb(bt_adapter_state_changed_cb callback, void *user_data);
915
916 /**
917  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
918  * @brief       Unregisters the callback function.
919  *
920  * @return      0 on success, otherwise a negative error value.
921  * @retval #BT_ERROR_NONE  Successful
922  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
923  *
924  * @pre The Bluetooth service must be initialized with bt_initialize(). 
925  *
926  * @see bt_initialize()
927  * @see bt_adapter_set_state_changed_cb()
928  */
929 int bt_adapter_unset_state_changed_cb(void);
930
931 /**
932  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
933  * @brief  Registers a callback function to be invoked when the name of Bluetooth adapter changes.
934  *
935  * @param[in] callback The callback function to invoke
936  * @param[in] user_data The user data to be passed to the callback function
937  *
938  * @return   0 on success, otherwise a negative error value.
939  * @retval #BT_ERROR_NONE  Successful
940  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
941  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
942  *
943  * @pre The Bluetooth service must be initialized with bt_initialize(). 
944  * @post  bt_adapter_name_changed_cb() will be invoked.
945  *
946  * @see bt_initialize() 
947  * @see bt_adapter_name_changed_cb()
948  * @see bt_adapter_unset_name_changed_cb()
949  */
950 int bt_adapter_set_name_changed_cb(bt_adapter_name_changed_cb callback, void *user_data);
951
952 /**
953  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
954  * @brief       Unregisters the callback function.
955  *
956  * @return      0 on success, otherwise a negative error value.
957  * @retval #BT_ERROR_NONE  Successful
958  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
959  *
960  * @pre The Bluetooth service must be initialized with bt_initialize().
961  *
962  * @see bt_initialize()
963  * @see bt_adapter_set_name_changed_cb()
964  */
965 int bt_adapter_unset_name_changed_cb(void);
966
967 /**
968  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
969  * @brief  Registers a callback function to be invoked when the visibility mode changes.
970  *
971  * @param[in] callback The callback function to register
972  * @param[in] user_data The user data to be passed to the callback function
973  *
974  * @return   0 on success, otherwise a negative error value.
975  * @retval #BT_ERROR_NONE  Successful
976  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
977  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
978  *
979  * @pre The Bluetooth service must be initialized with bt_initialize(). 
980  * @post bt_adapter_visibility_mode_changed_cb() will be invoked.
981  *
982  * @see bt_initialize() 
983  * @see bt_adapter_visibility_mode_changed_cb()
984  * @see bt_adapter_unset_visibility_mode_changed_cb()
985  */
986 int bt_adapter_set_visibility_mode_changed_cb(bt_adapter_visibility_mode_changed_cb callback, void *user_data);
987
988 /**
989  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
990  * @brief       Unregisters the callback function.
991  *
992  * @return      0 on success, otherwise a negative error value.
993  * @retval #BT_ERROR_NONE  Successful
994  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
995  *
996  * @pre The Bluetooth service must be initialized with bt_initialize(). 
997  *
998  * @see bt_initialize() 
999  * @see bt_adapter_set_visibility_mode_changed_cb()
1000  */
1001 int bt_adapter_unset_visibility_mode_changed_cb(void);
1002
1003 /**
1004  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
1005  * @brief  Registers a callback function to be invoked when the device discovery state changes.
1006  *
1007  * @param[in] callback The callback function to register
1008  * @param[in] user_data The user data to be passed to the callback function
1009  *
1010  * @return   0 on success, otherwise a negative error value.
1011  * @retval #BT_ERROR_NONE  Successful
1012  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1013  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1014  *
1015  * @pre The Bluetooth service must be initialized with bt_initialize(). 
1016  * @post bt_adapter_device_discovery_state_changed_cb() will be invoked.
1017  *
1018  * @see bt_initialize() 
1019  * @see bt_adapter_device_discovery_state_changed_cb()
1020  * @see bt_adapter_set_device_discovery_state_changed_cb()
1021  * @see bt_adapter_unset_device_discovery_state_changed_cb() 
1022  */
1023 int bt_adapter_set_device_discovery_state_changed_cb(bt_adapter_device_discovery_state_changed_cb callback, void *user_data);
1024
1025 /**
1026  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
1027  * @brief       Unregisters the callback function.
1028  *
1029  * @return      0 on success, otherwise a negative error value.
1030  * @retval #BT_ERROR_NONE  Successful
1031  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1032  *
1033  * @pre The Bluetooth service must be initialized with bt_initialize().
1034  *
1035  * @see bt_initialize() 
1036  * @see bt_adapter_set_device_discovery_state_changed_cb()  
1037  */
1038 int bt_adapter_unset_device_discovery_state_changed_cb(void);
1039
1040
1041 /**
1042  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1043  * @brief Creates a bond with a remote Bluetooth device, asynchronously. 
1044  *
1045  * @remarks A bond can be destroyed by bt_device_destroy_bond().\n
1046  * The bonding request can be cancelled by bt_device_cancel_bonding().
1047  *
1048  * @param[in] remote_address The address of the remote Bluetooth device with which the bond should be created
1049  *
1050  * @return 0 on success, otherwise a negative error value.
1051  * @retval #BT_ERROR_NONE  Successful
1052  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1053  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1054  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
1055  * @retval #BT_ERROR_RESOURCE_BUSY  Device or resource busy
1056  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
1057  *
1058  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable()
1059  * @pre The remote device must be discoverable with bt_adapter_start_device_discovery().
1060  * @post This function invokes bt_device_bond_created_cb().
1061  *
1062  * @see bt_adapter_enable()
1063  * @see bt_adapter_start_device_discovery()
1064  * @see bt_device_bond_created_cb()
1065  * @see bt_device_cancel_bonding()
1066  * @see bt_device_destroy_bond()
1067  * @see bt_device_set_bond_created_cb()
1068  * @see bt_device_unset_bond_created_cb() 
1069  */
1070 int bt_device_create_bond(const char *remote_address);
1071
1072 /**
1073  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1074  * @brief Cancels the bonding process. 
1075  *
1076  * @remakrs Use this function when the remote Bluetooth device is not responding to the 
1077  * bond request or you wish to cancel the bonding request.
1078  * 
1079  * @return 0 on success, otherwise a negative error value.
1080  * @retval #BT_ERROR_NONE  Successful
1081  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1082  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
1083  * @retval #BT_ERROR_NOT_IN_PROGRESS  Operation not in progress
1084  * @pre The creating a bond must be in progress by bt_device_create_bond(). 
1085  *
1086  * @see bt_device_create_bond()
1087  * @see bt_device_bond_created_cb() 
1088  * @see bt_device_set_bond_created_cb()
1089  * @see bt_device_unset_bond_created_cb() 
1090  */
1091 int bt_device_cancel_bonding(void);
1092
1093 /**
1094  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1095  * @brief Destroys the bond, asynchronously. 
1096  *
1097  * @param[in] remote_address The address of the remote Bluetooth device to remove bonding
1098  *
1099  * @return 0 on success, otherwise a negative error value.
1100  * @retval #BT_ERROR_NONE  Successful
1101  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1102  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1103  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
1104  * @retval #BT_ERROR_RESOURCE_BUSY  Device or resource busy
1105  * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED  Remote device not bonded
1106  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
1107  *
1108  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable().
1109  * @pre The bond with the remote device must be created with bt_device_create_bond(). 
1110  * @post This function invokes bt_device_bond_destroyed_cb().
1111  *
1112  * @see bt_adapter_enable()
1113  * @see bt_device_create_bond()
1114  * @see bt_device_bond_destroyed_cb()
1115  * @see bt_device_set_bond_destroyed_cb()
1116  * @see bt_device_unset_bond_destroyed_cb() 
1117  */
1118 int bt_device_destroy_bond(const char *remote_address);
1119
1120 /**
1121  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1122  * @brief Sets an alias for the bonded device. 
1123  *
1124  * @param[in] remote_address The address of the remote Bluetooth device
1125  * @param[in] alias The alias of the remote Bluetooth device
1126  *
1127  * @return 0 on success, otherwise a negative error value.
1128  * @retval #BT_ERROR_NONE  Successful
1129  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1130  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1131  * @retval #BT_ERROR_NOT_ENABLED  Not enabled 
1132  * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED  Remote device not bonded 
1133  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
1134  *
1135  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable().
1136  * @pre The bond with the remote device must be created with bt_device_create_bond(). 
1137  *
1138  * @see bt_adapter_enable()
1139  * @see bt_device_create_bond() 
1140  */
1141 int bt_device_set_alias(const char *remote_address, const char *alias);
1142
1143 /**
1144  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1145  * @brief Sets the authorization of a bonded device, asynchronously. 
1146  *
1147  * @remarks Once a device is authorized, you don't need to receive a confirmation.
1148  * 
1149  * @param[in] remote_address The address of the remote Bluetooth device to authorize
1150  * @param[in] authorization The Bluetooth authorization state
1151  * 
1152  * @return 0 on success, otherwise a negative error value.
1153  * @retval #BT_ERROR_NONE  Successful
1154  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1155  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1156  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
1157  * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED  Remote device not bonded 
1158  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
1159  *
1160  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable().
1161  * @pre The bond with the remote device must be created with bt_device_create_bond(). 
1162  * @post bt_device_authorization_changed_cb() will be invoked.
1163  *
1164  * @see bt_adapter_enable()
1165  * @see bt_device_create_bond()  
1166  * @see bt_device_authorization_changed_cb()
1167  * @see bt_device_set_authorization_changed_cb()
1168  * @see bt_device_unset_authorization_changed_cb() 
1169  */
1170 int bt_device_set_authorization(const char *remote_address, bt_device_authorization_e authorization_state);
1171
1172 /**
1173  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1174  * @brief Starts the search for services supported by the specified device, asynchronously.  
1175  *
1176  * @remarks If creating a bond succeeds, which means bt_device_bond_created_cb() is called with result #BT_ERROR_NONE,
1177  * then you don't need to run this function.\n
1178  * The service search takes a couple of seconds to complete normally. \n
1179  * The service search can be canceled by bt_device_cancel_service_search().
1180  *
1181  * @param[in] remote_address The address of the remote Bluetooth device whose services need to be checked
1182  *
1183  * @return 0 on success, otherwise a negative error value.
1184  * @retval #BT_ERROR_NONE  Successful
1185  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1186  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1187  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
1188  * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED  Remote device not bonded
1189  * @retval #BT_ERROR_SERVICE_SEARCH_FAILED  Service search failed
1190  * 
1191  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable().
1192  * @pre The remote device must be discoverable with bt_adapter_start_device_discovery(). 
1193  * @pre The bond with the remote device must be created with bt_device_create_bond(). 
1194  * @post This function invokes bt_device_service_searched_cb().
1195  *
1196  * @see bt_adapter_enable()
1197  * @see bt_adapter_start_device_discovery()
1198  * @see bt_device_create_bond() 
1199  * @see bt_device_bond_created_cb()
1200  * @see bt_device_service_searched_cb()
1201  * @see bt_device_cancel_service_search()
1202  * @see bt_device_set_service_searched_cb()
1203  * @see bt_device_unset_service_searched_cb() 
1204  */
1205 int bt_device_start_service_search(const char *remote_address);
1206
1207 /**
1208  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1209  * @brief Cancels service search process.
1210  *
1211  * @return 0 on success, otherwise a negative error value.
1212  * @retval #BT_ERROR_NONE  Successful
1213  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1214  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
1215  * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED  Remote device not bonded 
1216  * @retval #BT_ERROR_NOT_IN_PROGRESS  Operation not in progress
1217  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
1218  *
1219  * @pre The service search must be in progress by bt_device_start_service_search(). 
1220  *
1221  * @see bt_device_start_service_search()
1222  * @see bt_device_service_searched_cb() 
1223  * @see bt_device_set_service_searched_cb()
1224  * @see bt_device_unset_service_searched_cb() 
1225  */
1226 int bt_device_cancel_service_search(void);
1227
1228 /**
1229  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1230  * @brief  Registers a callback function to be invoked when the bond creates.
1231  * @param[in] callback The callback function to register
1232  * @param[in] user_data The user data to be passed to the callback function
1233  * @return   0 on success, otherwise a negative error value.
1234  * @retval #BT_ERROR_NONE  Successful
1235  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1236  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1237  * @pre The Bluetooth service must be initialized with bt_initialize(). 
1238  * @post  bt_device_bond_created_cb() will be invoked. 
1239  * @see bt_initialize()
1240  * @see bt_device_bond_created_cb()
1241  * @see bt_device_unset_bond_created_cb()
1242  */
1243 int bt_device_set_bond_created_cb(bt_device_bond_created_cb callback, void *user_data);
1244
1245 /**
1246  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1247  * @brief       Unregisters the callback function.
1248  * @return      0 on success, otherwise a negative error value.
1249  * @retval #BT_ERROR_NONE  Successful
1250  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1251  * @pre The Bluetooth service must be initialized with bt_initialize(). 
1252  * @see bt_initialize() 
1253  * @see bt_device_set_bond_created_cb()
1254  */
1255 int bt_device_unset_bond_created_cb(void);
1256
1257 /**
1258  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1259  * @brief  Registers a callback function to be invoked when the bond destroys.
1260  * @param[in] callback The callback function to register
1261  * @param[in] user_data The user data to be passed to the callback function
1262  * @return   0 on success, otherwise a negative error value.
1263  * @retval #BT_ERROR_NONE  Successful
1264  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1265  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1266  * @pre The Bluetooth service must be initialized with bt_initialize(). 
1267  * @post  bt_device_bond_destroyed_cb() will be invoked. 
1268  * @see bt_initialize() 
1269  * @see bt_device_bond_destroyed_cb()
1270  * @see bt_device_unset_bond_destroyed_cb()
1271  */
1272 int bt_device_set_bond_destroyed_cb(bt_device_bond_destroyed_cb callback, void *user_data);
1273
1274 /**
1275  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1276  * @brief       Unregisters the callback function.
1277  * @return      0 on success, otherwise a negative error value.
1278  * @retval #BT_ERROR_NONE  Successful
1279  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1280  * @pre The Bluetooth service must be initialized with bt_initialize(). 
1281  * @see bt_initialize() 
1282  * @see bt_device_set_bond_destroyed_cb()
1283  */
1284 int bt_device_unset_bond_destroyed_cb(void);
1285
1286 /**
1287  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1288  * @brief  Registers a callback function to be invoked when the authorization of device changes.
1289  * @param[in] callback The callback function to register
1290  * @param[in] user_data The user data to be passed to the callback function
1291  * @return   0 on success, otherwise a negative error value.
1292  * @retval #BT_ERROR_NONE  Successful
1293  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1294  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1295  * @pre The Bluetooth service must be initialized with bt_initialize(). 
1296  * @post  bt_device_authorization_changed_cb() will be invoked. 
1297  * @see bt_initialize() 
1298  * @see bt_device_authorization_changed_cb()
1299  * @see bt_device_set_authorization_changed_cb() 
1300  * @see bt_device_unset_authorization_changed_cb()
1301  */
1302 int bt_device_set_authorization_changed_cb(bt_device_authorization_changed_cb callback, void *user_data);
1303
1304 /**
1305  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1306  * @brief       Unregisters the callback function.
1307  * @return      0 on success, otherwise a negative error value.
1308  * @retval #BT_ERROR_NONE  Successful
1309  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1310  * @pre The Bluetooth service must be initialized with bt_initialize(). 
1311  * @see bt_initialize() 
1312  * @see bt_device_set_authorization_changed_cb()
1313  */
1314 int bt_device_unset_authorization_changed_cb(void);
1315
1316 /**
1317  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1318  * @brief  Registers a callback function to be invoked when the process of service search finishes.
1319  * @param[in] callback The callback function to register
1320  * @param[in] user_data The user data to be passed to the callback function
1321  * @return   0 on success, otherwise a negative error value.
1322  * @retval #BT_ERROR_NONE  Successful
1323  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1324  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1325  * @pre The Bluetooth service must be initialized with bt_initialize(). 
1326  * @post  bt_device_service_searched_cb() will be invoked. 
1327  * @see bt_initialize() 
1328  * @see bt_device_service_searched_cb()
1329  * @see bt_device_unset_service_searched_cb()
1330  */
1331 int bt_device_set_service_searched_cb(bt_device_service_searched_cb callback, void *user_data);
1332
1333 /**
1334  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
1335  * @brief       Unregisters the callback function.
1336  * @return      0 on success, otherwise a negative error value.
1337  * @retval #BT_ERROR_NONE  Successful
1338  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1339  * @pre The Bluetooth service must be initialized with bt_initialize(). 
1340  * @see bt_initialize() 
1341  * @see bt_device_set_service_searched_cb()
1342  */
1343 int bt_device_unset_service_searched_cb(void);
1344
1345 /**
1346  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
1347  * @brief Registers a rfcomm socket with a specific UUID. 
1348  *
1349  * @remarks A socket can be destroyed by bt_socket_destroy_rfcomm().
1350  *
1351  * @param[in] port_uuid The UUID of service to provide
1352  * @param[out] socket_fd A socket file descriptor to be used to communicate
1353  * @return 0 on success, otherwise a negative error value.
1354  *
1355  * @retval #BT_ERROR_NONE  Successful
1356  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1357  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1358  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
1359  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
1360  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). 
1361  *
1362  * @see bt_adapter_enable() 
1363  * @see bt_socket_listen_and_accept_rfcomm()
1364  * @see bt_socket_destroy_rfcomm()
1365  */
1366 int bt_socket_create_rfcomm(const char* port_uuid, int *socket_fd);
1367
1368 /**
1369  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
1370  * @brief Removes the rfcomm socket with the given socket file descriptor.
1371  *
1372  * @param[in] socket_fd The socket file descriptor to destroy
1373  * @return 0 on success, otherwise a negative error value.
1374  * @retval #BT_ERROR_NONE  Successful
1375  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1376  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1377  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
1378  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
1379  *
1380  * @pre The socket must be created with bt_socket_create_rfcomm(). 
1381  * @post If callback function bt_socket_connection_state_changed_cb() is set and the remote Bluetooth device is connected,
1382  * then bt_socket_connection_state_changed_cb() will be called.
1383  *
1384  * @see bt_socket_create_rfcomm()
1385  * @see bt_socket_connection_state_changed_cb()
1386  * @see bt_socket_set_connection_state_changed_cb()
1387  * @see bt_socket_unset_connection_state_changed_cb()
1388  */
1389 int bt_socket_destroy_rfcomm(int socket_fd);
1390
1391 /**
1392  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
1393  * @brief Starts listening on passed rfcomm socket and accepts connection requests, asynchronously. 
1394  *
1395  * @param[in] socket_fd The socket file descriptor on which start to listen
1396  * @param[in] max_pending_connections The maximum number of pending connections
1397  *
1398  * @return 0 on success, otherwise a negative error value.
1399  * @retval #BT_ERROR_NONE  Successful
1400  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1401  * @retval #BT_ERROR_NOT_ENABLED  Not enabled 
1402  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1403  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed 
1404  *
1405  * @pre The socket must be created with bt_socket_create_rfcomm(). 
1406  * @post This function invokes bt_socket_connection_state_changed_cb().
1407  *
1408  * @see bt_socket_create_rfcomm()
1409  * @see bt_socket_connection_state_changed_cb()
1410  * @see bt_socket_set_connection_state_changed_cb()
1411  * @see bt_socket_unset_connection_state_changed_cb() 
1412  */
1413 int bt_socket_listen_and_accept_rfcomm(int socket_fd, int max_pending_connections);
1414
1415 /**
1416  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
1417  * @brief Connects to a specific RFCOMM based service on a remote Bluetooth device UUID, asynchronously.  
1418  *
1419  * @remarks A connection can be disconnected by bt_socket_disconnect_rfcomm(). 
1420  *
1421  * @param[in] remote_address The address of the remote Bluetooth device
1422  * @param[in] remote_port_uuid The UUID of service provided by the remote Bluetooth device
1423  *
1424  * @return 0 on success, otherwise a negative error value.
1425  * @retval #BT_ERROR_NONE  Successful
1426  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1427  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1428  * @retval #BT_ERROR_NOT_ENABLED  Not enabled
1429  * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED  Remote device not bonded
1430  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
1431  *
1432  * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable().
1433  * @pre The remote device must be discoverable with bt_adapter_start_device_discovery().
1434  * @pre The bond with the remote device must be created with bt_device_create_bond().  
1435  * @post This function invokes bt_socket_connection_state_changed_cb().
1436  * 
1437  * @see bt_adapter_enable()
1438  * @see bt_device_create_bond()
1439  * @see bt_adapter_start_device_discovery()
1440  * @see bt_device_start_service_search()
1441  * @see bt_socket_disconnect_rfcomm()
1442  * @see bt_socket_connection_state_changed_cb()
1443  * @see bt_socket_set_connection_state_changed_cb()
1444  * @see bt_socket_unset_connection_state_changed_cb()  
1445  */
1446 int bt_socket_connect_rfcomm(const char *remote_address, const char* remote_port_uuid);
1447
1448 /**
1449  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
1450  * @brief Disconnects the RFCOMM connection with the given socket file descriptor. 
1451  * @remarks Because this is a synchronous function, bt_socket_connection_state_changed_cb() won't be called
1452  * even though a connection is disconnected successfully. 
1453  *
1454  * @param[in] socket_fd The socket file descriptor to close
1455  *
1456  * @return 0 on success, otherwise a negative error value.
1457  * @retval #BT_ERROR_NONE  Successful
1458  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1459  * @retval #BT_ERROR_NOT_ENABLED  Not enabled 
1460  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1461  *
1462  * @pre The connection must be established with bt_socket_connect_rfcomm(). 
1463  * 
1464  * @see bt_socket_connect_rfcomm()
1465  */
1466 int bt_socket_disconnect_rfcomm(int socket_fd);
1467
1468 /**
1469  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
1470  * @brief Sends data to the connected device. 
1471  *
1472  * @param[in] socket_fd The connected socket 
1473  * @param[in] data The data to be sent
1474  * @param[in] length The length of data to be sent
1475  *
1476  * @return 0 on success, otherwise a negative error value.
1477  * @retval #BT_ERROR_NONE  Successful
1478  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1479  * @retval #BT_ERROR_NOT_ENABLED  Not enabled 
1480  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1481  * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
1482  *
1483  * @pre The connection must be established with either bt_socket_connect_rfcomm() or bt_socket_listen_and_accept_rfcomm(). 
1484  *
1485  * @see bt_socket_connect_rfcomm() 
1486  * @see bt_socket_listen_and_accept_rfcomm()
1487  */
1488 int bt_socket_send_data(int socket_fd, const char* data, int length);
1489
1490 /**
1491  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
1492  * @brief  Register a callback function that will be invoked when you receive data.
1493  * @param[in] callback The callback function to register
1494  * @param[in] user_data The user data to be passed to the callback function
1495  * @return   0 on success, otherwise a negative error value.
1496  * @retval #BT_ERROR_NONE  Successful
1497  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1498  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1499  * @pre The Bluetooth service must be initialized with bt_initialize(). 
1500  * @post  bt_socket_data_received_cb() will be invoked.
1501  * @see bt_initialize()
1502  * @see bt_socket_data_received_cb()
1503  * @see bt_socket_set_data_received_cb() 
1504  * @see bt_socket_unset_data_received_cb()
1505  */
1506 int bt_socket_set_data_received_cb(bt_socket_data_received_cb callback, void *user_data);
1507
1508 /**
1509  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
1510  * @brief       Unregisters the callback function.
1511  * @return      0 on success, otherwise a negative error value.
1512  * @retval #BT_ERROR_NONE  Successful
1513  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1514  * @pre The Bluetooth service must be initialized with bt_initialize(). 
1515  * @see bt_initialize()
1516  * @see bt_socket_data_received_cb()
1517  * @see bt_socket_set_data_received_cb()
1518  */
1519 int bt_socket_unset_data_received_cb(void);
1520
1521 /**
1522  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
1523  * @brief  Register a callback function that will be invoked when the connection state changes.
1524  * @param[in] callback The callback function to register
1525  * @param[in] user_data The user data to be passed to the callback function
1526  * @return   0 on success, otherwise a negative error value.
1527  * @retval #BT_ERROR_NONE  Successful
1528  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1529  * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
1530  * @pre The Bluetooth service must be initialized with bt_initialize(). 
1531  * @post bt_socket_connection_state_changed_cb() will be invoked.
1532  * @see bt_initialize() 
1533  * @see bt_socket_connection_state_changed_cb()
1534  * @see bt_socket_unset_connection_state_changed_cb()
1535  */
1536 int bt_socket_set_connection_state_changed_cb(bt_socket_connection_state_changed_cb callback, void *user_data);
1537
1538 /**
1539  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
1540  * @brief       Unregisters the callback function.
1541  * @return      0 on success, otherwise a negative error value.
1542  * @retval #BT_ERROR_NONE  Successful
1543  * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
1544  * @pre The Bluetooth service must be initialized with bt_initialize(). 
1545  * @see bt_initialize() 
1546  * @see bt_socket_connection_state_changed_cb()
1547  * @see bt_socket_set_connection_state_changed_cb()
1548  */
1549 int bt_socket_unset_connection_state_changed_cb(void);
1550
1551
1552 /**
1553  * @}
1554  */
1555
1556 #ifdef __cplusplus
1557 }
1558 #endif /* __cplusplus */
1559
1560 #endif // __TIZEN_NETWORK_BLUETOOTH_H__