Mesh: Add support for Node Reset in OAL & HAL
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / include / oal-device-mgr.h
1 /*
2  * Open Adaptation Layer (OAL)
3  *
4  * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
5  *
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
9  *
10  *              http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  */
19
20 #ifndef _OAL_DEVICE_MGR_H_
21 #define _OAL_DEVICE_MGR_H_
22
23 #include <glib.h>
24 #include <sys/types.h>
25
26 #include <oal-manager.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 /**
33  * @brief Connection type
34  *
35  * @see  device_create_bond
36  */
37
38 typedef enum {
39         OAL_CONN_TYPE_DEFAULT = 0xFF, /* represents that connection type can both BR/EDR and LE */
40         OAL_CONN_TYPE_BREDR = 0x00,
41         OAL_CONN_TYPE_LE = 0x01,
42 } oal_conn_type_e;
43
44 /**
45  * @brief OSP server type
46  *
47  * @see device_set_osp_server()
48  * @see device_register_osp_server()
49  */
50 typedef enum {
51         OAL_OSP_SERVER_OBEX = 0x00,
52         OAL_OSP_SERVER_RFCOMM
53 } oal_osp_server_type_e;
54
55 /**
56  * @brief Trusted profile types
57  *
58  * @see  device_set_trust_profile/device_get_trust_profile
59  */
60 typedef enum {
61         OAL_TRUSTED_PROFILE_PBAP = 1,
62         OAL_TRUSTED_PROFILE_MAP,
63         OAL_TRUSTED_PROFILE_SAP,
64         OAL_TRUSTED_PROFILE_HFP_HF,
65         OAL_TRUSTED_PROFILE_A2DP,
66         OAL_TRUSTED_PROFILE_ALL = 0xFFFFFFFF,
67 } oal_trusted_profile_e;
68
69 /**
70  * @brief GAP authentication types
71  *
72  * @see  device_enable_gap_auth_notifications
73  */
74 typedef enum {
75         OAL_PASSKEY_CONFIRMATION = 1,
76         OAL_PASSKEY_DISPLAY,
77         OAL_PASSKEY_ENTRY,
78         OAL_PINCODE_ENTRY,
79 } oal_gap_auth_type_e;
80
81 /**
82  * @brief Request remote device attributes
83  *
84  * @details Attibutes such as name, vidpid, bond state etc are requested. remote_device_t is provided
85  *                 with OAL_EVENT_DEVICE_PROPERTIES
86  *
87  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
88  * @retval #OAL_STATUS_SUCCESS  Successful
89  *
90  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
91  *
92  * @see  OAL_EVENT_DEVICE_PROPERTIES
93  * @see  remote_device_t
94  */
95 oal_status_t device_query_attributes(bt_address_t * addr);
96
97 /**
98  * @brief Set alias for remote device
99  *
100  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
101  * @retval #OAL_STATUS_SUCCESS  Successful
102  *
103  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
104  *
105  * @see  remote_device_t
106  */
107 oal_status_t device_set_alias(bt_address_t * addr, char * alias);
108
109
110 /**
111  * @brief Initiate bonding with remote device
112  *
113  * @details Based on IO capabilties of 2 devices, different events can be generated
114  *
115  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
116  * @retval #OAL_STATUS_SUCCESS  Successful
117  *
118  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
119  *
120  * @see  OAL_EVENT_DEVICE_PIN_REQUEST
121  * @see  OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
122  * @see  OAL_EVENT_DEVICE_PASSKEY_CONFIRMATION_REQUEST
123  * @see  OAL_EVENT_DEVICE_PASSKEY_DISPLAY
124  * @see  OAL_EVENT_DEVICE_SSP_CONSENT_REQUEST
125  * @see  OAL_EVENT_DEVICE_BONDING_SUCCESS
126  * @see  OAL_EVENT_DEVICE_BONDING_FAILED
127  */
128 oal_status_t device_create_bond(bt_address_t * addr, oal_conn_type_e transport);
129
130 /**
131  * @brief Cancel already in-progress bonding procedure
132  *
133  * @details Based on current progress different events can be recieved.
134  *
135  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
136  * @retval #OAL_STATUS_SUCCESS  Successful
137  *
138  * @pre Bonding must be in progress by calling device_create_bond()
139  *
140  * @see  OAL_EVENT_DEVICE_BONDING_SUCCESS
141  * @see  OAL_EVENT_DEVICE_BONDING_FAILED
142  * @see  OAL_EVENT_DEVICE_BONDING_REMOVED
143  */
144 oal_status_t device_stop_bond(bt_address_t * addr);
145
146 /**
147  * @brief Remove the already created Bond with remote device
148  *
149  * @details Based on current progress different events can be recieved.
150  *
151  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
152  * @retval #OAL_STATUS_SUCCESS  Successful
153  *
154  * @pre Bond should exist
155  *
156  * @see  OAL_EVENT_DEVICE_BONDING_REMOVED
157  */
158 oal_status_t device_destroy_bond(bt_address_t * addr);
159
160 /**
161  * @brief Request services supported by remote device
162  *
163  * @details List of services in form UUIDs will be provided in event data
164  *
165  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
166  * @retval #OAL_STATUS_SUCCESS  Successful
167  *
168  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
169  *
170  * @see  OAL_EVENT_DEVICE_SERVICES
171  * @see  event_dev_services_t
172  */
173 oal_status_t device_query_services(bt_address_t * addr);
174
175 /**
176  * @brief Cancel already in-progress SDP procedure
177  *
178  * @details Based on current progress different events can be recieved.
179  *
180  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
181  * @retval #OAL_STATUS_SUCCESS  Successful
182  *
183  * @pre SDP must be in progress by calling device_query_services()
184  *
185  */
186 oal_status_t device_stop_query_sevices(bt_address_t * addr);
187
188 /**
189  * @brief Accept PIN request as part of Bonding procedure
190  *
191  * @details Positive response to OAL_EVENT_DEVICE_PIN_REQUEST
192  *
193  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
194  * @retval #OAL_STATUS_SUCCESS  Successful
195  *
196  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
197  *
198  * @see  OAL_EVENT_DEVICE_PIN_REQUEST
199  */
200 oal_status_t device_accept_pin_request(bt_address_t * addr, const char * pin);
201
202 /**
203  * @brief Reject PIN request as part of Bonding procedure
204  *
205  * @details Negative response to OAL_EVENT_DEVICE_PIN_REQUEST
206  *
207  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
208  * @retval #OAL_STATUS_SUCCESS  Successful
209  *
210  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
211  *
212  * @see  OAL_EVENT_DEVICE_PIN_REQUEST
213  */
214 oal_status_t device_reject_pin_request(bt_address_t * addr);
215
216 /**
217  * @brief Accept passkey entry request as part of Bonding procedure
218  *
219  * @details Positive response to OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
220  *
221  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
222  * @retval #OAL_STATUS_SUCCESS  Successful
223  *
224  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
225  *
226  * @see  OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
227  */
228 oal_status_t device_accept_passkey_entry(bt_address_t * addr, uint32_t passkey);
229
230 /**
231  * @brief Reject passkey entry request as part of Bonding procedure
232  *
233  * @details Negative response to OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
234  *
235  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
236  * @retval #OAL_STATUS_SUCCESS  Successful
237  *
238  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
239  *
240  * @see  OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
241  */
242 oal_status_t device_reject_passkey_entry(bt_address_t * addr);
243
244 /**
245  * @brief Reply passkey confirmation request as part of Bonding procedure
246  *
247  * @details Response to OAL_EVENT_DEVICE_PASSKEY_CONFIRMATION_REQUEST
248  *
249  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
250  * @retval #OAL_STATUS_SUCCESS  Successful
251  *
252  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
253  *
254  * @see  OAL_EVENT_DEVICE_PASSKEY_CONFIRMATION_REQUEST
255  */
256 oal_status_t device_reply_passkey_confirmation(bt_address_t * addr, int accept);
257
258 /**
259  * @brief Reply SSP consent request as part of Bonding procedure
260  *
261  * @details Response to OAL_EVENT_DEVICE_SSP_CONSENT_REQUEST
262  *
263  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
264  * @retval #OAL_STATUS_SUCCESS  Successful
265  *
266  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
267  *
268  * @see  OAL_EVENT_DEVICE_SSP_CONSENT_REQUEST
269  */
270 oal_status_t device_reply_ssp_consent(bt_address_t * addr, int accept);
271
272 /**
273  * @brief Accept or reject authorization request for a connection from remote device
274  *
275  * @details authorize = TRUE: all connections from this device will be auto accepted without any auth-event
276  *                 authorize = FALSE: all connections from this device will result in auth request event
277  *
278  * @param[in] always  If TRUE, future connection requests will be automatically accepted.
279  *
280  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
281  * @retval #OAL_STATUS_SUCCESS  Successful
282  *
283  * @pre OAL_EVENT_DEVICE_AUTHORIZE_REQUEST or, OAL_EVENT_SOCKET_AUTHORIZE_REQUEST should have
284  * been recieved by application.
285  *
286  * @see OAL_EVENT_DEVICE_AUTHORIZE_REQUEST
287  * @see OAL_EVENT_SOCKET_AUTHORIZE_REQUEST
288  */
289 oal_status_t device_reply_auth_request(bt_address_t * addr, oal_service_t service_type, int accept, int always);
290
291 /**
292  * @brief Set a device as authorized or unauthorized
293  *
294  * @details authorize = TRUE: all connections from this device will be auto accepted without any auth-event
295  *                 authorize = FALSE: all connections from this device will result in auth request event
296  *
297  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
298  * @retval #OAL_STATUS_SUCCESS  Successful
299  *
300  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
301  *
302  * @see  OAL_EVENT_DEVICE_AUTHORIZE_REQUEST
303  */
304 oal_status_t device_set_authorized(bt_address_t * addr, int authorize);
305
306 /**
307  * @brief Get ACL connection state for remote device
308  *
309  * @details This API is to check whether ACL connection is established with the remote device
310  *
311  * @param[in] addr: Remote device address.
312  *
313  * @return TRUE if ACL connection is established with the remote device and FALSE otherwise.
314  *
315  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
316  */
317 gboolean device_get_acl_conn_state(bt_address_t * addr);
318
319 /**
320  * @brief Get PROFILE connection state for remote device
321  *
322  * @details This API is to check whether requested profile connection is established with the remote device
323  *
324  * @param[in] addr: Remote device address.
325  * @param[in] svc_id: Profile Id to be checked for connection status.
326  *
327  * @return TRUE if ACL connection is established with the remote device and FALSE otherwise.
328  *
329  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
330  */
331 gboolean device_get_svc_conn_state(bt_address_t * addr, oal_service_t svc_id);
332
333 /**
334  * @brief Register OSP server in GAP agent
335  *
336  * @details This API is to register OSP server in GAP agent. if OSP server is enabled,
337  * connection authorization events are sent to application otherwise handled internally in HAL.
338  *
339  * @param[in] type: OSP Server type
340  * @param[in] uuid: UUID
341  * @param[in] path: Dbus path
342  * @param[in] fd: Socket fd
343  *
344  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
345  *
346  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
347  */
348 oal_status_t device_register_osp_server(oal_osp_server_type_e type, char *uuid, char *path, int fd);
349
350 /**
351  * @brief Unregister OSP server in GAP agent
352  *
353  * @details This API is to unregister OSP server in GAP agent. if OSP server is enabled,
354  * connection authorization events are sent to application otherwise handled internally in HAL.
355  *
356  * @param[in] type: OSP Server type
357  * @param[in] uuid: UUID
358  *
359  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
360  *
361  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
362  */
363 oal_status_t device_unregister_osp_server(oal_osp_server_type_e type, char *uuid);
364
365 /**
366  * @brief Set profile trust info for remote device
367  *
368  * @details This API is used to set profile as trusted/blocked for remote device
369  *
370  * @param[in] addr: Remote device address.
371  * @param[in] profile: Trusted profile enum
372  * @param[in] trust: TRUE == Trusted, FALSE == Blocked
373  *
374  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
375  * @retval #OAL_STATUS_SUCCESS  Successful
376  *
377  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
378  */
379 oal_status_t device_set_trust_profile(bt_address_t *addr, oal_trusted_profile_e profile, gboolean trust);
380
381 /**
382  * @brief Gets the identity address for remote device
383  *
384  * @details This API is used to get the identity address for the remote device
385  *
386  * @param[in] device_address: Remote device address.
387  *
388  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
389  * @retval #OAL_STATUS_SUCCESS  Successful
390  *
391  */
392 oal_status_t device_get_ida(bt_address_t *addr, bt_address_t *id_addr);
393
394 /**
395  * @brief Set profile trust info for remote device
396  *
397  * @details This API is used to set profile as trusted/blocked for remote device
398  *
399  * @param[in] addr: Remote device address.
400  * @param[in] profile: Trusted profile enum
401  * @param[out] trusted: 0 == Blocked, non-zero: Trusted values
402  *
403  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
404  * @retval #OAL_STATUS_SUCCESS  Successful
405  *
406  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
407  */
408 oal_status_t device_get_trust_profile(bt_address_t *addr, oal_trusted_profile_e profile, unsigned int *trusted);
409
410 /**
411  * @brief Get RSSI strength of remote device
412  *
413  * @details This API is used to get RSSI strength of remote device for conncted link type
414  *
415  * @param[in] addr: Remote device address.
416  * @param[in] link_type: conncted link type (0 = BR/EDR link, 1 = LE link, 0xFF = Any (Default))
417  *
418  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
419  * @retval #OAL_STATUS_SUCCESS  Successful
420  *
421  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
422  */
423 oal_status_t device_get_connected_link_rssi_strength(bt_address_t *addr, unsigned int link_type);
424
425 /**
426  * @brief Enable remote device RSSI monitoring
427  *
428  * @details This API is used to enable remote device RSSI monitoring
429  *
430  * @param[in] addr: Remote device address.
431  * @param[in] link_type: conncted link type (0 = BR/EDR link, 1 = LE link, 0xFF = Any (Default))
432  * @param[in] low_threshold: Lower limit for RSSI value
433  * @param[in] in_range_threshold: in range RSSI values
434  * @param[in] high_threshold: Upper limit for RSSI value
435  *
436  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
437  * @retval #OAL_STATUS_SUCCESS  Successful
438  *
439  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
440  */
441 oal_status_t device_enable_rssi_monitoring(bt_address_t *addr, unsigned int link_type,
442                 int low_threshold, int in_range_threshold, int high_threshold);
443
444 /**
445  * @brief Enable/Disable GAP authentication requests to be received from stack
446  *
447  * @details This API is used to enable/disable GAP authentication requests to be received from stack
448  *
449  * @param[in] type: GAP authentication types oal_gap_auth_type_e
450  * @param[in] enable: TRUE/FALSE
451  *
452  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
453  * @retval #OAL_STATUS_SUCCESS  Successful
454  *
455  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
456  */
457 oal_status_t device_enable_gap_auth_notifications(oal_gap_auth_type_e type, gboolean enable);
458
459 /**
460  * @brief Disconnect the device
461  *
462  * @details This API is used to ACL disconnect the device
463  *
464  * @param[in] addr: Remote device address.
465  *
466  * @return TRUE if adapter has accepted the ACL Disconnect request FALSE otherwise.
467  *
468  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
469  */
470 oal_status_t device_disconnect(bt_address_t * addr);
471
472 #ifdef __cplusplus
473 }
474 #endif /* __cplusplus */
475 #endif /*_OAL_DEVICE_MGR_H_*/
476