2 * Open Adaptation Layer (OAL)
4 * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #ifndef _OAL_ADAPTER_MGR_H_
21 #define _OAL_ADAPTER_MGR_H_
24 #include <sys/types.h>
26 #include <oal-manager.h>
33 #define OAL_BT_ADDRESS_STRING_SIZE 18
37 * @brief Enable BT chip for usage.
39 * @remarks Other API can only be used after successful event. \n
41 * @details EVENT: OAL_EVENT_ADAPTER_ENABLED/OAL_EVENT_ADAPTER_DISABLED
43 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
44 * @retval #OAL_STATUS_SUCCESS Successful
46 * @pre OAL API must be initialized with oal_bt_init().
48 * @see adapter_disable()
50 oal_status_t adapter_enable(void);
54 * @brief Disable Adapter.
56 * @remarks Disables the BT stack and chip. After this, no OAL API is valid except "adapter_enable()"
58 * @details EVENT: OAL_EVENT_ADAPTER_DISABLED
60 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
61 * @retval #OAL_STATUS_SUCCESS Successful
63 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
65 * @see adapter_enable()
67 oal_status_t adapter_disable(void);
72 * @brief Enable LE Mode BT chip for usage.
74 * @remarks Other API can only be used after successful event. \n
76 * @details EVENT: OAL_EVENT_LE_ENABLED/OAL_EVENT_LE_DISABLED
78 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
79 * @retval #OAL_STATUS_SUCCESS Successful
81 * @pre OAL API must be initialized with oal_bt_init().
85 oal_status_t le_enable(void);
88 * @brief Disable LE Adapter.
90 * @remarks Disables the LE mode in the chip. After this, no OAL API is valid except "le_enable()"
92 * @details EVENT: OAL_EVENT_LE_DISABLED
94 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
95 * @retval #OAL_STATUS_SUCCESS Successful
97 * @pre LE Adapter must be enabled with le_enable() followed by OAL_EVENT_LE_ENABLED
101 oal_status_t le_disable(void);
105 * @brief init LE Adapter.
107 * @remarks Initilizes LE Advertisement slot list
109 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
110 * @retval #OAL_STATUS_SUCCESS Successful
112 * @pre LE Adapter must be enabled with le_enable() followed by OAL_EVENT_LE_ENABLED
116 oal_status_t le_init(void);
120 * @brief deinit LE Adapter.
122 * @remarks free LE Advertisement slot list
124 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
125 * @retval #OAL_STATUS_SUCCESS Successful
127 * @pre LE Adapter must be enabled with le_enable() followed by OAL_EVENT_LE_ENABLED and Initilized using le_init()
131 oal_status_t le_deinit(void);
136 * @brief Start Custom Discovery.
138 * @remarks Based on discovery type, it either starts BREDR, LE or DUAL discovery in Adapter
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.
143 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
144 * @retval #OAL_STATUS_SUCCESS Successful
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
152 oal_status_t adapter_start_custom_inquiry(discovery_type_t disc_type);
156 * @brief Get Adapter Powered state.
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
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.
165 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
166 * @retval #OAL_STATUS_SUCCESS Successful
169 oal_status_t adapter_get_powered_status(gboolean *status);
172 * @brief Get Adapter Energy info.
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.
177 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
178 * @retval #OAL_STATUS_SUCCESS Successful
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);
184 * @brief Reset Adapter.
186 * @remarks Disables the BT stack and chip.
188 * @details EVENT: OAL_EVENT_ADAPTER_DISABLED
190 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
191 * @retval #OAL_STATUS_SUCCESS Successful
193 * @see adapter_enable()
195 oal_status_t adapter_reset(void);
198 * @brief Recovers Adapter.
200 * @remarks Disables the BT stack and chip, enables after after seconds.
202 * @details EVENT: OAL_EVENT_ADAPTER_DISABLED
204 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
205 * @retval #OAL_STATUS_SUCCESS Successful
208 oal_status_t adapter_recover(void);
211 * @brief Start device discovery
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.
216 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
217 * @retval #OAL_STATUS_SUCCESS Successful
219 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
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
227 oal_status_t adapter_start_inquiry(unsigned short duration);
230 * @brief Stop device discovery
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
236 * @pre Discovery must be in progress by calling adapter_start_inquiry()
238 * @see adapter_start_inquiry()
239 * @see OAL_EVENT_ADAPTER_INQUIRY_FINISHED
241 oal_status_t adapter_stop_inquiry(void);
244 * @brief Get local adapter properties
246 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
247 * @retval #OAL_STATUS_SUCCESS Successful
249 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
251 oal_status_t adapter_get_properties(void);
254 * @brief Get local BT chip address
256 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
257 * @retval #OAL_STATUS_SUCCESS Successful
259 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
261 * @see OAL_EVENT_ADAPTER_PROPERTY_ADDRESS
263 oal_status_t adapter_get_address(void);
266 * @brief Get local BT version
268 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
269 * @retval #OAL_STATUS_SUCCESS Successful
271 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
273 * @see OAL_EVENT_ADAPTER_PROPERTY_VERSION
275 oal_status_t adapter_get_version(void);
278 * @brief Get local BT chip name
280 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
281 * @retval #OAL_STATUS_SUCCESS Successful
283 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
285 * @see OAL_EVENT_ADAPTER_PROPERTY_NAME
287 oal_status_t adapter_get_name(void);
290 * @brief Set local BT chip name
292 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
293 * @retval #OAL_STATUS_SUCCESS Successful
295 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
297 * @see OAL_EVENT_ADAPTER_PROPERTY_NAME
299 oal_status_t adapter_set_name(char * name);
302 * @brief Sets output variable to TRUE if adapter is discoverable & connectable.
304 oal_status_t adapter_is_discoverable(int *p_discoverable);
307 * @brief Sets output variable to TRUE if adapter is either discoverable or connectable.
309 oal_status_t adapter_is_connectable(int *p_connectable);
312 * @brief Gets the connectable state of the adapter.
314 oal_status_t adapter_get_connectable(void);
317 * @brief Sets output variable to value of current discoverable timeout.
319 oal_status_t adapter_get_discoverable_timeout(int *p_timeout);
322 * @brief Get List of UUIDs for services supported
324 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
325 * @retval #OAL_STATUS_SUCCESS Successful
327 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
329 * @see OAL_EVENT_ADAPTER_PROPERTY_SERVICES
331 oal_status_t adapter_get_service_uuids(void);
334 * @brief Get list of bonded devices
336 * @remarks A list of bt_address_t is provided in the event data.
338 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
339 * @retval #OAL_STATUS_SUCCESS Successful
341 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
343 * @see OAL_EVENT_ADAPTER_BONDED_DEVICE_LIST
345 oal_status_t adapter_get_bonded_devices(void);
348 * @brief Get list of profile connected devices
350 * @remarks A list of bt_address_t is provided in the event data.
352 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
353 * @retval #OAL_STATUS_SUCCESS Successful
355 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
357 oal_status_t adapter_get_profile_connected_devices(const char *profile_uuid);
360 * @brief Set connectability of adapter
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.
366 * @details EVENT: OAL_EVENT_ADAPTER_MODE_CONNECTABLE/OAL_EVENT_ADAPTER_MODE_NON_CONNECTABLE
368 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
369 * @retval #OAL_STATUS_SUCCESS Successful
371 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
373 * @see adapter_is_connectable()
374 * @see OAL_EVENT_ADAPTER_MODE_CONNECTABLE
375 * @see OAL_EVENT_ADAPTER_MODE_NON_CONNECTABLE
377 oal_status_t adapter_set_connectable(int connectable);
380 * @brief Make adapter discoverable
382 * @remarks This device appears in inquiries and can be connected by remote device.
384 * @details If operation successful OAL_EVENT_ADAPTER_MODE_DISCOVERABLE is generated
386 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
387 * @retval #OAL_STATUS_SUCCESS Successful
389 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
391 * @see adapter_is_discoverable()
392 * @see OAL_EVENT_ADAPTER_MODE_DISCOVERABLE
394 oal_status_t adapter_set_discoverable(void);
397 * @brief Set discoverable timeout
399 * @param timeout Timeout in seconds after which device cannot be found in discoveries
401 * @details Event OAL_EVENT_ADAPTER_MODE_DISCOVERABLE_TIMEOUT will be generated.
403 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
404 * @retval #OAL_STATUS_SUCCESS Successful
406 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
408 * @see adapter_is_discoverable()
409 * @see OAL_EVENT_ADAPTER_MODE_DISCOVERABLE_TIMEOUT
411 oal_status_t adapter_set_discoverable_timeout(int timeout);
414 * @brief Set Advertising data on specific Instance ID
416 * @param instance_id Multi advertising slot ID initialized by stack
418 * @details Event OAL_EVENT_BLE_MULTI_ADVERTISING_SET_INST_DATA will be generated.
420 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
421 * @retval #OAL_STATUS_SUCCESS Successful
423 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
425 * @see gatts_multi_adv_set_inst_data()
427 oal_status_t adapter_ble_multi_adv_set_inst_data(int instance_id, oal_ble_multi_adv_param_setup_t *adv_param_setup);
430 * @brief Set Advertising parameters on specific Instance ID
432 * @param instance_id Multi advertising slot ID initialized by stack
434 * @details Event OAL_EVENT_BLE_MULTI_ADVERTISING_UPDATE event will be generated.
436 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
437 * @retval #OAL_STATUS_SUCCESS Successful
439 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
441 * @see gatts_multi_adv_set_inst_data()
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);
447 * @brief Set Advertising filter policy for a advertiser
449 * @param filter_policy Type of policy to be used for a particular advertiser.
451 * @return OAL_STATUS_SUCCESS on success.
453 * @pre Adapter must be enabled with adapter_enable()
455 oal_status_t adapter_ble_set_filter_policy(int filter_policy);
458 * @brief Enable Multi Advertising on specific Instance ID
460 * @param instance_id Multi advertising slot ID initialized by stack
462 * @details Event OAL_EVENT_BLE_MULTI_ADVERTISING_ENABLE will be generated.
464 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
465 * @retval #OAL_STATUS_SUCCESS Successful
467 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
469 oal_status_t adapter_ble_multi_adv_enable(int instance_id);
472 * @brief Disable Multi Advertising on specific Instance ID
474 * @param instance_id Multi advertising slot ID initialized by stack
476 * @details Event OAL_EVENT_BLE_MULTI_ADVERTISING_DISABLE will be generated.
478 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
479 * @retval #OAL_STATUS_SUCCESS Successful
481 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
483 oal_status_t adapter_ble_multi_adv_disable(int instance_id);
485 oal_status_t adapter_set_le_static_random_address(int enable);
488 * @brief Check if the advertising is enable
492 * @details check from the LE adv list if the Advertising is enabled on the server created.
494 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
495 * @retval #OAL_STATUS_SUCCESS Successful
497 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
499 oal_status_t is_advertising(void);
502 * @brief Add/removes device to/from whitelist
504 * @param remote device address
505 * @param remote device address type
506 * @param whether to add/remove from white list
508 * @details adds/removes device to/from controller's white list.
510 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
511 * @retval #OAL_STATUS_SUCCESS Successful
513 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
515 oal_status_t adapter_set_white_list(bt_address_t* device_address, int address_type, bool is_add);
518 * @brief Set the privacy functionality of the adapter
520 * @param privacy mode
522 * @details Set the privacy functionality of the adaptor.
524 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
525 * @retval #OAL_STATUS_SUCCESS Successful
527 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
529 oal_status_t adapter_ble_set_privacy(int set_privacy);
532 * @brief set the manufacturer data of the adapter
534 * @param manufacturer data
536 * @details sets the specified manufacturer data in the BT-chip
538 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
539 * @retval #OAL_STATUS_SUCCESS Successful
541 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
543 oal_status_t adapter_set_manufacturer_data(oal_manufacturer_data_t* m_data);
546 #endif /* __cplusplus */
547 #endif /*_OAL_ADAPTER_MGR_H_*/