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