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_MANAGER_H_
21 #define _OAL_MANAGER_H_
25 #include <sys/types.h>
31 #define BT_VERSION_STR_LEN_MAX 30 /**< This specifies maximum adapter version string length */
33 #define BT_DEVICE_NAME_LENGTH_MAX 248 /**< This specifies maximum device name length */
35 #define BT_ADDRESS_BYTES_NUM 6 /**< This specifies bluetooth device address length */
37 #define OAL_UUID_MAX_LENGTH 16/**< This specifies ble service UUID Length */
39 #define BLE_ADV_DATA_LENGTH 31 /**< This specifies Advertising Data Length */
41 #define BT_ADDRESS_STR_LEN 18 /**< BT address String length> */
43 #define BT_MAX_SERVICES_FOR_DEVICE 60 /**< This specifies the Maximum UUID Id mentioned in bta_api.h>*/
45 #define BLUETOOTH_UUID_STRING_MAX 50
47 #define BT_DEVICE_MANUFACTURER_DATA_LEN_MAX 31 /**<This specifies the Maximum manufacturer data Length>*/
49 typedef void (*oal_event_callback)(int event, gpointer event_data, gsize size);
52 unsigned char addr[BT_ADDRESS_BYTES_NUM];
56 char name[BT_DEVICE_NAME_LENGTH_MAX + 1];
60 int data_len; /**< manafacturer specific data length */
61 char data[BT_DEVICE_MANUFACTURER_DATA_LEN_MAX];
62 } oal_manufacturer_data_t;
67 OAL_STATUS_INTERNAL_ERROR,
70 OAL_STATUS_INVALID_PARAM,
71 OAL_STATUS_RMT_DEVICE_DOWN,
72 OAL_STATUS_AUTH_FAILED,
73 OAL_STATUS_NOT_SUPPORT, //For APIs not supported
74 OAL_STATUS_NOT_PAIRED,
75 OAL_STATUS_ALREADY_DONE,
77 OAL_STATUS_CONN_TIMEOUT,
79 OAL_STATUS_HID_FAILED_MOUSE,
84 OAL_STATUS_CONN_TERM_LOCAL_HOST,
85 OAL_STATUS_CONN_TERM_RMT_HOST
91 /* NOTE: If anything changes in bt_service_id_t enum definition of Bluedroid header, change here too */
93 A2DP_SRC_SERVICE_ID = 3,
97 AVRCP_CT_SERVICE_ID = 9,
100 AVRCP_SERVICE_ID = 19,
102 HSP_HS_SERVICE_ID = 23,
103 HFP_HS_SERVICE_ID = 24,
105 IOTIVITY_SERVICE_ID = 29,
109 /** Bluetooth 128-bit UUID */
114 typedef oal_uuid_t service_uuid_t;
123 BT_DISC_TYPE_BREDR = 0x01,
129 char name[BT_DEVICE_NAME_LENGTH_MAX + 1];
130 char alias[BT_DEVICE_NAME_LENGTH_MAX + 1];
131 bt_address_t address;
140 oal_uuid_t uuid[BT_MAX_SERVICES_FOR_DEVICE];
145 /** GATT ID adding instance id tracking to the UUID */
151 /** GATT Service ID also identifies the service type (primary/secondary) */
155 } oal_gatt_srvc_id_t;
158 * @brief Initializes OAL layer
160 * @remarks Other API can only be used after successful return. \n
162 * @details EVENT: N/A
164 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
165 * @retval #OAL_STATUS_SUCCESS Successful
169 * @see oal_bt_deinit()
171 oal_status_t oal_bt_init(oal_event_callback cb);
174 * @brief Deinitializes OAL Layer
176 * @remarks Other API can only be used after oal_bt_init done again. \n
178 * @details EVENT: N/A
187 void oal_bt_deinit(void);
190 * @brief Initialize Stack lib based on chip
192 * @remarks Other API can only be used after oal_lib_init done. \n
194 * @details EVENT: OAL_EVENT_OAL_INITIALISED_SUCCESS, OAL_EVENT_OAL_INITIALISED_FAILED
203 gboolean oal_lib_init(gpointer data);
206 * @brief Set Debug Mode Flag to TRUE
208 * @remarks OAL will run in exclusive mode, no processing of api-call and no event sending. \n
210 * @details EVENT: N/A
217 * @see oal_get_debug_mode()
219 void oal_set_debug_mode(gboolean mode);
222 * @brief Set Debug Mode Flag
224 * @remarks To check whether Debug mode is running. \n
226 * @details EVENT: N/A
228 * @return TRUE if debug mode is on, otherwise FALSE
229 * @retval #TRUE Successful
233 * @see oal_set_debug_mode()
235 gboolean oal_get_debug_mode(void);
239 * @brief Register the debug mode event catcher
241 * @remarks handles the incoming events and passes to debug handler. \n
243 * @details EVENT: N/A
252 void server_event_catch_register(oal_event_callback dbg_cb);
256 * @brief Get stack name
260 * @pre OAL API must be initialized with oal_bt_init().
262 const char *oal_get_stack_name(void);
266 #endif /* __cplusplus */
267 #endif /*_OAL_HARDWARE_H_*/
270 * @brief calls function to set the is_activating variable in HAL to true
272 * @remarks It is required to let adapter switched on event propagate upwards
274 * @details EVENT: N/A
276 * @return sucess if variable set in HAL
277 * @retval BT_STATUS_SUCCESS
283 int oal_set_adapter_request_state(int enable);
286 * @brief calls function to set the is_activating variable in HAL to true
288 * @remarks It is required to let le adapter switched on event propagate upwards
290 * @details EVENT: N/A
292 * @return sucess if variable set in HAL
293 * @retval BT_STATUS_SUCCESS
299 int oal_set_le_request_state(int enable);