Tizen Native API
5.5
|
Bluetooth Device API provides functions for managing bonds with other devices and searching for supported services.
#include <bluetooth.h>
This set of functions is used to handle the connection with other devices. Connected devices exchange keys needed for encrypted communication, but each connection has to be approved by the latest application user. You can also set authorization of other devices. Authorized devices are connected, and it is connected automatically without the latest user being asked for authorization. In addition, this is used to search for services available on remote devices.
This API is related with the following features:
It is recommended to design feature related codes in your application for reliability.
You can check if a device supports the related features for this API by using System Information,thereby controlling the procedure of your application.
To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
More details on featuring your application can be found from Feature Element.
FUNCTION | CALLBACK | DESCRIPTION |
---|---|---|
bt_device_create_bond() bt_device_cancel_bonding() | bt_device_bond_created_cb() | Used to create bond or cancel creating bond. |
bt_device_destroy_bond() | bt_device_bond_destroyed_cb() | Used to destroy bond. |
bt_device_set_authorization() | bt_device_authorization_changed_cb() | Used to set as authorized or unauthorized device. |
bt_device_start_service_search() | bt_device_service_searched_cb() | Used to start or cancel service search. |
REGISTER | UNREGISTER | CALLBACK | DESCRIPTION |
---|---|---|---|
bt_device_set_bond_created_cb() | bt_device_unset_bond_created_cb() | bt_device_bond_created_cb() | Used to be notified of the result of creating bond. |
bt_device_set_bond_destroyed_cb() | bt_device_unset_bond_destroyed_cb() | bt_device_bond_destroyed_cb() | Used to be notified of the result of destroying bond. |
bt_device_set_authorization_changed_cb() | bt_device_unset_authorization_changed_cb() | bt_device_authorization_changed_cb() | Used to be notified of change of authorization. |
bt_device_set_service_searched_cb() | bt_device_unset_service_searched_cb() | bt_device_service_searched_cb() | Used to be notified of change of service search state. |
Please refer Bluetooth Tutorial if you want to get more detailed usages and information of this api.
Functions | |
int | bt_device_get_service_mask_from_uuid_list (char **uuids, int no_of_service, bt_service_class_t *service_mask_list) |
Gets the service mask from the UUID list. | |
int | bt_device_create_bond (const char *remote_address) |
Creates a bond with a remote Bluetooth device, asynchronously. | |
int | bt_device_cancel_bonding (void) |
Cancels the bonding process. | |
int | bt_device_destroy_bond (const char *remote_address) |
Destroys the bond, asynchronously. | |
int | bt_device_set_alias (const char *remote_address, const char *alias) |
Sets an alias for the bonded device. | |
int | bt_device_set_authorization (const char *remote_address, bt_device_authorization_e authorization_state) |
Sets the authorization of a bonded device, asynchronously. | |
int | bt_device_start_service_search (const char *remote_address) |
Starts the search for services supported by the specified device, asynchronously. | |
int | bt_device_foreach_connected_profiles (const char *remote_address, bt_device_connected_profile callback, void *user_data) |
Gets the connected profiles. | |
int | bt_device_is_profile_connected (const char *remote_address, bt_profile_e bt_profile, bool *connected_status) |
Gets the profile connected status. | |
int | bt_device_update_le_connection_mode (const char *remote_address, bt_device_le_connection_mode_e mode) |
Updates a LE connection mode. | |
int | bt_device_set_bond_created_cb (bt_device_bond_created_cb callback, void *user_data) |
Registers a callback function to be invoked when the bond creates. | |
int | bt_device_unset_bond_created_cb (void) |
Unregisters the callback function. | |
int | bt_device_set_bond_destroyed_cb (bt_device_bond_destroyed_cb callback, void *user_data) |
Registers a callback function to be invoked when the bond destroys. | |
int | bt_device_unset_bond_destroyed_cb (void) |
Unregisters the callback function. | |
int | bt_device_set_authorization_changed_cb (bt_device_authorization_changed_cb callback, void *user_data) |
Registers a callback function to be invoked when the authorization of device changes. | |
int | bt_device_unset_authorization_changed_cb (void) |
Unregisters the callback function. | |
int | bt_device_set_service_searched_cb (bt_device_service_searched_cb callback, void *user_data) |
Registers a callback function to be invoked when the process of service search finishes. | |
int | bt_device_unset_service_searched_cb (void) |
Unregisters the callback function. | |
int | bt_device_set_connection_state_changed_cb (bt_device_connection_state_changed_cb callback, void *user_data) |
Registers a callback function to be invoked when the connection state is changed. | |
int | bt_device_unset_connection_state_changed_cb (void) |
Unregisters the callback function to be invoked when the connection state is changed. | |
Typedefs | |
typedef void(* | bt_device_bond_created_cb )(int result, bt_device_info_s *device_info, void *user_data) |
Called when the process of creating bond finishes. | |
typedef bool(* | bt_device_connected_profile )(bt_profile_e profile, void *user_data) |
Called when you get connected profiles repeatedly. | |
typedef void(* | bt_device_bond_destroyed_cb )(int result, char *remote_address, void *user_data) |
Called when the bond destroys. | |
typedef void(* | bt_device_authorization_changed_cb )(bt_device_authorization_e authorization, char *remote_address, void *user_data) |
Called when the authorization of device changes. | |
typedef void(* | bt_device_service_searched_cb )(int result, bt_device_sdp_info_s *sdp_info, void *user_data) |
Called when the process of service search finishes. | |
typedef void(* | bt_device_connection_state_changed_cb )(bool connected, bt_device_connection_info_s *conn_info, void *user_data) |
Called when the connection state is changed. |
typedef void(* bt_device_authorization_changed_cb)(bt_device_authorization_e authorization, char *remote_address, void *user_data) |
Called when the authorization of device changes.
[in] | authorization | The authorization of device |
[in] | remote_address | The address of the remote Bluetooth device which is (un)authorized |
[in] | user_data | The user data passed from the callback registration function |
typedef void(* bt_device_bond_created_cb)(int result, bt_device_info_s *device_info, void *user_data) |
Called when the process of creating bond finishes.
[in] | result | The result of the bonding device |
[in] | device_info | The device information which you creates bond with |
[in] | user_data | The user data passed from the callback registration function |
typedef void(* bt_device_bond_destroyed_cb)(int result, char *remote_address, void *user_data) |
Called when the bond destroys.
[in] | result | The result that a bond is destroyed |
[in] | remote_address | The address of the remote Bluetooth device to destroy bond with |
[in] | user_data | The user data passed from the callback registration function |
typedef bool(* bt_device_connected_profile)(bt_profile_e profile, void *user_data) |
Called when you get connected profiles repeatedly.
[in] | profile | The connected Bluetooth profile |
[in] | user_data | The user data passed from the foreach function |
true
to continue with the next iteration of the loop, false
to break out of the loop. typedef void(* bt_device_connection_state_changed_cb)(bool connected, bt_device_connection_info_s *conn_info, void *user_data) |
Called when the connection state is changed.
[in] | connected | The connection status: (true = connected, false = disconnected) |
[in] | conn_info | The connection information |
[in] | user_data | The user data passed from the callback registration function |
typedef void(* bt_device_service_searched_cb)(int result, bt_device_sdp_info_s *sdp_info, void *user_data) |
Called when the process of service search finishes.
[in] | result | The result of the service searching |
[in] | sdp_info | The structure of service lists found on a device |
[in] | user_data | The user data passed from the callback registration function |
enum bt_appearance_type_e |
Enumerations of gap appearance type.
Enumerations of device disconnect reason.
Enumerations of the Bluetooth device's LE connection mode.
Enumerations of major device class.
Enumerations of major service class.
Enumerations of minor device class.
enum bt_profile_e |
Enumerations of Bluetooth profile.
enum bt_service_class_t |
Enumerations of service class.
int bt_device_cancel_bonding | ( | void | ) |
Cancels the bonding process.
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_NOT_ENABLED | Not enabled |
BT_ERROR_NOT_IN_PROGRESS | Operation not in progress |
BT_ERROR_PERMISSION_DENIED | Permission denied |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_create_bond | ( | const char * | remote_address | ) |
Creates a bond with a remote Bluetooth device, asynchronously.
[in] | remote_address | The address of the remote Bluetooth device with which the bond should be created |
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_INVALID_PARAMETER | Invalid parameter |
BT_ERROR_NOT_ENABLED | Not enabled |
BT_ERROR_RESOURCE_BUSY | Device or resource busy |
BT_ERROR_OPERATION_FAILED | Operation failed |
BT_ERROR_PERMISSION_DENIED | Permission denied |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_destroy_bond | ( | const char * | remote_address | ) |
Destroys the bond, asynchronously.
[in] | remote_address | The address of the remote Bluetooth device to remove bonding |
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_INVALID_PARAMETER | Invalid parameter |
BT_ERROR_NOT_ENABLED | Not enabled |
BT_ERROR_RESOURCE_BUSY | Device or resource busy |
BT_ERROR_REMOTE_DEVICE_NOT_BONDED | Remote device not bonded |
BT_ERROR_OPERATION_FAILED | Operation failed |
BT_ERROR_PERMISSION_DENIED | Permission denied |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_foreach_connected_profiles | ( | const char * | remote_address, |
bt_device_connected_profile | callback, | ||
void * | user_data | ||
) |
Gets the connected profiles.
[in] | remote_address | The address of the remote device |
[in] | callback | The callback function to invoke |
[in] | user_data | The user data to be passed to the callback function |
BT_ERROR_NONE | Successful |
BT_ERROR_INVALID_PARAMETER | Invalid parameter |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_NOT_ENABLED | Not enabled |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_get_service_mask_from_uuid_list | ( | char ** | uuids, |
int | no_of_service, | ||
bt_service_class_t * | service_mask_list | ||
) |
Gets the service mask from the UUID list.
[in] | uuids | The UUID list of the device. |
[in] | no_of_service | The number of the UUID list count. |
[out] | service_mask_list | Service mask list converted from the given UUID list. |
BT_ERROR_NONE | Successful |
BT_ERROR_INVALID_PARAMETER | Invalid parameter |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_is_profile_connected | ( | const char * | remote_address, |
bt_profile_e | bt_profile, | ||
bool * | connected_status | ||
) |
Gets the profile connected status.
[in] | remote_address | The address of the remote device |
[in] | bt_profile | wish to know bt_profile |
[out] | connected_status | the connected status |
BT_ERROR_NONE | Successful |
BT_ERROR_INVALID_PARAMETER | Invalid parameter |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_NOT_ENABLED | Not enabled |
BT_ERROR_REMOTE_DEVICE_NOT_BONDED | Remote device not bonded |
BT_ERROR_OPERATION_FAILED | Operation failed |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_set_alias | ( | const char * | remote_address, |
const char * | alias | ||
) |
Sets an alias for the bonded device.
[in] | remote_address | The address of the remote Bluetooth device |
[in] | alias | The alias of the remote Bluetooth device |
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_INVALID_PARAMETER | Invalid parameter |
BT_ERROR_NOT_ENABLED | Not enabled |
BT_ERROR_REMOTE_DEVICE_NOT_BONDED | Remote device not bonded |
BT_ERROR_OPERATION_FAILED | Operation failed |
BT_ERROR_PERMISSION_DENIED | Permission denied |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_set_authorization | ( | const char * | remote_address, |
bt_device_authorization_e | authorization_state | ||
) |
Sets the authorization of a bonded device, asynchronously.
[in] | remote_address | The address of the remote Bluetooth device to authorize |
[in] | authorization_state | The Bluetooth authorization state |
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_INVALID_PARAMETER | Invalid parameter |
BT_ERROR_NOT_ENABLED | Not enabled |
BT_ERROR_REMOTE_DEVICE_NOT_BONDED | Remote device not bonded |
BT_ERROR_OPERATION_FAILED | Operation failed |
BT_ERROR_PERMISSION_DENIED | Permission denied |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_set_authorization_changed_cb | ( | bt_device_authorization_changed_cb | callback, |
void * | user_data | ||
) |
Registers a callback function to be invoked when the authorization of device changes.
[in] | callback | The callback function to register |
[in] | user_data | The user data to be passed to the callback function |
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_INVALID_PARAMETER | Invalid parameter |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_set_bond_created_cb | ( | bt_device_bond_created_cb | callback, |
void * | user_data | ||
) |
Registers a callback function to be invoked when the bond creates.
[in] | callback | The callback function to register |
[in] | user_data | The user data to be passed to the callback function |
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_INVALID_PARAMETER | Invalid parameter |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_set_bond_destroyed_cb | ( | bt_device_bond_destroyed_cb | callback, |
void * | user_data | ||
) |
Registers a callback function to be invoked when the bond destroys.
[in] | callback | The callback function to register |
[in] | user_data | The user data to be passed to the callback function |
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_INVALID_PARAMETER | Invalid parameter |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_set_connection_state_changed_cb | ( | bt_device_connection_state_changed_cb | callback, |
void * | user_data | ||
) |
Registers a callback function to be invoked when the connection state is changed.
[in] | callback | The callback function to register |
[in] | user_data | The user data to be passed to the callback function |
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_INVALID_PARAMETER | Invalid parameter |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_set_service_searched_cb | ( | bt_device_service_searched_cb | callback, |
void * | user_data | ||
) |
Registers a callback function to be invoked when the process of service search finishes.
[in] | callback | The callback function to register |
[in] | user_data | The user data to be passed to the callback function |
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_INVALID_PARAMETER | Invalid parameter |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_start_service_search | ( | const char * | remote_address | ) |
Starts the search for services supported by the specified device, asynchronously.
[in] | remote_address | The address of the remote Bluetooth device whose services need to be checked |
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_INVALID_PARAMETER | Invalid parameter |
BT_ERROR_NOT_ENABLED | Not enabled |
BT_ERROR_REMOTE_DEVICE_NOT_BONDED | Remote device not bonded |
BT_ERROR_SERVICE_SEARCH_FAILED | Service search failed |
BT_ERROR_PERMISSION_DENIED | Permission denied |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_unset_authorization_changed_cb | ( | void | ) |
Unregisters the callback function.
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_unset_bond_created_cb | ( | void | ) |
Unregisters the callback function.
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_unset_bond_destroyed_cb | ( | void | ) |
Unregisters the callback function.
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_unset_connection_state_changed_cb | ( | void | ) |
Unregisters the callback function to be invoked when the connection state is changed.
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_unset_service_searched_cb | ( | void | ) |
Unregisters the callback function.
BT_ERROR_NONE | Successful |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_NOT_SUPPORTED | Not supported |
int bt_device_update_le_connection_mode | ( | const char * | remote_address, |
bt_device_le_connection_mode_e | mode | ||
) |
Updates a LE connection mode.
[in] | remote_address | The address of the remote Bluetooth device |
[in] | mode | The LE connection mode |
BT_ERROR_NONE | Successful |
BT_ERROR_INVALID_PARAMETER | Invalid parameter |
BT_ERROR_NOT_INITIALIZED | Not initialized |
BT_ERROR_NOT_ENABLED | Not enabled |
BT_ERROR_OPERATION_FAILED | Operation failed |
BT_ERROR_PERMISSION_DENIED | Permission denied |
BT_ERROR_NOT_SUPPORTED | Not supported |