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_DEVICE_MGR_H_
21 #define _OAL_DEVICE_MGR_H_
24 #include <sys/types.h>
26 #include <oal-manager.h>
33 * @brief Connection type
35 * @see device_create_bond
39 CONN_TYPE_DEFAULT = 0xFF, /* represents that connection type can both BR/EDR and LE */
40 CONN_TYPE_BREDR = 0x00,
45 * @brief OSP server type
47 * @see device_set_osp_server()
50 OAL_OSP_SERVER_OBEX = 0x00,
51 /*TODO: Add more server type if and when required */
52 } oal_osp_server_type_e;
55 * @brief Trusted profile types
57 * @see device_set_trust_profile/device_get_trust_profile
60 OAL_TRUSTED_PROFILE_PBAP = 1,
61 OAL_TRUSTED_PROFILE_MAP,
62 OAL_TRUSTED_PROFILE_SAP,
63 OAL_TRUSTED_PROFILE_HFP_HF,
64 OAL_TRUSTED_PROFILE_A2DP,
65 OAL_TRUSTED_PROFILE_ALL = 0xFFFFFFFF,
66 } oal_trusted_profile_e;
69 * @brief GAP authentication types
71 * @see device_enable_gap_auth_notifications
74 OAL_PASSKEY_CONFIRMATION = 1,
78 } oal_gap_auth_type_e;
81 * @brief Request remote device attributes
83 * @details Attibutes such as name, vidpid, bond state etc are requested. remote_device_t is provided
84 * with OAL_EVENT_DEVICE_PROPERTIES
86 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
87 * @retval #OAL_STATUS_SUCCESS Successful
89 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
91 * @see OAL_EVENT_DEVICE_PROPERTIES
92 * @see remote_device_t
94 oal_status_t device_query_attributes(bt_address_t * addr);
97 * @brief Set alias for remote device
99 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
100 * @retval #OAL_STATUS_SUCCESS Successful
102 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
104 * @see remote_device_t
106 oal_status_t device_set_alias(bt_address_t * addr, char * alias);
110 * @brief Initiate bonding with remote device
112 * @details Based on IO capabilties of 2 devices, different events can be generated
114 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
115 * @retval #OAL_STATUS_SUCCESS Successful
117 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
119 * @see OAL_EVENT_DEVICE_PIN_REQUEST
120 * @see OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
121 * @see OAL_EVENT_DEVICE_PASSKEY_CONFIRMATION_REQUEST
122 * @see OAL_EVENT_DEVICE_PASSKEY_DISPLAY
123 * @see OAL_EVENT_DEVICE_SSP_CONSENT_REQUEST
124 * @see OAL_EVENT_DEVICE_BONDING_SUCCESS
125 * @see OAL_EVENT_DEVICE_BONDING_FAILED
127 oal_status_t device_create_bond(bt_address_t * addr, connection_type_e transport);
130 * @brief Cancel already in-progress bonding procedure
132 * @details Based on current progress different events can be recieved.
134 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
135 * @retval #OAL_STATUS_SUCCESS Successful
137 * @pre Bonding must be in progress by calling device_create_bond()
139 * @see OAL_EVENT_DEVICE_BONDING_SUCCESS
140 * @see OAL_EVENT_DEVICE_BONDING_FAILED
141 * @see OAL_EVENT_DEVICE_BONDING_REMOVED
143 oal_status_t device_stop_bond(bt_address_t * addr);
146 * @brief Remove the already created Bond with remote device
148 * @details Based on current progress different events can be recieved.
150 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
151 * @retval #OAL_STATUS_SUCCESS Successful
153 * @pre Bond should exist
155 * @see OAL_EVENT_DEVICE_BONDING_REMOVED
157 oal_status_t device_destroy_bond(bt_address_t * addr);
160 * @brief Request services supported by remote device
162 * @details List of services in form UUIDs will be provided in event data
164 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
165 * @retval #OAL_STATUS_SUCCESS Successful
167 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
169 * @see OAL_EVENT_DEVICE_SERVICES
170 * @see event_dev_services_t
172 oal_status_t device_query_services(bt_address_t * addr);
175 * @brief Cancel already in-progress SDP procedure
177 * @details Based on current progress different events can be recieved.
179 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
180 * @retval #OAL_STATUS_SUCCESS Successful
182 * @pre SDP must be in progress by calling device_query_services()
185 oal_status_t device_stop_query_sevices(bt_address_t * addr);
188 * @brief Accept PIN request as part of Bonding procedure
190 * @details Positive response to OAL_EVENT_DEVICE_PIN_REQUEST
192 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
193 * @retval #OAL_STATUS_SUCCESS Successful
195 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
197 * @see OAL_EVENT_DEVICE_PIN_REQUEST
199 oal_status_t device_accept_pin_request(bt_address_t * addr, const char * pin);
202 * @brief Reject PIN request as part of Bonding procedure
204 * @details Negative response to OAL_EVENT_DEVICE_PIN_REQUEST
206 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
207 * @retval #OAL_STATUS_SUCCESS Successful
209 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
211 * @see OAL_EVENT_DEVICE_PIN_REQUEST
213 oal_status_t device_reject_pin_request(bt_address_t * addr);
216 * @brief Accept passkey entry request as part of Bonding procedure
218 * @details Positive response to OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
220 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
221 * @retval #OAL_STATUS_SUCCESS Successful
223 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
225 * @see OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
227 oal_status_t device_accept_passkey_entry(bt_address_t * addr, uint32_t passkey);
230 * @brief Reject passkey entry request as part of Bonding procedure
232 * @details Negative response to OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
234 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
235 * @retval #OAL_STATUS_SUCCESS Successful
237 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
239 * @see OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
241 oal_status_t device_reject_passkey_entry(bt_address_t * addr);
244 * @brief Reply passkey confirmation request as part of Bonding procedure
246 * @details Response to OAL_EVENT_DEVICE_PASSKEY_CONFIRMATION_REQUEST
248 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
249 * @retval #OAL_STATUS_SUCCESS Successful
251 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
253 * @see OAL_EVENT_DEVICE_PASSKEY_CONFIRMATION_REQUEST
255 oal_status_t device_reply_passkey_confirmation(bt_address_t * addr, int accept);
258 * @brief Reply SSP consent request as part of Bonding procedure
260 * @details Response to OAL_EVENT_DEVICE_SSP_CONSENT_REQUEST
262 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
263 * @retval #OAL_STATUS_SUCCESS Successful
265 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
267 * @see OAL_EVENT_DEVICE_SSP_CONSENT_REQUEST
269 oal_status_t device_reply_ssp_consent(bt_address_t * addr, int accept);
272 * @brief Accept or reject authorization request for a connection from remote device
274 * @details authorize = TRUE: all connections from this device will be auto accepted without any auth-event
275 * authorize = FALSE: all connections from this device will result in auth request event
277 * @param[in] always If TRUE, future connection requests will be automatically accepted.
279 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
280 * @retval #OAL_STATUS_SUCCESS Successful
282 * @pre OAL_EVENT_DEVICE_AUTHORIZE_REQUEST or, OAL_EVENT_SOCKET_AUTHORIZE_REQUEST should have
283 * been recieved by application.
285 * @see OAL_EVENT_DEVICE_AUTHORIZE_REQUEST
286 * @see OAL_EVENT_SOCKET_AUTHORIZE_REQUEST
288 oal_status_t device_reply_auth_request(bt_address_t * addr, oal_service_t service_type, int accept, int always);
291 * @brief Set a device as authorized or unauthorized
293 * @details authorize = TRUE: all connections from this device will be auto accepted without any auth-event
294 * authorize = FALSE: all connections from this device will result in auth request event
296 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
297 * @retval #OAL_STATUS_SUCCESS Successful
299 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
301 * @see OAL_EVENT_DEVICE_AUTHORIZE_REQUEST
303 oal_status_t device_set_authorized(bt_address_t * addr, int authorize);
306 * @brief Get ACL connection state for remote device
308 * @details This API is to check whether ACL connection is established with the remote device
310 * @param[in] addr: Remote device address.
312 * @return TRUE if ACL connection is established with the remote device and FALSE otherwise.
314 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
316 gboolean device_get_acl_conn_state(bt_address_t * addr);
319 * @brief Get PROFILE connection state for remote device
321 * @details This API is to check whether requested profile connection is established with the remote device
323 * @param[in] addr: Remote device address.
324 * @param[in] svc_id: Profile Id to be checked for connection status.
326 * @return TRUE if ACL connection is established with the remote device and FALSE otherwise.
328 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
330 gboolean device_get_svc_conn_state(bt_address_t * addr, oal_service_t svc_id);
333 * @brief Set OSP server status in GAP agent
335 * @details This API is to enable/disable OSP server in GAP agent. if OSP server is enabled,
336 * connection authorization events are sent to application otherwise handled internally in HAL.
338 * @param[in] tpye : OSP Server type
339 * @param[in] enable: 0 -> enable server, 1 -> Disable server
341 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
343 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
345 oal_status_t device_set_osp_server(oal_osp_server_type_e type, int enable);
348 * @brief Set profile trust info for remote device
350 * @details This API is used to set profile as trusted/blocked for remote device
352 * @param[in] addr: Remote device address.
353 * @param[in] profile: Trusted profile enum
354 * @param[in] trust: TRUE == Trusted, FALSE == Blocked
356 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
357 * @retval #OAL_STATUS_SUCCESS Successful
359 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
361 oal_status_t device_set_trust_profile(bt_address_t *addr, oal_trusted_profile_e profile, gboolean trust);
364 * @brief Set profile trust info for remote device
366 * @details This API is used to set profile as trusted/blocked for remote device
368 * @param[in] addr: Remote device address.
369 * @param[in] profile: Trusted profile enum
370 * @param[out] trusted: 0 == Blocked, non-zero: Trusted values
372 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
373 * @retval #OAL_STATUS_SUCCESS Successful
375 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
377 oal_status_t device_get_trust_profile(bt_address_t *addr, oal_trusted_profile_e profile, unsigned int *trusted);
380 * @brief Get RSSI strength of remote device
382 * @details This API is used to get RSSI strength of remote device for conncted link type
384 * @param[in] addr: Remote device address.
385 * @param[in] link_type: conncted link type (0 = BR/EDR link, 1 = LE link, 0xFF = Any (Default))
387 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
388 * @retval #OAL_STATUS_SUCCESS Successful
390 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
392 oal_status_t device_get_connected_link_rssi_strength(bt_address_t *addr, unsigned int link_type);
395 * @brief Enable remote device RSSI monitoring
397 * @details This API is used to enable remote device RSSI monitoring
399 * @param[in] addr: Remote device address.
400 * @param[in] link_type: conncted link type (0 = BR/EDR link, 1 = LE link, 0xFF = Any (Default))
401 * @param[in] low_threshold: Lower limit for RSSI value
402 * @param[in] in_range_threshold: in range RSSI values
403 * @param[in] high_threshold: Upper limit for RSSI value
405 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
406 * @retval #OAL_STATUS_SUCCESS Successful
408 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
410 oal_status_t device_enable_rssi_monitoring(bt_address_t *addr, unsigned int link_type,
411 int low_threshold, int in_range_threshold, int high_threshold);
414 * @brief Enable/Disable GAP authentication requests to be received from stack
416 * @details This API is used to enable/disable GAP authentication requests to be received from stack
418 * @param[in] type: GAP authentication types oal_gap_auth_type_e
419 * @param[in] enable: TRUE/FALSE
421 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
422 * @retval #OAL_STATUS_SUCCESS Successful
424 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
426 oal_status_t device_enable_gap_auth_notifications(oal_gap_auth_type_e type, gboolean enable);
430 #endif /* __cplusplus */
431 #endif /*_OAL_DEVICE_MGR_H_*/