ec3ccb5d5386cf86a112829cab3d5596b51db02b
[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 Request remote device attributes
46  *
47  * @details Attibutes such as name, vidpid, bond state etc are requested. remote_device_t is provided
48  *                 with OAL_EVENT_DEVICE_PROPERTIES
49  *
50  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
51  * @retval #OAL_STATUS_SUCCESS  Successful
52  *
53  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
54  *
55  * @see  OAL_EVENT_DEVICE_PROPERTIES
56  * @see  remote_device_t
57  */
58 oal_status_t device_query_attributes(bt_address_t * addr);
59
60 /**
61  * @brief Set alias for remote device
62  *
63  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
64  * @retval #OAL_STATUS_SUCCESS  Successful
65  *
66  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
67  *
68  * @see  remote_device_t
69  */
70 oal_status_t device_set_alias(bt_address_t * addr, char * alias);
71
72
73 /**
74  * @brief Initiate bonding with remote device
75  *
76  * @details Based on IO capabilties of 2 devices, different events can be generated
77  *
78  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
79  * @retval #OAL_STATUS_SUCCESS  Successful
80  *
81  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
82  *
83  * @see  OAL_EVENT_DEVICE_PIN_REQUEST
84  * @see  OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
85  * @see  OAL_EVENT_DEVICE_PASSKEY_CONFIRMATION_REQUEST
86  * @see  OAL_EVENT_DEVICE_PASSKEY_DISPLAY
87  * @see  OAL_EVENT_DEVICE_SSP_CONSENT_REQUEST
88  * @see  OAL_EVENT_DEVICE_BONDING_SUCCESS
89  * @see  OAL_EVENT_DEVICE_BONDING_FAILED
90  */
91 oal_status_t device_create_bond(bt_address_t * addr, connection_type_e transport);
92
93 /**
94  * @brief Cancel already in-progress bonding procedure
95  *
96  * @details Based on current progress different events can be recieved.
97  *
98  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
99  * @retval #OAL_STATUS_SUCCESS  Successful
100  *
101  * @pre Bonding must be in progress by calling device_create_bond()
102  *
103  * @see  OAL_EVENT_DEVICE_BONDING_SUCCESS
104  * @see  OAL_EVENT_DEVICE_BONDING_FAILED
105  * @see  OAL_EVENT_DEVICE_BONDING_REMOVED
106  */
107 oal_status_t device_stop_bond(bt_address_t * addr);
108
109 /**
110  * @brief Remove the already created Bond with remote device
111  *
112  * @details Based on current progress different events can be recieved.
113  *
114  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
115  * @retval #OAL_STATUS_SUCCESS  Successful
116  *
117  * @pre Bond should exist
118  *
119  * @see  OAL_EVENT_DEVICE_BONDING_REMOVED
120  */
121 oal_status_t device_destroy_bond(bt_address_t * addr);
122
123 /**
124  * @brief Request services supported by remote device
125  *
126  * @details List of services in form UUIDs will be provided in event data
127  *
128  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
129  * @retval #OAL_STATUS_SUCCESS  Successful
130  *
131  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
132  *
133  * @see  OAL_EVENT_DEVICE_SERVICES
134  * @see  event_dev_services_t
135  */
136 oal_status_t device_query_services(bt_address_t * addr);
137
138 /**
139  * @brief Cancel already in-progress SDP procedure
140  *
141  * @details Based on current progress different events can be recieved.
142  *
143  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
144  * @retval #OAL_STATUS_SUCCESS  Successful
145  *
146  * @pre SDP must be in progress by calling device_query_services()
147  *
148  */
149 oal_status_t device_stop_query_sevices(bt_address_t * addr);
150
151 /**
152  * @brief Accept PIN request as part of Bonding procedure
153  *
154  * @details Positive response to OAL_EVENT_DEVICE_PIN_REQUEST
155  *
156  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
157  * @retval #OAL_STATUS_SUCCESS  Successful
158  *
159  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
160  *
161  * @see  OAL_EVENT_DEVICE_PIN_REQUEST
162  */
163 oal_status_t device_accept_pin_request(bt_address_t * addr, const char * pin);
164
165 /**
166  * @brief Reject PIN request as part of Bonding procedure
167  *
168  * @details Negative response to OAL_EVENT_DEVICE_PIN_REQUEST
169  *
170  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
171  * @retval #OAL_STATUS_SUCCESS  Successful
172  *
173  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
174  *
175  * @see  OAL_EVENT_DEVICE_PIN_REQUEST
176  */
177 oal_status_t device_reject_pin_request(bt_address_t * addr);
178
179 /**
180  * @brief Accept passkey entry request as part of Bonding procedure
181  *
182  * @details Positive response to OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
183  *
184  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
185  * @retval #OAL_STATUS_SUCCESS  Successful
186  *
187  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
188  *
189  * @see  OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
190  */
191 oal_status_t device_accept_passkey_entry(bt_address_t * addr, uint32_t passkey);
192
193 /**
194  * @brief Reject passkey entry request as part of Bonding procedure
195  *
196  * @details Negative response to OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
197  *
198  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
199  * @retval #OAL_STATUS_SUCCESS  Successful
200  *
201  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
202  *
203  * @see  OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
204  */
205 oal_status_t device_reject_passkey_entry(bt_address_t * addr);
206
207 /**
208  * @brief Reply passkey confirmation request as part of Bonding procedure
209  *
210  * @details Response to OAL_EVENT_DEVICE_PASSKEY_CONFIRMATION_REQUEST
211  *
212  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
213  * @retval #OAL_STATUS_SUCCESS  Successful
214  *
215  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
216  *
217  * @see  OAL_EVENT_DEVICE_PASSKEY_CONFIRMATION_REQUEST
218  */
219 oal_status_t device_reply_passkey_confirmation(bt_address_t * addr, int accept);
220
221 /**
222  * @brief Reply SSP consent request as part of Bonding procedure
223  *
224  * @details Response to OAL_EVENT_DEVICE_SSP_CONSENT_REQUEST
225  *
226  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
227  * @retval #OAL_STATUS_SUCCESS  Successful
228  *
229  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
230  *
231  * @see  OAL_EVENT_DEVICE_SSP_CONSENT_REQUEST
232  */
233 oal_status_t device_reply_ssp_consent(bt_address_t * addr, int accept);
234
235 /**
236  * @brief Accept or reject authorization request for a connection from remote device
237  *
238  * @details authorize = TRUE: all connections from this device will be auto accepted without any auth-event
239  *                 authorize = FALSE: all connections from this device will result in auth request event
240  *
241  * @param[in] always  If TRUE, future connection requests will be automatically accepted.
242  *
243  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
244  * @retval #OAL_STATUS_SUCCESS  Successful
245  *
246  * @pre OAL_EVENT_DEVICE_AUTHORIZE_REQUEST should have been recieved by application.
247  *
248  * @see  OAL_EVENT_DEVICE_AUTHORIZE_REQUEST
249  */
250 oal_status_t device_reply_auth_request(bt_address_t * addr, oal_service_t service_type, int accept, int always);
251
252 /**
253  * @brief Set a device as authorized or unauthorized
254  *
255  * @details authorize = TRUE: all connections from this device will be auto accepted without any auth-event
256  *                 authorize = FALSE: all connections from this device will result in auth request event
257  *
258  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
259  * @retval #OAL_STATUS_SUCCESS  Successful
260  *
261  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
262  *
263  * @see  OAL_EVENT_DEVICE_AUTHORIZE_REQUEST
264  */
265 oal_status_t device_set_authorized(bt_address_t * addr, int authorize);
266
267 #ifdef __cplusplus
268 }
269 #endif /* __cplusplus */
270 #endif /*_OAL_DEVICE_MGR_H_*/
271