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 OAL_CONN_TYPE_DEFAULT = 0xFF, /* represents that connection type can both BR/EDR and LE */
40 OAL_CONN_TYPE_BREDR = 0x00,
41 OAL_CONN_TYPE_LE = 0x01,
45 * @brief OSP server type
47 * @see device_set_osp_server()
48 * @see device_register_osp_server()
51 OAL_OSP_SERVER_OBEX = 0x00,
53 } oal_osp_server_type_e;
56 * @brief Trusted profile types
58 * @see device_set_trust_profile/device_get_trust_profile
61 OAL_TRUSTED_PROFILE_PBAP = 1,
62 OAL_TRUSTED_PROFILE_MAP,
63 OAL_TRUSTED_PROFILE_SAP,
64 OAL_TRUSTED_PROFILE_HFP_HF,
65 OAL_TRUSTED_PROFILE_A2DP,
66 OAL_TRUSTED_PROFILE_ALL = 0xFFFFFFFF,
67 } oal_trusted_profile_e;
70 * @brief GAP authentication types
72 * @see device_enable_gap_auth_notifications
75 OAL_PASSKEY_CONFIRMATION = 1,
79 } oal_gap_auth_type_e;
82 * @brief Request remote device attributes
84 * @details Attibutes such as name, vidpid, bond state etc are requested. remote_device_t is provided
85 * with OAL_EVENT_DEVICE_PROPERTIES
87 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
88 * @retval #OAL_STATUS_SUCCESS Successful
90 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
92 * @see OAL_EVENT_DEVICE_PROPERTIES
93 * @see remote_device_t
95 oal_status_t device_query_attributes(bt_address_t * addr);
98 * @brief Set alias for remote device
100 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
101 * @retval #OAL_STATUS_SUCCESS Successful
103 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
105 * @see remote_device_t
107 oal_status_t device_set_alias(bt_address_t * addr, char * alias);
111 * @brief Initiate bonding with remote device
113 * @details Based on IO capabilties of 2 devices, different events can be generated
115 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
116 * @retval #OAL_STATUS_SUCCESS Successful
118 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
120 * @see OAL_EVENT_DEVICE_PIN_REQUEST
121 * @see OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
122 * @see OAL_EVENT_DEVICE_PASSKEY_CONFIRMATION_REQUEST
123 * @see OAL_EVENT_DEVICE_PASSKEY_DISPLAY
124 * @see OAL_EVENT_DEVICE_SSP_CONSENT_REQUEST
125 * @see OAL_EVENT_DEVICE_BONDING_SUCCESS
126 * @see OAL_EVENT_DEVICE_BONDING_FAILED
128 oal_status_t device_create_bond(bt_address_t * addr, oal_conn_type_e transport);
131 * @brief Cancel already in-progress bonding procedure
133 * @details Based on current progress different events can be recieved.
135 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
136 * @retval #OAL_STATUS_SUCCESS Successful
138 * @pre Bonding must be in progress by calling device_create_bond()
140 * @see OAL_EVENT_DEVICE_BONDING_SUCCESS
141 * @see OAL_EVENT_DEVICE_BONDING_FAILED
142 * @see OAL_EVENT_DEVICE_BONDING_REMOVED
144 oal_status_t device_stop_bond(bt_address_t * addr);
147 * @brief Remove the already created Bond with remote device
149 * @details Based on current progress different events can be recieved.
151 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
152 * @retval #OAL_STATUS_SUCCESS Successful
154 * @pre Bond should exist
156 * @see OAL_EVENT_DEVICE_BONDING_REMOVED
158 oal_status_t device_destroy_bond(bt_address_t * addr);
161 * @brief Request services supported by remote device
163 * @details List of services in form UUIDs will be provided in event data
165 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
166 * @retval #OAL_STATUS_SUCCESS Successful
168 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
170 * @see OAL_EVENT_DEVICE_SERVICES
171 * @see event_dev_services_t
173 oal_status_t device_query_services(bt_address_t * addr);
176 * @brief Cancel already in-progress SDP procedure
178 * @details Based on current progress different events can be recieved.
180 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
181 * @retval #OAL_STATUS_SUCCESS Successful
183 * @pre SDP must be in progress by calling device_query_services()
186 oal_status_t device_stop_query_sevices(bt_address_t * addr);
189 * @brief Accept PIN request as part of Bonding procedure
191 * @details Positive response to OAL_EVENT_DEVICE_PIN_REQUEST
193 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
194 * @retval #OAL_STATUS_SUCCESS Successful
196 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
198 * @see OAL_EVENT_DEVICE_PIN_REQUEST
200 oal_status_t device_accept_pin_request(bt_address_t * addr, const char * pin);
203 * @brief Reject PIN request as part of Bonding procedure
205 * @details Negative response to OAL_EVENT_DEVICE_PIN_REQUEST
207 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
208 * @retval #OAL_STATUS_SUCCESS Successful
210 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
212 * @see OAL_EVENT_DEVICE_PIN_REQUEST
214 oal_status_t device_reject_pin_request(bt_address_t * addr);
217 * @brief Accept passkey entry request as part of Bonding procedure
219 * @details Positive response to OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
221 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
222 * @retval #OAL_STATUS_SUCCESS Successful
224 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
226 * @see OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
228 oal_status_t device_accept_passkey_entry(bt_address_t * addr, uint32_t passkey);
231 * @brief Reject passkey entry request as part of Bonding procedure
233 * @details Negative response to OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
235 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
236 * @retval #OAL_STATUS_SUCCESS Successful
238 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
240 * @see OAL_EVENT_DEVICE_PASSKEY_ENTRY_REQUEST
242 oal_status_t device_reject_passkey_entry(bt_address_t * addr);
245 * @brief Reply passkey confirmation request as part of Bonding procedure
247 * @details Response to OAL_EVENT_DEVICE_PASSKEY_CONFIRMATION_REQUEST
249 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
250 * @retval #OAL_STATUS_SUCCESS Successful
252 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
254 * @see OAL_EVENT_DEVICE_PASSKEY_CONFIRMATION_REQUEST
256 oal_status_t device_reply_passkey_confirmation(bt_address_t * addr, int accept);
259 * @brief Reply SSP consent request as part of Bonding procedure
261 * @details Response to OAL_EVENT_DEVICE_SSP_CONSENT_REQUEST
263 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
264 * @retval #OAL_STATUS_SUCCESS Successful
266 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
268 * @see OAL_EVENT_DEVICE_SSP_CONSENT_REQUEST
270 oal_status_t device_reply_ssp_consent(bt_address_t * addr, int accept);
273 * @brief Accept or reject authorization request for a connection from remote device
275 * @details authorize = TRUE: all connections from this device will be auto accepted without any auth-event
276 * authorize = FALSE: all connections from this device will result in auth request event
278 * @param[in] always If TRUE, future connection requests will be automatically accepted.
280 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
281 * @retval #OAL_STATUS_SUCCESS Successful
283 * @pre OAL_EVENT_DEVICE_AUTHORIZE_REQUEST or, OAL_EVENT_SOCKET_AUTHORIZE_REQUEST should have
284 * been recieved by application.
286 * @see OAL_EVENT_DEVICE_AUTHORIZE_REQUEST
287 * @see OAL_EVENT_SOCKET_AUTHORIZE_REQUEST
289 oal_status_t device_reply_auth_request(bt_address_t * addr, oal_service_t service_type, int accept, int always);
292 * @brief Set a device as authorized or unauthorized
294 * @details authorize = TRUE: all connections from this device will be auto accepted without any auth-event
295 * authorize = FALSE: all connections from this device will result in auth request event
297 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
298 * @retval #OAL_STATUS_SUCCESS Successful
300 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
302 * @see OAL_EVENT_DEVICE_AUTHORIZE_REQUEST
304 oal_status_t device_set_authorized(bt_address_t * addr, int authorize);
307 * @brief Get ACL connection state for remote device
309 * @details This API is to check whether ACL connection is established with the remote device
311 * @param[in] addr: Remote device address.
313 * @return TRUE if ACL connection is established with the remote device and FALSE otherwise.
315 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
317 gboolean device_get_acl_conn_state(bt_address_t * addr);
320 * @brief Get PROFILE connection state for remote device
322 * @details This API is to check whether requested profile connection is established with the remote device
324 * @param[in] addr: Remote device address.
325 * @param[in] svc_id: Profile Id to be checked for connection status.
327 * @return TRUE if ACL connection is established with the remote device and FALSE otherwise.
329 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
331 gboolean device_get_svc_conn_state(bt_address_t * addr, oal_service_t svc_id);
334 * @brief Register OSP server in GAP agent
336 * @details This API is to register OSP server in GAP agent. if OSP server is enabled,
337 * connection authorization events are sent to application otherwise handled internally in HAL.
339 * @param[in] type: OSP Server type
340 * @param[in] uuid: UUID
341 * @param[in] path: Dbus path
342 * @param[in] fd: Socket fd
344 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
346 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
348 oal_status_t device_register_osp_server(oal_osp_server_type_e type, char *uuid, char *path, int fd);
351 * @brief Unregister OSP server in GAP agent
353 * @details This API is to unregister OSP server in GAP agent. if OSP server is enabled,
354 * connection authorization events are sent to application otherwise handled internally in HAL.
356 * @param[in] type: OSP Server type
357 * @param[in] uuid: UUID
359 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
361 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
363 oal_status_t device_unregister_osp_server(oal_osp_server_type_e type, char *uuid);
366 * @brief Set profile trust info for remote device
368 * @details This API is used to set profile as trusted/blocked for remote device
370 * @param[in] addr: Remote device address.
371 * @param[in] profile: Trusted profile enum
372 * @param[in] trust: TRUE == Trusted, FALSE == Blocked
374 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
375 * @retval #OAL_STATUS_SUCCESS Successful
377 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
379 oal_status_t device_set_trust_profile(bt_address_t *addr, oal_trusted_profile_e profile, gboolean trust);
382 * @brief Set profile trust info for remote device
384 * @details This API is used to set profile as trusted/blocked for remote device
386 * @param[in] addr: Remote device address.
387 * @param[in] profile: Trusted profile enum
388 * @param[out] trusted: 0 == Blocked, non-zero: Trusted values
390 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
391 * @retval #OAL_STATUS_SUCCESS Successful
393 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
395 oal_status_t device_get_trust_profile(bt_address_t *addr, oal_trusted_profile_e profile, unsigned int *trusted);
398 * @brief Get RSSI strength of remote device
400 * @details This API is used to get RSSI strength of remote device for conncted link type
402 * @param[in] addr: Remote device address.
403 * @param[in] link_type: conncted link type (0 = BR/EDR link, 1 = LE link, 0xFF = Any (Default))
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_get_connected_link_rssi_strength(bt_address_t *addr, unsigned int link_type);
413 * @brief Enable remote device RSSI monitoring
415 * @details This API is used to enable remote device RSSI monitoring
417 * @param[in] addr: Remote device address.
418 * @param[in] link_type: conncted link type (0 = BR/EDR link, 1 = LE link, 0xFF = Any (Default))
419 * @param[in] low_threshold: Lower limit for RSSI value
420 * @param[in] in_range_threshold: in range RSSI values
421 * @param[in] high_threshold: Upper limit for RSSI value
423 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
424 * @retval #OAL_STATUS_SUCCESS Successful
426 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
428 oal_status_t device_enable_rssi_monitoring(bt_address_t *addr, unsigned int link_type,
429 int low_threshold, int in_range_threshold, int high_threshold);
432 * @brief Enable/Disable GAP authentication requests to be received from stack
434 * @details This API is used to enable/disable GAP authentication requests to be received from stack
436 * @param[in] type: GAP authentication types oal_gap_auth_type_e
437 * @param[in] enable: TRUE/FALSE
439 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
440 * @retval #OAL_STATUS_SUCCESS Successful
442 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
444 oal_status_t device_enable_gap_auth_notifications(oal_gap_auth_type_e type, gboolean enable);
447 * @brief Disconnect the device
449 * @details This API is used to ACL disconnect the device
451 * @param[in] addr: Remote device address.
453 * @return TRUE if adapter has accepted the ACL Disconnect request FALSE otherwise.
455 * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
457 oal_status_t device_disconnect(bt_address_t * addr);
461 #endif /* __cplusplus */
462 #endif /*_OAL_DEVICE_MGR_H_*/