Fix SAM tool violations (GlobalVariable)
[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 Get Adapter Energy info.
173  *
174  * @details If API returns OAL_STATUS_FAIL, then adapter can be considered Powered Down.
175  * or the BT chip does not support the method.
176  *
177  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
178  * @retval #OAL_STATUS_SUCCESS  Successful
179  *
180  */
181 oal_status_t adapter_get_energy_info(uint32_t *tx_time, uint32_t *rx_time,
182                                         uint32_t *idle_time, uint32_t *energy_used);
183 /**
184  * @brief Reset Adapter.
185  *
186  * @remarks  Disables the BT stack and chip.
187  *
188  * @details EVENT: OAL_EVENT_ADAPTER_DISABLED
189  *
190  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
191  * @retval #OAL_STATUS_SUCCESS  Successful
192  *
193  * @see  adapter_enable()
194  */
195 oal_status_t adapter_reset(void);
196
197 /**
198  * @brief Recovers Adapter.
199  *
200  * @remarks  Disables the BT stack and chip, enables after after seconds.
201  *
202  * @details EVENT: OAL_EVENT_ADAPTER_DISABLED
203  *
204  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
205  * @retval #OAL_STATUS_SUCCESS  Successful
206  *
207  */
208 oal_status_t adapter_recover(void);
209
210 /**
211  * @brief Start device discovery
212  *
213  * @details For each device found either OAL_EVENT_ADAPTER_INQUIRY_RESULT_BREDR_ONLY
214  *                or OAL_EVENT_ADAPTER_INQUIRY_RESULT_BLE will be generated.
215  *
216  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
217  * @retval #OAL_STATUS_SUCCESS  Successful
218  *
219  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
220  *
221  * @see  adapter_stop_inquiry()
222  * @see  OAL_EVENT_ADAPTER_INQUIRY_STARTED
223  * @see  OAL_EVENT_ADAPTER_INQUIRY_RESULT_BREDR_ONLY
224  * @see  OAL_EVENT_ADAPTER_INQUIRY_RESULT_BLE
225  * @see  OAL_EVENT_ADAPTER_INQUIRY_FINISHED
226  */
227 oal_status_t adapter_start_inquiry(unsigned short duration);
228
229 /**
230  * @brief Stop device discovery
231  *
232  * @details OAL_EVENT_ADAPTER_INQUIRY_FINISHED will be generated by OAL
233  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
234  * @retval #OAL_STATUS_SUCCESS  Successful
235  *
236  * @pre Discovery must be in progress by calling adapter_start_inquiry()
237  *
238  * @see  adapter_start_inquiry()
239  * @see  OAL_EVENT_ADAPTER_INQUIRY_FINISHED
240  */
241 oal_status_t adapter_stop_inquiry(void);
242
243 /**
244  * @brief Get local adapter properties
245  *
246  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
247  * @retval #OAL_STATUS_SUCCESS  Successful
248  *
249  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
250  */
251 oal_status_t adapter_get_properties(void);
252
253 /**
254  * @brief Get local BT chip address
255  *
256  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
257  * @retval #OAL_STATUS_SUCCESS  Successful
258  *
259  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
260  *
261  * @see OAL_EVENT_ADAPTER_PROPERTY_ADDRESS
262  */
263 oal_status_t adapter_get_address(void);
264
265 /**
266  * @brief Get local BT version
267  *
268  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
269  * @retval #OAL_STATUS_SUCCESS  Successful
270  *
271  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
272  *
273  * @see OAL_EVENT_ADAPTER_PROPERTY_VERSION
274  */
275 oal_status_t adapter_get_version(void);
276
277 /**
278  * @brief Get local BT chip name
279  *
280  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
281  * @retval #OAL_STATUS_SUCCESS  Successful
282  *
283  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
284  *
285  * @see OAL_EVENT_ADAPTER_PROPERTY_NAME
286  */
287 oal_status_t adapter_get_name(void);
288
289 /**
290  * @brief Set local BT chip name
291  *
292  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
293  * @retval #OAL_STATUS_SUCCESS  Successful
294  *
295  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
296  *
297  * @see OAL_EVENT_ADAPTER_PROPERTY_NAME
298  */
299 oal_status_t adapter_set_name(char * name);
300
301 /**
302  * @brief Sets output variable to TRUE if adapter is discoverable & connectable.
303  */
304 oal_status_t adapter_is_discoverable(int *p_discoverable);
305
306 /**
307  * @brief Sets output variable to TRUE if adapter is either discoverable or connectable.
308  */
309 oal_status_t adapter_is_connectable(int *p_connectable);
310
311 /**
312  * @brief Gets the connectable state of the adapter.
313  */
314 oal_status_t adapter_get_connectable(void);
315
316 /**
317  * @brief Sets output variable to value of current discoverable timeout.
318  */
319 oal_status_t adapter_get_discoverable_timeout(int *p_timeout);
320
321 /**
322  * @brief Get List of UUIDs for services supported
323  *
324  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
325  * @retval #OAL_STATUS_SUCCESS  Successful
326  *
327  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
328  *
329  * @see OAL_EVENT_ADAPTER_PROPERTY_SERVICES
330  */
331 oal_status_t adapter_get_service_uuids(void);
332
333 /**
334  * @brief Get list of bonded devices
335  *
336  * @remarks     A list of bt_address_t is provided in the event data.
337  *
338  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
339  * @retval #OAL_STATUS_SUCCESS  Successful
340  *
341  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
342  *
343  * @see OAL_EVENT_ADAPTER_BONDED_DEVICE_LIST
344  */
345 oal_status_t adapter_get_bonded_devices(void);
346
347 /**
348  * @brief Get list of profile connected devices
349  *
350  * @remarks A list of bt_address_t is provided in the event data.
351  *
352  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
353  * @retval #OAL_STATUS_SUCCESS  Successful
354  *
355  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
356  */
357 oal_status_t adapter_get_profile_connected_devices(const char *profile_uuid);
358
359 /*
360  * @brief Set connectability of adapter
361  *
362  * @remarks     If enabled, after success event, device can connected from remote device.
363  *                      If disabled, after success event, device cannot be connected from remote device;
364  *                      neither can be found in discoveries.
365  *
366  * @details EVENT:  OAL_EVENT_ADAPTER_MODE_CONNECTABLE/OAL_EVENT_ADAPTER_MODE_NON_CONNECTABLE
367  *
368  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
369  * @retval #OAL_STATUS_SUCCESS  Successful
370  *
371  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
372  *
373  * @see  adapter_is_connectable()
374  * @see  OAL_EVENT_ADAPTER_MODE_CONNECTABLE
375  * @see  OAL_EVENT_ADAPTER_MODE_NON_CONNECTABLE
376  */
377 oal_status_t adapter_set_connectable(int connectable);
378
379 /**
380  * @brief Make adapter discoverable
381  *
382  * @remarks  This device appears in inquiries and can be connected by remote device.
383  *
384  * @details If operation successful OAL_EVENT_ADAPTER_MODE_DISCOVERABLE is generated
385  *
386  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
387  * @retval #OAL_STATUS_SUCCESS  Successful
388  *
389  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
390  *
391  * @see  adapter_is_discoverable()
392  * @see  OAL_EVENT_ADAPTER_MODE_DISCOVERABLE
393  */
394 oal_status_t adapter_set_discoverable(void);
395
396 /**
397  * @brief Set discoverable timeout
398  *
399  * @param timeout Timeout in seconds after which device cannot be found in discoveries
400  *
401  * @details Event  OAL_EVENT_ADAPTER_MODE_DISCOVERABLE_TIMEOUT will be generated.
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  * @see  adapter_is_discoverable()
409  * @see  OAL_EVENT_ADAPTER_MODE_DISCOVERABLE_TIMEOUT
410  */
411 oal_status_t adapter_set_discoverable_timeout(int timeout);
412
413 /**
414  * @brief Set Advertising data on specific Instance ID
415  *
416  * @param instance_id Multi advertising slot ID initialized by stack
417  *
418  * @details Event  OAL_EVENT_BLE_MULTI_ADVERTISING_SET_INST_DATA will be generated.
419  *
420  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
421  * @retval #OAL_STATUS_SUCCESS  Successful
422  *
423  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
424  *
425  * @see  gatts_multi_adv_set_inst_data()
426  */
427 oal_status_t adapter_ble_multi_adv_set_inst_data(int instance_id, oal_ble_multi_adv_param_setup_t *adv_param_setup);
428
429 /**
430  * @brief Set Advertising parameters on specific Instance ID
431  *
432  * @param instance_id Multi advertising slot ID initialized by stack
433  *
434  * @details Event  OAL_EVENT_BLE_MULTI_ADVERTISING_UPDATE event will be generated.
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  * @see  gatts_multi_adv_set_inst_data()
442  */
443 oal_status_t adapter_ble_multi_adv_update(int Ins_id, int min_intv, int max_intv,
444                 int adv_type, int chnl_map, int tx_power, int timeout_s);
445
446 /**
447  * @brief Set Advertising filter policy for a advertiser
448  *
449  * @param filter_policy Type of policy to be used for a particular advertiser.
450  *
451  * @return OAL_STATUS_SUCCESS on success.
452  *
453  * @pre Adapter must be enabled with adapter_enable()
454  */
455 oal_status_t adapter_ble_set_filter_policy(int filter_policy);
456
457 /**
458  * @brief Enable Multi Advertising on specific Instance ID
459  *
460  * @param instance_id Multi advertising slot ID initialized by stack
461  *
462  * @details Event OAL_EVENT_BLE_MULTI_ADVERTISING_ENABLE will be generated.
463  *
464  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
465  * @retval #OAL_STATUS_SUCCESS  Successful
466  *
467  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
468  */
469 oal_status_t adapter_ble_multi_adv_enable(int instance_id);
470
471 /**
472  * @brief Disable Multi Advertising on specific Instance ID
473  *
474  * @param instance_id Multi advertising slot ID initialized by stack
475  *
476  * @details Event OAL_EVENT_BLE_MULTI_ADVERTISING_DISABLE will be generated.
477  *
478  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
479  * @retval #OAL_STATUS_SUCCESS  Successful
480  *
481  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
482  */
483 oal_status_t adapter_ble_multi_adv_disable(int instance_id);
484
485 oal_status_t adapter_set_le_static_random_address(int enable);
486
487 /**
488  * @brief Check if the advertising is enable
489  *
490  * @param void
491  *
492  * @details check from the LE adv list if the Advertising is enabled on the server created.
493  *
494  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
495  * @retval #OAL_STATUS_SUCCESS  Successful
496  *
497  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
498  */
499 oal_status_t is_advertising(void);
500
501 /**
502  * @brief Add/removes device to/from whitelist
503  *
504  * @param remote device address
505  * @param remote device address type
506  * @param whether to add/remove from white list
507  *
508  * @details adds/removes device to/from controller's white list.
509  *
510  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
511  * @retval #OAL_STATUS_SUCCESS  Successful
512  *
513  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
514  */
515 oal_status_t adapter_set_white_list(bt_address_t* device_address, int address_type, bool is_add);
516
517 /**
518  * @brief Set the privacy functionality of the adapter
519  *
520  * @param privacy mode
521  *
522  * @details Set the privacy functionality of the adaptor.
523  *
524  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
525  * @retval #OAL_STATUS_SUCCESS  Successful
526  *
527  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
528  */
529 oal_status_t adapter_ble_set_privacy(int set_privacy);
530
531 /**
532  * @brief set the manufacturer data of the adapter
533  *
534  * @param manufacturer data
535  *
536  * @details sets the specified manufacturer data in the BT-chip
537  *
538  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
539  * @retval #OAL_STATUS_SUCCESS  Successful
540  *
541  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
542  */
543 oal_status_t adapter_set_manufacturer_data(oal_manufacturer_data_t* m_data);
544 #ifdef __cplusplus
545 }
546 #endif /* __cplusplus */
547 #endif /*_OAL_ADAPTER_MGR_H_*/