Merge "Add default deny policy in conf files" into tizen
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / include / oal-adapter-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_ADAPTER_MGR_H_
21 #define _OAL_ADAPTER_MGR_H_
22
23 #include <glib.h>
24 #include <sys/types.h>
25
26 #include <oal-manager.h>
27 #include <oal-gatt.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #define OAL_BT_ADDRESS_STRING_SIZE 18
34
35
36 /**
37  * @brief Enable BT chip for usage.
38  *
39  * @remarks Other API can only be used after successful event. \n
40  *
41  * @details EVENT: OAL_EVENT_ADAPTER_ENABLED/OAL_EVENT_ADAPTER_DISABLED
42  *
43  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
44  * @retval #OAL_STATUS_SUCCESS  Successful
45  *
46  * @pre OAL API must be initialized with oal_bt_init().
47  *
48  * @see  adapter_disable()
49  */
50 oal_status_t adapter_enable(void);
51
52
53 /**
54  * @brief Disable Adapter.
55  *
56  * @remarks  Disables the BT stack and chip. After this, no OAL API is valid except "adapter_enable()"
57  *
58  * @details EVENT: OAL_EVENT_ADAPTER_DISABLED
59  *
60  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
61  * @retval #OAL_STATUS_SUCCESS  Successful
62  *
63  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
64  *
65  * @see  adapter_enable()
66  */
67 oal_status_t adapter_disable(void);
68
69 #ifdef TIZEN_BT_HAL
70
71 /**
72  * @brief Enable LE Mode BT chip for usage.
73  *
74  * @remarks Other API can only be used after successful event. \n
75  *
76  * @details EVENT: OAL_EVENT_LE_ENABLED/OAL_EVENT_LE_DISABLED
77  *
78  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
79  * @retval #OAL_STATUS_SUCCESS  Successful
80  *
81  * @pre OAL API must be initialized with oal_bt_init().
82  *
83  * @see  le_disable()
84  */
85 oal_status_t le_enable(void);
86
87 /**
88  * @brief Disable LE Adapter.
89  *
90  * @remarks  Disables the LE mode in the chip. After this, no OAL API is valid except "le_enable()"
91  *
92  * @details EVENT: OAL_EVENT_LE_DISABLED
93  *
94  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
95  * @retval #OAL_STATUS_SUCCESS  Successful
96  *
97  * @pre LE Adapter must be enabled with le_enable() followed by OAL_EVENT_LE_ENABLED
98  *
99  * @see  le_enable()
100  */
101 oal_status_t le_disable(void);
102
103
104 /**
105  * @brief init LE Adapter.
106  *
107  * @remarks  Initilizes LE Advertisement slot list
108  *
109  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
110  * @retval #OAL_STATUS_SUCCESS  Successful
111  *
112  * @pre LE Adapter must be enabled with le_enable() followed by OAL_EVENT_LE_ENABLED
113  *
114  * @see  le_enable()
115  */
116 oal_status_t le_init(void);
117
118
119 /**
120  * @brief deinit LE Adapter.
121  *
122  * @remarks  free LE Advertisement slot list
123  *
124  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
125  * @retval #OAL_STATUS_SUCCESS  Successful
126  *
127  * @pre LE Adapter must be enabled with le_enable() followed by OAL_EVENT_LE_ENABLED and Initilized using le_init()
128  *
129  * @see  le_enable()
130  */
131 oal_status_t le_deinit(void);
132
133 #endif
134
135 /**
136  * @brief Start Custom Discovery.
137  *
138  * @remarks  Based on discovery type, it either starts BREDR, LE or DUAL discovery in Adapter
139  *
140  * @details For each device found either OAL_EVENT_ADAPTER_INQUIRY_RESULT_BREDR_ONLY
141  *                or OAL_EVENT_ADAPTER_INQUIRY_RESULT_BLE will be generated.
142  *
143  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
144  * @retval #OAL_STATUS_SUCCESS  Successful
145  *
146  * @see  adapter_stop_inquiry()
147  * @see  OAL_EVENT_ADAPTER_INQUIRY_STARTED
148  * @see  OAL_EVENT_ADAPTER_INQUIRY_RESULT_BREDR_ONLY
149  * @see  OAL_EVENT_ADAPTER_INQUIRY_RESULT_BLE
150  * @see  OAL_EVENT_ADAPTER_INQUIRY_FINISHED
151  */
152 oal_status_t adapter_start_custom_inquiry(discovery_type_t disc_type);
153
154
155 /**
156  * @brief Get Adapter Powered state.
157  *
158  * @remarks  It is possible that stack is up but BT hardware interface is still not enabled.
159  * Application can call this API to explicitly check for Powered state
160  *
161  * @details If API returns OAL_STATUS_FAIL, then adapter can be considered Powered Down.
162  * If API returns OAL_STATUS_SUCCESS, then application needs to check powered status. It can be either
163  * true or false depending on real status of the BT hardware.
164  *
165  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
166  * @retval #OAL_STATUS_SUCCESS  Successful
167  *
168  */
169 oal_status_t adapter_get_powered_status(gboolean *status);
170
171 /**
172  * @brief Reset Adapter.
173  *
174  * @remarks  Disables the BT stack and chip.
175  *
176  * @details EVENT: OAL_EVENT_ADAPTER_DISABLED
177  *
178  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
179  * @retval #OAL_STATUS_SUCCESS  Successful
180  *
181  * @see  adapter_enable()
182  */
183 oal_status_t adapter_reset(void);
184
185 /**
186  * @brief Start device discovery
187  *
188  * @details For each device found either OAL_EVENT_ADAPTER_INQUIRY_RESULT_BREDR_ONLY
189  *                or OAL_EVENT_ADAPTER_INQUIRY_RESULT_BLE will be generated.
190  *
191  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
192  * @retval #OAL_STATUS_SUCCESS  Successful
193  *
194  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
195  *
196  * @see  adapter_stop_inquiry()
197  * @see  OAL_EVENT_ADAPTER_INQUIRY_STARTED
198  * @see  OAL_EVENT_ADAPTER_INQUIRY_RESULT_BREDR_ONLY
199  * @see  OAL_EVENT_ADAPTER_INQUIRY_RESULT_BLE
200  * @see  OAL_EVENT_ADAPTER_INQUIRY_FINISHED
201  */
202 oal_status_t adapter_start_inquiry(unsigned short duration);
203
204 /**
205  * @brief Stop device discovery
206  *
207  * @details OAL_EVENT_ADAPTER_INQUIRY_FINISHED will be generated by OAL
208  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
209  * @retval #OAL_STATUS_SUCCESS  Successful
210  *
211  * @pre Discovery must be in progress by calling adapter_start_inquiry()
212  *
213  * @see  adapter_start_inquiry()
214  * @see  OAL_EVENT_ADAPTER_INQUIRY_FINISHED
215  */
216 oal_status_t adapter_stop_inquiry(void);
217
218 /**
219  * @brief Get local adapter properties
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 oal_status_t adapter_get_properties(void);
227
228 /**
229  * @brief Get local BT chip address
230  *
231  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
232  * @retval #OAL_STATUS_SUCCESS  Successful
233  *
234  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
235  *
236  * @see OAL_EVENT_ADAPTER_PROPERTY_ADDRESS
237  */
238 oal_status_t adapter_get_address(void);
239
240 /**
241  * @brief Get local BT version
242  *
243  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
244  * @retval #OAL_STATUS_SUCCESS  Successful
245  *
246  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
247  *
248  * @see OAL_EVENT_ADAPTER_PROPERTY_VERSION
249  */
250 oal_status_t adapter_get_version(void);
251
252 /**
253  * @brief Get local BT chip name
254  *
255  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
256  * @retval #OAL_STATUS_SUCCESS  Successful
257  *
258  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
259  *
260  * @see OAL_EVENT_ADAPTER_PROPERTY_NAME
261  */
262 oal_status_t adapter_get_name(void);
263
264 /**
265  * @brief Set local BT chip name
266  *
267  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
268  * @retval #OAL_STATUS_SUCCESS  Successful
269  *
270  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
271  *
272  * @see OAL_EVENT_ADAPTER_PROPERTY_NAME
273  */
274 oal_status_t adapter_set_name(char * name);
275
276 /**
277  * @brief Sets output variable to TRUE if adapter is discoverable & connectable.
278  */
279 oal_status_t adapter_is_discoverable(int *p_discoverable);
280
281 /**
282  * @brief Sets output variable to TRUE if adapter is either discoverable or connectable.
283  */
284 oal_status_t adapter_is_connectable(int *p_connectable);
285
286 /**
287  * @brief Sets output variable to value of current discoverable timeout.
288  */
289 oal_status_t adapter_get_discoverable_timeout(int *p_timeout);
290
291 /**
292  * @brief Get List of UUIDs for services supported
293  *
294  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
295  * @retval #OAL_STATUS_SUCCESS  Successful
296  *
297  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
298  *
299  * @see OAL_EVENT_ADAPTER_PROPERTY_SERVICES
300  */
301 oal_status_t adapter_get_service_uuids(void);
302
303 /**
304  * @brief Get list of bonded devices
305  *
306  * @remarks     A list of bt_address_t is provided in the event data.
307  *
308  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
309  * @retval #OAL_STATUS_SUCCESS  Successful
310  *
311  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
312  *
313  * @see OAL_EVENT_ADAPTER_BONDED_DEVICE_LIST
314  */
315 oal_status_t adapter_get_bonded_devices(void);
316
317 /*
318  * @brief Set connectability of adapter
319  *
320  * @remarks     If enabled, after success event, device can connected from remote device.
321  *                      If disabled, after success event, device cannot be connected from remote device;
322  *                      neither can be found in discoveries.
323  *
324  * @details EVENT:  OAL_EVENT_ADAPTER_MODE_CONNECTABLE/OAL_EVENT_ADAPTER_MODE_NON_CONNECTABLE
325  *
326  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
327  * @retval #OAL_STATUS_SUCCESS  Successful
328  *
329  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
330  *
331  * @see  adapter_is_connectable()
332  * @see  OAL_EVENT_ADAPTER_MODE_CONNECTABLE
333  * @see  OAL_EVENT_ADAPTER_MODE_NON_CONNECTABLE
334  */
335 oal_status_t adapter_set_connectable(int connectable);
336
337 /**
338  * @brief Make adapter discoverable
339  *
340  * @remarks  This device appears in inquiries and can be connected by remote device.
341  *
342  * @details If operation successful OAL_EVENT_ADAPTER_MODE_DISCOVERABLE is generated
343  *
344  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
345  * @retval #OAL_STATUS_SUCCESS  Successful
346  *
347  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
348  *
349  * @see  adapter_is_discoverable()
350  * @see  OAL_EVENT_ADAPTER_MODE_DISCOVERABLE
351  */
352 oal_status_t adapter_set_discoverable(void);
353
354 /**
355  * @brief Set discoverable timeout
356  *
357  * @param timeout Timeout in seconds after which device cannot be found in discoveries
358  *
359  * @details Event  OAL_EVENT_ADAPTER_MODE_DISCOVERABLE_TIMEOUT will be generated.
360  *
361  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
362  * @retval #OAL_STATUS_SUCCESS  Successful
363  *
364  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
365  *
366  * @see  adapter_is_discoverable()
367  * @see  OAL_EVENT_ADAPTER_MODE_DISCOVERABLE_TIMEOUT
368  */
369 oal_status_t adapter_set_discoverable_timeout(int timeout);
370
371 /**
372  * @brief Set Advertising data on specific Instance ID
373  *
374  * @param instance_id Multi advertising slot ID initialized by stack
375  *
376  * @details Event  OAL_EVENT_BLE_MULTI_ADVERTISING_SET_INST_DATA will be generated.
377  *
378  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
379  * @retval #OAL_STATUS_SUCCESS  Successful
380  *
381  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
382  *
383  * @see  gatts_multi_adv_set_inst_data()
384  */
385 oal_status_t adapter_ble_multi_adv_set_inst_data(int instance_id, oal_ble_multi_adv_param_setup_t *adv_param_setup);
386
387 /**
388  * @brief Set Advertising parameters on specific Instance ID
389  *
390  * @param instance_id Multi advertising slot ID initialized by stack
391  *
392  * @details Event  OAL_EVENT_BLE_MULTI_ADVERTISING_UPDATE event will be generated.
393  *
394  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
395  * @retval #OAL_STATUS_SUCCESS  Successful
396  *
397  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
398  *
399  * @see  gatts_multi_adv_set_inst_data()
400  */
401 oal_status_t adapter_ble_multi_adv_update(int Ins_id, int min_intv, int max_intv,
402                 int adv_type, int chnl_map, int tx_power, int timeout_s);
403
404 /**
405  * @brief Enable Multi Advertising on specific Instance ID
406  *
407  * @param instance_id Multi advertising slot ID initialized by stack
408  *
409  * @details Event OAL_EVENT_BLE_MULTI_ADVERTISING_ENABLE will be generated.
410  *
411  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
412  * @retval #OAL_STATUS_SUCCESS  Successful
413  *
414  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
415  */
416 oal_status_t adapter_ble_multi_adv_enable(int instance_id);
417
418 /**
419  * @brief Disable Multi Advertising on specific Instance ID
420  *
421  * @param instance_id Multi advertising slot ID initialized by stack
422  *
423  * @details Event OAL_EVENT_BLE_MULTI_ADVERTISING_DISABLE will be generated.
424  *
425  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
426  * @retval #OAL_STATUS_SUCCESS  Successful
427  *
428  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
429  */
430 oal_status_t adapter_ble_multi_adv_disable(int instance_id);
431
432 /**
433  * @brief Check if the advertising is enable
434  *
435  * @param void
436  *
437  * @details check from the LE adv list if the Advertising is enabled on the server created.
438  *
439  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
440  * @retval #OAL_STATUS_SUCCESS  Successful
441  *
442  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
443  */
444 oal_status_t is_advertising(void);
445 #ifdef __cplusplus
446 }
447 #endif /* __cplusplus */
448 #endif /*_OAL_ADAPTER_MGR_H_*/