diff options
author | jk7744.park <jk7744.park@samsung.com> | 2015-10-24 16:22:12 +0900 |
---|---|---|
committer | jk7744.park <jk7744.park@samsung.com> | 2015-10-24 16:22:12 +0900 |
commit | 88ce95fe92123a34fdd7e9fb8f2d467bf7124fd1 (patch) | |
tree | c1e62530d479dbcd1b08a39414f235aaf1c67c56 | |
parent | 990ea211013af6cfc2353b9e324ed84741f59981 (diff) | |
download | bluetooth-accepted/tizen/2.4/mobile/20151029.034930.tar.gz bluetooth-accepted/tizen/2.4/mobile/20151029.034930.tar.bz2 bluetooth-accepted/tizen/2.4/mobile/20151029.034930.zip |
tizen 2.4 releasetizen_2.4_mobile_releasesubmit/tizen_2.4/20151028.063515accepted/tizen/2.4/mobile/20151029.034930
66 files changed, 26762 insertions, 3644 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 98e31fb..fc0cd19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,18 +7,26 @@ SET(CMAKE_INSTALL_PREFIX /usr) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(INC_DIR include) -INCLUDE_DIRECTORIES(${INC_DIR}) -IF (TIZEN_WEARABLE) - INCLUDE_DIRECTORIES(${INC_DIR}/wearable) +IF (TIZEN_TV) + INCLUDE_DIRECTORIES(${INC_DIR}/tv) ELSE () - INCLUDE_DIRECTORIES(${INC_DIR}/mobile) -ENDIF (TIZEN_WEARABLE) - -IF (TIZEN_WEARABLE) -SET(dependents "dlog glib-2.0 capi-base-common bluetooth-api privacy-manager-client") + INCLUDE_DIRECTORIES(${INC_DIR}) + IF (TIZEN_WEARABLE) + INCLUDE_DIRECTORIES(${INC_DIR}/wearable) + ELSE () + INCLUDE_DIRECTORIES(${INC_DIR}/mobile) + ENDIF (TIZEN_WEARABLE) +ENDIF (TIZEN_TV) + +IF (TIZEN_TV) +SET(dependents "dlog glib-2.0 capi-base-common bluetooth-tv-api db-util") ELSE () -SET(dependents "dlog glib-2.0 capi-base-common bluetooth-api") -ENDIF (TIZEN_WEARABLE) + IF (TIZEN_WEARABLE) + SET(dependents "dlog glib-2.0 capi-base-common bluetooth-api privacy-manager-client") + ELSE () + SET(dependents "dlog glib-2.0 capi-base-common bluetooth-api") + ENDIF (TIZEN_WEARABLE) +ENDIF (TIZEN_TV) SET(pc_dependents "capi-base-common glib-2.0") INCLUDE(FindPkgConfig) @@ -39,6 +47,24 @@ ADD_DEFINITIONS("-DTIZEN_DEBUG") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib") +IF (TIZEN_TV) +SET(SOURCES +tv_src/bluetooth-common.c +tv_src/bluetooth-adapter.c +tv_src/bluetooth-device.c +tv_src/bluetooth-socket.c +tv_src/bluetooth-opp-server.c +tv_src/bluetooth-opp-client.c +tv_src/bluetooth-pan.c +tv_src/bluetooth-hdp.c +tv_src/bluetooth-hid.c +tv_src/bluetooth-audio.c +tv_src/bluetooth-avrcp.c +tv_src/bluetooth-gatt.c +tv_src/bluetooth-dut.c +tv_src/bluetooth-sync3d.c +) +ELSE () SET(SOURCES src/bluetooth-common.c src/bluetooth-adapter.c @@ -52,10 +78,12 @@ src/bluetooth-hid.c src/bluetooth-audio.c src/bluetooth-avrcp.c src/bluetooth-gatt.c +src/bluetooth-ipsp.c ) IF (TIZEN_WEARABLE) LIST(APPEND SOURCES src/bluetooth-pbap.c) ENDIF (TIZEN_WEARABLE) +ENDIF (TIZEN_TV) ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) @@ -69,25 +97,35 @@ SET_TARGET_PROPERTIES(${fw_name} ) INSTALL(TARGETS ${fw_name} DESTINATION lib) + INSTALL( DIRECTORY ${INC_DIR}/ DESTINATION include/network FILES_MATCHING PATTERN "*_private.h" EXCLUDE PATTERN "${INC_DIR}/*.h" ) -IF (TIZEN_WEARABLE) +IF (TIZEN_TV) INSTALL( - DIRECTORY ${INC_DIR}/wearable/ DESTINATION include/network + DIRECTORY ${INC_DIR}/tv/ DESTINATION include/network FILES_MATCHING - PATTERN "${INC_DIR}/wearable/*.h" + PATTERN "${INC_DIR}/tv/*.h" ) + ELSE () -INSTALL( - DIRECTORY ${INC_DIR}/mobile/ DESTINATION include/network - FILES_MATCHING - PATTERN "${INC_DIR}/mobile/*.h" - ) -ENDIF (TIZEN_WEARABLE) + IF (TIZEN_WEARABLE) + INSTALL( + DIRECTORY ${INC_DIR}/wearable/ DESTINATION include/network + FILES_MATCHING + PATTERN "${INC_DIR}/wearable/*.h" + ) + ELSE () + INSTALL( + DIRECTORY ${INC_DIR}/mobile/ DESTINATION include/network + FILES_MATCHING + PATTERN "${INC_DIR}/mobile/*.h" + ) + ENDIF (TIZEN_WEARABLE) +ENDIF (TIZEN_TV) SET(PC_NAME ${fw_name}) SET(PC_REQUIRED ${pc_dependents}) @@ -100,7 +138,10 @@ CONFIGURE_FILE( ) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig) +IF (TIZEN_TV) +ELSE () ADD_SUBDIRECTORY(test) +ENDIF (TIZEN_TV) IF(UNIX) diff --git a/doc/bluetooth_doc.h b/doc/bluetooth_doc.h index 6f318c0..a2229b4 100644 --- a/doc/bluetooth_doc.h +++ b/doc/bluetooth_doc.h @@ -44,7 +44,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ @@ -75,7 +75,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * * @section CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE_ASYNCHRONOUS_OPERATIONS Asynchronous Operations * <div><table class="doxtable" > @@ -175,7 +175,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ @@ -206,7 +206,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * * @section CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE_ASYNCHRONOUS_OPERATIONS Asynchronous Operations * <div><table class="doxtable" > @@ -318,7 +318,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * * @section CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE_ASYNCHRONOUS_OPERATIONS Asynchronous Operations * <div><table class="doxtable" > @@ -396,7 +396,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ @@ -421,7 +421,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ @@ -445,7 +445,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ @@ -471,7 +471,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ @@ -497,7 +497,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ @@ -524,7 +524,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ @@ -550,7 +550,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ @@ -578,7 +578,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ @@ -606,12 +606,11 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ /** - * @internal * @defgroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE Bluetooth AVRCP * @brief Bluetooth AVRCP(Audio/Video Remote Control Profile) API provides functions for notifying the change of target device to the control device. * @ingroup CAPI_NETWORK_BLUETOOTH_MODULE @@ -634,7 +633,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ @@ -660,7 +659,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ @@ -689,7 +688,7 @@ * * 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.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ diff --git a/include/bluetooth_private.h b/include/bluetooth_private.h index 8367ce8..df37dd8 100644..100755 --- a/include/bluetooth_private.h +++ b/include/bluetooth_private.h @@ -25,6 +25,7 @@ #include <bluetooth-telephony-api.h> #include <bluetooth-media-control.h> #include <bluetooth-hid-api.h> +#include <bluetooth-ipsp-api.h> #include "bluetooth.h" #include "bluetooth_internal.h" @@ -59,6 +60,7 @@ typedef enum BT_EVENT_BOND_CREATED, /**< A bond is created */ BT_EVENT_BOND_DESTROYED, /**< A bond is destroyed */ BT_EVENT_AUTHORIZATION_CHANGED, /**< Authorization is changed */ + BT_EVENT_AUTHENTICATION_REQUEST, /**< Authentication events during pairing process*/ BT_EVENT_SERVICE_SEARCHED, /**< Service search finish */ BT_EVENT_DATA_RECEIVED, /**< Data is received */ BT_EVENT_CONNECTION_STATE_CHANGED, /**< Connection state is changed */ @@ -76,7 +78,6 @@ typedef enum BT_EVENT_HDP_DISCONNECTED, /**< HDP disconnection change */ BT_EVENT_HDP_DATA_RECEIVED, /**< HDP Data receive Callabck */ BT_EVENT_AUDIO_CONNECTION_STATUS, /**< Audio Connection change callback */ - BT_EVENT_A2DP_SOURCE_CONNECTION_STATUS, /**< A2dp Source Connection Change */ BT_EVENT_AG_SCO_CONNECTION_STATUS, /**< Audio - AG SCO Connection state change callback */ BT_EVENT_AG_CALL_HANDLING_EVENT, /**< Audio - AG call event callback */ BT_EVENT_AG_MULTI_CALL_HANDLING_EVENT, /**< Audio - AG 3-way call event callback */ @@ -93,6 +94,8 @@ typedef enum BT_EVENT_AVRCP_SONG_POSITION_CHANGED, /**< AVRCP scan mode change callback */ BT_EVENT_AVRCP_TRACK_INFO_CHANGED, /**< AVRCP scan mode change callback */ BT_EVENT_HID_CONNECTION_STATUS, /**< HID connection status callback */ + BT_EVENT_HID_DEVICE_CONNECTION_STATUS, /**< HID Device connection status callback */ + BT_EVENT_HID_DEVICE_DATA_RECEIVED, /**< HID Device Data received callback */ BT_EVENT_DEVICE_CONNECTION_STATUS, /**< Device connection status callback */ BT_EVENT_GATT_CONNECTION_STATUS, /** < GATT connection status callback */ BT_EVENT_GATT_CLIENT_SERVICE_DISCOVERED, /** GATT services discovered callback */ @@ -109,6 +112,9 @@ typedef enum BT_EVENT_GATT_CLIENT_READ_CHARACTERISTIC_LEGACY, /**< GATT characteristic value read callback */ BT_EVENT_GATT_CLIENT_WRITE_CHARACTERISTIC_LEGACY, /**< GATT characteristic value write callback */ #endif + BT_EVENT_IPSP_INIT_STATE_CHANGED, /**< IPSP Init status changed callback */ + BT_EVENT_IPSP_CONNECTION_STATUS, /**< IPSP connection status callback */ + BT_EVENT_LE_DATA_LENGTH_CHANGED, /** LE data length changed callback */ BT_EVENT_ADVERTISING_STATE_CHANGED, /**< Advertising state changed callback */ BT_EVENT_MANUFACTURER_DATA_CHANGED, /**< Manufacturer data changed callback */ BT_EVENT_CONNECTABLE_CHANGED_EVENT, /**< Adapter connectable changed callback */ @@ -175,7 +181,8 @@ typedef enum { BT_ADAPTER_LE_ADVERTISING_DATA_COMP_LIST_16_BIT_SERVICE_CLASS_UUIDS = 0x03, /**< Complete list of 16 bit UUIDs */ BT_ADAPTER_LE_ADVERTISING_DATA_INCOMP_LIST_128_BIT_SERVICE_CLASS_UUIDS = 0x06, /**< Incomplete list of 128 bit UUIDs */ BT_ADAPTER_LE_ADVERTISING_DATA_COMP_LIST_128_BIT_SERVICE_CLASS_UUIDS = 0x07, /**< Complete list of 128 bit UUID */ - BT_ADAPTER_LE_ADVERTISING_DATA_LOCAL_NAME = 0x09, /**<local device name */ + BT_ADAPTER_LE_ADVERTISING_DATA_SHORT_LOCAL_NAME = 0x08, /**<Shortened local name */ + BT_ADAPTER_LE_ADVERTISING_DATA_LOCAL_NAME = 0x09, /**<Complete local name */ BT_ADAPTER_LE_ADVERTISING_DATA_TX_POWER_LEVEL = 0x0a, /**< TX-Power level*/ BT_ADAPTER_LE_ADVERTISING_DATA_16_BIT_SERVICE_SOLICITATION_UUIDS = 0x14, /**< List of 16-bit Service Solicitation UUIDs*/ BT_ADAPTER_LE_ADVERTISING_DATA_128_BIT_SERVICE_SOLICITATION_UUIDS = 0x15, /**< List of 128-bit Service Solicitation UUIDs*/ @@ -292,6 +299,9 @@ typedef struct { bt_gatt_server_read_value_requested_cb read_requested_cb; void *read_requested_user_data; + bt_gatt_server_notification_state_change_cb notification_changed_cb; + void *notification_changed_user_data; + int value_length; char *value; } bt_gatt_characteristic_s; @@ -342,6 +352,17 @@ typedef void (*_bt_gatt_client_value_changed_cb)(char *char_path, #endif /** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enumerations of the authentication event types. + * + */ +typedef enum { + BT_AUTH_KEYBOARD_PASSKEY_DISPLAY = 0, /**< PIN display event to user for entering PIN in keyboard */ + BT_AUTH_PIN_REQUEST, /**< Legacy PIN or PASSKEY request event */ + BT_AUTH_PASSKEY_CONFIRM_REQUEST, /**< PASSKEY confirmation event to match PASSKEY in remote device */ +} bt_authentication_type_info_e; + +/** * @internal * @brief Check the initialzating status */ @@ -481,6 +502,251 @@ const GSList* _bt_gatt_get_server_list(void); int _bt_gatt_client_update_all(bt_gatt_client_h client); +/* HID device related type */ +typedef struct +{ + unsigned char btcode; + unsigned char rep_id; + unsigned char button; + signed char axis_x; + signed char axis_y; + signed char axis_z; +} bt_hid_mouse_data_s; + +typedef struct +{ + unsigned char btcode; + unsigned char rep_id; + unsigned char modify; + unsigned char key[8]; +} bt_hid_key_data_s; + +typedef enum { + BT_HID_HEADER_HANDSHAKE, + BT_HID_HEADER_HID_CONTROL, + BT_HID_HEADER_GET_REPORT, + BT_HID_HEADER_SET_REPORT, + BT_HID_HEADER_GET_PROTOCOL, + BT_HID_HEADER_SET_PROTOCOL, + BT_HID_HEADER_DATA, + BT_HID_HEADER_UNKNOWN +} bluetooth_hid_header_type_t; + +typedef enum { + BT_HID_PARAM_DATA_RTYPE_INPUT, + BT_HID_PARAM_DATA_RTYPE_OUTPUT +} bluetooth_hid_param_type_t; + +typedef struct +{ + const char *address; + bluetooth_hid_header_type_t type; + bluetooth_hid_param_type_t param; + int data_size; /**< The length of the received data */ + const char *data; /**< The received data */ +} bt_hid_device_received_data_s; + +typedef void (*bt_hid_device_connection_state_changed_cb) (int result, + bool connected, const char *remote_address, void *user_data); + +typedef void (*bt_hid_device_data_received_cb)(const bt_hid_device_received_data_s *data, void *user_data); +/* HID device related type */ + +/** + * @internal + * @brief IPSP Init state changed callback + */ +typedef void (*bt_le_ipsp_init_state_changed_cb) + (int result, bool ipsp_initialized, void *user_data); + +/** + * @internal + * @brief Initialize Bluetooth LE IPSP service and set the callback + */ +int _bt_le_ipsp_initialize(bt_le_ipsp_init_state_changed_cb callback, void *user_data); + +/** + * @internal + * @brief De-Initialize Bluetooth LE IPSP service and unset the callback + */ +int _bt_le_ipsp_deinitialize(void); + +/** + * @internal + * @brief Connect to a IPSP service over LE to remote device. + */ +int _bt_le_ipsp_connect(const char *address); + +/** + * @internal + * @brief Disconnect to a IPSP service over LE to remote device. + */ +int _bt_le_ipsp_disconnect(const char *address); + +/** +* @internal +* @brief Check whether IPSP service is initialized +*/ +int _bt_le_ipsp_is_initialized(void); + +/** + * @internal + * @brief IPSP Connection state changed callback + */ +typedef void (*_bt_le_ipsp_connection_state_changed_cb) + (int result, bool connected, const char *remote_address, void *user_data); +/** + * @internal + * @brief Set IPSP connection state event change callback. + */ +int _bt_le_ipsp_set_connection_state_changed_cb(_bt_le_ipsp_connection_state_changed_cb callback, + void *user_data); + +/** + * @internal + * @brief Unset IPSP connection state event change callback. + */ +int _bt_le_ipsp_unset_connection_state_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_LE_MODULE + * @brief Reads the maximum data length of LE packets supported by the controller. + * @since_tizen 3.0 + * + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_initialize + */ +int bt_adapter_le_read_maximum_data_length( + int *max_tx_octets, int *max_tx_time, + int *max_rx_octets, int *max_rx_time); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_LE_MODULE + * @brief Writes the Host suggested default data length of LE packets to the controller. + * @since_tizen 3.0 + * + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_initialize + */ +int bt_adapter_le_write_host_suggested_default_data_length( + const unsigned int def_tx_Octets, const unsigned int def_tx_Time); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_LE_MODULE + * @brief Reads the Host suggested data length values of LE packets from the controller. + * @since_tizen 3.0 + * + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_initialize + */ +int bt_adapter_le_read_suggested_default_data_length( + unsigned int *def_tx_Octets, unsigned int *def_tx_Time); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_LE_MODULE + * @brief Allows the host to suggest to controller, the data length parameters to be used + * for a given LE Connection. + * @since_tizen 3.0 + * + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_initialize + */ +int bt_device_le_set_data_length(const char *remote_address, + unsigned int max_tx_Octets, unsigned int max_tx_Time); + +/** + * @internal + * @brief LE data length changed callback + */ +typedef void (*_bt_le_set_data_length_changed_cb) + (int result, const char *remote_address, int max_tx_octets, + int max_tx_time, int max_rx_octets, int max_rx_time, void *user_data); + +int bt_device_le_set_data_length_change_cb( + _bt_le_set_data_length_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when remote device requests authentication. + * @param[in] result + * @param[in] auth_type + * typedef enum { + * BT_AUTH_KEYBOARD_PASSKEY_DISPLAY = 0, : PIN display event to user for entering PIN in keyboard + * BT_AUTH_PIN_REQUEST, : Legacy PIN or PASSKEY request event + * BT_AUTH_PASSKEY_CONFIRM_REQUEST, : PASSKEY confirmation event to match PASSKEY in remote device + * } bt_authentication_type_info_e; + * @param[in] device_name Name of the remote device + * @param[in] remote_addr Remote BD address + * @param[in] pass_key PASSKEY string + * PASSKEY string is valid only if authentication types are following + * a/ BT_AUTH_KEYBOARD_PASSKEY_DISPLAY + * b/ BT_AUTH_PASSKEY_CONFIRM_REQUEST + * pass_key string will be invalid if authentication event is of type BT_AUTH_PIN_REQUEST + * as this event indicates that user MUST enter PIN or PASSKEY and perform authentication. + * + * Upon receiving BT_AUTH_KEYBOARD_PASSKEY_DISPLAY event, user should enter PASSKEY in keyboard + * Application can also call bt_device_cancel_bonding() Upon receiving BT_AUTH_KEYBOARD_PASSKEY_DISPLAY + * event which will fail the on-going pairing with remote device. + * @param[in] user_data The user data passed from the callback registration function + * @see bt_adapter_set_authentication_req_cb() + */ +typedef void (*bt_adapter_authentication_req_cb)(int result, bt_authentication_type_info_e auth_type, + char *device_name, char *remote_addr, + char *pass_key, void *user_data); + +int bt_adapter_set_authentication_req_cb(bt_adapter_authentication_req_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters a callback function that will be invoked when remote device requests authentication. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @see bt_initialize() + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_adapter_unset_authentication_req_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief API to reply with PIN or PASSKEY with authentication type - TRUE or FALSE. + * @remarks This function can be called by application when remote device requests PIN or PASSKEY from + * local adapter. + * @param[in] passkey The passkey to be provided by application when remote devices requests for it. + * @param[in] authentication_reply This indicates whether application wants to accept or cancel the on-going pairing + * @pre This function can only be called when application receieves authentication event (BT_AUTH_PIN_REQUEST) + * from remote device. + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_passkey_reply(char *passkey, bool authentication_reply); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief API to reply to the PASSKEY confirmation for on-going pairing with remote device. + * @remarks This function can be called by application, when local adapter wants PASSKEY confirmation from user. + * @param[in] confirmation_reply This indicates whether application wants to accepts or cancels the on-going pairing + * confirmation_reply : TRUE will indicate that Application has confirmed the PASSKEY + * confirmation_reply : FALSE will indicate that Application has failed to confirm the PASSKEY. In this situation + * the pairing will be failed. + * @pre This function can only be called when application receives authentication event (BT_AUTH_PASSKEY_CONFIRM_REQUEST) + * from remote device. + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_passkey_confirmation_reply(bool confirmation_reply); + #ifdef __cplusplus } #endif diff --git a/include/mobile/bluetooth.h b/include/mobile/bluetooth.h index 13fe96f..3e0b269 100755 --- a/include/mobile/bluetooth.h +++ b/include/mobile/bluetooth.h @@ -81,126 +81,6 @@ int bt_initialize(void); int bt_deinitialize(void); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Enables the local Bluetooth adapter, asynchronously. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @details This function enables Bluetooth protocol stack and hardware. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_ALREADY_DONE Already enabled - * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre Bluetooth service must be initialized with bt_initialize(). - * @pre The state of local Bluetooth must be #BT_ADAPTER_DISABLED - * @post This function invokes bt_adapter_state_changed_cb(). - * - * @see bt_initialize() - * @see bt_adapter_get_state() - * @see bt_adapter_set_state_changed_cb() - * @see bt_adapter_unset_state_changed_cb() - * @see bt_adapter_state_changed_cb() - * - */ -int bt_adapter_enable(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Disables the local Bluetooth adapter, asynchronously. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @details This function disables Bluetooth protocol stack and hardware. - * - * @remarks You should disable Bluetooth adapter, which is helpful for saving power. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED - * @post This function invokes bt_adapter_state_changed_cb(). - * - * @see bt_adapter_get_state() - * @see bt_adapter_state_changed_cb() - * @see bt_adapter_set_state_changed_cb() - * @see bt_adapter_unset_state_changed_cb () - * - */ -int bt_adapter_disable(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Recover the local Bluetooth adapter, asynchronously. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @details This function does recovery logic, disables Bluetooth protocol stack and hardware, then enables after a few seconds. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED - * @post This function invokes bt_adapter_state_changed_cb(). - * - * @see bt_adapter_get_state() - * @see bt_adapter_state_changed_cb() - * @see bt_adapter_set_state_changed_cb() - * @see bt_adapter_unset_state_changed_cb () - * - */ -int bt_adapter_recover(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Reset the local Bluetooth adapter, synchronously. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @details This function resets Bluetooth protocol and values. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre Bluetooth service must be initialized with bt_initialize(). - * @post bt_adapter_state_changed_cb() will be invoked if The state of local Bluetooth was #BT_ADAPTER_ENABLED. - * - * @see bt_initialize() - * @see bt_adapter_get_state() - * @see bt_adapter_set_state_changed_cb() - * @see bt_adapter_unset_state_changed_cb() - * @see bt_adapter_state_changed_cb() - * - */ -int bt_adapter_reset(void); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Gets the current state of local Bluetooth adapter. * @since_tizen 2.3 @@ -243,53 +123,6 @@ int bt_adapter_get_state(bt_adapter_state_e *adapter_state); int bt_adapter_get_address(char **local_address); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Gets the version of local Bluetooth adapter. - * @since_tizen 2.3 - * @remarks The @a local_version must be released with free() by you. - * - * @param[out] local_version The version of local Bluetooth adapter - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - */ -int bt_adapter_get_version(char **local_version); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Gets the information regarding local Bluetooth adapter. - * @since_tizen 2.3 - * @remarks The @a all parameters must be released with free() by you. - * - * @param[out] chipset Chipset name of local Bluetooth adapter - * @param[out] firmware Firmware info. of local Bluetooth adapter - * @param[out] stack_version Bluetooth stack version - * @param[out] profiles The profile list of local Bluetooth adapter - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - */ -int bt_adapter_get_local_info(char **chipset, char **firmware, char **stack_version, char **profiles); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Gets the name of local Bluetooth adapter. * @since_tizen 2.3 @@ -365,40 +198,6 @@ int bt_adapter_set_name(const char *local_name); int bt_adapter_get_visibility(bt_adapter_visibility_mode_e *mode, int *duration); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Sets the visibility mode. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @remarks #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE will change to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE - * after the given @a duration goes. - * - * @param[in] discoverable_mode The Bluetooth visibility mode to set - * @param[in] duration The duration until the visibility mode is changed to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE (in seconds). - * @a duration is used only for #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE mode. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * @post bt_adapter_visibility_mode_changed_cb() will be invoked if this function returns #BT_ERROR_NONE. - * - * @see bt_adapter_get_visibility() - * @see bt_adapter_visibility_mode_changed_cb() - * @see bt_adapter_set_visibility_mode_changed_cb() - * @see bt_adapter_unset_visibility_mode_changed_cb() - */ -int bt_adapter_set_visibility(bt_adapter_visibility_mode_e discoverable_mode, int duration); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Starts the device discovery, asynchronously. * @since_tizen 2.3 @@ -866,183 +665,6 @@ int bt_adapter_set_remote_oob_data(const char *remote_address, int bt_adapter_remove_remote_oob_data(const char *remote_address); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Registers a callback function to be invoked when the connectable state changes. - * @since_tizen 2.3 - * - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_adapter_connectable_changed_cb() will be invoked. - * - * @see bt_initialize() - * @see bt_adapter_connectable_changed_cb() - * @see bt_adapter_unset_connectable_changed_cb() - */ -int bt_adapter_set_connectable_changed_cb(bt_adapter_connectable_changed_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Unregisters the callback function. - * @since_tizen 2.3 - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * - * @see bt_initialize() - * @see bt_adapter_set_connectable_changed_cb() - */ -int bt_adapter_unset_connectable_changed_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Gets the connectable state of local Bluetooth adapter. - * @since_tizen 2.3 - * - * @remarks When connectable state is false, no device can connect to this device and visibility mode cannot be changed. - * - * @param[out] connectable The connectable state of local Bluetooth adapter - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * - * @see bt_adapter_set_connectable() - */ -int bt_adapter_get_connectable(bool *connectable); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Sets the connectable state of local Bluetooth adapter. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @remarks When connectable state is false, no device can connect to this device and visibility mode cannot be changed. - * - * @param[in] connectable The connectable state to set - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * @post bt_adapter_connectable_changed_cb() will be invoked if this function returns #BT_ERROR_NONE. - * - * @see bt_adapter_get_connectable() - * @see bt_adapter_connectable_changed_cb() - * @see bt_adapter_set_connectable_changed_cb() - * @see bt_adapter_unset_connectable_changed_cb() - */ -int bt_adapter_set_connectable(bool connectable); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Enables the local Bluetooth le adapter, asynchronously. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @details This function enables Bluetooth protocol stack and hardware. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_ALREADY_DONE Already enabled - * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre Bluetooth service must be initialized with bt_initialize(). - * @post This function invokes bt_adapter_le_state_changed_cb(). - * - * @see bt_initialize() - * @see bt_adapter_le_get_state() - * @see bt_adapter_le_set_state_changed_cb() - * @see bt_adapter_le_unset_state_changed_cb() - * @see bt_adapter_le_state_changed_cb() - * - */ -int bt_adapter_le_enable(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Disables the local Bluetooth le adapter, asynchronously. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @details This function disables Bluetooth le protocol stack and hardware. - * - * @remarks - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_LE_ENABLED - * @post This function invokes bt_adapter_le_state_changed_cb(). - * - * @see bt_adapter_le_get_state() - * @see bt_adapter_le_state_changed_cb() - * @see bt_adapter_le_set_state_changed_cb() - * @see bt_adapter_le_unset_state_changed_cb () - * - */ -int bt_adapter_le_disable(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Gets the current state of local Bluetooth adapter. - * @since_tizen 2.3 - * - * @param[out] adapter_le_state The current adapter le state - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre Bluetooth service must be initialized with bt_initialize(). - * - * @see bt_initialize() - */ -int bt_adapter_le_get_state(bt_adapter_le_state_e *adapter_le_state); - -/** * @deprecated Deprecated since 2.3.1 * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE * @brief Starts the LE device discovery. @@ -1422,141 +1044,6 @@ int bt_adapter_le_get_scan_result_manufacturer_data(const bt_adapter_le_device_s bt_adapter_le_packet_type_e pkt_type, int *manufacturer_id, char **manufacturer_data, int *manufacturer_data_len); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Registers a callback function to be invoked when the Bluetooth adapter le state changes. - * @since_tizen 2.3 - * - * @param[in] callback The callback function to invoke - * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_adapter_le_state_changed_cb() will be invoked. - * - * @see bt_initialize() - * @see bt_adapter_le_state_changed_cb() - * @see bt_adapter_le_unset_state_changed_cb() - */ -int bt_adapter_le_set_state_changed_cb(bt_adapter_le_state_changed_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Unregisters the callback function. - * @since_tizen 2.3 - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * - * @see bt_initialize() - * @see bt_adapter_le_set_state_changed_cb() - */ -int bt_adapter_le_unset_state_changed_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief add address to whitelist for accepting scanning request. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @remarks If the adress is in the whitelist then other LE devices are able to - * search this device. Before calling this API, make sure that the adapter is - * enabled. There is no callback event for this API. - - * @param[in] address The other device's address - * @param[in] address_type The other device's address type - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled - * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * - * @see bt_adapter_le_start_advertising_new() - * @see bt_adapter_le_stop_advertising() - */ -int bt_adapter_le_add_white_list(const char *address, bt_device_address_type_e address_type); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief remove address from the whitelist for not accepting scanning request. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @remarks If the adress is in the whitelist then other LE devices are able to - * search this device. Before calling this API, make sure that the adapter is - * enabled. There is no callback event for this API. - * - * @param[in] address The other device's address - * @param[in] address_type The other device's address type - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled - * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * - * @see bt_adapter_le_start_advertising_new() - * @see bt_adapter_le_stop_advertising() - */ -int bt_adapter_le_remove_white_list(const char *address, bt_device_address_type_e address_type); - -/** - * @internal - * @deprecated Deprecated since 2.3.1 - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief clear address from the whitelist for not accepting scanning request. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @remarks If the adress is in the whitelist then other LE devices are able to - * search this device. Before calling this API, make sure that the adapter is - * enabled. There is no callback event for this API. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled - * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * - * @see bt_adapter_le_start_advertising_new() - * @see bt_adapter_le_stop_advertising() - */ -int bt_adapter_le_clear_white_list(void); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE * @brief Create advertiser to advertise device's existence or respond to LE scanning reqeust. * @since_tizen 2.3 @@ -2016,30 +1503,6 @@ int bt_adapter_le_set_advertising_mode(bt_advertiser_h advertiser, bt_adapter_le int bt_adapter_le_set_advertising_connectable(bt_advertiser_h advertiser, bool connectable); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Sets the Privacy feature state of local Bluetooth adapter. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @param[in] enable_privacy The privacy feature to set/unset. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * @pre The state of local Bluetooth must be #BT_ADAPTER_LE_ENABLED. - * - */ -int bt_adapter_le_enable_privacy(bool enable_privacy); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Creates a bond with a remote Bluetooth device, asynchronously. * @since_tizen 2.3 @@ -2075,45 +1538,6 @@ int bt_adapter_le_enable_privacy(bool enable_privacy); int bt_device_create_bond(const char *remote_address); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Creates a bond with a remote Bluetooth device, asynchronously. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @remarks A bond can be destroyed by bt_device_destroy_bond().\n - * The bonding request can be cancelled by bt_device_cancel_bonding(). - * - * @param[in] remote_address The address of the remote Bluetooth device with which the bond should be created - * @param[in] conn_type The connection type(LE or BREDR) to create bond with remote device - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * @pre The remote device must be discoverable with bt_adapter_start_device_discovery(). - * @post This function invokes bt_device_bond_created_cb(). - * - * @see bt_adapter_start_device_discovery() - * @see bt_device_create_bond() - * @see bt_device_bond_created_cb() - * @see bt_device_cancel_bonding() - * @see bt_device_destroy_bond() - * @see bt_device_set_bond_created_cb() - * @see bt_device_unset_bond_created_cb() - */ -int bt_device_create_bond_by_type(const char *remote_address, - bt_device_connection_link_type_e conn_type); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Cancels the bonding process. * @since_tizen 2.3 @@ -2269,33 +1693,6 @@ int bt_device_set_authorization(const char *remote_address, bt_device_authorizat int bt_device_start_service_search(const char *remote_address); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Cancels service search process. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded - * @retval #BT_ERROR_NOT_IN_PROGRESS Operation not in progress - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The service search must be in progress by bt_device_start_service_search(). - * - * @see bt_device_start_service_search() - * @see bt_device_service_searched_cb() - * @see bt_device_set_service_searched_cb() - * @see bt_device_unset_service_searched_cb() - */ -int bt_device_cancel_service_search(void); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Gets the connected profiles. * @since_tizen 2.3 @@ -2600,87 +1997,6 @@ int bt_socket_destroy_rfcomm(int socket_fd); int bt_socket_listen_and_accept_rfcomm(int socket_fd, int max_pending_connections); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE - * @brief Starts listening on passed rfcomm socket. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @details bt_socket_connection_requested_cb() will be called when a RFCOMM connection is requested. - * - * @param[in] socket_fd The file descriptor socket on which start to listen - * @param[in] max_pending_connections The number of pending connections - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The socket must be created with bt_socket_create_rfcomm(). - * @post This function invokes bt_socket_connection_state_changed_cb(). - * - * @see bt_socket_create_rfcomm() - * @see bt_socket_set_connection_requested_cb() - * @see bt_socket_unset_connection_requested_cb() - * @see bt_socket_connection_requested_cb() - */ -int bt_socket_listen(int socket_fd, int max_pending_connections); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE - * @brief Accepts a connection request. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @param[in] requested_socket_fd The file descriptor of socket on which a connection is requested - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The connection is requested by bt_socket_connection_requested_cb(). - * @see bt_socket_create_rfcomm() - * @see bt_socket_connection_requested_cb() - * @see bt_socket_listen() - * @see bt_socket_reject() -*/ -int bt_socket_accept(int requested_socket_fd); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE - * @brief Rejects a connection request. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @param[in] socket_fd The file descriptor of socket on which a connection is requested - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The connection is requested by bt_socket_connection_requested_cb(). - * @see bt_socket_create_rfcomm() - * @see bt_socket_connection_requested_cb() - * @see bt_socket_listen() - * @see bt_socket_accept() - */ -int bt_socket_reject(int socket_fd); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE * @brief Connects to a specific RFCOMM based service on a remote Bluetooth device UUID, asynchronously. * @since_tizen 2.3 @@ -2816,8 +2132,7 @@ int bt_socket_unset_data_received_cb(void); * @retval #BT_ERROR_NOT_SUPPORTED Not supported * * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post If you listen and accept a socket by bt_socket_listen_and_accept_rfcomm(), - bt_socket_connection_requested_cb() will be invoked. + * @post bt_socket_connection_requested_cb() will be invoked. * @see bt_initialize() * @see bt_socket_unset_connection_requested_cb() */ @@ -2876,35 +2191,6 @@ int bt_socket_set_connection_state_changed_cb(bt_socket_connection_state_changed int bt_socket_unset_connection_state_changed_cb(void); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE - * @brief Initializes the Bluetooth OPP server requested by bt_opp_server_push_requested_cb(). - * @since_tizen 2.3 - * @details The popup appears when an OPP connection is requested from a remote device. - * If you accept the request, then connection will be established and bt_opp_server_push_requested_cb() will be called. - * At that time, you can call either bt_opp_server_accept() or bt_opp_server_reject(). - * @remarks This function must be called to start Bluetooth OPP server. You must free all resources of the Bluetooth service - * by calling bt_opp_server_deinitialize() if Bluetooth OPP service is no longer needed. - * @param[in] destination The destination path - * @param[in] push_requested_cb The callback called when a push is requested - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_opp_server_push_requested_cb() - * @see bt_opp_server_deinitialize() - * @see bt_opp_server_accept() - * @see bt_opp_server_reject() - */ -int bt_opp_server_initialize(const char *destination, bt_opp_server_push_requested_cb push_requested_cb, void *user_data); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE * @brief Initializes the Bluetooth OPP server requested by bt_opp_server_connection_requested_cb(). * @since_tizen 2.3 @@ -3029,7 +2315,6 @@ int bt_opp_server_cancel_transfer(int transfer_id); * @retval #BT_ERROR_OPERATION_FAILED Operation failed * @retval #BT_ERROR_PERMISSION_DENIED Permission denied * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * */ int bt_opp_server_set_destination(const char *destination); @@ -3359,506 +2644,9 @@ int bt_audio_set_connection_state_changed_cb(bt_audio_connection_state_changed_c int bt_audio_unset_connection_state_changed_cb(void); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Opens a SCO(Synchronous Connection Oriented link) to connected remote device, asynchronously. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_ALREADY_DONE Operation is already done - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio device must be connected with bt_audio_connect(). - * @post bt_ag_sco_state_changed_cb() will be invoked. - * @see bt_ag_close_sco() - * @see bt_ag_sco_state_changed_cb() - * @see bt_audio_connect() - */ -int bt_ag_open_sco(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Closes an opened SCO(Synchronous Connection Oriented link), asynchronously. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The SCO must be opened with bt_ag_open_sco(). - * @post bt_ag_sco_state_changed_cb() will be invoked. - * @see bt_ag_open_sco() - * @see bt_ag_sco_state_changed_cb() - */ -int bt_ag_close_sco(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Checks whether an opened SCO(Synchronous Connection Oriented link) exists or not. - * @since_tizen 2.3 - * @param[out] opened The SCO status: (@c true = opened, @c false = not opened) - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_ag_open_sco() - * @see bt_ag_close_sco() - */ -int bt_ag_is_sco_opened(bool *opened); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Registers a callback function that will be invoked when the SCO(Synchronous Connection Oriented link) state is changed. - * @since_tizen 2.3 - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_sco_state_changed_cb() - * @see bt_ag_unset_sco_state_changed_cb() - */ -int bt_ag_set_sco_state_changed_cb(bt_ag_sco_state_changed_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Unregisters a callback function that will be invoked when the SCO(Synchronous Connection Oriented link) state is changed. - * @since_tizen 2.3 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_sco_state_changed_cb() - * @see bt_ag_set_sco_state_changed_cb() - */ -int bt_ag_unset_sco_state_changed_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Notifies the call event to the remote bluetooth device. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @remarks Before notifying #BT_AG_CALL_EVENT_ANSWERED or #BT_AG_CALL_EVENT_DIALING, you should open SCO(Synchronous Connection Oriented link) - * if Bluetooth Hands-Free need SCO connection. - * @param[in] event The call event - * @param[in] call_id The call ID - * @param[in] phone_number The phone number. You must set this value in case of #BT_AG_CALL_EVENT_DIALING and #BT_AG_CALL_EVENT_INCOMING. - * In other cases, this value can be NULL. - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio device must be connected with bt_audio_connect(). - * @see bt_audio_connect() - */ -int bt_ag_notify_call_event(bt_ag_call_event_e event, unsigned int call_id, const char *phone_number); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Notifies the call list to the remote bluetooth device. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @param[in] list The call list - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio device must be connected with bt_audio_connect(). - * @see bt_audio_connect() - */ -int bt_ag_notify_call_list(bt_call_list_h list); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Notifies the state of voice recognition. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @param[in] state The state of voice recognition: (@c true = enabled, @c false = disabled) - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio device must be connected with bt_audio_connect(). - * @see bt_audio_connect() - */ -int bt_ag_notify_voice_recognition_state(bool state); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Registers a callback function that will be invoked when a call handling event happened from Hands-Free. - * @since_tizen 2.3 - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_call_handling_event_cb() - * @see bt_ag_unset_call_handling_event_cb() - */ -int bt_ag_set_call_handling_event_cb(bt_ag_call_handling_event_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Unregisters a callback function that will be invoked when a call handling event happened from Hands-Free. - * @since_tizen 2.3 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_call_handling_event_cb() - * @see bt_ag_set_call_handling_event_cb() - */ -int bt_ag_unset_call_handling_event_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Registers a callback function that will be invoked when a multi call handling event happened from Hands-Free. - * @since_tizen 2.3 - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_multi_call_handling_event_cb() - * @see bt_ag_unset_multi_call_handling_event_cb() - */ -int bt_ag_set_multi_call_handling_event_cb(bt_ag_multi_call_handling_event_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Unregisters a callback function that will be invoked when a multi call handling event happened from Hands-Free. - * @since_tizen 2.3 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_multi_call_handling_event_cb() - * @see bt_ag_set_multi_call_handling_event_cb() - */ -int bt_ag_unset_multi_call_handling_event_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Registers a callback function that will be invoked when a DTMF(Dual Tone Multi Frequency) is transmitted from Hands-Free. - * @since_tizen 2.3 - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_dtmf_transmitted_cb() - * @see bt_ag_unset_dtmf_transmitted_cb() - */ -int bt_ag_set_dtmf_transmitted_cb(bt_ag_dtmf_transmitted_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Unregisters a callback function that will be invoked when a DTMF(Dual Tone Multi Frequency) is transmitted from Hands-Free. - * @since_tizen 2.3 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_dtmf_transmitted_cb() - * @see bt_ag_set_dtmf_transmitted_cb() - */ -int bt_ag_unset_dtmf_transmitted_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Notifies the speaker gain to the remote device. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @details This function sends a signal to the remote device. This signal has the gain value. - * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. - * When the speaker gain of remote device is changed to the requested gain, bt_audio_speaker_gain_changed_cb() will be called. - * @param[in] gain The gain of speaker (0 ~ 15) - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. - * @see bt_ag_get_speaker_gain() - * @see bt_ag_set_speaker_gain_changed_cb() - * @see bt_ag_unset_speaker_gain_changed_cb() - */ -int bt_ag_notify_speaker_gain(int gain); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Gets the current speaker gain of the remote device. - * @since_tizen 2.3 - * @details This function gets the value of speaker gain of the remote device. - * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. - * @param[out] gain The gain of speaker (0 ~ 15) - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. - * @see bt_ag_notify_speaker_gain() - * @see bt_ag_set_speaker_gain_changed_cb() - * @see bt_ag_unset_speaker_gain_changed_cb() - */ -int bt_ag_get_speaker_gain(int *gain); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Checks whether the remoted device enables NREC(Noise Reduction and Echo Canceling) or not. - * @since_tizen 2.3 - * @param[out] enabled The NREC status: (@c true = enabled, @c false = not enabled) - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. - * @see bt_audio_connect() - */ -int bt_ag_is_nrec_enabled(bool *enabled); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Registers a callback function that will be invoked when the speaker gain of the remote device is changed. - * @since_tizen 2.3 - * @details This function let you know the change of the speaker gain of the remote device. - * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_unset_speaker_gain_changed_cb() - */ -int bt_ag_set_speaker_gain_changed_cb(bt_ag_speaker_gain_changed_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Unregisters a callback function that will be invoked when the speaker gain of the remote device is changed. - * @since_tizen 2.3 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_set_speaker_gain_changed_cb() - */ -int bt_ag_unset_speaker_gain_changed_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Registers a callback function that will be invoked when the microphone gain of the remote device is changed. - * @since_tizen 2.3 - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_unset_microphone_gain_changed_cb() - */ -int bt_ag_set_microphone_gain_changed_cb(bt_ag_microphone_gain_changed_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Unregisters a callback function that will be invoked when the microphone gain of the remote device is changed. - * @since_tizen 2.3 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_set_microphone_gain_changed_cb() - */ -int bt_ag_unset_microphone_gain_changed_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE - * @brief Creates a handle of call list. - * @since_tizen 2.3 - * @param[out] list The handle of call list - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_call_list_destroy() - */ -int bt_call_list_create(bt_call_list_h *list); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE - * @brief Destroys the handle of call list. - * @since_tizen 2.3 - * @param[in] list The handle of call list - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_call_list_create() - */ -int bt_call_list_destroy(bt_call_list_h list); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE - * @brief Resets the handle of call list. - * @since_tizen 2.3 - * @param[in] list The handle of call list - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_call_list_create() - */ -int bt_call_list_reset(bt_call_list_h list); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE - * @brief Adds a call to the handle of call list. - * @since_tizen 2.3 - * @param[in] list The handle of call list - * @param[in] call_id The call ID - * @param[in] state The state of audio gate call - * @param[in] phone_number The phone number. You must set this value in case of #BT_AG_CALL_EVENT_DIALING and #BT_AG_CALL_EVENT_INCOMING. - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_call_list_create() - */ -int bt_call_list_add(bt_call_list_h list, unsigned int call_id, bt_ag_call_state_e state, const char *phone_number); - -/** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Initializes the Bluetooth AVRCP(Audio/Video Remote Control Profile) service. - * @since_tizen 2.3 + * @since_tizen 2.4 * @remarks This function must be called before Bluetooth AVRCP service. \n * You must free all resources of the this service by calling bt_avrcp_target_deinitialize() * if Bluetooth AVRCP service is no longer needed. @@ -3878,10 +2666,9 @@ int bt_call_list_add(bt_call_list_h list, unsigned int call_id, bt_ag_call_state int bt_avrcp_target_initialize(bt_avrcp_target_connection_state_changed_cb callback, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Deinitializes the Bluetooth AVRCP(Audio/Video Remote Control Profile) service. - * @since_tizen 2.3 + * @since_tizen 2.4 * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized @@ -3893,12 +2680,11 @@ int bt_avrcp_target_initialize(bt_avrcp_target_connection_state_changed_cb callb int bt_avrcp_target_deinitialize(void); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Notifies the equalize state to the remote device. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth * @param[in] state The state of equalizer * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -3917,12 +2703,11 @@ int bt_avrcp_target_deinitialize(void); int bt_avrcp_target_notify_equalizer_state(bt_avrcp_equalizer_state_e state); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Notifies the repeat mode to the remote device. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth * @param[in] mode The repeat mode * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -3941,12 +2726,11 @@ int bt_avrcp_target_notify_equalizer_state(bt_avrcp_equalizer_state_e state); int bt_avrcp_target_notify_repeat_mode(bt_avrcp_repeat_mode_e mode); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Notifies the shuffle mode to the remote device. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth * @param[in] mode The repeat mode * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -3965,12 +2749,11 @@ int bt_avrcp_target_notify_repeat_mode(bt_avrcp_repeat_mode_e mode); int bt_avrcp_target_notify_shuffle_mode(bt_avrcp_shuffle_mode_e mode); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Notifies the scan mode to the remote device. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth * @param[in] mode The scan mode * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -3989,12 +2772,11 @@ int bt_avrcp_target_notify_shuffle_mode(bt_avrcp_shuffle_mode_e mode); int bt_avrcp_target_notify_scan_mode(bt_avrcp_scan_mode_e mode); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Notifies the player state to the remote device. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth * @param[in] state The player state * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -4013,12 +2795,11 @@ int bt_avrcp_target_notify_scan_mode(bt_avrcp_scan_mode_e mode); int bt_avrcp_target_notify_player_state(bt_avrcp_player_state_e state); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Notifies the current position of song to the remote device. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth * @param[in] position The current position in milliseconds * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -4037,12 +2818,11 @@ int bt_avrcp_target_notify_player_state(bt_avrcp_player_state_e state); int bt_avrcp_target_notify_position(unsigned int position); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Notifies the track to the remote device. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth * @param[in] title The title of track * @param[in] artist The artist of track * @param[in] album The album of track @@ -4067,10 +2847,9 @@ int bt_avrcp_target_notify_position(unsigned int position); int bt_avrcp_target_notify_track(const char *title, const char *artist, const char *album, const char *genre, unsigned int track_num, unsigned int total_tracks, unsigned int duration); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Registers a callback function that will be invoked when the equalizer state is changed by the remote control device. - * @since_tizen 2.3 + * @since_tizen 2.4 * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function * @return 0 on success, otherwise a negative error value. @@ -4086,10 +2865,9 @@ int bt_avrcp_target_notify_track(const char *title, const char *artist, const ch int bt_avrcp_set_equalizer_state_changed_cb(bt_avrcp_equalizer_state_changed_cb callback, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Unregisters a callback function that will be invoked when the equalizer state is changed by the remote control device. - * @since_tizen 2.3 + * @since_tizen 2.4 * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized @@ -4102,10 +2880,9 @@ int bt_avrcp_set_equalizer_state_changed_cb(bt_avrcp_equalizer_state_changed_cb int bt_avrcp_unset_equalizer_state_changed_cb(void); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Registers a callback function that will be invoked when the repeat mode is changed by the remote control device. - * @since_tizen 2.3 + * @since_tizen 2.4 * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function * @return 0 on success, otherwise a negative error value. @@ -4121,10 +2898,9 @@ int bt_avrcp_unset_equalizer_state_changed_cb(void); int bt_avrcp_set_repeat_mode_changed_cb(bt_avrcp_repeat_mode_changed_cb callback, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Unregisters a callback function that will be invoked when the repeat mode is changed by the remote control device. - * @since_tizen 2.3 + * @since_tizen 2.4 * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized @@ -4137,10 +2913,9 @@ int bt_avrcp_set_repeat_mode_changed_cb(bt_avrcp_repeat_mode_changed_cb callback int bt_avrcp_unset_repeat_mode_changed_cb(void); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Registers a callback function that will be invoked when the shuffle mode is changed by the remote control device. - * @since_tizen 2.3 + * @since_tizen 2.4 * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function * @return 0 on success, otherwise a negative error value. @@ -4156,10 +2931,9 @@ int bt_avrcp_unset_repeat_mode_changed_cb(void); int bt_avrcp_set_shuffle_mode_changed_cb(bt_avrcp_shuffle_mode_changed_cb callback, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Unregisters a callback function that will be invoked when the shuffle mode is changed by the remote control device. - * @since_tizen 2.3 + * @since_tizen 2.4 * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized @@ -4172,10 +2946,9 @@ int bt_avrcp_set_shuffle_mode_changed_cb(bt_avrcp_shuffle_mode_changed_cb callba int bt_avrcp_unset_shuffle_mode_changed_cb(void); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Registers a callback function that will be invoked when the scan mode is changed by the remote control device. - * @since_tizen 2.3 + * @since_tizen 2.4 * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function * @return 0 on success, otherwise a negative error value. @@ -4191,10 +2964,9 @@ int bt_avrcp_unset_shuffle_mode_changed_cb(void); int bt_avrcp_set_scan_mode_changed_cb(bt_avrcp_scan_mode_changed_cb callback, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Unregisters a callback function that will be invoked when the scan mode is changed by the remote control device. - * @since_tizen 2.3 + * @since_tizen 2.4 * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized @@ -5377,239 +4149,6 @@ int bt_gatt_set_connection_state_changed_cb(bt_gatt_connection_state_changed_cb int bt_gatt_unset_connection_state_changed_cb(void); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE - * @brief Activates the NAP(Network Access Point). - * @since_tizen 2.3 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_ALREADY_DONE Operation is already done - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED - * @see bt_nap_deactivate() - */ -int bt_nap_activate(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE - * @brief Deactivates the NAP(Network Access Point). - * @since_tizen 2.3 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_ALREADY_DONE Operation is already done - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). - * @see bt_nap_activate() - */ -int bt_nap_deactivate(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE - * @brief Disconnects the all PANUs(Personal Area Networking User) which are connected to you. - * @since_tizen 2.3 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). - * @see bt_nap_activate() - */ -int bt_nap_disconnect_all(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE - * @brief Disconnects the specified PANU(Personal Area Networking User) which is connected to you. - * @since_tizen 2.3 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * @param[in] remote_address The remote address - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). - * @see bt_nap_activate() - */ -int bt_nap_disconnect(const char *remote_address); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE - * @brief Registers a callback function that will be invoked when the connection state changes. - * @since_tizen 2.3 - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_nap_connection_state_changed_cb() will be invoked. - * @see bt_initialize() - * @see bt_nap_connection_state_changed_cb() - * @see bt_nap_unset_connection_state_changed_cb() - */ -int bt_nap_set_connection_state_changed_cb(bt_nap_connection_state_changed_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE - * @brief Unregisters a callback function that will be invoked when the connection state changes. - * @since_tizen 2.3 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_nap_connection_state_changed_cb() will be invoked. - * @see bt_initialize() - * @see bt_nap_connection_state_changed_cb() - * @see bt_nap_set_connection_state_changed_cb() - */ -int bt_nap_unset_connection_state_changed_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE - * @brief Registers a callback function that will be invoked when the connection state changes. - * @since_tizen 2.3 - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_nap_connection_state_changed_cb() will be invoked. - * @see bt_initialize() - * @see bt_panu_connection_state_changed_cb() - * @see bt_panu_unset_connection_state_changed_cb() - */ -int bt_panu_set_connection_state_changed_cb(bt_panu_connection_state_changed_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE - * @brief Unregisters a callback function that will be invoked when the connection state changes. - * @since_tizen 2.3 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_nap_connection_state_changed_cb() will be invoked. - * @see bt_initialize() - * @see bt_panu_connection_state_changed_cb() - * @see bt_panu_set_connection_state_changed_cb() - */ -int bt_panu_unset_connection_state_changed_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE - * @brief Connects the remote device with the PAN(Personal Area Networking) service, asynchronously. - * @since_tizen 2.3 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * @param[in] remote_address The remote address - * @param[in] type The type of PAN service - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The local device must be bonded with the remote device by bt_device_create_bond(). - * @post bt_panu_connection_state_changed_cb() will be invoked. - * @see bt_panu_disconnect() - * @see bt_panu_connection_state_changed_cb() - */ -int bt_panu_connect(const char *remote_address, bt_panu_service_type_e type); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE - * @brief Disconnects the remote device with the PAN(Personal Area Networking) service, asynchronously. - * @since_tizen 2.3 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * @param[in] remote_address The remote address - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The remote device must be connected by bt_panu_connect(). - * @post bt_panu_connection_state_changed_cb() will be invoked. - * @see bt_panu_connect() - * @see bt_panu_connection_state_changed_cb() - */ -int bt_panu_disconnect(const char *remote_address); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief update LE connection. - * @since_tizen 2.3 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized by bt_initialize(). - * @pre The remote device must be connected with bt_gatt_connect(). - */ -int bt_device_le_conn_update(const char *device_address, - const bt_le_conn_update_s *parameters); - - -/** * @} */ diff --git a/include/mobile/bluetooth_extension.h b/include/mobile/bluetooth_extension.h new file mode 100644 index 0000000..dac46e5 --- /dev/null +++ b/include/mobile/bluetooth_extension.h @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_NETWORK_BLUETOOTH_EXTENSION_H__ +#define __TIZEN_NETWORK_BLUETOOTH_EXTENSION_H__ + +#include "bluetooth_type.h" +#include "bluetooth_type_extension.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** + * @file bluetooth_extension.h + */ + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Opens a SCO(Synchronous Connection Oriented link) to connected remote device, asynchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @post bt_ag_sco_state_changed_cb() will be invoked. + * @see bt_ag_close_sco() + * @see bt_ag_sco_state_changed_cb() + * @see bt_audio_connect() + */ +int bt_ag_open_sco(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Closes an opened SCO(Synchronous Connection Oriented link), asynchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The SCO must be opened with bt_ag_open_sco(). + * @post bt_ag_sco_state_changed_cb() will be invoked. + * @see bt_ag_open_sco() + * @see bt_ag_sco_state_changed_cb() + */ +int bt_ag_close_sco(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Checks whether an opened SCO(Synchronous Connection Oriented link) exists or not. + * @since_tizen 2.3 + * @param[out] opened The SCO status: (@c true = opened, @c false = not opened) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_ag_open_sco() + * @see bt_ag_close_sco() + */ +int bt_ag_is_sco_opened(bool *opened); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when the SCO(Synchronous Connection Oriented link) state is changed. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_sco_state_changed_cb() + * @see bt_ag_unset_sco_state_changed_cb() + */ +int bt_ag_set_sco_state_changed_cb(bt_ag_sco_state_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when the SCO(Synchronous Connection Oriented link) state is changed. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_sco_state_changed_cb() + * @see bt_ag_set_sco_state_changed_cb() + */ +int bt_ag_unset_sco_state_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the state of voice recognition. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] state The state of voice recognition: (@c true = enabled, @c false = disabled) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @see bt_audio_connect() + */ +int bt_ag_notify_voice_recognition_state(bool state); + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // __TIZEN_NETWORK_BLUETOOTH_EXTENSION_H__ + diff --git a/include/mobile/bluetooth_internal.h b/include/mobile/bluetooth_internal.h index 647a2bb..c1fc1d6 100644 --- a/include/mobile/bluetooth_internal.h +++ b/include/mobile/bluetooth_internal.h @@ -34,6 +34,303 @@ extern "C" /** * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enables the local Bluetooth adapter, asynchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function enables Bluetooth protocol stack and hardware. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_ALREADY_DONE Already enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre Bluetooth service must be initialized with bt_initialize(). + * @pre The state of local Bluetooth must be #BT_ADAPTER_DISABLED + * @post This function invokes bt_adapter_state_changed_cb(). + * + * @see bt_initialize() + * @see bt_adapter_get_state() + * @see bt_adapter_set_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb() + * @see bt_adapter_state_changed_cb() + * + */ +int bt_adapter_enable(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Disables the local Bluetooth adapter, asynchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function disables Bluetooth protocol stack and hardware. + * + * @remarks You should disable Bluetooth adapter, which is helpful for saving power. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED + * @post This function invokes bt_adapter_state_changed_cb(). + * + * @see bt_adapter_get_state() + * @see bt_adapter_state_changed_cb() + * @see bt_adapter_set_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb () + * + */ +int bt_adapter_disable(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Recover the local Bluetooth adapter, asynchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function does recovery logic, disables Bluetooth protocol stack and hardware, then enables after a few seconds. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED + * @post This function invokes bt_adapter_state_changed_cb(). + * + * @see bt_adapter_get_state() + * @see bt_adapter_state_changed_cb() + * @see bt_adapter_set_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb () + * + */ +int bt_adapter_recover(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Reset the local Bluetooth adapter, synchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function resets Bluetooth protocol and values. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_state_changed_cb() will be invoked if The state of local Bluetooth was #BT_ADAPTER_ENABLED. + * + * @see bt_initialize() + * @see bt_adapter_get_state() + * @see bt_adapter_set_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb() + * @see bt_adapter_state_changed_cb() + * + */ +int bt_adapter_reset(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Gets the version of local Bluetooth adapter. + * @since_tizen 2.3 + * @remarks The @a local_version must be released with free() by you. + * + * @param[out] local_version The version of local Bluetooth adapter + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + */ +int bt_adapter_get_version(char **local_version); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Gets the information regarding local Bluetooth adapter. + * @since_tizen 2.3 + * @remarks The @a all parameters must be released with free() by you. + * + * @param[out] chipset Chipset name of local Bluetooth adapter + * @param[out] firmware Firmware info. of local Bluetooth adapter + * @param[out] stack_version Bluetooth stack version + * @param[out] profiles The profile list of local Bluetooth adapter + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + */ +int bt_adapter_get_local_info(char **chipset, char **firmware, char **stack_version, char **profiles); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Sets the visibility mode. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @remarks #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE will change to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE + * after the given @a duration goes. + * + * @param[in] discoverable_mode The Bluetooth visibility mode to set + * @param[in] duration The duration until the visibility mode is changed to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE (in seconds). + * @a duration is used only for #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE mode. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post bt_adapter_visibility_mode_changed_cb() will be invoked if this function returns #BT_ERROR_NONE. + * + * @see bt_adapter_get_visibility() + * @see bt_adapter_visibility_mode_changed_cb() + * @see bt_adapter_set_visibility_mode_changed_cb() + * @see bt_adapter_unset_visibility_mode_changed_cb() + */ +int bt_adapter_set_visibility(bt_adapter_visibility_mode_e discoverable_mode, int duration); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function to be invoked when the connectable state changes. + * @since_tizen 2.3 + * + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_connectable_changed_cb() will be invoked. + * + * @see bt_initialize() + * @see bt_adapter_connectable_changed_cb() + * @see bt_adapter_unset_connectable_changed_cb() + */ +int bt_adapter_set_connectable_changed_cb(bt_adapter_connectable_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + * @see bt_adapter_set_connectable_changed_cb() + */ +int bt_adapter_unset_connectable_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Gets the connectable state of local Bluetooth adapter. + * @since_tizen 2.3 + * + * @remarks When connectable state is false, no device can connect to this device and visibility mode cannot be changed. + * + * @param[out] connectable The connectable state of local Bluetooth adapter + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * + * @see bt_adapter_set_connectable() + */ +int bt_adapter_get_connectable(bool *connectable); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Sets the connectable state of local Bluetooth adapter. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @remarks When connectable state is false, no device can connect to this device and visibility mode cannot be changed. + * + * @param[in] connectable The connectable state to set + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post bt_adapter_connectable_changed_cb() will be invoked if this function returns #BT_ERROR_NONE. + * + * @see bt_adapter_get_connectable() + * @see bt_adapter_connectable_changed_cb() + * @see bt_adapter_set_connectable_changed_cb() + * @see bt_adapter_unset_connectable_changed_cb() + */ +int bt_adapter_set_connectable(bool connectable); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Sets the manufacturer data of local Bluetooth adapter. * @since_tizen 2.3 * @privlevel platform @@ -105,6 +402,247 @@ int bt_adapter_set_manufacturer_data_changed_cb( */ int bt_adapter_unset_manufacturer_data_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Enables the local Bluetooth le adapter, asynchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function enables Bluetooth protocol stack and hardware. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_ALREADY_DONE Already enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre Bluetooth service must be initialized with bt_initialize(). + * @post This function invokes bt_adapter_le_state_changed_cb(). + * + * @see bt_initialize() + * @see bt_adapter_le_get_state() + * @see bt_adapter_le_set_state_changed_cb() + * @see bt_adapter_le_unset_state_changed_cb() + * @see bt_adapter_le_state_changed_cb() + * + */ +int bt_adapter_le_enable(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Disables the local Bluetooth le adapter, asynchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function disables Bluetooth le protocol stack and hardware. + * + * @remarks + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_LE_ENABLED + * @post This function invokes bt_adapter_le_state_changed_cb(). + * + * @see bt_adapter_le_get_state() + * @see bt_adapter_le_state_changed_cb() + * @see bt_adapter_le_set_state_changed_cb() + * @see bt_adapter_le_unset_state_changed_cb () + * + */ +int bt_adapter_le_disable(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Gets the current state of local Bluetooth adapter. + * @since_tizen 2.3 + * + * @param[out] adapter_le_state The current adapter le state + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + */ +int bt_adapter_le_get_state(bt_adapter_le_state_e *adapter_le_state); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Registers a callback function to be invoked when the Bluetooth adapter le state changes. + * @since_tizen 2.3 + * + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_le_state_changed_cb() will be invoked. + * + * @see bt_initialize() + * @see bt_adapter_le_state_changed_cb() + * @see bt_adapter_le_unset_state_changed_cb() + */ +int bt_adapter_le_set_state_changed_cb(bt_adapter_le_state_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + * @see bt_adapter_le_set_state_changed_cb() + */ +int bt_adapter_le_unset_state_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief add address to whitelist for accepting scanning request. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @remarks If the adress is in the whitelist then other LE devices are able to + * search this device. Before calling this API, make sure that the adapter is + * enabled. There is no callback event for this API. + + * @param[in] address The other device's address + * @param[in] address_type The other device's address type + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * + * @see bt_adapter_le_start_advertising_new() + * @see bt_adapter_le_stop_advertising() + */ +int bt_adapter_le_add_white_list(const char *address, bt_device_address_type_e address_type); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief remove address from the whitelist for not accepting scanning request. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @remarks If the adress is in the whitelist then other LE devices are able to + * search this device. Before calling this API, make sure that the adapter is + * enabled. There is no callback event for this API. + * + * @param[in] address The other device's address + * @param[in] address_type The other device's address type + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * + * @see bt_adapter_le_start_advertising_new() + * @see bt_adapter_le_stop_advertising() + */ +int bt_adapter_le_remove_white_list(const char *address, bt_device_address_type_e address_type); + +/** + * @internal + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief clear address from the whitelist for not accepting scanning request. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @remarks If the adress is in the whitelist then other LE devices are able to + * search this device. Before calling this API, make sure that the adapter is + * enabled. There is no callback event for this API. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * + * @see bt_adapter_le_start_advertising_new() + * @see bt_adapter_le_stop_advertising() + */ +int bt_adapter_le_clear_white_list(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Sets the Privacy feature state of local Bluetooth adapter. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @param[in] enable_privacy The privacy feature to set/unset. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @pre The state of local Bluetooth must be #BT_ADAPTER_LE_ENABLED. + * + */ +int bt_adapter_le_enable_privacy(bool enable_privacy); + /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE * @brief Set Bluetooth LE scan mode @@ -484,6 +1022,72 @@ int bt_device_get_connection_state(const char *remote_address, bt_device_connect /** * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Creates a bond with a remote Bluetooth device, asynchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @remarks A bond can be destroyed by bt_device_destroy_bond().\n + * The bonding request can be cancelled by bt_device_cancel_bonding(). + * + * @param[in] remote_address The address of the remote Bluetooth device with which the bond should be created + * @param[in] conn_type The connection type(LE or BREDR) to create bond with remote device + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @pre The remote device must be discoverable with bt_adapter_start_device_discovery(). + * @post This function invokes bt_device_bond_created_cb(). + * + * @see bt_adapter_start_device_discovery() + * @see bt_device_create_bond() + * @see bt_device_bond_created_cb() + * @see bt_device_cancel_bonding() + * @see bt_device_destroy_bond() + * @see bt_device_set_bond_created_cb() + * @see bt_device_unset_bond_created_cb() + */ +int bt_device_create_bond_by_type(const char *remote_address, + bt_device_connection_link_type_e conn_type); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Cancels service search process. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * @retval #BT_ERROR_NOT_IN_PROGRESS Operation not in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The service search must be in progress by bt_device_start_service_search(). + * + * @see bt_device_start_service_search() + * @see bt_device_service_searched_cb() + * @see bt_device_set_service_searched_cb() + * @see bt_device_unset_service_searched_cb() + */ +int bt_device_cancel_service_search(void); + +/** + * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE * @brief Registers a rfcomm server socket with a specific UUID. Activation by dbus is possible when the profile is connected. * @since_tizen 2.4 @@ -578,6 +1182,509 @@ int bt_socket_destroy_rfcomm_ex(const char *uuid); int bt_socket_listen_and_accept_rfcomm_ex(const char *uuid, int max_pending_connections, const char* bus_name, const char *object_path); /** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Starts listening on passed rfcomm socket. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @details bt_socket_connection_requested_cb() will be called when a RFCOMM connection is requested. + * + * @param[in] socket_fd The file descriptor socket on which start to listen + * @param[in] max_pending_connections The number of pending connections + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The socket must be created with bt_socket_create_rfcomm(). + * @post This function invokes bt_socket_connection_state_changed_cb(). + * + * @see bt_socket_create_rfcomm() + * @see bt_socket_set_connection_requested_cb() + * @see bt_socket_unset_connection_requested_cb() + * @see bt_socket_connection_requested_cb() + */ +int bt_socket_listen(int socket_fd, int max_pending_connections); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Accepts a connection request. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] requested_socket_fd The file descriptor of socket on which a connection is requested + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The connection is requested by bt_socket_connection_requested_cb(). + * @see bt_socket_create_rfcomm() + * @see bt_socket_connection_requested_cb() + * @see bt_socket_listen() + * @see bt_socket_reject() +*/ +int bt_socket_accept(int requested_socket_fd); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Rejects a connection request. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] socket_fd The file descriptor of socket on which a connection is requested + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The connection is requested by bt_socket_connection_requested_cb(). + * @see bt_socket_create_rfcomm() + * @see bt_socket_connection_requested_cb() + * @see bt_socket_listen() + * @see bt_socket_accept() + */ +int bt_socket_reject(int socket_fd); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Initializes the Bluetooth OPP server requested by bt_opp_server_push_requested_cb(). + * @since_tizen 2.3 + * @details The popup appears when an OPP connection is requested from a remote device. + * If you accept the request, then connection will be established and bt_opp_server_push_requested_cb() will be called. + * At that time, you can call either bt_opp_server_accept() or bt_opp_server_reject(). + * @remarks This function must be called to start Bluetooth OPP server. You must free all resources of the Bluetooth service + * by calling bt_opp_server_deinitialize() if Bluetooth OPP service is no longer needed. + * @param[in] destination The destination path + * @param[in] push_requested_cb The callback called when a push is requested + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_opp_server_push_requested_cb() + * @see bt_opp_server_deinitialize() + * @see bt_opp_server_accept() + * @see bt_opp_server_reject() + */ +int bt_opp_server_initialize(const char *destination, bt_opp_server_push_requested_cb push_requested_cb, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the call event to the remote bluetooth device. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @remarks Before notifying #BT_AG_CALL_EVENT_ANSWERED or #BT_AG_CALL_EVENT_DIALING, you should open SCO(Synchronous Connection Oriented link) + * if Bluetooth Hands-Free need SCO connection. + * @param[in] event The call event + * @param[in] call_id The call ID + * @param[in] phone_number The phone number. You must set this value in case of #BT_AG_CALL_EVENT_DIALING and #BT_AG_CALL_EVENT_INCOMING. + * In other cases, this value can be NULL. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @see bt_audio_connect() + */ +int bt_ag_notify_call_event(bt_ag_call_event_e event, unsigned int call_id, const char *phone_number); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the call list to the remote bluetooth device. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] list The call list + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @see bt_audio_connect() + */ +int bt_ag_notify_call_list(bt_call_list_h list); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the state of voice recognition. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] state The state of voice recognition: (@c true = enabled, @c false = disabled) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @see bt_audio_connect() + */ +int bt_ag_notify_voice_recognition_state(bool state); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when a call handling event happened from Hands-Free. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_call_handling_event_cb() + * @see bt_ag_unset_call_handling_event_cb() + */ +int bt_ag_set_call_handling_event_cb(bt_ag_call_handling_event_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when a call handling event happened from Hands-Free. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_call_handling_event_cb() + * @see bt_ag_set_call_handling_event_cb() + */ +int bt_ag_unset_call_handling_event_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when a multi call handling event happened from Hands-Free. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_multi_call_handling_event_cb() + * @see bt_ag_unset_multi_call_handling_event_cb() + */ +int bt_ag_set_multi_call_handling_event_cb(bt_ag_multi_call_handling_event_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when a multi call handling event happened from Hands-Free. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_multi_call_handling_event_cb() + * @see bt_ag_set_multi_call_handling_event_cb() + */ +int bt_ag_unset_multi_call_handling_event_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when a DTMF(Dual Tone Multi Frequency) is transmitted from Hands-Free. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_dtmf_transmitted_cb() + * @see bt_ag_unset_dtmf_transmitted_cb() + */ +int bt_ag_set_dtmf_transmitted_cb(bt_ag_dtmf_transmitted_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when a DTMF(Dual Tone Multi Frequency) is transmitted from Hands-Free. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_dtmf_transmitted_cb() + * @see bt_ag_set_dtmf_transmitted_cb() + */ +int bt_ag_unset_dtmf_transmitted_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the speaker gain to the remote device. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @details This function sends a signal to the remote device. This signal has the gain value. + * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. + * When the speaker gain of remote device is changed to the requested gain, bt_audio_speaker_gain_changed_cb() will be called. + * @param[in] gain The gain of speaker (0 ~ 15) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. + * @see bt_ag_get_speaker_gain() + * @see bt_ag_set_speaker_gain_changed_cb() + * @see bt_ag_unset_speaker_gain_changed_cb() + */ +int bt_ag_notify_speaker_gain(int gain); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Gets the current speaker gain of the remote device. + * @since_tizen 2.3 + * @details This function gets the value of speaker gain of the remote device. + * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. + * @param[out] gain The gain of speaker (0 ~ 15) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. + * @see bt_ag_notify_speaker_gain() + * @see bt_ag_set_speaker_gain_changed_cb() + * @see bt_ag_unset_speaker_gain_changed_cb() + */ +int bt_ag_get_speaker_gain(int *gain); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Checks whether the remoted device enables NREC(Noise Reduction and Echo Canceling) or not. + * @since_tizen 2.3 + * @param[out] enabled The NREC status: (@c true = enabled, @c false = not enabled) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. + * @see bt_audio_connect() + */ +int bt_ag_is_nrec_enabled(bool *enabled); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when the speaker gain of the remote device is changed. + * @since_tizen 2.3 + * @details This function let you know the change of the speaker gain of the remote device. + * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_unset_speaker_gain_changed_cb() + */ +int bt_ag_set_speaker_gain_changed_cb(bt_ag_speaker_gain_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when the speaker gain of the remote device is changed. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_set_speaker_gain_changed_cb() + */ +int bt_ag_unset_speaker_gain_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when the microphone gain of the remote device is changed. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_unset_microphone_gain_changed_cb() + */ +int bt_ag_set_microphone_gain_changed_cb(bt_ag_microphone_gain_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when the microphone gain of the remote device is changed. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_set_microphone_gain_changed_cb() + */ +int bt_ag_unset_microphone_gain_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE + * @brief Creates a handle of call list. + * @since_tizen 2.3 + * @param[out] list The handle of call list + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_call_list_destroy() + */ +int bt_call_list_create(bt_call_list_h *list); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE + * @brief Destroys the handle of call list. + * @since_tizen 2.3 + * @param[in] list The handle of call list + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_call_list_create() + */ +int bt_call_list_destroy(bt_call_list_h list); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE + * @brief Resets the handle of call list. + * @since_tizen 2.3 + * @param[in] list The handle of call list + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_call_list_create() + */ +int bt_call_list_reset(bt_call_list_h list); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE + * @brief Adds a call to the handle of call list. + * @since_tizen 2.3 + * @param[in] list The handle of call list + * @param[in] call_id The call ID + * @param[in] state The state of audio gate call + * @param[in] phone_number The phone number. You must set this value in case of #BT_AG_CALL_EVENT_DIALING and #BT_AG_CALL_EVENT_INCOMING. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_call_list_create() + */ +int bt_call_list_add(bt_call_list_h list, unsigned int call_id, bt_ag_call_state_e state, const char *phone_number); + +/** * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE * @brief Checks whether the remoted device is wbs (Wide Band Speech) mode or not. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif @@ -812,6 +1919,22 @@ int bt_gatt_characteristic_add_descriptor(bt_gatt_h characteristic, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Updates the properties which a characteristic's GATT handle has + * @since_tizen 2.4 + * + * @param[in] characteristic The characteristic's GATT handle + * @param[in] properties The properties to be updated + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_property_e + */ +int bt_gatt_characteristic_set_properties(bt_gatt_h characteristic, int properties); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE * @brief Creates the GATT characteristic descriptor * @since_tizen 2.4 * @@ -921,6 +2044,25 @@ int bt_gatt_server_set_read_value_requested_cb(bt_gatt_h gatt_handle, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Registers a callback function to be invoked when the remote device enables or disables the Notification/Indication for particular characteristics. + * @since_tizen 2.4 + * + * @param[in] gatt_handle The GATT handle of a characteristic or descriptor + * @param[in] callback The callback to be invoked + * @param[in] user_data The user data to be passed to @a callback function + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_notification_state_change_cb() + */ +int bt_gatt_server_set_notification_state_change_cb(bt_gatt_h gatt_handle, + bt_gatt_server_notification_state_change_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE * @brief Registers a callback function to be invoked when a value of a characteristic or descriptor has been changed by a remote device(GATT client)'s request * @since_tizen 2.4 * @@ -1590,6 +2732,238 @@ int bt_avrcp_control_get_track_info(bt_avrcp_metadata_attributes_info_s **track) int bt_avrcp_control_free_track_info(bt_avrcp_metadata_attributes_info_s *track); /** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Activates the NAP(Network Access Point). + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED + * @see bt_nap_deactivate() + */ +int bt_nap_activate(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Deactivates the NAP(Network Access Point). + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). + * @see bt_nap_activate() + */ +int bt_nap_deactivate(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Disconnects the all PANUs(Personal Area Networking User) which are connected to you. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). + * @see bt_nap_activate() + */ +int bt_nap_disconnect_all(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Disconnects the specified PANU(Personal Area Networking User) which is connected to you. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] remote_address The remote address + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). + * @see bt_nap_activate() + */ +int bt_nap_disconnect(const char *remote_address); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Registers a callback function that will be invoked when the connection state changes. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_nap_connection_state_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_nap_connection_state_changed_cb() + * @see bt_nap_unset_connection_state_changed_cb() + */ +int bt_nap_set_connection_state_changed_cb(bt_nap_connection_state_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Unregisters a callback function that will be invoked when the connection state changes. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_nap_connection_state_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_nap_connection_state_changed_cb() + * @see bt_nap_set_connection_state_changed_cb() + */ +int bt_nap_unset_connection_state_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE + * @brief Registers a callback function that will be invoked when the connection state changes. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_nap_connection_state_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_panu_connection_state_changed_cb() + * @see bt_panu_unset_connection_state_changed_cb() + */ +int bt_panu_set_connection_state_changed_cb(bt_panu_connection_state_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE + * @brief Unregisters a callback function that will be invoked when the connection state changes. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_nap_connection_state_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_panu_connection_state_changed_cb() + * @see bt_panu_set_connection_state_changed_cb() + */ +int bt_panu_unset_connection_state_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE + * @brief Connects the remote device with the PAN(Personal Area Networking) service, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] remote_address The remote address + * @param[in] type The type of PAN service + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The local device must be bonded with the remote device by bt_device_create_bond(). + * @post bt_panu_connection_state_changed_cb() will be invoked. + * @see bt_panu_disconnect() + * @see bt_panu_connection_state_changed_cb() + */ +int bt_panu_connect(const char *remote_address, bt_panu_service_type_e type); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE + * @brief Disconnects the remote device with the PAN(Personal Area Networking) service, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] remote_address The remote address + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected by bt_panu_connect(). + * @post bt_panu_connection_state_changed_cb() will be invoked. + * @see bt_panu_connect() + * @see bt_panu_connection_state_changed_cb() + */ +int bt_panu_disconnect(const char *remote_address); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief update LE connection. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @pre The remote device must be connected with bt_gatt_connect(). + */ +int bt_device_le_conn_update(const char *device_address, + const bt_le_conn_update_s *parameters); + +/** * @} */ diff --git a/include/mobile/bluetooth_type.h b/include/mobile/bluetooth_type.h index 96aa359..fe6405e 100644 --- a/include/mobile/bluetooth_type.h +++ b/include/mobile/bluetooth_type.h @@ -75,18 +75,6 @@ typedef enum } bt_adapter_state_e; /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Enumerations of the Bluetooth adapter le state. - * @since_tizen 2.3 - */ -typedef enum -{ - BT_ADAPTER_LE_DISABLED = 0x00, /**< Bluetooth le is disabled */ - BT_ADAPTER_LE_ENABLED, /**< Bluetooth le is enabled */ -} bt_adapter_le_state_e; - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Enumerations of the Bluetooth visibility mode. * @since_tizen 2.3 @@ -242,13 +230,14 @@ typedef enum typedef enum { BT_PROFILE_RFCOMM = 0x01, /**< RFCOMM Profile */ - BT_PROFILE_A2DP = 0x02, /**< Advanced Audio Distribution Profile */ + BT_PROFILE_A2DP = 0x02, /**< Advanced Audio Distribution Profile Source role */ BT_PROFILE_HSP = 0x04, /**< Headset Profile */ BT_PROFILE_HID = 0x08, /**< Human Interface Device Profile */ BT_PROFILE_NAP = 0x10, /**< Network Access Point Profile */ BT_PROFILE_AG = 0x20, /**< Audio Gateway Profile */ BT_PROFILE_GATT = 0x40, /**< Generic Attribute Profile */ BT_PROFILE_NAP_SERVER = 0x80, /**< NAP server Profile */ + BT_PROFILE_A2DP_SINK = 0x100, /**< Advanced Audio Distribution Profile Sink role */ } bt_profile_e; /** @@ -479,7 +468,6 @@ typedef enum { } bt_audio_profile_type_e; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE * @brief Enumerations for the call handling event * @since_tizen 2.3 @@ -491,7 +479,6 @@ typedef enum { } bt_ag_call_handling_event_e; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE * @brief Enumerations for the multi call handling event * @since_tizen 2.3 @@ -505,42 +492,9 @@ typedef enum { } bt_ag_multi_call_handling_event_e; /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Enumerations for the call state - * @since_tizen 2.3 - */ -typedef enum { - BT_AG_CALL_EVENT_IDLE = 0x00, /**< Idle */ - BT_AG_CALL_EVENT_ANSWERED, /**< Answered */ - BT_AG_CALL_EVENT_HELD, /**< Held */ - BT_AG_CALL_EVENT_RETRIEVED, /**< Retrieved */ - BT_AG_CALL_EVENT_DIALING, /**< Dialing */ - BT_AG_CALL_EVENT_ALERTING, /**< Alerting */ - BT_AG_CALL_EVENT_INCOMING, /**< Incoming */ -} bt_ag_call_event_e; - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Enumerations for the call state - * @since_tizen 2.3 - */ -typedef enum { - BT_AG_CALL_STATE_IDLE = 0x00, /**< Idle state */ - BT_AG_CALL_STATE_ACTIVE, /**< Active state */ - BT_AG_CALL_STATE_HELD, /**< Held state */ - BT_AG_CALL_STATE_DIALING, /**< Dialing state */ - BT_AG_CALL_STATE_ALERTING, /**< Alerting state */ - BT_AG_CALL_STATE_INCOMING, /**< Incoming state */ - BT_AG_CALL_STATE_WAITING, /**< Waiting for connected indication event after answering an incoming call*/ -} bt_ag_call_state_e; - -/** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Enumerations for the equalizer state - * @since_tizen 2.3 + * @since_tizen 2.4 */ typedef enum { BT_AVRCP_EQUALIZER_STATE_OFF = 0x01, /**< Equalizer Off */ @@ -548,10 +502,9 @@ typedef enum { } bt_avrcp_equalizer_state_e; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Enumerations for the repeat mode - * @since_tizen 2.3 + * @since_tizen 2.4 */ typedef enum { BT_AVRCP_REPEAT_MODE_OFF = 0x01, /**< Repeat Off */ @@ -561,10 +514,9 @@ typedef enum { } bt_avrcp_repeat_mode_e; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Enumerations for the shuffle mode - * @since_tizen 2.3 + * @since_tizen 2.4 */ typedef enum { BT_AVRCP_SHUFFLE_MODE_OFF = 0x01, /**< Shuffle Off */ @@ -573,10 +525,9 @@ typedef enum { } bt_avrcp_shuffle_mode_e; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Enumerations for the scan mode - * @since_tizen 2.3 + * @since_tizen 2.4 */ typedef enum { BT_AVRCP_SCAN_MODE_OFF = 0x01, /**< Scan Off */ @@ -585,10 +536,9 @@ typedef enum { } bt_avrcp_scan_mode_e; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Enumerations for the player state - * @since_tizen 2.3 + * @since_tizen 2.4 */ typedef enum { BT_AVRCP_PLAYER_STATE_STOPPED = 0x00, /**< Stopped */ @@ -888,22 +838,6 @@ typedef struct } bt_device_connection_info_s; /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Device LE connection update structure. - * @since_tizen 2.3 - * - * @see bt_device_le_conn_update() - */ -typedef struct -{ - unsigned int interval_min; /**< Minimum value for the connection event interval (msec) */ - unsigned int interval_max; /**< Maximum value for the connection event interval (msec) */ - unsigned int latency; /**< Slave latency (msec) */ - unsigned int time_out; /**< Supervision timeout (msec) */ -} bt_le_conn_update_s; - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE * @brief Rfcomm connection data used for exchanging data between Bluetooth devices. * @since_tizen 2.3 @@ -1040,26 +974,6 @@ typedef void (*bt_adapter_device_discovery_state_changed_cb) typedef bool (*bt_adapter_bonded_device_cb)(bt_device_info_s *device_info, void *user_data); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Called when the connectable state changes. - * @since_tizen 2.3 - * - * @param[in] result The result of the connectable state changing - * @param[in] connectable The connectable to be changed - * @param[in] user_data The user data passed from the callback registration function - * - * @pre This function will be invoked when the connectable state of local Bluetooth adapter changes - * if you register this callback using bt_adapter_set_connectable_changed_cb(). - * - * @see bt_adapter_set_connectable() - * @see bt_adapter_set_connectable_changed_cb() - * @see bt_adapter_unset_connectable_changed_cb() - */ -typedef void (*bt_adapter_connectable_changed_cb) - (int result, bool connectable, void *user_data); - -/** * @deprecated Deprecated since 2.3.1 * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE * @brief Called when the state of LE device discovery changes. @@ -1119,23 +1033,6 @@ typedef void (*bt_adapter_le_advertising_state_changed_cb)(int result, bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, void *user_data); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Called when the Bluetooth adapter le state changes. - * @since_tizen 2.3 - * - * @param[in] result The result of the adapter state changing - * @param[in] adapter_le_state The adapter le state to be changed - * @param[in] user_data The user data passed from the callback registration function - * @pre Either bt_adapter_le_enable() or bt_adapter_le_disable() will invoke this callback if you register this callback using bt_adapter_le_set_state_changed_cb(). - * @see bt_adapter_le_enable() - * @see bt_adapter_le_disable() - * @see bt_adapter_le_set_state_changed_cb() - * @see bt_adapter_le_unset_state_changed_cb() - */ -typedef void (*bt_adapter_le_state_changed_cb)(int result, bt_adapter_le_state_e adapter_le_state, void *user_data); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Called when the process of creating bond finishes. * @since_tizen 2.3 @@ -1192,7 +1089,6 @@ typedef bool (*bt_device_connected_profile)(bt_profile_e profile, void *user_dat typedef void (*bt_device_bond_destroyed_cb)(int result, char *remote_address, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Called when the authorization of device changes. * @since_tizen 2.3 @@ -1279,40 +1175,19 @@ typedef void (*bt_socket_connection_state_changed_cb) (int result, bt_socket_connection_state_e connection_state, bt_socket_connection_s *connection, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE * @brief Called when a RFCOMM connection is requested. * @since_tizen 2.3 * - * @details You must call bt_socket_accept() if you want to accept. Otherwise, you must call bt_socket_reject(). * @param[in] socket_fd The file descriptor of socket on which a connection is requested * @param[in] remote_address The address of remote device * @param[in] user_data The user data passed from the callback registration function - * @pre If you register this callback function by bt_socket_set_connection_requested_cb() and listen a socket by bt_socket_listen(), + * @pre If you register this callback function by bt_socket_set_connection_requested_cb(), * bt_socket_connection_requested_cb() will be invoked. - * @see bt_socket_listen() - * @see bt_socket_accept() - * @see bt_socket_reject() */ typedef void (*bt_socket_connection_requested_cb) (int socket_fd, const char *remote_address, void *user_data); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE - * @brief Called when the push is requested. - * @since_tizen 2.3 - * - * @details You must call bt_opp_server_accept() if you want to accept. - * Otherwise, you must call bt_opp_server_reject(). - * @param[in] file The path of file to be pushed - * @param[in] size The file size (bytes) - * @param[in] user_data The user data passed from the callback registration function - * @see bt_opp_server_initialize() - */ -typedef void (*bt_opp_server_push_requested_cb)(const char *file, int size, void *user_data); - -/** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE * @brief Called when an OPP connection is requested. * @since_tizen 2.3 @@ -1412,23 +1287,6 @@ typedef void (*bt_audio_connection_state_changed_cb) (int result, bool connected /** * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Called when the SCO(Synchronous Connection Oriented link) state is changed. - * @since_tizen 2.3 - * - * @details This callback is called when the SCO state is changed. - * When you call bt_ag_open_sco() or bt_ag_close_sco(), this callback is also called with error result even though these functions failed. - * @param[in] result The result of changing the connection state - * @param[in] opened The state to be changed: (@c true = opened, @c false = not opened) - * @param[in] user_data The user data passed from the callback registration function - * @see bt_ag_set_sco_state_changed_cb() - * @see bt_ag_unset_sco_state_changed_cb() - * @see bt_ag_open_sco() - * @see bt_ag_close_sco() - */ -typedef void (*bt_ag_sco_state_changed_cb) (int result, bool opened, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE * @brief Called when a call handling event happened from Hands-Free. * @since_tizen 2.3 * diff --git a/include/mobile/bluetooth_type_extension.h b/include/mobile/bluetooth_type_extension.h new file mode 100644 index 0000000..4018e6c --- /dev/null +++ b/include/mobile/bluetooth_type_extension.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_NETWORK_BLUETOOTH_TYPE_EXTENSION_H__ +#define __TIZEN_NETWORK_BLUETOOTH_TYPE_EXTENSION_H__ + + #ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** + * @file bluetooth_type_extension.h + */ + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Called when the SCO(Synchronous Connection Oriented link) state is changed. + * @since_tizen 2.3 + * + * @details This callback is called when the SCO state is changed. + * When you call bt_ag_open_sco() or bt_ag_close_sco(), this callback is also called with error result even though these functions failed. + * @param[in] result The result of changing the connection state + * @param[in] opened The state to be changed: (@c true = opened, @c false = not opened) + * @param[in] user_data The user data passed from the callback registration function + * @see bt_ag_set_sco_state_changed_cb() + * @see bt_ag_unset_sco_state_changed_cb() + * @see bt_ag_open_sco() + * @see bt_ag_close_sco() + */ +typedef void (*bt_ag_sco_state_changed_cb) (int result, bool opened, void *user_data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // __TIZEN_NETWORK_BLUETOOTH_TYPE_EXTENSION_H__ diff --git a/include/mobile/bluetooth_type_internal.h b/include/mobile/bluetooth_type_internal.h index c1be7e8..afa3534 100644 --- a/include/mobile/bluetooth_type_internal.h +++ b/include/mobile/bluetooth_type_internal.h @@ -29,6 +29,96 @@ extern "C" /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Enumerations of the Bluetooth adapter le state. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_ADAPTER_LE_DISABLED = 0x00, /**< Bluetooth le is disabled */ + BT_ADAPTER_LE_ENABLED, /**< Bluetooth le is enabled */ +} bt_adapter_le_state_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Called when the Bluetooth adapter le state changes. + * @since_tizen 2.3 + * + * @param[in] result The result of the adapter state changing + * @param[in] adapter_le_state The adapter le state to be changed + * @param[in] user_data The user data passed from the callback registration function + * @pre Either bt_adapter_le_enable() or bt_adapter_le_disable() will invoke this callback if you register this callback using bt_adapter_le_set_state_changed_cb(). + * @see bt_adapter_le_enable() + * @see bt_adapter_le_disable() + * @see bt_adapter_le_set_state_changed_cb() + * @see bt_adapter_le_unset_state_changed_cb() + */ +typedef void (*bt_adapter_le_state_changed_cb)(int result, bt_adapter_le_state_e adapter_le_state, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Enumerations for the call state + * @since_tizen 2.3 + */ +typedef enum { + BT_AG_CALL_EVENT_IDLE = 0x00, /**< Idle */ + BT_AG_CALL_EVENT_ANSWERED, /**< Answered */ + BT_AG_CALL_EVENT_HELD, /**< Held */ + BT_AG_CALL_EVENT_RETRIEVED, /**< Retrieved */ + BT_AG_CALL_EVENT_DIALING, /**< Dialing */ + BT_AG_CALL_EVENT_ALERTING, /**< Alerting */ + BT_AG_CALL_EVENT_INCOMING, /**< Incoming */ +} bt_ag_call_event_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Enumerations for the call state + * @since_tizen 2.3 + */ +typedef enum { + BT_AG_CALL_STATE_IDLE = 0x00, /**< Idle state */ + BT_AG_CALL_STATE_ACTIVE, /**< Active state */ + BT_AG_CALL_STATE_HELD, /**< Held state */ + BT_AG_CALL_STATE_DIALING, /**< Dialing state */ + BT_AG_CALL_STATE_ALERTING, /**< Alerting state */ + BT_AG_CALL_STATE_INCOMING, /**< Incoming state */ + BT_AG_CALL_STATE_WAITING, /**< Waiting for connected indication event after answering an incoming call*/ +} bt_ag_call_state_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when the connectable state changes. + * @since_tizen 2.3 + * + * @param[in] result The result of the connectable state changing + * @param[in] connectable The connectable to be changed + * @param[in] user_data The user data passed from the callback registration function + * + * @pre This function will be invoked when the connectable state of local Bluetooth adapter changes + * if you register this callback using bt_adapter_set_connectable_changed_cb(). + * + * @see bt_adapter_set_connectable() + * @see bt_adapter_set_connectable_changed_cb() + * @see bt_adapter_unset_connectable_changed_cb() + */ +typedef void (*bt_adapter_connectable_changed_cb) + (int result, bool connectable, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Called when the push is requested. + * @since_tizen 2.3 + * + * @details You must call bt_opp_server_accept() if you want to accept. + * Otherwise, you must call bt_opp_server_reject(). + * @param[in] file The path of file to be pushed + * @param[in] size The file size (bytes) + * @param[in] user_data The user data passed from the callback registration function + * @see bt_opp_server_initialize() + */ +typedef void (*bt_opp_server_push_requested_cb)(const char *file, int size, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE * @brief Enumerations of the Bluetooth adapter le scan type. * @since_tizen 2.3 */ @@ -51,7 +141,6 @@ typedef enum } bt_adapter_le_scan_mode_e; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Called when the manufacturer dat changes. * @since_tizen 2.3 @@ -140,6 +229,20 @@ typedef void (*bt_gatt_server_read_value_requested_cb) (char *remote_address, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Called when the remote device enables or disables the Notification/Indication for particular characteristics. + * @since_tizen 2.4 + * + * @param[in] server The GATT server handle + * @param[in] gatt_handle The characteristic's GATT handle to be read + * @param[in] user_data The user data passed from the registration function + * + * @see bt_gatt_server_set_read_value_requested_cb() + */ +typedef void (*bt_gatt_server_notification_state_change_cb) (bool notify, + bt_gatt_server_h server, bt_gatt_h gatt_handle, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE * @brief Called when the sending notification / indication is done * @since_tizen 2.4 * @@ -161,7 +264,6 @@ typedef void (*bt_gatt_server_notification_sent_cb) (int result, bt_gatt_h characteristic, bool completed, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Enumerations for the player control command * @since_tizen 2.3 @@ -176,8 +278,7 @@ typedef void (*bt_gatt_server_notification_sent_cb) (int result, BT_AVRCP_CONTROL_REWIND /**< Rewind */ } bt_avrcp_player_command_e; - /** - * @internal +/** * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Structure of Track metadata information. * @since_tizen 2.3 @@ -195,7 +296,6 @@ typedef struct { } bt_avrcp_metadata_attributes_info_s; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Called when the connection state is changed. * @since_tizen 2.3 @@ -244,6 +344,19 @@ typedef void (*bt_avrcp_track_info_changed_cb) (bt_avrcp_metadata_attributes_inf typedef void (*bt_avrcp_play_status_changed_cb) (bt_avrcp_player_state_e play_state, void *user_data); /** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Device LE connection update structure. + * @since_tizen 2.3 + */ +typedef struct +{ + unsigned int interval_min; /**< Minimum value for the connection event interval (msec) */ + unsigned int interval_max; /**< Maximum value for the connection event interval (msec) */ + unsigned int latency; /**< Slave latency (msec) */ + unsigned int time_out; /**< Supervision timeout (msec) */ +} bt_le_conn_update_s; + +/** * @} */ diff --git a/include/tv/BTLogger.h b/include/tv/BTLogger.h new file mode 100644 index 0000000..e17691b --- /dev/null +++ b/include/tv/BTLogger.h @@ -0,0 +1,95 @@ +/* + * Bluetooth Configuration Module + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + /** + * This file declares Logger functions for Logger Interface. + * + * @file BTLogger.h + * @author Amit Kumar Verma + */ + + +#ifndef __BT_LOGGER_H__ +#define __BT_LOGGER_H__ + +#include <logger/ILogger.h> +#include <capi-system-info/system_info.h> +#include <iostream> + +using namespace std; + +typedef enum e_KPIEVENT{ + SC_BATTERY_STATUS = 0, + APPID, + SPEAKER_MODEL, + RSSI_LEVEL, +}KPIEVENT; + +class CBTLogger +{ + private: + + ILogger* logger = NULL; + int mQueueMax; + int mExpiration; + int mLoglevel; + int mLoglevelForEvent; + int mThreshHold; + unsigned long lTime; + + //Start and end event Epoch time. + unsigned long lCurTime; + unsigned long lEndTime; + + //KPI Log data members. + std::string mServiceName; + std::string mEventName; + std::string mStartTime; + std::string mEndTime; + std::string mCategory; + std::string mValue; + std::string mDesc; + std::string mLog; + std::string mCountryCode; + std::string mServerURL; + std::string strModelName; + std::string strUserID; + std::string strDUID; + + public: + CBTLogger(); + CBTLogger(const CBTLogger &Cbtlogger); + CBTLogger & operator = (const CBTLogger &Cbtlogger); + + bool m_GetData(string& cInput,system_info_key_e key); + void m_GetConnectInfo(string &mModelName, string &mUserID, string &mDUID); + string m_GetProductSWVersion(); + bool m_Send_RC_Battery_Status_to_BTLogger(unsigned char batteryStatus); + bool m_AddFullLog(string eventName, string msgLog); + string m_ConvertToFormatTime(); + bool m_ParseConfigXml(string strFileUrl, KPIEVENT eventName); + bool m_Send_AppID_to_BTLogger(long Timeduration, const char * appid); + void m_DestroyILogger(void); + bool m_Send_Event_to_Logger(KPIEVENT eventName); + bool m_Send_Speaker_Details_to_BTLogger(const char * DeviceName,const char * Model); + bool m_Send_RSSI_Level_to_BTLogger(unsigned short pid, int rssi); + ~CBTLogger(); + +}; +#endif diff --git a/include/tv/BTLogger_interface.h b/include/tv/BTLogger_interface.h new file mode 100644 index 0000000..b9c583d --- /dev/null +++ b/include/tv/BTLogger_interface.h @@ -0,0 +1,95 @@ +/* + * Bluetooth Configuration Module + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + /** + * This file declares Logger functions for Logger Interface. + * + * @file BTLogger_interface.h + * @author Amit Kumar Verma + */ + + +#ifndef __BT_LOGGER_INTERFACE__ +#define __BT_LOGGER_INTERFACE__ + +#if defined __cplusplus + extern "C" { +#endif + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @bt_Send_App_ID_to_BTLogger + * + * @param[in] TimeDuration + * @param[in] long + + * @return true on success, otherwise a false + */ +bool bt_Send_App_ID_to_BTLogger(long TimeDuration, const char *appid); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @bt_Send_SC_Battery_Status_to_BTLogger + * + * @param[in] batteryStat + * @param[in] unsigned char + + * @return true on success, otherwise a false + */ +bool bt_Send_SC_Battery_Status_to_BTLogger(unsigned char batteryStat); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @bt_Send_Speaker_Details_to_BTLogger + * + * @param[in1] DeviceName of Remote Device + * @param[in1] const char* + + * @param[in2] Model Number + * @param[in2] const char* + + * @return true on success, otherwise a false + */ +bool bt_Send_Speaker_Details_to_BTLogger(const char*DeviceName, const char *Model); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @bt_Send_RSSI_Level_to_BTLogger + * + * @param[in1] Pid of device + * @param[in1] unsigned short + + * @param[in2] App id + * @param[in2] const char* + + * @param[in3] RSSI Level + * @param[in3] int + + * @return true on success, otherwise a false + */ +bool bt_Send_RSSI_Level_to_BTLogger(unsigned short pid, int rssi); + + +#if defined __cplusplus + } +#endif +#endif + diff --git a/include/tv/bluetooth.h b/include/tv/bluetooth.h new file mode 100644 index 0000000..35c99dc --- /dev/null +++ b/include/tv/bluetooth.h @@ -0,0 +1,4163 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_NETWORK_BLUETOOTH_H__ +#define __TIZEN_NETWORK_BLUETOOTH_H__ + +#include <stdlib.h> +#include <unistd.h> +#include <stdbool.h> +#include <tizen_error.h> + +#include "bluetooth_internal.h" +#include "bluetooth_extension.h" +#include "bluetooth_product.h" +#include "bluetooth_type.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** + * @file bluetooth.h + * @brief API to control the Bluetooth adapter and devices and communications. + * @ingroup CAPI_NETWORK_BLUETOOTH_MODULE + */ + + +/** + * @addtogroup CAPI_NETWORK_BLUETOOTH_MODULE + * @{ + */ + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_MODULE + * @brief Initializes the Bluetooth API. + * @since_tizen 2.3 + * + * @remarks This function must be called before Bluetooth API starts. \n + * You must free all resources of the Bluetooth service by calling bt_deinitialize() if Bluetooth service is no longer needed. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_deinitialize() + */ +int bt_initialize(void); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_MODULE + * @brief Releases all resources of the Bluetooth API. + * @since_tizen 2.3 + * + * @remarks This function must be called if Bluetooth API is no longer needed. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre Bluetooth API must be initialized with bt_initialize(). + * + * @see bt_initialize() + */ +int bt_deinitialize(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Gets the current state of local Bluetooth adapter. + * @since_tizen 2.3 + * + * @param[out] adapter_state The current adapter state + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + */ +int bt_adapter_get_state(bt_adapter_state_e *adapter_state); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Gets the address of local Bluetooth adapter. + * @since_tizen 2.3 + * + * @remarks The @a local_address must be released with free() by you. + * + * @param[out] local_address The device address of local Bluetooth adapter + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @see bt_adapter_get_name() + */ +int bt_adapter_get_address(char **local_address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Gets the name of local Bluetooth adapter. + * @since_tizen 2.3 + * + * @details Use this function to get the friendly name associated with Bluetooth + * device, retrieved by the remote Bluetooth devices. + * + * @remarks The @a local_name must be released with free() by you. + * + * @param[out] local_name The local device name + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * + * @see bt_adapter_set_name() + */ +int bt_adapter_get_name(char **local_name); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Sets the name of local Bluetooth adapter. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] local_name The name of the Bluetooth device. \n + * The maximum length is 248 characters. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post bt_adapter_name_changed_cb() will be invoked if this function returns #BT_ERROR_NONE. + * + * @see bt_adapter_get_name() + * @see bt_adapter_name_changed_cb() + * @see bt_adapter_set_name_changed_cb() + * @see bt_adapter_unset_name_changed_cb() + */ +int bt_adapter_set_name(const char *local_name); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Gets the visibility mode of local Bluetooth adapter. + * @since_tizen 2.3 + * @param[out] mode The visibility mode of the Bluetooth device + * @param[out] duration The duration until the visibility mode is changed to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE (in seconds). + * @a duration is valid only if @a mode is #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE. This value can be NULL. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + */ +int bt_adapter_get_visibility(bt_adapter_visibility_mode_e *mode, int *duration); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Starts the device discovery, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @details If a device is discovered, bt_adapter_device_discovery_state_changed_cb() will be invoked + * with #BT_ADAPTER_DEVICE_DISCOVERY_FOUND, and then bt_adapter_device_discovery_state_changed_cb() + * will be called with #BT_ADAPTER_DEVICE_DISCOVERY_FINISHED in case of the completion or cancellation of the discovery. + * + * @remarks To connect to peer Bluetooth device, you need to know its Bluetooth address. \n + * The device discovery can be stopped by bt_adapter_stop_device_discovery(). + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post This function invokes bt_adapter_device_discovery_state_changed_cb(). + * + * @see bt_adapter_is_discovering() + * @see bt_adapter_stop_device_discovery() + * @see bt_adapter_device_discovery_state_changed_cb() + * @see bt_adapter_set_device_discovery_state_changed_cb() + * @see bt_adapter_unset_device_discovery_state_changed_cb() + */ +int bt_adapter_start_device_discovery(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Stops the device discovery, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @remarks The device discovery process will take 10 ~ 20 seconds to get all the devices in vicinity. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOT_IN_PROGRESS Operation is not in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The device discovery must be in progress with bt_adapter_start_device_discovery(). + * @post This function invokes bt_adapter_device_discovery_state_changed_cb(). + * + * @see bt_adapter_is_discovering() + * @see bt_adapter_start_device_discovery() + * @see bt_adapter_set_device_discovery_state_changed_cb() + * @see bt_adapter_unset_device_discovery_state_changed_cb() + * @see bt_adapter_device_discovery_state_changed_cb() + */ +int bt_adapter_stop_device_discovery(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Checks for the device discovery is in progress or not. + * @since_tizen 2.3 + * + * @remarks If Bluetooth discovery is in progress, other operations are not allowed and + * you have to either stop the discovery operation, or wait for it to be finished, + * before performing other operations. + + * @param[out] is_discovering The discovering status: (@c true = in progress , @c false = not in progress ) + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * + * @see bt_adapter_start_device_discovery() + * @see bt_adapter_stop_device_discovery() + */ +int bt_adapter_is_discovering(bool *is_discovering); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Get the service mask from the uuid list. + * @since_tizen 2.3 + * + * @param[in] uuids The UUID list of the device. + * @param[in] no_of_service The number of the UUID list count. + * @param[out] service_mask_list Service mask list converted from the given UUID list. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_service_class_t + */ +int bt_device_get_service_mask_from_uuid_list(char **uuids, + int no_of_service, + bt_service_class_t *service_mask_list); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Retrieves the device information of all bonded devices. + * @since_tizen 2.3 + * + * @param [in] callback The callback function to invoke + * @param [in] user_data The user data passed from the foreach function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post This function invokes bt_adapter_bonded_device_cb(). + * + * @see bt_adapter_bonded_device_cb() + */ +int bt_adapter_foreach_bonded_device(bt_adapter_bonded_device_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Gets the device information of a bonded device. + * @since_tizen 2.3 + * @remarks The @a device_info must be released with bt_adapter_free_device_info() by you . + * + * @param [in] remote_address The address of remote device + * @param [out] device_info The bonded device information + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post This function invokes bt_adapter_bonded_device_cb(). + * + * @see bt_adapter_bonded_device_cb() + */ +int bt_adapter_get_bonded_device_info(const char *remote_address, bt_device_info_s **device_info); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Frees device info. + * @since_tizen 2.3 + * + * @param [in] device_info The bonded device information + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_adapter_get_bonded_device_info() + */ +int bt_adapter_free_device_info(bt_device_info_s *device_info); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Checks whether the UUID of service is used or not + * @since_tizen 2.3 + * @param[in] service_uuid The UUID of service + * @param[out] used Indicates whether the service is used or not + * @return true on success, otherwise false. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_adapter_is_service_used(const char *service_uuid, bool *used); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function to be invoked when the Bluetooth adapter state changes. + * @since_tizen 2.3 + * + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_state_changed_cb() will be invoked. + * + * @see bt_initialize() + * @see bt_adapter_state_changed_cb() + * @see bt_adapter_set_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb() + */ +int bt_adapter_set_state_changed_cb(bt_adapter_state_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + * @see bt_adapter_set_state_changed_cb() + */ +int bt_adapter_unset_state_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function to be invoked when the name of Bluetooth adapter changes. + * @since_tizen 2.3 + * + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_name_changed_cb() will be invoked. + * + * @see bt_initialize() + * @see bt_adapter_name_changed_cb() + * @see bt_adapter_unset_name_changed_cb() + */ +int bt_adapter_set_name_changed_cb(bt_adapter_name_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + * @see bt_adapter_set_name_changed_cb() + */ +int bt_adapter_unset_name_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function to be invoked when the visibility mode changes. + * @since_tizen 2.3 + * + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_visibility_mode_changed_cb() will be invoked. + * + * @see bt_initialize() + * @see bt_adapter_visibility_mode_changed_cb() + * @see bt_adapter_unset_visibility_mode_changed_cb() + */ +int bt_adapter_set_visibility_mode_changed_cb(bt_adapter_visibility_mode_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + * @see bt_adapter_set_visibility_mode_changed_cb() + */ +int bt_adapter_unset_visibility_mode_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function to be invoked every second + * @since_tizen 2.3 + * until the visibility mode is changed from #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE + * to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE. + * @details When you set visibility mode as #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE, + * @a callback will be called every second until visibility mode is changed to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE. + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @post bt_adapter_visibility_duration_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_adapter_visibility_duration_changed_cb() + * @see bt_adapter_unset_visibility_duration_changed_cb() + */ +int bt_adapter_set_visibility_duration_changed_cb(bt_adapter_visibility_duration_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + * @see bt_adapter_set_visibility_duration_changed_cb() + */ +int bt_adapter_unset_visibility_duration_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function to be invoked when the device discovery state changes. + * @since_tizen 2.3 + * + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_device_discovery_state_changed_cb() will be invoked. + * + * @see bt_initialize() + * @see bt_adapter_device_discovery_state_changed_cb() + * @see bt_adapter_set_device_discovery_state_changed_cb() + * @see bt_adapter_unset_device_discovery_state_changed_cb() + */ +int bt_adapter_set_device_discovery_state_changed_cb(bt_adapter_device_discovery_state_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + * @see bt_adapter_set_device_discovery_state_changed_cb() + */ +int bt_adapter_unset_device_discovery_state_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Get the Hash and Randmoizer value, synchronously. + * @since_tizen 2.3 + * + * @param[out] hash The hash value recieved from the controller + * @param[out] randomizer The hash value recieved from the controller + * @param[out] hash_len The length of the hash value + * @param[out] randomizer_len The length of the randomizer value + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + */ +int bt_adapter_get_local_oob_data(unsigned char **hash, unsigned char **randomizer, + int *hash_len, int *randomizer_len); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Sets the Hash and Randmoizer value, synchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] remote_address Remote device address + * @param[in] hash The hash value recieved from the controller + * @param[in] randomizer The hash value recieved from the controller + * @param[in] hash_len The length of the hash value. Allowed value is 16 + * @param[in] randomizer_len The length of the randomizer value. Allowed value is 16 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + */ +int bt_adapter_set_remote_oob_data(const char *remote_address, + unsigned char *hash, unsigned char *randomizer, + int hash_len, int randomizer_len); +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Deletes the Hash and Randomizer value, synchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] remote_address Remote device address + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + */ +int bt_adapter_remove_remote_oob_data(const char *remote_address); + +/** + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Starts the LE device discovery. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @details If a LE device is discovered, bt_adapter_le_device_discovery_state_changed_cb() +* will be invoked with #BT_ADAPTER_LE_DEVICE_DISCOVERY_FOUND, and then bt_adapter_le_device_discovery_state_changed_cb() + * will be called with #BT_ADAPTER_LE_DEVICE_DISCOVERY_FINISHED in case of the completion or cancellation of the discovery. + * + * @remarks To connect to peer Bluetooth device, you need to know its Bluetooth address. \n + * The device discovery can be stopped by bt_adapter_le_stop_device_discovery(). + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post This function invokes bt_adapter_le_device_discovery_state_changed_cb(). + * + * @see bt_adapter_le_is_discovering() + * @see bt_adapter_le_device_discovery_state_changed_cb() + * @see bt_adapter_le_set_device_discovery_state_changed_cb() + * @see bt_adapter_le_unset_device_discovery_state_changed_cb() + */ +int bt_adapter_le_start_device_discovery(void); + +/** + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Stops the LE device discovery, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOT_IN_PROGRESS Operation is not in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The device discovery must be in progress with bt_adapter_le_start_device_discovery(). + * @post This function invokes bt_adapter_le_device_discovery_state_changed_cb(). + * + * @see bt_adapter_le_is_discovering() + * @see bt_adapter_le_start_device_discovery() + * @see bt_adapter_le_set_device_discovery_state_changed_cb() + * @see bt_adapter_le_unset_device_discovery_state_changed_cb() + * @see bt_adapter_le_device_discovery_state_changed_cb() + */ +int bt_adapter_le_stop_device_discovery(void); + +/** + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Checks for the LE device discovery is in progress or not. + * @since_tizen 2.3 + * + * @remarks If Bluetooth LE discovery is in progress, other operations are not allowed and + * you have to either stop the LE discovery operation, or wait for it to be finished, + * before performing other operations. + + * @param[out] is_discovering The discovering status: (@c true = in progress , @c false = not in progress ) + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * + * @see bt_adapter_le_start_device_discovery() + * @see bt_adapter_le_stop_device_discovery() + */ +int bt_adapter_le_is_discovering(bool *is_discovering); + +/** + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Registers a callback function to be invoked when the LE device discovery state changes. + * @since_tizen 2.3 + * + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_le_device_discovery_state_changed_cb() will be invoked. + * + * @see bt_initialize() + * @see bt_adapter_le_device_discovery_state_changed_cb() + * @see bt_adapter_le_unset_device_discovery_state_changed_cb() + */ +int bt_adapter_le_set_device_discovery_state_changed_cb(bt_adapter_le_device_discovery_state_changed_cb callback, void *user_data); + +/** + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + * @see bt_adapter_le_set_device_discovery_state_changed_cb() + */ +int bt_adapter_le_unset_device_discovery_state_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Starts the LE scan to find LE advertisement. + * @since_tizen 2.3.1 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @details If a LE advertisement is found, bt_adapter_le_scan_result_cb() will be invoked. + * + * @param[in] cb The callback to report the result of this function + * @param[in] user_data The user data to be passed when callback is called + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post This function invokes bt_adapter_le_scan_result_cb(). + * + * @see bt_adapter_le_scan_result_cb() + */ +int bt_adapter_le_start_scan(bt_adapter_le_scan_result_cb cb, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Stops the LE scan. + * @since_tizen 2.3.1 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOT_IN_PROGRESS Operation is not in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The LE scan must be in progress with bt_adapter_le_start_scan(). + * + * @see bt_adapter_le_start_scan() + */ +int bt_adapter_le_stop_scan(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Gets the service UUID list from the scan result information + * @since_tizen 2.3.1 + * + * @remarks The @a uuids must be iterated as count and each pointed data must be released with free(). + * Then uuids must be released with free(). \n + * 16-bit service UUID or 128-bit service UUID is supported. (e.g. 180F, 0000180F-0000-1000-8000-00805F9B34FB) + * + * @param[in] info The scan result information + * @param[in] pkt_type The packet type + * @param[out] uuids The list of string of the service uuid + * @param[out] count The count of the service UUIDs + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NO_DATA No data available + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_scan_result_cb() + */ +int bt_adapter_le_get_scan_result_service_uuids(const bt_adapter_le_device_scan_result_info_s *info, + bt_adapter_le_packet_type_e pkt_type, char ***uuids, int *count); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Gets the device name from the scan result information + * @since_tizen 2.3.1 + * + * @remarks The @a name must be released with free() by you. + * + * @param[in] info The scan result information + * @param[in] pkt_type The packet type + * @param[out] name The device name + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NO_DATA No data available + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_scan_result_cb() + */ +int bt_adapter_le_get_scan_result_device_name(const bt_adapter_le_device_scan_result_info_s *info, + bt_adapter_le_packet_type_e pkt_type, char **name); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Gets the transmission power level from the scan result information + * @since_tizen 2.3.1 + * + * @param[in] info The scan result information + * @param[in] pkt_type The packet type + * @param[out] power_level The transmission power level in dBm + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NO_DATA No data available + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_scan_result_cb() + */ +int bt_adapter_le_get_scan_result_tx_power_level(const bt_adapter_le_device_scan_result_info_s *info, + bt_adapter_le_packet_type_e pkt_type, int *power_level); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Gets the service solicitation UUID list from the scan result information + * @since_tizen 2.3.1 + * + * @remarks The @a uuids must be iterated as count and each pointed data must be released with free(). + * Then uuids must be released with free(). \n + * 16-bit service solicitation UUID or 128-bit service solicitaion UUID is supported. + * (e.g. 180F, 0000180F-0000-1000-8000-00805F9B34FB) + * + * @param[in] info The scan result information + * @param[in] pkt_type The packet type + * @param[out] uuids The list of string of the service solicitation uuid + * @param[out] count The count of the service UUIDs + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NO_DATA No data available + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_scan_result_cb() + */ +int bt_adapter_le_get_scan_result_service_solicitation_uuids(const bt_adapter_le_device_scan_result_info_s *info, + bt_adapter_le_packet_type_e pkt_type, char ***uuids, int *count); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Gets the service data list from the scan result information + * @since_tizen 2.3.1 + * + * @remarks The @a data_list must be released with bt_adapter_le_free_service_data_list() by you . + * + * @param[in] info The scan result information + * @param[in] pkt_type The packet type + * @param[out] data_list The list of the service data + * @param[out] count The count of the service data list + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NO_DATA No data available + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_scan_result_cb() + */ +int bt_adapter_le_get_scan_result_service_data_list(const bt_adapter_le_device_scan_result_info_s *info, + bt_adapter_le_packet_type_e pkt_type, bt_adapter_le_service_data_s **data_list, int *count); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Frees service data list. + * @since_tizen 2.3.1 + * + * @param[in] data_list The list of the service data + * @param[in] count The count of the service data list + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_adapter_le_get_scan_result_service_data_list() + */ +int bt_adapter_le_free_service_data_list(bt_adapter_le_service_data_s *data_list, int count); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Gets the appearance from the scan result information + * @since_tizen 2.3.1 + * + * @param[in] info The scan result information + * @param[in] pkt_type The packet type + * @param[out] appearance The appearance + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NO_DATA No data available + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_scan_result_cb() + */ +int bt_adapter_le_get_scan_result_appearance(const bt_adapter_le_device_scan_result_info_s *info, + bt_adapter_le_packet_type_e pkt_type, int *appearance); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Gets the manufacturer data from the scan result information + * @since_tizen 2.3.1 + * + * @remarks The @a manufacturer_data must be released with free() by you. + * + * @param[in] info The scan result information + * @param[in] pkt_type The packet type + * @param[out] manufacturer_id The manufacturer ID + * @param[out] manufacturer_data The manufacturer data (byte array) + * @param[out] manufacturer_data_len The length of manufacturer data + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NO_DATA No data available + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_scan_result_cb() + */ +int bt_adapter_le_get_scan_result_manufacturer_data(const bt_adapter_le_device_scan_result_info_s *info, + bt_adapter_le_packet_type_e pkt_type, int *manufacturer_id, char **manufacturer_data, int *manufacturer_data_len); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Create advertiser to advertise device's existence or respond to LE scanning reqeust. + * @since_tizen 2.3 + * + * @param[out] advertiser The handle of advertiser + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_destroy_advertiser() + */ +int bt_adapter_le_create_advertiser(bt_advertiser_h *advertiser); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Destroy advertiser. + * @since_tizen 2.3 + * + * @param[out] advertiser The handle of advertiser + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_create_advertiser() + */ +int bt_adapter_le_destroy_advertiser(bt_advertiser_h advertiser); + +/** + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Set the data to be advertised or responded to scan request from LE scanning device. + * The maximum advertised or responded data size is 31 bytes + * including data type and system wide data. + * @since_tizen 2.3 + * + * @remarks In case the data_type is local name or tx power level, you don't need to input data + * because the data value is written automatically by system. + * + * @param[in] advertiser The handle of advertiser + * @param[in] pkt_type The packet type + * @param[in] data_type The data type that is included in packet + * @param[in] data The data to be advertised or be responded to scan request from LE scanning device, no need in case of LOCAL_NAME or TX_POWER_LEVEL + * @param[in] data_size The size of data to be set. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_QUOTA_EXCEEDED Quota exceeded + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_clear_advertising_data() + */ +int bt_adapter_le_add_advertising_data(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, bt_adapter_le_packet_data_type_e data_type, + void *data, unsigned int data_size); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Add a service UUID to advertise or scan response data. + * The maximum advertised or responded data size is 31 bytes + * including data type and system wide data. + * @since_tizen 2.3.1 + * + * @remarks 16-bit UUID or 128-bit UUID is supported. (e.g. 180F, 0000180F-0000-1000-8000-00805F9B34FB) + * + * @param[in] advertiser The handle of advertiser + * @param[in] pkt_type The packet type + * @param[in] uuid The string of the service UUID. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_QUOTA_EXCEEDED Quota exceeded + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_clear_advertising_data() + */ +int bt_adapter_le_add_advertising_service_uuid(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, const char *uuid); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Add a service solicitation UUID to advertise or scan response data. + * The maximum advertised or responded data size is 31 bytes + * including data type and system wide data. + * @since_tizen 2.3.1 + * + * @remarks 16-bit service solicitation UUID or 128-bit service solicitation UUID is supported. + * (e.g. 180F, 0000180F-0000-1000-8000-00805F9B34FB) + * + * @param[in] advertiser The handle of advertiser + * @param[in] pkt_type The packet type + * @param[in] uuid The string of the service solicitation UUID. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_QUOTA_EXCEEDED Quota exceeded + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_clear_advertising_data() + */ +int bt_adapter_le_add_advertising_service_solicitation_uuid(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, const char *uuid); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Add service data to advertise or scan response data. + * The maximum advertised or responded data size is 31 bytes + * including data type and system wide data. + * @since_tizen 2.3.1 + * + * @remarks 16-bit UUID is supported. (e.g. 180F) + * + * @param[in] advertiser The handle of advertiser + * @param[in] pkt_type The packet type + * @param[in] uuid 16-bit UUID of the service + * @param[in] service_data The service data + * @param[in] service_data_len The data length of service data + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_QUOTA_EXCEEDED Quota exceeded + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_clear_advertising_data() + */ +int bt_adapter_le_add_advertising_service_data(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, const char *uuid, + const char *service_data, int service_data_len); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Sets the external appearance of this device to advertise or scan response data. + * Please refer to the adopted Bluetooth specification for the the appearance. + * @since_tizen 2.3.1 + * + * @param[in] advertiser The handle of advertiser + * @param[in] pkt_type The packet type + * @param[in] appearance The external appearance of device + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_QUOTA_EXCEEDED Quota exceeded + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_clear_advertising_data() + */ +int bt_adapter_le_set_advertising_appearance(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, int appearance); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Add manufacturer specific data to advertise or scan response data. + * Please refer to the Bluetooth Assigned Numbers provided by the Bluetooth SIG for a list of existing company identifiers. + * The maximum advertised or responded data size is 31 bytes + * including data type and system wide data. + * @since_tizen 2.3.1 + * + * + * @param[in] advertiser The handle of advertiser + * @param[in] pkt_type The packet type + * @param[in] manufacturer_id Manufacturer identifier + * @param[in] manufacturer_data The manufacturer specific data + * @param[in] manufacturer_data_len The data length of manufacturer data + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_QUOTA_EXCEEDED Quota exceeded + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_clear_advertising_data() + */ +int bt_adapter_le_add_advertising_manufacturer_data(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, int manufacturer_id, const char *manufacturer_data, int manufacturer_data_len); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Set whether the device name should be included in advertise or scan response data. + * The maximum advertised or responded data size is 31 bytes + * including data type and system wide data. + * @since_tizen 2.3.1 + * + * @param[in] advertiser The handle of advertiser + * @param[in] pkt_type The packet type + * @param[in] include_name Whether the device name should be included + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_QUOTA_EXCEEDED Quota exceeded + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_clear_advertising_data() + */ +int bt_adapter_le_set_advertising_device_name(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, bool include_name); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Set whether the transmission power level should be included in advertise or scan response data. + * The maximum advertised or responded data size is 31 bytes + * including data type and system wide data. + * @since_tizen 2.3.1 + * + * @param[in] advertiser The handle of advertiser + * @param[in] pkt_type The packet type + * @param[in] include_tx_power Whether the transmission power level should be included + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_QUOTA_EXCEEDED Quota exceeded + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_clear_advertising_data() + */ +int bt_adapter_le_set_advertising_tx_power_level(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, bool include_tx_power); + +/** + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Unset the data to be advertised or responded to scan request from LE scanning device. + * @since_tizen 2.3 + * + * @param[in] advertiser The handle of advertiser + * @param[in] pkt_type The packet type + * @param[in] data_type The data type to be removed from selected packet + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_add_advertising_data() + * @see bt_adapter_le_clear_advertising_data() + */ +int bt_adapter_le_remove_advertising_data(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, bt_adapter_le_packet_data_type_e data_type); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Clear all data to be advertised or responded to scan request from LE scanning device. + * @since_tizen 2.3 + * + * @param[in] advertiser The handle of advertiser + * @param[in] pkt_type The packet type to be cleared + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_add_advertising_data() + */ +int bt_adapter_le_clear_advertising_data(bt_advertiser_h advertiser, bt_adapter_le_packet_type_e pkt_type); + +/** + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Start advertising with passed advertiser and advertising parameters. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @details Once Bluetooth advertising is started, nearby Bluetooth LE(Low Energy) supported + * devices can know this device's existence. And one of them can make a connection reqeust, + * if it is allowed. + * + * @param[in] advertiser The handle of advertiser + * @param[in] adv_params The parameters of advertising \n + * If NULL is passed, default values which are defined in driver / controller are used. + * @param[in] cb The callback to report the result of this function + * @param[in] user_data The user data to be passed when callback is called + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post This function invokes bt_adapter_le_advertising_state_changed_cb(). + * + * @see bt_adapter_le_stop_advertising() + * @see bt_adapter_le_advertising_state_changed_cb() + */ +int bt_adapter_le_start_advertising(bt_advertiser_h advertiser, bt_adapter_le_advertising_params_s *adv_params, + bt_adapter_le_advertising_state_changed_cb cb, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Stops the advertising. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] advertiser The handle of advertiser + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOT_IN_PROGRESS Operation is not in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The advertising must be going on with bt_adapter_le_start_advertising_new(). + * @post This function invokes bt_adapter_le_advertising_state_changed_cb(). + * + * @see bt_adapter_le_start_advertising_new() + * @see bt_adapter_le_advertising_state_changed_cb() + */ +int bt_adapter_le_stop_advertising(bt_advertiser_h advertiser); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Start advertising with passed advertiser and advertising parameters. + * @since_tizen 2.3.1 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @details Once Bluetooth advertising is started, nearby Bluetooth LE(Low Energy) supported + * devices can know this device's existence. And one of them can make a connection reqeust, + * if it is allowed. + * + * @param[in] advertiser The handle of advertiser + * @param[in] cb The callback to report the result of this function + * @param[in] user_data The user data to be passed when callback is called + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post This function invokes bt_adapter_le_advertising_state_changed_cb(). + * + * @see bt_adapter_le_stop_advertising() + * @see bt_adapter_le_advertising_state_changed_cb() + */ +int bt_adapter_le_start_advertising_new(bt_advertiser_h advertiser, bt_adapter_le_advertising_state_changed_cb cb, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Set advertising mode to control the advertising power and latency. + * @since_tizen 2.3.1 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] advertiser The handle of advertiser + * @param[in] mode The mode of advertising + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_start_advertising_new() + */ +int bt_adapter_le_set_advertising_mode(bt_advertiser_h advertiser, bt_adapter_le_advertising_mode_e mode); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Set whether the advertising type should be connectable or non-connectable + * @since_tizen 2.3.1 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] advertiser The handle of advertiser + * @param[in] connectable The type of advertising + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_adapter_le_start_advertising_new() + */ +int bt_adapter_le_set_advertising_connectable(bt_advertiser_h advertiser, bool connectable); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Creates a bond with a remote Bluetooth device, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @remarks A bond can be destroyed by bt_device_destroy_bond().\n + * The bonding request can be cancelled by bt_device_cancel_bonding(). + * + * @param[in] remote_address The address of the remote Bluetooth device with which the bond should be created + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @pre The remote device must be discoverable with bt_adapter_start_device_discovery(). + * @post This function invokes bt_device_bond_created_cb(). + * + * @see bt_adapter_start_device_discovery() + * @see bt_device_bond_created_cb() + * @see bt_device_cancel_bonding() + * @see bt_device_destroy_bond() + * @see bt_device_set_bond_created_cb() + * @see bt_device_unset_bond_created_cb() + */ +int bt_device_create_bond(const char *remote_address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Cancels the bonding process. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @remarks Use this function when the remote Bluetooth device is not responding to the + * bond request or you wish to cancel the bonding request. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOT_IN_PROGRESS Operation not in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The creating a bond must be in progress by bt_device_create_bond(). + * + * @see bt_device_create_bond() + * @see bt_device_bond_created_cb() + * @see bt_device_set_bond_created_cb() + * @see bt_device_unset_bond_created_cb() + */ +int bt_device_cancel_bonding(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Destroys the bond, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] remote_address The address of the remote Bluetooth device to remove bonding + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @pre The bond with the remote device must be created with bt_device_create_bond(). + * @post This function invokes bt_device_bond_destroyed_cb(). + * + * @see bt_device_create_bond() + * @see bt_device_bond_destroyed_cb() + * @see bt_device_set_bond_destroyed_cb() + * @see bt_device_unset_bond_destroyed_cb() + */ +int bt_device_destroy_bond(const char *remote_address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Sets an alias for the bonded device. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] remote_address The address of the remote Bluetooth device + * @param[in] alias The alias of the remote Bluetooth device + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @pre The bond with the remote device must be created with bt_device_create_bond(). + * + * @see bt_device_create_bond() + */ +int bt_device_set_alias(const char *remote_address, const char *alias); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Sets the authorization of a bonded device, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @remarks Once a device is authorized, you don't need to receive a confirmation. + * + * @param[in] remote_address The address of the remote Bluetooth device to authorize + * @param[in] authorization_state The Bluetooth authorization state + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @pre The bond with the remote device must be created with bt_device_create_bond(). + * @post bt_device_authorization_changed_cb() will be invoked. + * + * @see bt_device_create_bond() + * @see bt_device_authorization_changed_cb() + * @see bt_device_set_authorization_changed_cb() + * @see bt_device_unset_authorization_changed_cb() + */ +int bt_device_set_authorization(const char *remote_address, bt_device_authorization_e authorization_state); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Starts the search for services supported by the specified device, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @remarks If creating a bond succeeds, which means bt_device_bond_created_cb() is called with result #BT_ERROR_NONE, + * then you don't need to run this function.\n + * The service search takes a couple of seconds to complete normally. \n + * + * @param[in] remote_address The address of the remote Bluetooth device whose services need to be checked + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * @retval #BT_ERROR_SERVICE_SEARCH_FAILED Service search failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @pre The remote device must be discoverable with bt_adapter_start_device_discovery(). + * @pre The bond with the remote device must be created with bt_device_create_bond(). + * @post This function invokes bt_device_service_searched_cb(). + * + * @see bt_adapter_start_device_discovery() + * @see bt_device_create_bond() + * @see bt_device_bond_created_cb() + * @see bt_device_service_searched_cb() + * @see bt_device_set_service_searched_cb() + * @see bt_device_unset_service_searched_cb() + */ +int bt_device_start_service_search(const char *remote_address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Gets the connected profiles. + * @since_tizen 2.3 + * @param[in] remote_address The address of the remote device + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post bt_device_connected_profile() will be invoked. + * @see bt_device_connected_profile() + */ +int bt_device_foreach_connected_profiles(const char *remote_address, bt_device_connected_profile callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Gets the profile connected status. + * @since_tizen 2.3 + * @param[in] remote_address The address of the remote device + * @param[in] bt_profile wish to know bt_profile + * @param[out] connected_status the connected status + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + */ +int bt_device_is_profile_connected(const char *remote_address, bt_profile_e bt_profile, + bool *connected_status); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Registers a callback function to be invoked when the bond creates. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_device_bond_created_cb() will be invoked. + * @see bt_initialize() + * @see bt_device_bond_created_cb() + * @see bt_device_unset_bond_created_cb() + */ +int bt_device_set_bond_created_cb(bt_device_bond_created_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + * @see bt_device_set_bond_created_cb() + */ +int bt_device_unset_bond_created_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Registers a callback function to be invoked when the bond destroys. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_device_bond_destroyed_cb() will be invoked. + * @see bt_initialize() + * @see bt_device_bond_destroyed_cb() + * @see bt_device_unset_bond_destroyed_cb() + */ +int bt_device_set_bond_destroyed_cb(bt_device_bond_destroyed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + * @see bt_device_set_bond_destroyed_cb() + */ +int bt_device_unset_bond_destroyed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Registers a callback function to be invoked when the authorization of device changes. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_device_authorization_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_device_authorization_changed_cb() + * @see bt_device_set_authorization_changed_cb() + * @see bt_device_unset_authorization_changed_cb() + */ +int bt_device_set_authorization_changed_cb(bt_device_authorization_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + * @see bt_device_set_authorization_changed_cb() + */ +int bt_device_unset_authorization_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Registers a callback function to be invoked when the process of service search finishes. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_device_service_searched_cb() will be invoked. + * @see bt_initialize() + * @see bt_device_service_searched_cb() + * @see bt_device_unset_service_searched_cb() + */ +int bt_device_set_service_searched_cb(bt_device_service_searched_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + * @see bt_device_set_service_searched_cb() + */ +int bt_device_unset_service_searched_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Registers a callback function to be invoked when the connection state is changed. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_device_connection_state_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_device_connection_state_changed_cb() + * @see bt_device_unset_connection_state_changed_cb() + */ +int bt_device_set_connection_state_changed_cb(bt_device_connection_state_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Unregisters the callback function to be invoked when the connection state is changed. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + * @see bt_device_set_connection_state_changed_cb() + */ +int bt_device_unset_connection_state_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Registers a rfcomm server socket with a specific UUID. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @remarks A socket can be destroyed by bt_socket_destroy_rfcomm(). + * + * @param[in] service_uuid The UUID of service to provide + * @param[out] socket_fd The file descriptor of socket to listen + * @return 0 on success, otherwise a negative error value. + * + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * + * @see bt_socket_listen_and_accept_rfcomm() + * @see bt_socket_destroy_rfcomm() + */ +int bt_socket_create_rfcomm(const char *service_uuid, int *socket_fd); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Removes the rfcomm server socket which was created using bt_socket_create_rfcomm(). + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @remarks If callback function bt_socket_connection_state_changed_cb() is set and the remote Bluetooth device is connected, + * then bt_socket_connection_state_changed_cb() will be called when this function is finished successfully. + * + * @param[in] socket_fd The file descriptor of socket (which was created using bt_socket_create_rfcomm()) to destroy + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The socket must be created with bt_socket_create_rfcomm(). + * @post If callback function bt_socket_connection_state_changed_cb() is set and the remote Bluetooth device is connected, + * then bt_socket_connection_state_changed_cb() will be called. + * @see bt_socket_create_rfcomm() + * @see bt_socket_connection_state_changed_cb() + * @see bt_socket_set_connection_state_changed_cb() + * @see bt_socket_unset_connection_state_changed_cb() + */ +int bt_socket_destroy_rfcomm(int socket_fd); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Starts listening on passed rfcomm socket and accepts connection requests. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @details Pop-up is shown automatically when a RFCOMM connection is requested. + * bt_socket_connection_state_changed_cb() will be called with + * #BT_SOCKET_CONNECTED if you click "yes" and connection is finished successfully. + * @param[in] socket_fd The file descriptor of socket on which start to listen + * @param[in] max_pending_connections The maximum number of pending connections + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The socket must be created with bt_socket_create_rfcomm(). + * @post If callback function bt_socket_connection_state_changed_cb() is set, + * then bt_socket_connection_state_changed_cb() will be called when the remote Bluetooth device is connected. + * @see bt_socket_create_rfcomm() + * @see bt_socket_connection_state_changed_cb() + * @see bt_socket_set_connection_state_changed_cb() + * @see bt_socket_unset_connection_state_changed_cb() + */ +int bt_socket_listen_and_accept_rfcomm(int socket_fd, int max_pending_connections); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Connects to a specific RFCOMM based service on a remote Bluetooth device UUID, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @remarks A connection can be disconnected by bt_socket_disconnect_rfcomm(). + * + * @param[in] remote_address The address of the remote Bluetooth device + * @param[in] service_uuid The UUID of service provided by the remote Bluetooth device + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @pre The remote device must be discoverable with bt_adapter_start_device_discovery(). + * @pre The bond with the remote device must be created with bt_device_create_bond(). + * @post This function invokes bt_socket_connection_state_changed_cb(). + * + * @see bt_device_create_bond() + * @see bt_adapter_start_device_discovery() + * @see bt_device_start_service_search() + * @see bt_socket_disconnect_rfcomm() + * @see bt_socket_connection_state_changed_cb() + * @see bt_socket_set_connection_state_changed_cb() + * @see bt_socket_unset_connection_state_changed_cb() + */ +int bt_socket_connect_rfcomm(const char *remote_address, const char *service_uuid); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Disconnects the RFCOMM connection with the given file descriptor of conneted socket. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] socket_fd The file descriptor of socket to close which was received using bt_socket_connection_state_changed_cb(). + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The connection must be established. + * + * @see bt_socket_connection_state_changed_cb() + * @see bt_socket_set_connection_state_changed_cb() + * @see bt_socket_unset_connection_state_changed_cb() + */ +int bt_socket_disconnect_rfcomm(int socket_fd); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Sends data to the connected device. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @remark The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section. + * + * @param[in] socket_fd The file descriptor of connected socket which was received using bt_socket_connection_state_changed_cb() + * @param[in] data The data to be sent + * @param[in] length The length of data to be sent + * + * @return the number of bytes written (zero indicates nothing was written). + * @retval On error, -1 is returned, and errno is set appropriately. See write 2 man page. + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * @exception BT_ERROR_PERMISSION_DENIED Permission denied + * @exception BT_ERROR_AGAIN Resource temporarily unavailable + * + * @pre The connection must be established. + * + * @see bt_socket_connection_state_changed_cb() + * @see bt_socket_set_connection_state_changed_cb() + * @see bt_socket_unset_connection_state_changed_cb() + */ +int bt_socket_send_data(int socket_fd, const char *data, int length); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Register a callback function that will be invoked when you receive data. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_socket_data_received_cb() will be invoked. + * @see bt_initialize() + * @see bt_socket_data_received_cb() + * @see bt_socket_set_data_received_cb() + * @see bt_socket_unset_data_received_cb() + */ +int bt_socket_set_data_received_cb(bt_socket_data_received_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + * @see bt_socket_data_received_cb() + * @see bt_socket_set_data_received_cb() + */ +int bt_socket_unset_data_received_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Register a callback function that will be invoked when a RFCOMM connection is requested. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_socket_connection_requested_cb() will be invoked. + * @see bt_initialize() + * @see bt_socket_unset_connection_requested_cb() + */ +int bt_socket_set_connection_requested_cb(bt_socket_connection_requested_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + * @see bt_socket_set_connection_requested_cb() + * @see bt_socket_connection_requested_cb() + */ +int bt_socket_unset_connection_requested_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Register a callback function that will be invoked when the connection state changes. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_socket_connection_state_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_socket_connection_state_changed_cb() + * @see bt_socket_unset_connection_state_changed_cb() + */ +int bt_socket_set_connection_state_changed_cb(bt_socket_connection_state_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + * @see bt_socket_connection_state_changed_cb() + * @see bt_socket_set_connection_state_changed_cb() + */ +int bt_socket_unset_connection_state_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Initializes the Bluetooth OPP server requested by bt_opp_server_connection_requested_cb(). + * @since_tizen 2.3 + * @details No popup appears when an OPP connection is requested from a remote device. + * Instead, @a connection_requested_cb() will be called. + * At that time, you can call either bt_opp_server_accept() or bt_opp_server_reject(). + * @remarks This function must be called to start Bluetooth OPP server. \n + * You must free all resources of the Bluetooth service by calling bt_opp_server_deinitialize() if Bluetooth OPP service is no longer needed. + * @param[in] destination The destination path + * @param[in] connection_requested_cb The callback called when an OPP connection is requested + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_opp_server_connection_requested_cb() + * @see bt_opp_server_deinitialize() + * @see bt_opp_server_accept() + * @see bt_opp_server_reject() + */ +int bt_opp_server_initialize_by_connection_request(const char *destination, bt_opp_server_connection_requested_cb connection_requested_cb, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Denitializes the Bluetooth OPP server. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_opp_server_deinitialize() + */ +int bt_opp_server_deinitialize(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Accepts the push request from the remote device. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @remarks If you initialize OPP server by bt_opp_server_initialize_by_connection_request(), then name is ignored. + * You can cancel the pushes by bt_opp_server_cancel_transfer() with transfer_id. + * @param[in] progress_cb The callback called when a file is being transfered + * @param[in] finished_cb The callback called when a transfer is finished + * @param[in] name The name to store. This can be NULL if you initialize OPP server by bt_opp_server_initialize_by_connection_request(). + * @param[in] user_data The user data to be passed to the callback function + * @param[out] transfer_id The ID of transfer + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_opp_server_reject() + */ +int bt_opp_server_accept(bt_opp_server_transfer_progress_cb progress_cb, bt_opp_server_transfer_finished_cb finished_cb, const char *name, + void *user_data, int *transfer_id); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Rejects the push request from the remote device. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_opp_server_accept() + */ +int bt_opp_server_reject(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Cancels the transfer. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] transfer_id The ID of transfer + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_opp_server_accept() + */ +int bt_opp_server_cancel_transfer(int transfer_id); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Sets the destination path of file to be pushed. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] destination The destination path of file to be pushed + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_opp_server_set_destination(const char *destination); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_CLIENT_MODULE + * @brief Initializes the Bluetooth OPP client. + * @since_tizen 2.3 + * @remarks This function must be called before Bluetooth OPP client starts. \n + * You must free all resources of the Bluetooth service by calling bt_opp_client_deinitialize() + * if Bluetooth OPP service is no longer needed. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_opp_client_deinitialize() + */ +int bt_opp_client_initialize(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_CLIENT_MODULE + * @brief Denitializes the Bluetooth OPP client. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_opp_client_initialize() + */ +int bt_opp_client_deinitialize(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_CLIENT_MODULE + * @brief Adds file to be pushed. + * @since_tizen 2.3 + * @param[in] file The path of file to be pushed + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_opp_client_clear_files() + * @see bt_opp_client_push_files() + */ +int bt_opp_client_add_file(const char *file); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_CLIENT_MODULE + * @brief Adds file to be pushed. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_opp_client_add_file() + * @see bt_opp_client_push_files() + */ +int bt_opp_client_clear_files(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_CLIENT_MODULE + * @brief Pushes the file to the remote device, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @details At first, bt_opp_client_push_responded_cb() will be called when OPP server responds to the push request. + * After connection is established, bt_opp_client_push_progress_cb() will be called repeatedly until a file is tranfered completely. + * If you send several files, then bt_opp_client_push_progress_cb() with another file will be called repeatedly until the file is tranfered completely. + * bt_opp_client_push_finished_cb() will be called when the push request is finished. + * @param[in] remote_address The remote address + * @param[in] responded_cb The callback called when OPP server responds to the push request + * @param[in] progress_cb The callback called when each file is being transfered + * @param[in] finished_cb The callback called when the push request is finished + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_opp_client_initialize() + * @see bt_opp_client_cancel_push + */ +int bt_opp_client_push_files(const char *remote_address, bt_opp_client_push_responded_cb responded_cb, + bt_opp_client_push_progress_cb progress_cb, bt_opp_client_push_finished_cb finished_cb, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_CLIENT_MODULE + * @brief Cancels the push request in progress, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre bt_opp_client_push_files() must be called. + * @post bt_opp_client_push_finished_cb() will be invoked with result #BT_ERROR_CANCELLED, + * which is a parameter of bt_opp_client_push_files(). + * @see bt_opp_client_initialize() + * @see bt_opp_client_push_files() + */ +int bt_opp_client_cancel_push(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Initializes the Bluetooth HID(Human Interface Device) Host. + * @since_tizen 2.3 + * @remarks This function must be called before Bluetooth HID Host starts. \n + * You must free all resources of the Bluetooth service by calling bt_hid_host_deinitialize() + * if Bluetooth HID Host service is no longer needed. + * @param[in] connection_cb The callback called when the connection state is changed + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + * @see bt_hid_host_deinitialize() + */ +int bt_hid_host_initialize(bt_hid_host_connection_state_changed_cb connection_cb, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Deinitializes the Bluetooth HID(Human Interface Device) Host. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + * @see bt_hid_host_initialize() + */ +int bt_hid_host_deinitialize(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Connects the remote device with the HID(Human Interface Device) service, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] remote_address The remote address + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The local device must be bonded with the remote device by bt_device_create_bond(). + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + * @post bt_hid_host_connection_state_changed_cb() will be invoked. + * @see bt_hid_host_disconnect() + * @see bt_hid_host_connection_state_changed_cb() + */ +int bt_hid_host_connect(const char *remote_address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Disconnects the remote device with the HID(Human Interface Device) service, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] remote_address The remote address + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected by bt_hid_host_connect(). + * @post bt_hid_host_connection_state_changed_cb() will be invoked. + * @see bt_hid_host_connect() + * @see bt_hid_host_connection_state_changed_cb() + */ +int bt_hid_host_disconnect(const char *remote_address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Initializes the Bluetooth profiles related with audio. + * @since_tizen 2.3 + * @remarks This function must be called before Bluetooth profiles related with audio starts. \n + * You must free all resources of the this service by calling bt_audio_deinitialize() + * if Bluetooth profiles related with audio service is no longer needed. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + * @see bt_audio_deinitialize() + */ +int bt_audio_initialize(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Deinitializes the Bluetooth profiles related with audio. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + */ +int bt_audio_deinitialize(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Connects the remote device with the given audio profile, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @details If you input type as #BT_AUDIO_PROFILE_TYPE_ALL and connection request succeeds, then bt_audio_connection_state_changed_cb() will be called twice + * when #BT_AUDIO_PROFILE_TYPE_HSP_HFP is connected and #BT_AUDIO_PROFILE_TYPE_A2DP is connected. + * @param[in] remote_address The remote address + * @param[in] type The type of audio profile + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @pre The local device must be bonded with the remote device by bt_device_create_bond(). + * @post bt_audio_connection_state_changed_cb() will be invoked. + * @see bt_audio_disconnect() + * @see bt_audio_connection_state_changed_cb() + */ +int bt_audio_connect(const char *remote_address, bt_audio_profile_type_e type); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Disconnects the remote device with the given audio profile, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @details If you input type as #BT_AUDIO_PROFILE_TYPE_ALL and disconnection request succeeds, then bt_audio_connection_state_changed_cb() will be called twice + * when #BT_AUDIO_PROFILE_TYPE_HSP_HFP is disconnected and #BT_AUDIO_PROFILE_TYPE_A2DP is disconnected. + * @param[in] remote_address The remote address + * @param[in] type The type of audio profile + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected by bt_audio_connect(). + * @post bt_audio_connection_state_changed_cb() will be invoked. + * @see bt_audio_connect() + * @see bt_audio_connection_state_changed_cb() + */ +int bt_audio_disconnect(const char *remote_address, bt_audio_profile_type_e type); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Registers a callback function that will be invoked when the connection state is changed. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_audio_connection_state_changed_cb() + */ +int bt_audio_set_connection_state_changed_cb(bt_audio_connection_state_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Unregisters a callback function that will be invoked when the connection state is changed. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_audio_connection_state_changed_cb() + * @see bt_audio_set_connection_state_changed_cb() + */ +int bt_audio_unset_connection_state_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Initializes the Bluetooth AVRCP(Audio/Video Remote Control Profile) service. + * @since_tizen 2.4 + * @remarks This function must be called before Bluetooth AVRCP service. \n + * You must free all resources of the this service by calling bt_avrcp_target_deinitialize() + * if Bluetooth AVRCP service is no longer needed. + * @param[in] callback The callback function called when the connection state is changed + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_initialize() + * @see bt_avrcp_target_deinitialize() + */ +int bt_avrcp_target_initialize(bt_avrcp_target_connection_state_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Deinitializes the Bluetooth AVRCP(Audio/Video Remote Control Profile) service. + * @since_tizen 2.4 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_avrcp_target_initialize(). + * @see bt_avrcp_target_initialize() + */ +int bt_avrcp_target_deinitialize(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Notifies the equalize state to the remote device. + * @since_tizen 2.4 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] state The state of equalizer + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected. + * @see bt_avrcp_target_connection_state_changed_cb() + * @see bt_avrcp_target_initialize() + */ +int bt_avrcp_target_notify_equalizer_state(bt_avrcp_equalizer_state_e state); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Notifies the repeat mode to the remote device. + * @since_tizen 2.4 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] mode The repeat mode + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected. + * @see bt_avrcp_target_connection_state_changed_cb() + * @see bt_avrcp_target_initialize() + */ +int bt_avrcp_target_notify_repeat_mode(bt_avrcp_repeat_mode_e mode); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Notifies the shuffle mode to the remote device. + * @since_tizen 2.4 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] mode The repeat mode + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected. + * @see bt_avrcp_target_connection_state_changed_cb() + * @see bt_avrcp_target_initialize() + */ +int bt_avrcp_target_notify_shuffle_mode(bt_avrcp_shuffle_mode_e mode); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Notifies the scan mode to the remote device. + * @since_tizen 2.4 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] mode The scan mode + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected. + * @see bt_avrcp_target_connection_state_changed_cb() + * @see bt_avrcp_target_initialize() + */ +int bt_avrcp_target_notify_scan_mode(bt_avrcp_scan_mode_e mode); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Notifies the player state to the remote device. + * @since_tizen 2.4 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] state The player state + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected. + * @see bt_avrcp_target_connection_state_changed_cb() + * @see bt_avrcp_target_initialize() + */ +int bt_avrcp_target_notify_player_state(bt_avrcp_player_state_e state); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Notifies the current position of song to the remote device. + * @since_tizen 2.4 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] position The current position in milliseconds + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected. + * @see bt_avrcp_target_connection_state_changed_cb() + * @see bt_avrcp_target_initialize() + */ +int bt_avrcp_target_notify_position(unsigned int position); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Notifies the track to the remote device. + * @since_tizen 2.4 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] title The title of track + * @param[in] artist The artist of track + * @param[in] album The album of track + * @param[in] genre The genre of track + * @param[in] track_num The track number + * @param[in] total_tracks The number of all tracks + * @param[in] duration The duration of track in milliseconds + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected. + * @see bt_avrcp_target_connection_state_changed_cb() + * @see bt_avrcp_target_initialize() + */ +int bt_avrcp_target_notify_track(const char *title, const char *artist, const char *album, const char *genre, unsigned int track_num, unsigned int total_tracks, unsigned int duration); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Registers a callback function that will be invoked when the equalizer state is changed by the remote control device. + * @since_tizen 2.4 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @see bt_initialize() + * @see bt_avrcp_unset_equalizer_state_changed_cb() + */ +int bt_avrcp_set_equalizer_state_changed_cb(bt_avrcp_equalizer_state_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Unregisters a callback function that will be invoked when the equalizer state is changed by the remote control device. + * @since_tizen 2.4 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @see bt_initialize() + * @see bt_avrcp_set_equalizer_state_changed_cb() + */ +int bt_avrcp_unset_equalizer_state_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Registers a callback function that will be invoked when the repeat mode is changed by the remote control device. + * @since_tizen 2.4 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @see bt_initialize() + * @see bt_avrcp_unset_repeat_mode_changed_cb() + */ +int bt_avrcp_set_repeat_mode_changed_cb(bt_avrcp_repeat_mode_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Unregisters a callback function that will be invoked when the repeat mode is changed by the remote control device. + * @since_tizen 2.4 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @see bt_initialize() + * @see bt_avrcp_set_repeat_mode_changed_cb() + */ +int bt_avrcp_unset_repeat_mode_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Registers a callback function that will be invoked when the shuffle mode is changed by the remote control device. + * @since_tizen 2.4 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @see bt_initialize() + * @see bt_avrcp_unset_shuffle_mode_changed_cb() + */ +int bt_avrcp_set_shuffle_mode_changed_cb(bt_avrcp_shuffle_mode_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Unregisters a callback function that will be invoked when the shuffle mode is changed by the remote control device. + * @since_tizen 2.4 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @see bt_initialize() + * @see bt_avrcp_set_shuffle_mode_changed_cb() + */ +int bt_avrcp_unset_shuffle_mode_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Registers a callback function that will be invoked when the scan mode is changed by the remote control device. + * @since_tizen 2.4 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @see bt_initialize() + * @see bt_avrcp_unset_scan_mode_changed_cb() + */ +int bt_avrcp_set_scan_mode_changed_cb(bt_avrcp_scan_mode_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Unregisters a callback function that will be invoked when the scan mode is changed by the remote control device. + * @since_tizen 2.4 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @see bt_initialize() + * @see bt_avrcp_set_scan_mode_changed_cb() + */ +int bt_avrcp_unset_scan_mode_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HDP_MODULE + * @brief Registers an application that acts as the @a Sink role of HDP(Health Device Profile). + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @remarks The @a app_id must be released with free() by you. + * @param[in] data_type The data type of MDEP. This value is defined in ISO/IEEE 11073-20601 spec. + * For example, pulse oximeter is 0x1004 and blood pressure monitor is 0x1007. + * @param[out] app_id The ID of application + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @see bt_hdp_unregister_sink_app() + */ +int bt_hdp_register_sink_app(unsigned short data_type, char **app_id); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HDP_MODULE + * @brief Unregisters the given application that acts as the @a Sink role of HDP(Health Device Profile). + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] app_id The ID of application + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_hdp_register_sink_app() + */ +int bt_hdp_unregister_sink_app(const char *app_id); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HDP_MODULE + * @brief Connects the remote device which acts as @a Source role, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] remote_address The remote address + * @param[in] app_id The ID of application + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Sink role of HDP must be registered with bt_hdp_register_sink_app(). + * @pre The local device must be bonded with the remote device by bt_device_create_bond(). + * @post bt_hdp_connected_cb() will be invoked. + * @see bt_hdp_disconnect() + * @see bt_hdp_set_connection_state_changed_cb() + * @see bt_hdp_unset_connection_state_changed_cb() + */ +int bt_hdp_connect_to_source(const char *remote_address, const char *app_id); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HDP_MODULE + * @brief Disconnects the remote device, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] remote_address The remote address + * @param[in] channel The connected data channel + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected. + * @post bt_hdp_disconnected_cb() will be invoked. + * @see bt_hdp_set_connection_state_changed_cb() + * @see bt_hdp_unset_connection_state_changed_cb() + */ +int bt_hdp_disconnect(const char *remote_address, unsigned int channel); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HDP_MODULE + * @brief Sends the data to the remote device. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] channel The connected data channel + * @param[in] data The data to send + * @param[in] size The size of data to send (byte) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected. + * @see bt_hdp_data_received_cb() + * @see bt_hdp_set_data_received_cb() + * @see bt_hdp_unset_data_received_cb() + */ +int bt_hdp_send_data(unsigned int channel, const char *data, unsigned int size); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HDP_MODULE + * @brief Registers a callback function that will be invoked when the connection state is changed. + * @since_tizen 2.3 + * @param[in] connected_cb The callback function called when a connection is established + * @param[in] disconnected_cb The callback function called when a connection is disconnected + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_hdp_unset_connection_state_changed_cb() + */ +int bt_hdp_set_connection_state_changed_cb(bt_hdp_connected_cb connected_cb, bt_hdp_disconnected_cb disconnected_cb, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HDP_MODULE + * @brief Unregisters a callback function that will be invoked when the connection state is changed. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_hdp_set_connection_state_changed_cb() + */ +int bt_hdp_unset_connection_state_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HDP_MODULE + * @brief Registers a callback function that will be invoked when you receive the data. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_hdp_unset_data_received_cb() + */ +int bt_hdp_set_data_received_cb(bt_hdp_data_received_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HDP_MODULE + * @brief Unregisters a callback function that will be invoked when you receive the data. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_hdp_set_data_received_cb() + */ +int bt_hdp_unset_data_received_cb(void); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_foreach_services or bt_gatt_client_get_service instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the primary services of GATT(Generic Attribute Profile). + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] remote_address The address of the remote device + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post @a callback will be called if there are primary services. + * @see bt_gatt_primary_service_cb() + */ +int bt_gatt_foreach_primary_services(const char *remote_address, bt_gatt_primary_service_cb callback, void *user_data); + +/** + * @deprecated Deprecated since 2.3.1. This function call is not required because characteristic discovery is happened automatically. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Discovers the characteristics in service, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] service The attribute handle of service + * @param[in] callback The result callback + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post @a callback will be called. + * @see bt_gatt_characteristics_discovered_cb() + */ +int bt_gatt_discover_characteristics(bt_gatt_attribute_h service, bt_gatt_characteristics_discovered_cb callback, void *user_data); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_get_uuid instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the UUID of service. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @remarks @a uuid must be released with free() by you. + * @param[in] service The attribute handle of service + * @param[out] uuid The UUID of service + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + */ +int bt_gatt_get_service_uuid(bt_gatt_attribute_h service, char **uuid); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_service_foreach_included_services or bt_gatt_service_get_included_service instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the included services in service. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] service The attribute handle of service + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post @a callback will be called if there are included services. + * @see bt_gatt_included_service_cb() + */ +int bt_gatt_foreach_included_services(bt_gatt_attribute_h service, bt_gatt_included_service_cb callback, void *user_data); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_set_characteristic_value_changed_cb instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Registers a callback function that will be invoked when a characteristic value is changed. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_gatt_unset_characteristic_changed_cb() + */ +int bt_gatt_set_characteristic_changed_cb(bt_gatt_characteristic_changed_cb callback, void *user_data); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_unset_characteristic_value_changed_cb instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Unregisters a callback function that will be invoked when a characteristic is changed. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_gatt_set_characteristic_changed_cb() + */ +int bt_gatt_unset_characteristic_changed_cb(void); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_set_characteristic_value_changed_cb instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Watches all the characteristic value changes of the service + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] service The attribute handle of service + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_gatt_unset_characteristic_changed_cb() + */ +int bt_gatt_watch_characteristic_changes(bt_gatt_attribute_h service); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_unset_characteristic_value_changed_cb instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Remove watching of all the characteristic value changes of the service + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] service The attribute handle of service + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @see bt_gatt_set_characteristic_changed_cb() + */ +int bt_gatt_unwatch_characteristic_changes(bt_gatt_attribute_h service); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_get_value or bt_gatt_get_uuid after bt_gatt_client_read_value instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the characteristic declaration. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @remarks @a uuid and @a value must be released with free() by you. + * @param[in] characteristic The attribute handle of characteristic + * @param[out] uuid The UUID of service + * @param[out] value The value of characteristic (byte array) + * @param[out] value_length The length of value + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @see bt_gatt_set_characteristic_value() + */ +int bt_gatt_get_characteristic_declaration(bt_gatt_attribute_h characteristic, char **uuid, unsigned char **value, int *value_length); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_set_value and bt_gatt_client_write_value instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Sets the value of characteristic. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] characteristic The attribute handle of characteristic + * @param[in] value The value of characteristic (byte array) + * @param[in] value_length The length of value + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @see bt_gatt_get_characteristic_declaration() + */ +int bt_gatt_set_characteristic_value(bt_gatt_attribute_h characteristic, const unsigned char *value, int value_length); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_set_value and bt_gatt_client_write_value instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Sets the value of characteristic request. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] characteristic The attribute handle of characteristic + * @param[in] value The value of characteristic (byte array) + * @param[in] value_length The length of value + * @param[in] callback The result callback + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @see bt_gatt_get_characteristic_declaration() + */ +int bt_gatt_set_characteristic_value_request(bt_gatt_attribute_h characteristic, const unsigned char *value, + int value_length, bt_gatt_characteristic_write_cb callback); + +/** +* @deprecated Deprecated since 2.3.1. GATT handle clone is not allowed. Instead, all handles for client role must be got from GATT client handle. +* @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE +* @brief Clones the attribute handle. +* @since_tizen 2.3 +* @remarks @a clone must be released with bt_gatt_destroy_attribute_handle(). +* @param[out] clone The cloned attribute handle +* @param[in] origin The origin attribute handle +* @return 0 on success, otherwise negative error value. +* @retval #BT_ERROR_NONE Successful +* @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #BT_ERROR_OUT_OF_MEMORY Out of memory +* @retval #BT_ERROR_NOT_SUPPORTED Not supported +* +* @see bt_gatt_destroy_attribute_handle() +*/ +int bt_gatt_clone_attribute_handle(bt_gatt_attribute_h* clone, bt_gatt_attribute_h origin); + +/** +* @deprecated Deprecated since 2.3.1. GATT handle clone and destroy are not allowed. +* @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE +* @brief Destroys the attribute handle. +* @since_tizen 2.3 +* @param[in] handle The attribute handle +* @return 0 on success, otherwise negative error value. +* @retval #BT_ERROR_NONE Successful +* @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #BT_ERROR_NOT_SUPPORTED Not supported +* +* @see bt_gatt_clone_attribute_handle() +*/ +int bt_gatt_destroy_attribute_handle(bt_gatt_attribute_h handle); + +/** + * @deprecated Deprecated since 2.3.1. Use gatt_client_read_value instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Reads the value of characteristic from remote device + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] char_handle The attribute handle of characteristic + * @param[in] callback The result callback + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @see bt_gatt_get_characteristic_declaration() + */ +int bt_gatt_read_characteristic_value(bt_gatt_attribute_h char_handle, + bt_gatt_characteristic_read_cb callback); + +/** + * @deprecated Deprecated since 2.3.1. This function call is not required because descriptor discovery is happened automatically. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Discovers the characteristic descriptors of a characteristic within its definition, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] characteristic_handle The attribute handle of characteristic + * @param[in] callback The result callback + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post @a callback will be called. + * @see bt_gatt_characteristic_descriptor_discovered_cb() + */ +int bt_gatt_discover_characteristic_descriptor(bt_gatt_attribute_h characteristic_handle, + bt_gatt_characteristic_descriptor_discovered_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the value of a characteristic or descriptor's GATT handle + * @since_tizen 2.3.1 + * + * @remarks @a value must be released using free(). \n + * When @a gatt_handle is associated with bt_gatt_client_h, bt_gatt_client_read_value() must be used prior to this function \n + * in order to get the remote device's current value. + * + * @param[in] gatt_handle The handle of a characteristic or descriptor + * @param[out] value The value of @a gatt_handle. It is a byte stream type. + * @param[out] value_length The length of @a value + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_get_value(bt_gatt_h gatt_handle, char **value, int *value_length); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the value of a characteristic or descriptor's GATT handle as an integer type + * @since_tizen 2.3.1 + * + * @remarks This function returns a locally saved value in @a gatt_handle. \n + * When @a gatt_handle is associated with bt_gatt_client_h, bt_gatt_client_read_value() must be used prior to this function \n + * in order to get the remote device's current value. + * + * @param[in] gatt_handle The handle of a characteristic or descriptor + * @param[in] type The type of a saved value in @a gatt_handle + * @param[in] offset The offset from where a value will be read from @a gatt_handle as an integer type + * @param[out] value The integer type's value of @a gatt_handle + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_get_int_value(bt_gatt_h gatt_handle, bt_data_type_int_e type, + int offset, int *value); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the value of a characteristic or descriptor's GATT handle as a float type + * @since_tizen 2.3.1 + * + * @remarks This function returns a locally saved value in @a gatt_handle. \n + * When @a gatt_handle is associated with bt_gatt_client_h, bt_gatt_client_read_value() must be used prior to this function \n + * in order to get the remote device's current value. + * + * @param[in] gatt_handle The handle of a characteristic or descriptor + * @param[in] type The type of a saved value in @a gatt_handle + * @param[in] offset The offset from where a value will be read from @a gatt_handle as an integer type + * @param[out] value The float type's value of @a gatt_handle + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_get_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type, + int offset, float *value); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Updates the value of a characteristic or descriptor's GATT handle + * @since_tizen 2.3.1 + * + * @remarks This function updates a value of @a gatt_handle locally. \n + * When @a gatt_handle is associated with bt_gatt_client_h, bt_gatt_client_write_value() can be used after this function \n + * in order to update the remote device's value. \n + * + * @param[in] gatt_handle The handle of a characteristic or descriptor + * @param[in] value The value to be updated + * @param[in] value_length The length of @a value + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_set_value(bt_gatt_h gatt_handle, const char *value, int value_length); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Updates the value of a characteristic or descriptor's GATT handle using a integer type's value + * @since_tizen 2.3.1 + * + * @remarks This function updates a value of @a gatt_handle locally. \n + * When @a gatt_handle is associated with bt_gatt_client_h, bt_gatt_client_write_value() can be used after this function \n + * in order to update the remote device's value. \n + * + * @param[in] gatt_handle The handle of a characteristic or descriptor + * @param[in] type @a value will be saved in @a gatt_handle as this type + * @param[in] value The integer type's value to be updated + * @param[in] offset The offset from where @a value will be saved in @a gatt_handle + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_set_int_value(bt_gatt_h gatt_handle, bt_data_type_int_e type, + int value, int offset); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Updates the value of a characteristic or descriptor's GATT handle using a float type's value + * @since_tizen 2.3.1 + * + * @remarks This function updates a value of @a gatt_handle locally. \n + * When @a gatt_handle is associated with bt_gatt_client_h, bt_gatt_client_write_value() can be used after this function \n + * in order to update the remote device's value. \n + * + * @param[in] gatt_handle The handle of a characteristic or descriptor + * @param[in] type @a mantissa and @a exponent will be saved in @a gatt_handle as this type + * @param[in] mantissa The mantissa of float type's value to be updated + * @param[in] exponent The exponent of float type's value to be updated + * @param[in] offset The offset from where @a mantissa and @a exponent will be saved in @a gatt_handle + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_set_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type, + int mantissa, int exponent, int offset); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the UUID of a service, characteristic or descriptor's GATT handle + * @since_tizen 2.3.1 + * + * @remarks @a uuid must be released using free(). \n + * 16-bit UUID or 128-bit UUID is supported. (e.g. 2A19, 00002A19-0000-1000-8000-00805F9B34FB) + * + * @param[in] gatt_handle The handle of a service, characteristic or descriptor + * @param[out] uuid The string of the UUID of @a gatt_handle + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_get_uuid(bt_gatt_h gatt_handle, char **uuid); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the type of GATT handle + * @since_tizen 2.3.1 + * + * @param[in] gatt_handle The GATT handle + * @param[out] gatt_type The type of @a gatt_handle + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_get_type(bt_gatt_h gatt_handle, bt_gatt_type_e *gatt_type); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the GATT client handle which the specified service belongs to + * @since_tizen 2.3.1 + * + * @remark This function doesn't allocate new memory for GATT client handle. + * The returned GATT client handle is the same one which was got from bt_gatt_client_create(). + * So if it is destroyed by bt_gatt_client_destroy(), all related GATT handles are freed also. + * + * @param[in] service The service's GATT handle + * @param[out] client The GATT client handle which @a service belongs to + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_client_create() + */ +int bt_gatt_service_get_client(bt_gatt_h service, bt_gatt_client_h *client); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets a characteristic's GATT handle which has specific UUID + * @since_tizen 2.3.1 + * + * @remark The returned GATT handle must not be freed by application. + * It will be freed when an associated client is destroyed by bt_gatt_client_destroy(). + * If there are multiple characteristics which have same UUID, only the first matched one will be returned. + * + * @param[in] service The service's GATT handle + * @param[in] uuid The characteristic's GATT handle which has this UUID will be returned if it exists + * @param[out] characteristic The characteristic's GATT handle which has @a uuid if it exists + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NO_DATA No data available + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_service_get_characteristic(bt_gatt_h service, const char *uuid, + bt_gatt_h *characteristic); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Invokes @a callback function on each characteristic that belongs to the specified service + * @since_tizen 2.3.1 + * + * @param[in] service The service's GATT handle + * @param[in] callback The function to be invoked on each characteristic + * @param[in] user_data The user data to be passed to @a callback function + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_foreach_cb() + */ +int bt_gatt_service_foreach_characteristics(bt_gatt_h service, + bt_gatt_foreach_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets an included service's GATT handle which has specific UUID + * @since_tizen 2.3.1 + * + * @remark The returned GATT handle must not be freed by application. + * It will be freed when an associated client is destroyed by bt_gatt_client_destroy(). + * If there are multiple included services which have same UUID, only the first matched one will be returned. + * + * @param[in] service The service's GATT handle + * @param[in] uuid The included service's GATT handle which has this UUID will be returned if it exists + * @param[out] included_service The included service's GATT handle which has @a uuid if it exists + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NO_DATA No data available + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_service_get_included_service(bt_gatt_h service, const char *uuid, + bt_gatt_h *included_service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Invokes @a callback function on each included service that belongs to the specified service + * @since_tizen 2.3.1 + * + * @param[in] service The service's GATT handle + * @param[in] callback The function to be invoked on each included service + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_foreach_cb() + */ +int bt_gatt_service_foreach_included_services(bt_gatt_h service, + bt_gatt_foreach_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the service's GATT handle which the specified characteristic belongs to + * @since_tizen 2.3.1 + * + * @remark The returned GATT handle must not be freed by application. + * It will be freed when an associated client is destroyed by bt_gatt_client_destroy(). + * + * @param[in] characteristic The characteristic's GATT handle + * @param[out] service The service's GATT handle which @a characteristic belongs to + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_characteristic_get_service(bt_gatt_h characteristic, bt_gatt_h *service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the properties which a characteristic's GATT handle has + * @since_tizen 2.3.1 + * + * @param[in] characteristic The characteristic's GATT handle + * @param[out] properties The properties which a characteristic's GATT handle has + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_property_e + */ +int bt_gatt_characteristic_get_properties(bt_gatt_h characteristic, int *properties); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the write type of the specified characteristic + * @since_tizen 2.3.1 + * + * @param[in] characteristic The characteristic's GATT handle + * @param[out] write_type The write type of the specified characteristic + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_write_type_e + */ +int bt_gatt_characteristic_get_write_type(bt_gatt_h characteristic, + bt_gatt_write_type_e *write_type); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Updates the write type of the specified charateristic + * @since_tizen 2.3.1 + * + * @param[in] characteristic The characteristic's GATT handle + * @param[in] write_type The write type to be updated + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_client_write_value() + * @see bt_gatt_write_type_e + */ +int bt_gatt_characteristic_set_write_type(bt_gatt_h characteristic, + bt_gatt_write_type_e write_type); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets a descriptor's GATT handle which has specific UUID + * @since_tizen 2.3.1 + * + * @remark The returned GATT handle must not be freed by application. + * It will be freed when an associated client is destroyed by bt_gatt_client_destroy(). + * If there are multiple descriptors which have same UUID, only the first matched one will be returned. + * + * @param[in] characteristic The characteristic's GATT handle + * @param[in] uuid The descriptor's GATT handle which has this UUID will be returned if it exists + * @param[out] descriptor The descriptor's GATT handle which has @a uuid if it exists + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NO_DATA No data available + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_characteristic_get_descriptor(bt_gatt_h characteristic, const char *uuid, + bt_gatt_h *descriptor); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Invokes @a callback function on each descriptor that belongs to the specified characteristic + * @since_tizen 2.3.1 + * + * @param[in] characteristic The characteristic's GATT handle + * @param[in] callback The function to be invoked on each descriptor + * @param[in] user_data The user data to be passed to @a callback function + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_foreach_cb() + */ +int bt_gatt_characteristic_foreach_descriptors(bt_gatt_h characteristic, + bt_gatt_foreach_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the characteristic's GATT handle which the specified descriptor belongs to + * @since_tizen 2.3.1 + * + * @remark The returned GATT handle must not be freed by application. + * It will be freed when an associated client is destroyed by bt_gatt_client_destroy(). + * + * @param[in] descriptor The descriptor's GATT handle + * @param[out] characteristic The characteristic's GATT handle which @a descriptor belongs to + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_descriptor_get_characteristic(bt_gatt_h descriptor, bt_gatt_h *characteristic); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Creates the GATT client handle + * @since_tizen 2.3.1 + * + * @remark The GATT client handle must be freed by bt_gatt_client_destroy() after use + * + * @param[in] remote_address The address of the remote device + * @param[out] client The created GATT client's handle + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_client_destroy() + */ +int bt_gatt_client_create(const char *remote_address, bt_gatt_client_h *client); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Destroys the GATT client's handle + * @since_tizen 2.3.1 + * + * @remark All related service, characteristic and descriptor's GATT handles are freed also + * + * @param[in] client The GATT client's handle + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_client_create() + */ +int bt_gatt_client_destroy(bt_gatt_client_h client); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets the address of remote device + * @since_tizen 2.3.1 + * + * @param[in] client The created GATT client's handle + * @param[out] remote_address The address of the remote device which is associated with @a client + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_client_create() + */ +int bt_gatt_client_get_remote_address(bt_gatt_client_h client, + char **remote_address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Reads the value of a characteristic or descriptor from the remote device asynchronously + * @since_tizen 2.3.1 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] gatt_handle The GATT handle of a characteristic or descriptor + * @param[in] callback When a read request is completed, this callback function will be called + * @param[in] user_data The user data to be passed to @a callback function + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_client_create() + * @see bt_gatt_client_request_completed_cb() + */ +int bt_gatt_client_read_value(bt_gatt_h gatt_handle, + bt_gatt_client_request_completed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Writes the value of a characteristic or descriptor to the remote device asynchronously + * @since_tizen 2.3.1 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] gatt_handle The GATT handle of a characteristic or descriptor + * @param[in] callback When a write request is completed, this callback function will be called + * @param[in] user_data The user data to be passed to @a callback function + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_client_create() + * @see bt_gatt_characteristic_set_write_type() + * @see bt_gatt_set_value() + * @see bt_gatt_set_int_value() + * @see bt_gatt_set_float_value() + * @see bt_gatt_client_request_completed_cb() + */ +int bt_gatt_client_write_value(bt_gatt_h gatt_handle, + bt_gatt_client_request_completed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Registers a callback function to be invoked when the characteristic value is changed on the remote device + * @since_tizen 2.3.1 + * + * @param[in] characteristic The characteristic's GATT handle + * @param[in] callback The callback to be invoked when the value is changed and it is informed + * @param[in] user_data The user data to be passed to @a callback function + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_client_characteristic_value_changed_cb() + * @see bt_gatt_client_unset_characteristic_value_change() + */ +int bt_gatt_client_set_characteristic_value_changed_cb(bt_gatt_h characteristic, + bt_gatt_client_characteristic_value_changed_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Unregisters a callback function to be invoked when the characteristic value is changed on the remote device + * @since_tizen 2.3.1 + * + * @param[in] characteristic The characteristic's GATT handle, whose value change will not be informed + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_client_set_characteristic_value_changed_cb() + */ +int bt_gatt_client_unset_characteristic_value_changed_cb(bt_gatt_h characteristic); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Gets a service's GATT handle which has specific UUID + * @since_tizen 2.3.1 + * + * @remark The returned GATT handle must not be freed by application. + * It will be freed when an associated client is destroyed by bt_gatt_client_destroy(). + * If there are multiple services which have same UUID, only the first matched one will be returned. + * + * @param[in] client The GATT client's handle + * @param[in] uuid The serivce's GATT handle which has this UUID will be returned if it exists + * @param[out] service The service's GATT handle which has @a uuid if it exists + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NO_DATA No data available + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + */ +int bt_gatt_client_get_service(bt_gatt_client_h client, const char *uuid, + bt_gatt_h *service); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Invokes @a callback function on each service that belongs to the specified GATT client + * @since_tizen 2.3.1 + * + * @param[in] client The GATT client's handle + * @param[in] callback The function to be invoked on each service + * @param[in] user_data The user data to be passed to @a callback function + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_foreach_cb() + */ +int bt_gatt_client_foreach_services(bt_gatt_client_h client, + bt_gatt_foreach_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Connect to a specific LE based service on a remote bluetooth dievice address, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @remarks A connection can be disconnected by bt_gatt_disconnect(). + * + * @param[in] address The address of the remote Bluetooth device. + * @param[in] auto_connect The flag of the auto connection. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid paramater + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @pre The remote device must support le connection. + * @post This function invokes bt_gatt_connection_state_changed_cb(). + * + * @see bt_initialize() + * @see bt_gatt_disconnect() + * @see bt_gatt_set_connection_state_changed_cb() + * @see bt_gatt_unset_connection_state_changed_cb() + * @see bt_gatt_connection_state_changed_cb() + */ +int bt_gatt_connect(const char *address, bool auto_connect); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Disconnect to LE connection with the given remote Bluetooth dievice address, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * + * @param[in] address The address of the remote Bluetooth device + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid paramater + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The connection must be established. + * @post This function invokes bt_gatt_connection_state_changed_cb(). + * + * @see bt_initialize() + * @see bt_gatt_connect() + * @see bt_gatt_set_connection_state_changed_cb() + * @see bt_gatt_unset_connection_state_changed_cb() + * @see bt_gatt_connection_state_changed_cb() + */ +int bt_gatt_disconnect(const char *address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Registers a callback function that will be invoked when the connection state is changed. + * @since_tizen 2.3 + * + * @param[in] callback The callback function to register. + * @param[in] user_data The user data to be passed to the callback function. + * + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid paramater + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_connect() + * @see bt_gatt_disconnect() + * @see bt_gatt_unset_connection_state_changed_cb() + */ +int bt_gatt_set_connection_state_changed_cb(bt_gatt_connection_state_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Unregisters a callback function that will be invoked when the connection state is changed. + * @since_tizen 2.3 + * + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_connect() + * @see bt_gatt_disconnect() + * @see bt_gatt_connection_state_changed_cb() + */ +int bt_gatt_unset_connection_state_changed_cb(void); + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // __TIZEN_NETWORK_BLUETOOTH_H__ diff --git a/include/tv/bluetooth_extension.h b/include/tv/bluetooth_extension.h new file mode 100644 index 0000000..dac46e5 --- /dev/null +++ b/include/tv/bluetooth_extension.h @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_NETWORK_BLUETOOTH_EXTENSION_H__ +#define __TIZEN_NETWORK_BLUETOOTH_EXTENSION_H__ + +#include "bluetooth_type.h" +#include "bluetooth_type_extension.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** + * @file bluetooth_extension.h + */ + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Opens a SCO(Synchronous Connection Oriented link) to connected remote device, asynchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @post bt_ag_sco_state_changed_cb() will be invoked. + * @see bt_ag_close_sco() + * @see bt_ag_sco_state_changed_cb() + * @see bt_audio_connect() + */ +int bt_ag_open_sco(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Closes an opened SCO(Synchronous Connection Oriented link), asynchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The SCO must be opened with bt_ag_open_sco(). + * @post bt_ag_sco_state_changed_cb() will be invoked. + * @see bt_ag_open_sco() + * @see bt_ag_sco_state_changed_cb() + */ +int bt_ag_close_sco(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Checks whether an opened SCO(Synchronous Connection Oriented link) exists or not. + * @since_tizen 2.3 + * @param[out] opened The SCO status: (@c true = opened, @c false = not opened) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_ag_open_sco() + * @see bt_ag_close_sco() + */ +int bt_ag_is_sco_opened(bool *opened); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when the SCO(Synchronous Connection Oriented link) state is changed. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_sco_state_changed_cb() + * @see bt_ag_unset_sco_state_changed_cb() + */ +int bt_ag_set_sco_state_changed_cb(bt_ag_sco_state_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when the SCO(Synchronous Connection Oriented link) state is changed. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_sco_state_changed_cb() + * @see bt_ag_set_sco_state_changed_cb() + */ +int bt_ag_unset_sco_state_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the state of voice recognition. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] state The state of voice recognition: (@c true = enabled, @c false = disabled) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @see bt_audio_connect() + */ +int bt_ag_notify_voice_recognition_state(bool state); + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // __TIZEN_NETWORK_BLUETOOTH_EXTENSION_H__ + diff --git a/include/tv/bluetooth_internal.h b/include/tv/bluetooth_internal.h new file mode 100644 index 0000000..7858dab --- /dev/null +++ b/include/tv/bluetooth_internal.h @@ -0,0 +1,936 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_NETWORK_BLUETOOTH_INTERNAL_H__ +#define __TIZEN_NETWORK_BLUETOOTH_INTERNAL_H__ + +#include <glib.h> +#include "bluetooth_type.h" +#include "bluetooth_type_internal.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** + * @file bluetooth_internal.h + */ + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enables the local Bluetooth adapter, asynchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function enables Bluetooth protocol stack and hardware. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_ALREADY_DONE Already enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre Bluetooth service must be initialized with bt_initialize(). + * @pre The state of local Bluetooth must be #BT_ADAPTER_DISABLED + * @post This function invokes bt_adapter_state_changed_cb(). + * + * @see bt_initialize() + * @see bt_adapter_get_state() + * @see bt_adapter_set_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb() + * @see bt_adapter_state_changed_cb() + * + */ +int bt_adapter_enable(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Disables the local Bluetooth adapter, asynchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function disables Bluetooth protocol stack and hardware. + * + * @remarks You should disable Bluetooth adapter, which is helpful for saving power. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED + * @post This function invokes bt_adapter_state_changed_cb(). + * + * @see bt_adapter_get_state() + * @see bt_adapter_state_changed_cb() + * @see bt_adapter_set_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb () + * + */ +int bt_adapter_disable(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Reset the local Bluetooth adapter, synchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function resets Bluetooth protocol and values. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_state_changed_cb() will be invoked if The state of local Bluetooth was #BT_ADAPTER_ENABLED. + * + * @see bt_initialize() + * @see bt_adapter_get_state() + * @see bt_adapter_set_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb() + * @see bt_adapter_state_changed_cb() + * + */ +int bt_adapter_reset(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Sets the visibility mode. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @remarks #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE will change to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE + * after the given @a duration goes. + * + * @param[in] discoverable_mode The Bluetooth visibility mode to set + * @param[in] duration The duration until the visibility mode is changed to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE (in seconds). + * @a duration is used only for #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE mode. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post bt_adapter_visibility_mode_changed_cb() will be invoked if this function returns #BT_ERROR_NONE. + * + * @see bt_adapter_get_visibility() + * @see bt_adapter_visibility_mode_changed_cb() + * @see bt_adapter_set_visibility_mode_changed_cb() + * @see bt_adapter_unset_visibility_mode_changed_cb() + */ +int bt_adapter_set_visibility(bt_adapter_visibility_mode_e discoverable_mode, int duration); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Cancels service search process. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * @retval #BT_ERROR_NOT_IN_PROGRESS Operation not in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The service search must be in progress by bt_device_start_service_search(). + * + * @see bt_device_start_service_search() + * @see bt_device_service_searched_cb() + * @see bt_device_set_service_searched_cb() + * @see bt_device_unset_service_searched_cb() + */ +int bt_device_cancel_service_search(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Starts listening on passed rfcomm socket. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @details bt_socket_connection_requested_cb() will be called when a RFCOMM connection is requested. + * + * @param[in] socket_fd The file descriptor socket on which start to listen + * @param[in] max_pending_connections The number of pending connections + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The socket must be created with bt_socket_create_rfcomm(). + * @post This function invokes bt_socket_connection_state_changed_cb(). + * + * @see bt_socket_create_rfcomm() + * @see bt_socket_set_connection_requested_cb() + * @see bt_socket_unset_connection_requested_cb() + * @see bt_socket_connection_requested_cb() + */ +int bt_socket_listen(int socket_fd, int max_pending_connections); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Accepts a connection request. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] requested_socket_fd The file descriptor of socket on which a connection is requested + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The connection is requested by bt_socket_connection_requested_cb(). + * @see bt_socket_create_rfcomm() + * @see bt_socket_connection_requested_cb() + * @see bt_socket_listen() + * @see bt_socket_reject() +*/ +int bt_socket_accept(int socket_fd, int *connected_socket_fd); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Accepts a connection request. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] requested_socket_fd The file descriptor of socket on which a connection is requested + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The connection is requested by bt_socket_connection_requested_cb(). + * @see bt_socket_create_rfcomm() + * @see bt_socket_connection_requested_cb() + * @see bt_socket_listen() + * @see bt_socket_reject() +*/ +int bt_socket_accept_sync(int socket_fd, int *connected_socket_fd); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Rejects a connection request. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] socket_fd The file descriptor of socket on which a connection is requested + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The connection is requested by bt_socket_connection_requested_cb(). + * @see bt_socket_create_rfcomm() + * @see bt_socket_connection_requested_cb() + * @see bt_socket_listen() + * @see bt_socket_accept() + */ +int bt_socket_reject(int socket_fd); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Initializes the Bluetooth OPP server requested by bt_opp_server_push_requested_cb(). + * @since_tizen 2.3 + * @details The popup appears when an OPP connection is requested from a remote device. + * If you accept the request, then connection will be established and bt_opp_server_push_requested_cb() will be called. + * At that time, you can call either bt_opp_server_accept() or bt_opp_server_reject(). + * @remarks This function must be called to start Bluetooth OPP server. You must free all resources of the Bluetooth service + * by calling bt_opp_server_deinitialize() if Bluetooth OPP service is no longer needed. + * @param[in] destination The destination path + * @param[in] push_requested_cb The callback called when a push is requested + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_opp_server_push_requested_cb() + * @see bt_opp_server_deinitialize() + * @see bt_opp_server_accept() + * @see bt_opp_server_reject() + */ +int bt_opp_server_initialize(const char *destination, bt_opp_server_push_requested_cb push_requested_cb, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the call event to the remote bluetooth device. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @remarks Before notifying #BT_AG_CALL_EVENT_ANSWERED or #BT_AG_CALL_EVENT_DIALING, you should open SCO(Synchronous Connection Oriented link) + * if Bluetooth Hands-Free need SCO connection. + * @param[in] event The call event + * @param[in] call_id The call ID + * @param[in] phone_number The phone number. You must set this value in case of #BT_AG_CALL_EVENT_DIALING and #BT_AG_CALL_EVENT_INCOMING. + * In other cases, this value can be NULL. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @see bt_audio_connect() + */ +int bt_ag_notify_call_event(bt_ag_call_event_e event, unsigned int call_id, const char *phone_number); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the call list to the remote bluetooth device. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] list The call list + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @see bt_audio_connect() + */ +int bt_ag_notify_call_list(bt_call_list_h list); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the state of voice recognition. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] state The state of voice recognition: (@c true = enabled, @c false = disabled) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @see bt_audio_connect() + */ +int bt_ag_notify_voice_recognition_state(bool state); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when a call handling event happened from Hands-Free. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_call_handling_event_cb() + * @see bt_ag_unset_call_handling_event_cb() + */ +int bt_ag_set_call_handling_event_cb(bt_ag_call_handling_event_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when a call handling event happened from Hands-Free. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_call_handling_event_cb() + * @see bt_ag_set_call_handling_event_cb() + */ +int bt_ag_unset_call_handling_event_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when a multi call handling event happened from Hands-Free. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_multi_call_handling_event_cb() + * @see bt_ag_unset_multi_call_handling_event_cb() + */ +int bt_ag_set_multi_call_handling_event_cb(bt_ag_multi_call_handling_event_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when a multi call handling event happened from Hands-Free. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_multi_call_handling_event_cb() + * @see bt_ag_set_multi_call_handling_event_cb() + */ +int bt_ag_unset_multi_call_handling_event_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when a DTMF(Dual Tone Multi Frequency) is transmitted from Hands-Free. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_dtmf_transmitted_cb() + * @see bt_ag_unset_dtmf_transmitted_cb() + */ +int bt_ag_set_dtmf_transmitted_cb(bt_ag_dtmf_transmitted_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when a DTMF(Dual Tone Multi Frequency) is transmitted from Hands-Free. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_dtmf_transmitted_cb() + * @see bt_ag_set_dtmf_transmitted_cb() + */ +int bt_ag_unset_dtmf_transmitted_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the speaker gain to the remote device. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @details This function sends a signal to the remote device. This signal has the gain value. + * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. + * When the speaker gain of remote device is changed to the requested gain, bt_audio_speaker_gain_changed_cb() will be called. + * @param[in] gain The gain of speaker (0 ~ 15) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. + * @see bt_ag_get_speaker_gain() + * @see bt_ag_set_speaker_gain_changed_cb() + * @see bt_ag_unset_speaker_gain_changed_cb() + */ +int bt_ag_notify_speaker_gain(int gain); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Gets the current speaker gain of the remote device. + * @since_tizen 2.3 + * @details This function gets the value of speaker gain of the remote device. + * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. + * @param[out] gain The gain of speaker (0 ~ 15) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. + * @see bt_ag_notify_speaker_gain() + * @see bt_ag_set_speaker_gain_changed_cb() + * @see bt_ag_unset_speaker_gain_changed_cb() + */ +int bt_ag_get_speaker_gain(int *gain); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Checks whether the remoted device enables NREC(Noise Reduction and Echo Canceling) or not. + * @since_tizen 2.3 + * @param[out] enabled The NREC status: (@c true = enabled, @c false = not enabled) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. + * @see bt_audio_connect() + */ +int bt_ag_is_nrec_enabled(bool *enabled); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when the speaker gain of the remote device is changed. + * @since_tizen 2.3 + * @details This function let you know the change of the speaker gain of the remote device. + * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_unset_speaker_gain_changed_cb() + */ +int bt_ag_set_speaker_gain_changed_cb(bt_ag_speaker_gain_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when the speaker gain of the remote device is changed. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_set_speaker_gain_changed_cb() + */ +int bt_ag_unset_speaker_gain_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when the microphone gain of the remote device is changed. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_unset_microphone_gain_changed_cb() + */ +int bt_ag_set_microphone_gain_changed_cb(bt_ag_microphone_gain_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when the microphone gain of the remote device is changed. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_set_microphone_gain_changed_cb() + */ +int bt_ag_unset_microphone_gain_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE + * @brief Creates a handle of call list. + * @since_tizen 2.3 + * @param[out] list The handle of call list + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_call_list_destroy() + */ +int bt_call_list_create(bt_call_list_h *list); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE + * @brief Destroys the handle of call list. + * @since_tizen 2.3 + * @param[in] list The handle of call list + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_call_list_create() + */ +int bt_call_list_destroy(bt_call_list_h list); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE + * @brief Resets the handle of call list. + * @since_tizen 2.3 + * @param[in] list The handle of call list + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_call_list_create() + */ +int bt_call_list_reset(bt_call_list_h list); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE + * @brief Adds a call to the handle of call list. + * @since_tizen 2.3 + * @param[in] list The handle of call list + * @param[in] call_id The call ID + * @param[in] state The state of audio gate call + * @param[in] phone_number The phone number. You must set this value in case of #BT_AG_CALL_EVENT_DIALING and #BT_AG_CALL_EVENT_INCOMING. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_call_list_create() + */ +int bt_call_list_add(bt_call_list_h list, unsigned int call_id, bt_ag_call_state_e state, const char *phone_number); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Activates the NAP(Network Access Point). + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED + * @see bt_nap_deactivate() + */ +int bt_nap_activate(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Deactivates the NAP(Network Access Point). + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). + * @see bt_nap_activate() + */ +int bt_nap_deactivate(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Disconnects the all PANUs(Personal Area Networking User) which are connected to you. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). + * @see bt_nap_activate() + */ +int bt_nap_disconnect_all(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Disconnects the specified PANU(Personal Area Networking User) which is connected to you. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] remote_address The remote address + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). + * @see bt_nap_activate() + */ +int bt_nap_disconnect(const char *remote_address); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Registers a callback function that will be invoked when the connection state changes. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_nap_connection_state_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_nap_connection_state_changed_cb() + * @see bt_nap_unset_connection_state_changed_cb() + */ +int bt_nap_set_connection_state_changed_cb(bt_nap_connection_state_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Unregisters a callback function that will be invoked when the connection state changes. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_nap_connection_state_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_nap_connection_state_changed_cb() + * @see bt_nap_set_connection_state_changed_cb() + */ +int bt_nap_unset_connection_state_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE + * @brief Registers a callback function that will be invoked when the connection state changes. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_nap_connection_state_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_panu_connection_state_changed_cb() + * @see bt_panu_unset_connection_state_changed_cb() + */ +int bt_panu_set_connection_state_changed_cb(bt_panu_connection_state_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE + * @brief Unregisters a callback function that will be invoked when the connection state changes. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_nap_connection_state_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_panu_connection_state_changed_cb() + * @see bt_panu_set_connection_state_changed_cb() + */ +int bt_panu_unset_connection_state_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE + * @brief Connects the remote device with the PAN(Personal Area Networking) service, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] remote_address The remote address + * @param[in] type The type of PAN service + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The local device must be bonded with the remote device by bt_device_create_bond(). + * @post bt_panu_connection_state_changed_cb() will be invoked. + * @see bt_panu_disconnect() + * @see bt_panu_connection_state_changed_cb() + */ +int bt_panu_connect(const char *remote_address, bt_panu_service_type_e type); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE + * @brief Disconnects the remote device with the PAN(Personal Area Networking) service, asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] remote_address The remote address + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected by bt_panu_connect(). + * @post bt_panu_connection_state_changed_cb() will be invoked. + * @see bt_panu_connect() + * @see bt_panu_connection_state_changed_cb() + */ +int bt_panu_disconnect(const char *remote_address); + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // __TIZEN_NETWORK_BLUETOOTH_INTERNAL_H__ diff --git a/include/tv/bluetooth_private.h b/include/tv/bluetooth_private.h new file mode 100644 index 0000000..9d78b4a --- /dev/null +++ b/include/tv/bluetooth_private.h @@ -0,0 +1,324 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_NETWORK_BLUETOOTH_PRIVATE_H__ +#define __TIZEN_NETWORK_BLUETOOTH_PRIVATE_H__ + +#include <dlog.h> +#include <stdbool.h> +#include <bluetooth-api.h> +#include <bluetooth-audio-api.h> +#include <bluetooth-telephony-api.h> +#include <bluetooth-media-control.h> +#include <bluetooth-hid-api.h> +#include <bluetooth-sync3d-api.h> + +#include "bluetooth.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#undef LOG_TAG +#define LOG_TAG "CAPI_NETWORK_BLUETOOTH" + +#define BT_INFO(fmt, args...) SLOGI(fmt, ##args) +#define BT_DBG(fmt, args...) SLOGD(fmt, ##args) +#define BT_ERR(fmt, args...) SLOGE(fmt, ##args) +#define BT_FATAL(fmt, args...) SLOGF(fmt, ##args) +#define ENTRY() BT_INFO("ENTER") +#define EXIT() BT_INFO("EXIT") +#define OPP_UUID "00001105-0000-1000-8000-00805f9b34fb" + +/** + * @internal + * @brief Bluetooth callback. + */ +typedef enum +{ + BT_EVENT_STATE_CHANGED = 0x00, /**< Adapter state is changed */ + BT_EVENT_NAME_CHANGED, /**< Adapter name is changed */ + BT_EVENT_VISIBILITY_MODE_CHANGED, /**< Adapter visibility mode is changed */ + BT_EVENT_DEVICE_DISCOVERY_STATE_CHANGED, /**< Device discovery state is changed */ + BT_EVENT_BOND_CREATED, /**< A bond is created */ + BT_EVENT_BOND_DESTROYED, /**< A bond is destroyed */ + BT_EVENT_AUTHORIZATION_CHANGED, /**< Authorization is changed */ + BT_EVENT_SERVICE_SEARCHED, /**< Service search finish */ + BT_EVENT_DATA_RECEIVED, /**< Data is received */ + BT_EVENT_CONNECTION_STATE_CHANGED, /**< Connection state is changed */ + BT_EVENT_RFCOMM_CONNECTION_REQUESTED, /**< RFCOMM connection is requested */ + BT_EVENT_OPP_CONNECTION_REQUESTED, /**< OPP connection is requested */ + BT_EVENT_OPP_PUSH_REQUESTED, /**< OPP push is requested */ + BT_EVENT_OPP_SERVER_TRANSFER_PROGRESS, /**< OPP transfer progress */ + BT_EVENT_OPP_SERVER_TRANSFER_FINISHED, /**< OPP transfer is completed */ + BT_EVENT_OPP_CLIENT_PUSH_RESPONSED, /**< OPP client connection is reponsed */ + BT_EVENT_OPP_CLIENT_PUSH_PROGRESS, /**< OPP client push progress */ + BT_EVENT_OPP_CLIENT_PUSH_FINISHED, /**< OPP client push is finished */ + BT_EVENT_PAN_CONNECTION_STATE_CHANGED, /**< PAN connection change */ + BT_EVENT_NAP_CONNECTION_STATE_CHANGED, /**< NAP connection change */ + BT_EVENT_HDP_CONNECTED, /**< HDP connection change */ + BT_EVENT_HDP_DISCONNECTED, /**< HDP disconnection change */ + BT_EVENT_HDP_DATA_RECEIVED, /**< HDP Data receive Callabck */ + BT_EVENT_AUDIO_CONNECTION_STATUS, /**< Audio Connection change callback */ + BT_EVENT_AG_SCO_CONNECTION_STATUS, /**< Audio - AG SCO Connection state change callback */ + BT_EVENT_AG_CALL_HANDLING_EVENT, /**< Audio - AG call event callback */ + BT_EVENT_AG_MULTI_CALL_HANDLING_EVENT, /**< Audio - AG 3-way call event callback */ + BT_EVENT_AG_DTMF_TRANSMITTED, /**< Audio - DTMF tone sending request */ + BT_EVENT_AG_MICROPHONE_GAIN_CHANGE, /**< Audio Microphone change callback */ + BT_EVENT_AG_SPEAKER_GAIN_CHANGE, /**< Audio Speaker gain change callback */ + BT_EVENT_AVRCP_CONNECTION_STATUS, /**< AVRCP connection change callback */ + BT_EVENT_AVRCP_EQUALIZER_STATE_CHANGED, /**< AVRCP equalizer state change callback */ + BT_EVENT_AVRCP_REPEAT_MODE_CHANGED, /**< AVRCP repeat mode change callback */ + BT_EVENT_AVRCP_SHUFFLE_MODE_CHANGED, /**< AVRCP equalizer mode change callback */ + BT_EVENT_AVRCP_SCAN_MODE_CHANGED, /**< AVRCP scan mode change callback */ + BT_EVENT_AVRCP_VOLUME_CHANGED, /**AVRCP Volume Changed callback*/ + BT_EVENT_AVRCP_MUTE_STATUS_CHANGED, /**AVRCP mute status change callback*/ + BT_EVENT_A2DP_SINK_CONNECTION_STATUS, /**< A2DP Sink Connection change callback */ + BT_EVENT_A2DP_SINK_AUDIO_STATUS, /**< A2DP Sink Connection change callback */ + BT_EVENT_AUDIO_DATA_RECVD, + BT_EVENT_HID_CONNECTION_STATUS, /**< HID connection status callback */ + BT_EVENT_DEVICE_CONNECTION_STATUS, /**< Device connection status callback */ + BT_EVENT_GATT_CHARACTERISTIC_DISCOVERED, /**< GATT characteristic discovered callback */ + BT_EVENT_GATT_VALUE_CHANGED, /**< GATT characteristic value changed callback */ + BT_EVENT_GATT_WRITE_CHARACTERISTIC, /**< GATT characteristic value read callback */ + BT_EVENT_GATT_CLIENT_CHARACTERISTIC_DISCOVERED_LEGACY, /**< GATT characteristic discovered callback */ + BT_EVENT_GATT_CLIENT_CHARACTERISTIC_DESCRIPTOR_DISCOVERED_LEGACY, /**< GATT characteristic descriptor discovered callback */ + BT_EVENT_GATT_CLIENT_VALUE_CHANGED_LEGACY, /**< GATT characteristic value changed callback */ + BT_EVENT_GATT_CLIENT_READ_CHARACTERISTIC_LEGACY, /**< GATT characteristic value read callback */ + BT_EVENT_GATT_CLIENT_WRITE_CHARACTERISTIC_LEGACY, /**< GATT characteristic value write callback */ + BT_EVENT_HID_AUDIO_DATA_RECVD, /**< HID AUDIO DATA RECVD callback*/ + BT_EVENT_HID_VOICE_KEY_PRESSED, /**< HID_AUDIO_BTN_PRESSED callback*/ + BT_EVENT_HID_BATTERY_STATUS_RECEIVED, /**< HID battery status received callback*/ + BT_EVENT_HID_MBR_RETURN_RECVD, /**< HID_MBR_RETURN_RECVD callback */ + BT_EVENT_HID_SENSOR_DATA_RECEIVED, /**< HID_SENSOR_DATA_RECEIVED callback */ + BT_EVENT_HID_SMARTRC_CONNECTION_STATUS, /**< HID SmartRC Connection callback*/ + BT_EVENT_AUTHORIZE_REQUEST, /**< Incoming authorization request callback event */ + BT_EVENT_MAX_CONNECTION_REACHED, /**< Max connection limit reached event callback*/ + BT_EVENT_AUTHENTICATION_REQUEST, /**< Authentication events during pairing process*/ + BT_EVENT_SYNC3D_ASSOCIATION_NOTIFIED, /**< 3DSYNC Glass associated callback */ + BT_EVENT_SYNC3D_VSPEC_EVENT_RECEIVED, /**< 3DSYNC vendor specific event received callback */ + BT_EVENT_ADVERTISING_STATE_CHANGED, /**< Advertising state changed callback */ + BT_EVENT_ADVERTISING_MANUFACTURER_DATA_CHANGED, /**< Advertising manufacturer data changed callback */ + BT_EVENT_SCAN_RESPONSE_MANUFACTURER_DATA_CHANGED, /**< Scan response manufacturer data changed callback */ + BT_EVENT_LE_DEVICE_DISCOVERY_STATE_CHANGED, /**< LE Only Device discovery state is changed */ + BT_EVENT_HID_SMARTRC_FW_UPDATE_STATUS, /**< Smart RC FW Upgrade status */ + BT_EVENT_DUT_MODE, /**< Throughput mode is running for smartRC */ + BT_EVENT_BT_CHIP_FW_UPDATE_STATUS, /**< BT Chip FW update status */ +} bt_event_e; + +/** + * @internal + */ +typedef struct bt_event_sig_event_slot_s +{ + int event_type; + void *callback; + void *user_data; +} bt_event_sig_event_slot_s; + + +#define BT_CHECK_INPUT_PARAMETER(arg) \ + if (arg == NULL) \ + { \ + LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, BT_ERROR_INVALID_PARAMETER); \ + return BT_ERROR_INVALID_PARAMETER; \ + } + +#define BT_NOT_SUPPORTED_FUNCTION() \ + { \ + LOGE("[%s] NOT SUPPORTED FUNCTION(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } + +#ifdef TIZEN_BT_DISABLE +#define BT_CHECK_BT_SUPPORT() \ + { \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_BT_SUPPORT() +#endif + +/** + * @internal + * @brief Check the initialzating status + */ +int _bt_check_init_status(void); + +#define BT_CHECK_INIT_STATUS() \ + if (_bt_check_init_status() == BT_ERROR_NOT_INITIALIZED) \ + { \ + LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \ + return BT_ERROR_NOT_INITIALIZED; \ + } + +/** + * @internal + * @brief Initialize Bluetooth LE adapter + */ +int _bt_le_adapter_init(void); + +/** + * @internal + * @brief Deinitialize Bluetooth LE adapter + */ +int _bt_le_adapter_deinit(void); + +/** + * @internal + * @brief Set the event callback. + */ +void _bt_set_cb(int events, void *callback, void *user_data); + +/** + * @internal + * @brief Unset the event callback. + */ +void _bt_unset_cb(int events); + +/** + * @internal + * @brief Check if the event callback exist or not. + */ +bool _bt_check_cb(int events); + +/** + * @internal + * @brief Convert Bluetooth F/W error codes to capi Bluetooth error codes. + */ +int _bt_get_error_code(int origin_error); + + +/** + * @internal + * @brief Convert Bluetooth F/W bluetooth_device_info_t to capi bt_device_info_s. + */ +int _bt_get_bt_device_info_s(bt_device_info_s **dest_dev, bluetooth_device_info_t *source_dev); + + +/** + * @internal + * @brief Free bt_device_info_s. + */ +void _bt_free_bt_device_info_s(bt_device_info_s *device_info); + +/** + * @internal + * @brief Free bt_adapter_headless_dev_info_s. + */ +void _bt_free_headless_device_info_s(bt_adapter_headless_dev_info_s *device_info); + +/** + * @internal + * @brief Convert Bluetooth F/W bluetooth_hid_device_info_t to capi bt_hid_device_info_s. + */ + +int _bt_get_specific_bt_device_info_s(bt_hid_device_info_s **dest_dev, bluetooth_hid_device_info_t *source_dev); + +/** + * @internal + * @brief Free bt_device_info_s. + */ +void _bt_free_specific_bt_device_info_s(bt_hid_device_info_s *device_info); + +/** + * @internal + * @brief Convert Bluetooth F/W bluetooth_device_address_t to string. + */ +int _bt_convert_address_to_string(char **addr_str, bluetooth_device_address_t *addr_hex); + + +/** + * @internal + * @brief Convert string to Bluetooth F/W bluetooth_device_address_t. + */ +void _bt_convert_address_to_hex(bluetooth_device_address_t *addr_hex, const char *addr_str); + + +/** + * @internal + * @brief Convert error code to string. + */ +const char* _bt_convert_error_to_string(int error); + +/** + * @internal + * @brief Convert the visibility mode + */ +bt_adapter_visibility_mode_e _bt_get_bt_visibility_mode_e(bluetooth_discoverable_mode_t mode); + +/** + * @internal + * @brief Since the Audio call back and event proxy call backs have different prototype it is wrapper function. + */ +void _bt_audio_event_proxy(int event, bt_audio_event_param_t *param, void *user_data); + +/** + * @internal + * @brief Since the Telephony call back and event proxy call backs have different prototype it is wrapper function. + */ +void _bt_telephony_event_proxy(int event, telephony_event_param_t *param, void *user_data); + +/** + * @internal + * @brief Since the AVRCP call back and event proxy call backs have different prototype it is wrapper function. + */ +void _bt_avrcp_event_proxy(int event, media_event_param_t *param, void *user_data); + +/** + * @internal + * @brief Since the HID call back and event proxy call backs have different prototype it is wrapper function. + */ +void _bt_hid_event_proxy(int event, hid_event_param_t *param, void *user_data); + +/** + * @internal + * @brief Since the Sync3d call back and event proxy call backs have different prototype it is wrapper function. + */ +void _bt_sync3d_event_proxy(int event, bt_sync3d_event_param_t *param, void *user_data); + +/** + * @internal + * @brief Start the smartRC throughput calculation mode. + */ +int _bt_start_smartrc_tput_mode(void); + +/** + * @internal + * @brief Start the throughput calculation mode. + */ +int _bt_stop_smartrc_tput_mode(void); + + +/** + * @internal + * @brief Convert Bluetooth F/W bluetooth_a2dp_sink_audio_info_t to capi bt_a2dp_sink_audio_info_s. + */ +int _bt_get_bt_a2dp_sink_audio_info_s(bt_a2dp_sink_audio_info_s **dest_audio_info, bluetooth_a2dp_sink_audio_info_t *source_audio_info); + +/** + * @internal + * @brief Frees memory allocated to bt_a2dp_sink_audio_info_s + */ +void _bt_free_bt_a2dp_sink_audio_info_s(bt_a2dp_sink_audio_info_s *audio_info); + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_BLUETOOTH_PRIVATE_H__ */ diff --git a/include/tv/bluetooth_product.h b/include/tv/bluetooth_product.h new file mode 100644 index 0000000..8add9f0 --- /dev/null +++ b/include/tv/bluetooth_product.h @@ -0,0 +1,2111 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_NETWORK_BLUETOOTH_PRODUCT_H__ +#define __TIZEN_NETWORK_BLUETOOTH_PRODUCT_H__ +#include <glib.h> +#include <stdlib.h> +#include <unistd.h> +#include <stdbool.h> +#include <tizen_error.h> + +#include "bluetooth_type.h" +#include "bluetooth_type_product.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** + * @file bluetooth_product.h + */ + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function that will be invoked when MaxDeviceConnected event is received. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @see bt_initialize() + */ +int bt_adapter_set_max_device_connected_cb(bt_adapter_max_conection_reached_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters a callback function that will be invoked when MaxDeviceConnected event is received. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @see bt_initialize() + * @see bt_adapter_set_max_device_connected_cb() + */ +int bt_adapter_unset_max_device_connected_cb(void); + + +int bt_adapter_set_authentication_req_cb(bt_adapter_authentication_req_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters a callback function that will be invoked when remote device requests authentication. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @see bt_initialize() + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_adapter_unset_authentication_req_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief API to reply with PIN or PASSKEY with authentication type - TRUE or FALSE. + * @remarks This function can be called by application when remote device requests PIN or PASSKEY from + * local adapter. + * @param[in] passkey The passkey to be provided by application when remote devices requests for it. + * @param[in] authentication_reply This indicates whether application wants to accept or cancel the on-going pairing + * @pre This function can only be called when application receieves authentication event (BT_AUTH_PIN_REQUEST) + * from remote device. + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_passkey_reply(char *passkey, bool authentication_reply); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief API to provide consent for on-going SSP with remote device. + * @remarks This function can be called by application, when local adapter wants PASSKEY confirmation from user. + * @param[in] reply This indicates whether application wants to accepts or cancels the on-going pairing + * reply : TRUE will indicate that Application has appeoved pairing request. + * reply : FALSE will indicate that Application has denied pairing request. + * In this situation the pairing will be failed. + * @pre This function should only be called when application receives authentication event (BT_AUTH_SSP_CONSENT_REQUEST) + * from remote device. + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_ssp_consent_reply(bool reply); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief API to reply to the PASSKEY confirmation for on-going pairing with remote device. + * @remarks This function can be called by application, when local adapter wants PASSKEY confirmation from user. + * @param[in] confirmation_reply This indicates whether application wants to accepts or cancels the on-going pairing + * confirmation_reply : TRUE will indicate that Application has confirmed the PASSKEY + * confirmation_reply : FALSE will indicate that Application has failed to confirm the PASSKEY. In this situation + * the pairing will be failed. + * @pre This function can only be called when application receives authentication event (BT_AUTH_PASSKEY_CONFIRM_REQUEST) + * from remote device. + * @see bt_adapter_set_authentication_req_cb() + */ +int bt_passkey_confirmation_reply(bool confirmation_reply); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Set duration of discovery. + * + * @remarks To connect to peer Bluetooth device, you need to know its Bluetooth address. \n + * The device discovery can be stopped by bt_adapter_stop_device_discovery(). + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @post After this function, bt_adapter_device_discovery_start() should be called. + * + * @see bt_adapter_enable() + * @see bt_adapter_is_discovering() + * @see bt_adapter_stop_device_discovery() + * @see bt_adapter_device_discovery_state_changed_cb() + * @see bt_adapter_set_device_discovery_state_changed_cb() + * @see bt_adapter_unset_device_discovery_state_changed_cb() + */ +int bt_adapter_set_duration(int duration); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Starts the device discovery, asynchronously with duration + * + * @details If a device is discovered, bt_adapter_device_discovery_state_changed_cb() will be invoked + * with #BT_ADAPTER_DEVICE_DISCOVERY_FOUND, and then bt_adapter_device_discovery_state_changed_cb() + * will be called with #BT_ADAPTER_DEVICE_DISCOVERY_FINISHED in case of the completion or cancellation of the discovery. + * + * @remarks To connect to peer Bluetooth device, you need to know its Bluetooth address. \n + * The device discovery can be stopped by bt_adapter_stop_device_discovery(). + * + * @param[in] duration the discvoery duration + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @post This function invokes bt_adapter_device_discovery_state_changed_cb(). + * + * @see bt_adapter_enable() + * @see bt_adapter_is_discovering() + * @see bt_adapter_stop_device_discovery() + * @see bt_adapter_device_discovery_state_changed_cb() + * @see bt_adapter_set_device_discovery_state_changed_cb() + * @see bt_adapter_unset_device_discovery_state_changed_cb() + */ +int bt_adapter_start_device_discovery_with_duration(int duration); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Starts the device discovery, asynchronously based on class of device. + * + * @details If a device is discovered, bt_adapter_device_discovery_state_changed_cb() will be invoked + * with #BT_ADAPTER_DEVICE_DISCOVERY_FOUND, and then bt_adapter_device_discovery_state_changed_cb() + * will be called with #BT_ADAPTER_DEVICE_DISCOVERY_FINISHED in case of the completion or cancellation of the discovery. + * + * @remarks To connect to peer Bluetooth device, you need to know its Bluetooth address. \n + * The device discovery can be stopped by bt_adapter_stop_device_discovery(). + * + * @param[in] major major class of the device + * @param[in] minor minor class of the device + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @post This function invokes bt_adapter_device_discovery_state_changed_cb(). + * + * @see bt_adapter_enable() + * @see bt_adapter_is_discovering() + * @see bt_adapter_stop_device_discovery() + * @see bt_adapter_device_discovery_state_changed_cb() + * @see bt_adapter_set_device_discovery_state_changed_cb() + * @see bt_adapter_unset_device_discovery_state_changed_cb() + */ +int bt_adapter_start_device_discovery_with_class_of_device(int major, int minor); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Starts the device discovery, asynchronously based on the remote bluetooth address. + * + * @details If a device is discovered, bt_adapter_device_discovery_state_changed_cb() will be invoked + * with #BT_ADAPTER_DEVICE_DISCOVERY_FOUND, and then bt_adapter_device_discovery_state_changed_cb() + * will be called with #BT_ADAPTER_DEVICE_DISCOVERY_FINISHED in case of the completion or cancellation of the discovery. + * + * @remarks To connect to peer Bluetooth device, you need to know its Bluetooth address. \n + * The device discovery can be stopped by bt_adapter_stop_device_discovery(). + * + * @param[in] remote_address bluetooth address of the remote device + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @post This function invokes bt_adapter_device_discovery_state_changed_cb(). + * + * @see bt_adapter_enable() + * @see bt_adapter_is_discovering() + * @see bt_adapter_stop_device_discovery() + * @see bt_adapter_device_discovery_state_changed_cb() + * @see bt_adapter_set_device_discovery_state_changed_cb() + * @see bt_adapter_unset_device_discovery_state_changed_cb() + */ +int bt_adapter_start_device_discovery_with_address(const char *remote_address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Starts the device discovery, asynchronously for peer 3D TV. + * + * @details If a device is discovered, bt_adapter_device_discovery_state_changed_cb() will be invoked + * with #BT_ADAPTER_DEVICE_DISCOVERY_FOUND, and then bt_adapter_device_discovery_state_changed_cb() + * will be called with #BT_ADAPTER_DEVICE_DISCOVERY_FINISHED in case of the completion or cancellation of the discovery. + * + * The device discovery can be stopped by bt_adapter_stop_device_discovery(). + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @post This function invokes bt_adapter_device_discovery_state_changed_cb(). + * + * @see bt_adapter_enable() + * @see bt_adapter_is_discovering() + * @see bt_adapter_stop_device_discovery() + * @see bt_adapter_device_discovery_state_changed_cb() + * @see bt_adapter_set_device_discovery_state_changed_cb() + * @see bt_adapter_unset_device_discovery_state_changed_cb() + */ +int bt_adapter_start_device_discovery_for_3dtv(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Gets the specific device information of a bonded device. + * @remarks The @a device_info must be released with bt_adapter_free_hid_device_info() by you . + * + * @param [in] remote_address The address of remote device + * @param [out] device_info The bonded device information + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @post This function invokes bt_adapter_bonded_device_cb(). + * + * @see bt_adapter_bonded_device_cb() + * @see bt_adapter_enable() + */ +int bt_adapter_get_specific_bonded_device_info(const char *remote_address, bt_hid_device_info_s **device_info); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Frees HID device info. + * + * @param [in] device_info The bonded device information of HID device + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see bt_adapter_get_bonded_device_info() + */ +int bt_adapter_free_hid_device_info(bt_hid_device_info_s *device_info); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE +* @brief Set Vendor Specific Tx Power Data based +* on TX Power Class. +* @param[in] tx power class type +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +*/ +int bt_adapter_set_tx_power(bt_adapter_tx_pwr_class tx_power_class); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enable or Disable Headless Mode + * Headless Mode MUST not be enabled during normal + * operation. Once Headless mode mode is enabled, + * HCI will stop working. Any further command to + * Bluetooth adapter will cause undefined behaviour. + * Headless Mode can only be enabled just before + * Power Down of TV stack. + * + * @param[in] enable TRUE: Enable FALSE: disable + * @retval #BLUETOOTH_ERROR_NONE - Success + * @retval #BLUETOOTH_ERROR_INTERNAL -Failure + */ +int bt_adapter_set_headless_mode(bool enable); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a headless device (which supports + * Headless Mode)to Bluetooth adapter. + * @param[in] remote_address BD address of the Headless + * device to be registered. + * @retval #BLUETOOTH_ERROR_NONE - Success + * @retval #BLUETOOTH_ERROR_INTERNAL -Failure + */ +int bt_adapter_register_headless_device(const char *remote_address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Un-registers a headless device (which supports + * Headless Mode)to Bluetooth adapter. + * @param[in] remote_address BD address of the Headless + * device to be un-registered. + * @retval #BLUETOOTH_ERROR_NONE - Success + * @retval #BLUETOOTH_ERROR_INTERNAL -Failure + */ +int bt_adapter_unregister_headless_device(const char *remote_address); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Retrieves the device information of all bonded devices. + * + * @param [in] callback The callback function to invoke + * @param [in] user_data The user data passed from the foreach function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @post This function invokes bt_adapter_headless_device_info_cb(). + * + */ +int bt_adapter_foreach_headless_device_info(bt_adapter_headless_device_info_cb foreach_cb, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Frees headless dev info structures allocated previously + * + * @param[in] device_info + * device_info is a poiter to one headless device info structure + * + * @retval #BLUETOOTH_ERROR_NONE - Success + * @retval #BLUETOOTH_ERROR_INTERNAL -Failure + */ +int bt_adapter_free_headless_device_info(bt_adapter_headless_dev_info_s *device_info); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Set Headless Scan Mode. + * LLR mode will be enabled by BT chip or firmware. + * + * @param[in] llr_scan Enable or Disable LLR scan + * + * @retval #BLUETOOTH_ERROR_NONE - Success + * @retval #BLUETOOTH_ERROR_INTERNAL -Failure + */ +int bt_adapter_set_headless_scan_control(bool llr_scan); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief bluetooth sleep API with Standby + * enable or disable. + * + * Case: Standby = false + * Intant TV on support + * + * Headless Mode will be turned on internally MUST not be enabled + * during normal operation. Once Headless mode mode + * is enabled. + * HCI will stop working. Any further command to + * Bluetooth adapter will cause undefined behaviour. + * Headless Mode can only be enabled just before + * Power Down of TV stack. + * + * Case: Standby = true + * This will trigger disconnection of all + * connected Bluetooth devices + * + * @param[in] standby TRUE:TV Instant On Mode + * standby FALSE: Headless Mode + * @retval #BT_ERROR_NONE - Success + * @retval #BT_ERROR_OPERATION_FAILED -Failure + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int bt_adapter_sleep_bluetooth(bool standby); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief bluetooth power off API + * + * Headless Mode will be turned on internally MUST not be enabled + * during normal operation. Once Headless mode mode + * is enabled. + * HCI will stop working. Any further command to + * Bluetooth adapter will cause undefined behaviour. + * Headless Mode can only be enabled just before + * Power Down of TV stack. + * + * @retval #BT_ERROR_NONE - Success + * @retval #BT_ERROR_OPERATION_FAILED -Failure + */ +int bt_adapter_power_off(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Checks if Samsung Audio dock device is connected. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED If A2DP device is not connected. + * + * @see bt_adapter_enable() + */ +int bt_adapter_is_samsung_audio_dock_connected(bool *connected); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called to register BT Chip FW update progress status. + * @details This callback is called when application wants to register + * the callback for receiving BT Chip FW update status event. + * @param[in] Callback to be registered for FW update status event. + * @param[in] user_data The user data passed from the callback registration + * function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + */ +int bt_adapter_set_bt_chip_fw_update_status_cb(bt_adapter_notify_bt_chip_fw_update_status_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters a callback function that will be invoked when the + * BT Chip FW update status event is received. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @see bt_adapter_set_bt_chip_fw_update_status_cb() + */ +int bt_adapter_unset_bt_chip_fw_update_status_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Accepts the authorization of a bonded device, asynchronously. + * + * @param[in] remote_address The address of the remote Bluetooth device to authorize + * @param[in] service_id The service id of the remote Bluetooth device + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @pre The bond with the remote device must be created with bt_device_create_bond(). + * @post bt_device_authorization_changed_cb() will be invoked. + * + * @see bt_adapter_enable() + * @see bt_device_create_bond() + * @see bt_device_authorization_changed_cb() + * @see bt_device_set_authorization_changed_cb() + * @see bt_device_unset_authorization_changed_cb() + */ +int bt_device_accept_authorization(const char *device_address, int service_id); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Rejects the authorization of a bonded device, asynchronously. + * + * @param[in] remote_address The address of the remote Bluetooth device + * @param[in] remote_address The service id of the remote Bluetooth device + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @see bt_adapter_enable() + * @see bt_device_create_bond() + * @see bt_device_authorization_changed_cb() + * @see bt_device_set_authorization_changed_cb() + * @see bt_device_unset_authorization_changed_cb() + */ +int bt_device_reject_authorization(const char *device_address, int service_id); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Checks whether stereo headset is connnected or not. + * @param[out] opened The SCO status: (@c true = connected, @c false = not connected) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + */ +int bt_device_is_a2dp_connected(bool *connected); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function to be invoked when incoming authorization event is received. + * + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_device_auth_event_state_changed_cb() will be invoked. + * + * @see bt_initialize() + */ +int bt_device_set_auth_event_state_changed_cb(bt_device_auth_event_state_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function to be invoked when incoming authorization event is received. + * + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_device_auth_event_cb() will be invoked. + * + * @see bt_initialize() + */ +int bt_device_set_auth_event_cb(bt_device_auth_event_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called when sound data from hid smart RC is received. + * @details This callback is called when the hid smart RC sends voice data. + * @param[in] pointer to bt_hid_voice_data_s. (contains raw pcm sample buffer and + * length of the buffer) + * @param[in] user_data The user data passed from the callback registration + * function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Failed + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + */ +int bt_hid_set_audio_data_receive_cb(bt_hid_audio_data_receive_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Unregisters a callback function that will be invoked when sound + * data from hid smart RC is received. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + * @see bt_hid_set_audio_data_receive_cb() + */ +int bt_hid_unset_audio_data_receive_cb(void); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE +* @brief To set bt_hid_notify_smart_rc_connection_cb callback. +* @details This is API to set is smart rc connection callback. +* @param[in] Callback to be register for is smart_rc connection. +* @param[in] user_data The user data passed from the callback registration function. +* @return 0 on success, otherwise a negative error value. +* @retval #BT_ERROR_NONE Successful. +* @retval #BT_ERROR_NOT_INITIALIZED Not initialized. +* @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). +*/ +int bt_hid_set_smart_rc_connection_cb(bt_hid_notify_smart_rc_connection_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Unregisters a callback function that will be invoked when smart_rc is disconnected. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful. + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized. + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + * @see bt_hid_set_smart_rc_connection_cb(). + */ +int bt_hid_unset_smart_rc_connection_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called when the sound button is pressed on hid smart RC. + * @details This callback is called when the user presses the sound button on + * hid smart RC. + * @param[in] sound button state (pressed = 1, released = 0) + * @param[in] user_data The user data passed from the callback registration + * function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + */ +int bt_hid_set_sound_key_pressed_cb(bt_hid_notify_sound_key_pressed_cb callback, + void *user_data); +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Unregisters a callback function that will be invoked when the sound + * button is pressed on hid smart RC. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + * @see bt_hid_set_sound_key_pressed_cb() + */ +int bt_hid_unset_sound_key_pressed_cb(void); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called to register callback for battery status receieve event. + * @details This callback is called when application wants to register + * the callback for receiving battery status event. + * @param[in] Callback to be registered for battery status event. + * @param[in] user_data The user data passed from the callback registration + * function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + */ +int bt_hid_set_battery_status_received_cb(bt_hid_notify_battery_status_received_cb callback, + void *user_data); +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Unregisters a callback function that will be invoked when the + * battery status event is received from smart RC. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + * @see bt_hid_set_battery_status_received_cb() + */ +int bt_hid_unset_battery_status_received_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called to register FW update progress status event from Smart RC. + * @details This callback is called when application wants to register + * the callback for receiving FW update status event. + * @param[in] Callback to be registered for FW update status event. + * @param[in] user_data The user data passed from the callback registration + * function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + */ +int bt_hid_set_smart_rc_fw_update_status_cb(bt_hid_notify_smart_rc_fw_update_status_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Unregisters a callback function that will be invoked when the + * FW update status event is received from smart RC. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + * @see bt_hid_set_smart_rc_fw_update_status_cb() + */ +int bt_hid_unset_smart_rc_fw_update_status_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODUL + * @brief Update SmartRC Firmware. + * This function is a synchronous call. + * @return #BT_ERROR_NONE Success + * @return #BT_ERROR_INVALID_PARAMETER Invalid paramete + * @return #BT_ERROR_NOT_ENABLED Not enable + * @return #BT_ERROR_OPERATION_FAILED Operation failed + * @exception None + * @param[in] remote_address This indicates an address of the device to which + * command should be sent + * @param[in] path of the Smart RC FW. Should be a valid path. + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + * @remark Can only be used when SmartRC is connected + */ +int bt_hid_update_smart_rc_fw(const char *remote_address, const char *path); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODUL + * @brief Get SmartRC Firmware Version. + * This function is a synchronous call. + * @return #BT_ERROR_NONE Success + * @return #BT_ERROR_INVALID_PARAMETER Invalid paramete + * @return #BT_ERROR_NOT_ENABLED Not enable + * @return #BT_ERROR_OPERATION_FAILED Operation failed + * @exception None + * @param[in] remote_address This indicates an address of the device to which + * command should be sent + * @param[out] version Firmware version of connected SmartRC + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + * @remark Can only be used when SmartRC is connected + */ +int bt_hid_get_smart_rc_fw_version(const char *remote_address, int *version); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called when mbr return from hid smart RC is received. + * @details This callback is called when the hid smart RC sends mbr return. + * @param[in] pointer to bt_hid_mbr_return_s. (contains mbr return buffer + * and length of the buffer + * @param[in] user_data The user data passed from the callback registration + * function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + */ +int bt_hid_set_mbr_return_receive_cb(bt_hid_mbr_return_receive_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Unregisters a callback function that will be invoked when mbr + * command response from hid smart RC is received. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + * @see bt_hid_set_mbr_return_receive_cb() + */ +int bt_hid_unset_mbr_return_receive_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called when sensor data from hid smart RC is received. + * @details This callback is called when the hid smart RC sends sensor data. + * @param[in] pointer to bt_hid_sensor_data_s. (contains sensor data) + * @param[in] user_data The user data passed from the callback registration + * function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + */ +int bt_hid_set_sensor_data_receive_cb(bt_hid_sensor_data_receive_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Unregisters a callback function that will be invoked when + * sensor data from hid smart RC is received. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + * @see bt_hid_set_sensor_data_receive_cb() + */ +int bt_hid_unset_sensor_data_receive_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Send stop voice data command to smart RC. + * service, asynchronously. + * @param[in] remote_address The remote address + * If remote address is NULL, RC command will be sent + * to all connected HID remotes. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @pre The remote device must be connected by bt_hid_host_connect(). + * @see bt_hid_host_connect() +*/ +int bt_hid_rc_stop_sending_voice(const char *remote_address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Send RC commands smart remote. + * @param[in] remote_address The remote address + * If remote address is NULL, RC command will be sent + * to all connected HID remotes. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @pre The remote device must be connected by bt_hid_host_connect(). + * @see bt_hid_host_connect() +*/ +int bt_hid_send_rc_command(const char *remote_address, + const unsigned char *data, unsigned short length); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Send haptic commands smart remote. + * @param[in] data Haptic command to send + * @param[in] force Whether if send command forcely or following menu option. + * @param[in] voltage voltage level + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @pre The remote device must be connected by bt_hid_host_connect(). + * @see bt_hid_host_connect() +*/ +int bt_hid_send_haptic_command(const unsigned char data, bool force, int voltage); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Send haptic data to Smart Touch Remote. + * @param[in] remote_address The remote address + * @param[in] data Haptic data to send + * Total 7 bytes of Haptic data are allowed + * Byte 0: Device Type + * Byte 1: Strength 0 + * Byte 2: Strength 1 + * Byte 3: Pattern Index #0 + * Byte 4: Pattern Index #1 + * Byte 5: Pattern Index #2 + * Byte 6: Reserved + * @param[in] length length of the data + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @pre The remote device must be connected by bt_hid_host_connect(). + * @see bt_hid_host_connect() +*/ +int bt_hid_send_haptic_data(const char *remote_address, const unsigned char *data, + unsigned short length); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Send Device Command to smart RC. + * @param[in] remote_address The remote address + * If remote address is NULL, RC command will be sent + * to all connected HID devices. + * @param[in] device_type Device type (for e.g Smart Remote) + * @param[in] device_cmd Device command. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @pre The remote device must be connected by bt_hid_host_connect(). + * @see bt_hid_host_connect() +*/ +int bt_hid_send_device_command(const char *remote_address, unsigned char device_type, + unsigned char device_cmd); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Send MBR command to smart RC. + * @param[in] remote_address The remote address + * If remote address is NULL, RC command will be sent + * to all connected HID devices. + * @param[in] data data buffer pointer. + * @param[in] len Length of data. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @pre The remote device must be connected by bt_hid_host_connect(). + * @see bt_hid_host_connect() +*/ +int bt_hid_send_mbr_command(const char *remote_address, const unsigned char* data, + unsigned short len); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Send MBR Data to smart RC. + * @param[in] remote_address The remote address + * If remote address is NULL, RC command will be sent + * to all connected HID devices. + * @param[in] data data buffer pointer. + * @param[in] len Length of data. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @pre The remote device must be connected by bt_hid_host_connect(). + * @see bt_hid_host_connect() +*/ +int bt_hid_send_mbr_data(const char *remote_address, const unsigned char* data, + unsigned short len); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Set smart remote sensor calibration mode. + * @param[in] enable = calibration status (enabled = TRUE, Disabled = FALSE) + * @param[in] mode = calibration mode(calibration algorithm to be used) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_ENABLED Not enabled + */ +int bt_hid_set_calibration_mode(bool enable, int mode); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Get connection status for smart remote. + * @param[out] is_connected: True if connected false otherwise. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + */ +int bt_hid_get_smart_remote_conn_status(bool *is_connected); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Get battery status for smart remote. + * @param[out] status: battery status for smart remote + * status can assume following values: + * 0x00 : Battery Level Monitoring is not supported + * 0x01 : Battey Level 1 + * 0x02 : Battery Level 2 + * 0x03 : Battery Level 3 + * 0x04 : Battery Full + * 0x05 : Low Battery + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED device not connected + */ +int bt_hid_get_smart_rc_battery_status(unsigned char *status); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Selects the audio stream to be routed to Bluetooth audio devices. + * @details One of following two audio streams can be selected for bluetooth audio devices: + * BT_AUDIO_MAIN_STREAM - to select main audio stream to be routed to bluetoot devices + * BT_AUDIO_SUB_STREAM - to select audio sub stream to be routed to bluetoot devices + * + * @param[in] stream The type of audio stream to be selected for bluetooth audio devices + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + */ +int bt_audio_select_stream(bt_audio_stream_type_s stream); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Selects the audio profile for Bluetooth audio devices. + * @details One of following two audio profiles can be selected for bluetooth audio devices: + * BT_AUDIO_SOURCE_ROLE - to select A2DP source profile for bluetoot devices + * BT_AUDIO_SINK_ROLE - to select A2DP sink profile for bluetoot devices + * + * @param[in] profile name The type of audio profile to be selected for bluetooth audio devices + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + */ +int bt_audio_select_role(bt_audio_role_type_s role); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Connects the remote device with the given a2dp sink profile, asynchronously. + * @details If you input type as #BT_AUDIO_PROFILE_TYPE_ALL and connection request succeeds, then bt_audio_connection_state_changed_cb() will be called twice + * when #BT_AUDIO_PROFILE_TYPE_HSP_HFP is connected and #BT_AUDIO_PROFILE_TYPE_A2DP is connected. + * @param[in] remote_address The remote address + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @pre The Bluetooth audio service must be initialized with bt_a2dp_sink_init(). + * @post bt_audio_connection_state_changed_cb() will be invoked. + * @see bt_a2dp_sink_disconnect() + * @see bt_a2dp_sink_connection_state_changed_cb() + */ +int bt_a2dp_sink_connect(const char *remote_address); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Disconnects the remote device with the given a2dp sink profile, asynchronously. + * @details if disconnection request succeeds, then bt_audio_connection_state_changed_cb() will be called + * @param[in] remote_address The remote address + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @pre The remote device must be connected by bt_a2dp_sink_connect(). + * @post bt_a2dp_sink_connection_state_changed_cb() will be invoked. + * @see bt_a2dp_sink_connect() + * @see bt_a2dp_sink_connection_state_changed_cb() + */ +int bt_a2dp_sink_disconnect(const char *remote_address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Registers a callback function that will be invoked when the connection state is changed. + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @see bt_a2dp_sink_connection_state_changed_cb() + */ +int bt_a2dp_sink_set_connection_state_changed_cb(bt_a2dp_sink_connection_state_changed_cb callback, void *user_data); + + + /** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Unregisters a callback function that will be invoked when the connection state is changed. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @see bt_a2dp_sink_connection_state_changed_cb() + * @see bt_a2dp_sink_set_connection_state_changed_cb() + */ +int bt_a2dp_sink_unset_connection_state_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Gets a2dp sink stream audio information + * @param[in] remote_address The remote address + * @param[out] audio_info Structure containing audio stream info + * @return 0 on success, otherwise a negative error value. + * + */ +int bt_a2dp_sink_get_audio_info(const char *remote_address, bt_a2dp_sink_audio_info_s **audio_info); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Frees memory allocated to bt_a2dp_sink_audio_info_s + * @param[in] audio_info Structure containing audio stream info + * @return 0 on success, otherwise a negative error value. + * + */ +int bt_a2dp_sink_free_audio_info(bt_a2dp_sink_audio_info_s *audio_info); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Registers a callback function that will be invoked when the audio state is changed. + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @see bt_a2dp_sink_audio_state_changed_cb() + */ +int bt_a2dp_sink_set_audio_state_changed_cb(bt_a2dp_sink_audio_state_changed_cb callback, void *user_data); + + + /** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Unregisters a callback function that will be invoked when the connection state is changed. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @see bt_a2dp_sink_audio_state_changed_cb() + * @see bt_a2dp_sink_set_audio_state_changed_cb() + */ +int bt_a2dp_sink_unset_audio_state_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief registers a callback function that will be invoked when sound + * data from remote audio source is received. + * @details This callback is called when the remote audio source sends audio data. + * @param[in] pointer to bt_audio_data_s. (contains raw pcm sample buffer and + * length of the buffer) + * @param[in] user_data The user data passed from the callback registration + * function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Failed + */ +int bt_set_audio_data_receive_cb(bt_audio_data_receive_cb callback, void *user_data); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Unregisters a callback function that will be invoked when sound + * data from remote audio source is received. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth HID service must be initialized with bt_hid_host_initialize(). + * @see bt_set_audio_data_receive_cb() + */ +int bt_unset_audio_data_receive_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Send AVRCP command to the target device + * @param[in] AVRCP command + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enableds + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @pre The remote device must be connected. + */ +int bt_avrcp_target_send_cmd(bt_device_send_avrcp_cmd_e avrcp_cmd); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Set AVRCP name + * @param[in] provide name + * @param[in] service name + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enableds + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + */ +int bt_avrcp_set_name(char *provider_name, char *service_name); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Registers a callback function that will be invoked when the SetAbsoluteVolume event is received. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @pre Initialize the AVRCP target by bt_avrcp_target_initialize. + * @see bt_initialize() + * @see bt_avrcp_target_initialize() + */ +int bt_set_avrcp_volume_changed_cb(bt_avrcp_volume_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Registers a callback function that will be invoked when the mute change status event is received. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @pre Initialize the AVRCP target by bt_avrcp_target_initialize. + * @see bt_initialize() + * @see bt_avrcp_target_initialize() + */ +int bt_set_avrcp_mute_state_changed_cb(bt_avrcp_mute_state_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Unregisters a callback function that will be invoked when the mute status is changed by the remote control device. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @see bt_initialize() + * @see bt_set_avrcp_mute_state_changed_cb() + */ +int bt_avrcp_unset_mute_status_changed_cb(void); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE +* @brief Sets the vendor ID and product ID. +* @param[in] vendor ID, 16 bit value +* @param[in] product ID, 16 bit value +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +*/ +int bt_adapter_set_device_id(unsigned short vid, unsigned short pid); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE +* @brief set AFH channel classification to block bluetooth channels for using wifi channel. +* @param[in] first_disabled_channel +* @param[in] last_disabled_channel +* @Note: wifichannel : 0 => no block, 1 ~ 13 => 0~79 +* [Chanels within first and last disabled channels will be blocked. +* +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +*/ +int bt_adapter_block_bt_channels_for_using_wifi(unsigned char first_disabled_channel, + unsigned char last_disabled_channel); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE +* @brief initializes the sync3d profile. +* @param[in} None +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +* @post bt_sync3d_broadcast_on_off(on) shall be called to register +* the sync3d profile and prepare for 3D broadcast +*/ +int bt_sync3d_init(void); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE +* @brief De-initializes the sync3d profile. +* @param[in} None +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +* @pre bt_sync3d_broadcast_on_off(off) shall be called to stop +* the 3D broadcast +*/ +int bt_sync3d_deinit(void); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE +* @brief Enables the sync 3D profile to prepare for 3D broad cast data. +* @param[in] on_off, bool value +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +*/ +int bt_sync3d_broadcast_on_off(bool on_off); + +/** + * @brief Registers a callback function to be invoked when the 3D glasses connects + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The Sync3D profile must be tunred on. + * @see bt_sync3d_association_notified_cb() +*/ +int bt_sync3d_set_association_notified_cb(bt_sync3d_association_notified_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE + * @brief Unregisters the callback function. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * + * @pre The Bluetooth Sync3D must be initialized with bt_sync3d_broadcast_on_off(). + * + * @see bt_sync3d_broadcast_on_off() + * @see bt_sync3d_set_association_notified_cb() + */ +int bt_sync3d_unset_association_notified_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE + * @brief Registers a callback function to be invoked when the sync3d events are generated by the chip + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The Sync3D profile must be tunred on. + * @see bt_sync3d_event_cb() +*/ +int bt_sync3d_set_event_received_cb(bt_sync3d_event_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE + * @brief Unregisters the callback function. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * + * @pre The Bluetooth Sync3D must be initialized with bt_sync3d_broadcast_on_off(). + * + * @see bt_sync3d_broadcast_on_off() + * @see bt_sync3d_set_event_received_cb() + */ +int bt_sync3d_unset_event_received_cb(void); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE +* @brief Sets the duty value for 3D Broadcast. +* @param[in] duty, short value +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +*/ +int bt_sync3d_set_duty_for_broadcast(short duty); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE +* @brief Sets the duty value for 3D Broadcast. +* @param[in] delay, short value +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +*/ +int bt_sync3d_set_dealy_for_broadcast(short delay); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE +* @brief Sets the DTV mode and the master bd addr. +* @param[in] mode, sync3d_dtv_mode value +* @param[in] master_bd_addr, pointer to the master bd address +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +*/ +int bt_sync3d_set_dtv_mode(bt_sync3d_dtv_mode mode, const char *master_bd_addr); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE +* @brief Sets the pairing mode. +* @param[in] on_off, unsigned char value +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +*/ +int bt_sync3d_set_pairing_mode(bool on_off); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE +* @brief Sets the veiw type for 3D Broadcast. +* @param[in] view_type, sync3d_view_type value +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +*/ +int bt_sync3d_set_view_type(bt_sync3d_view_type view_type); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE +* @brief Sets the daul audio mode. +* @param[in] on_off, bool value +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +*/ +int bt_sync3d_set_dual_audio_mode(bool on_off); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE +* @brief Gets the sync period set. +* @param[out] sync_period, unsigned shor value +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +*/ +int bt_sync3d_get_sync_period(unsigned short *sync_period); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE +* @brief Sets the RSSI for proximity pairing. +* @param[in] rssi, short value +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +*/ +int bt_sync3d_set_rssi_for_proximity_pairing(short rssi); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE +* @brief Enable/Disable Sync detect. +* @param[in] bool, bool value +* @retval #BLUETOOTH_ERROR_NONE - Success +* @retval #BLUETOOTH_ERROR_INTERNAL -Failure +*/ +int bt_sync3d_set_vsync_detect(bool on_off); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function to be invoked when the advertising state changes. + * + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_advertising_state_changed_cb() will be invoked. + * + * @see bt_initialize() + * @see bt_adapter_advertising_state_changed_cb() + * @see bt_adapter_unset_advertising_state_changed_cb() + */ +int bt_adapter_set_advertising_state_changed_cb(bt_adapter_advertising_state_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters the callback function. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + * @see bt_adapter_set_advertising_state_changed_cb() + */ +int bt_adapter_unset_advertising_state_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Starts the advertising with passed parameters. + * + * @details Once Bluetooth advertising is started, nearby Bluetooth LE(Low Energy) supported + * devices can know this device's existence. And one of them can make a connection reqeust, + * if it is allowed. + * + * @param[in] adv_params The parameters of advertising \n + * If NULL is passed, default values which are defined in driver / controller are used. + * + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @post This function invokes bt_adapter_advertising_state_changed_cb(). + * + * @see bt_adapter_enable() + * @see bt_adapter_is_advertising() + * @see bt_adapter_stop_advertising() + * @see bt_adapter_advertising_state_changed_cb() + * @see bt_adapter_set_advertising_state_changed_cb() + * @see bt_adapter_unset_advertising_state_changed_cb() + */ +int bt_adapter_start_advertising(bt_adapter_advertising_params_s *adv_params); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Stops the advertising. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOT_IN_PROGRESS Operation is not in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The advertising must be going on with bt_adapter_start_advertising(). + * @post This function invokes bt_adapter_advertising_state_changed_cb(). + * + * @see bt_adapter_is_advertising() + * @see bt_adapter_start_advertising() + * @see bt_adapter_set_advertising_state_changed_cb() + * @see bt_adapter_unset_advertising_state_changed_cb() + * @see bt_adapter_advertising_state_changed_cb() + */ +int bt_adapter_stop_advertising(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Checks for the advertising is going on or stopped. + * + * @remarks If Bluetooth advertising is going on, other LE devices are able to + * search this device. + + * @param[out] is_advertising The advertising status: (@c true = going on, @c false = stopped) + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + * @see bt_adapter_start_advertising() + * @see bt_adapter_stop_advertising() + */ +int bt_adapter_is_advertising(bool *is_advertising); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief add address to whitelist for accepting scanning request. + * + * @remarks If the adress is in the whitelist then other LE devices are able to + * search this device. Before calling this API, make sure that the adapter is + * enabled. There is no callback event for this API. + + * @param[in] address The other device's address + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + * @see bt_adapter_start_advertising() + * @see bt_adapter_stop_advertising() + */ +int bt_adapter_add_white_list(const char *address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief remove address from the whitelist for not accepting scanning request. + * + * @remarks If the adress is in the whitelist then other LE devices are able to + * search this device. Before calling this API, make sure that the adapter is + * enabled. There is no callback event for this API. + * + * @param[in] address The other device's address + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + * @see bt_adapter_start_advertising() + * @see bt_adapter_stop_advertising() + */ +int bt_adapter_remove_white_list(const char *address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief clear address from the whitelist for not accepting scanning request. + * + * @remarks If the adress is in the whitelist then other LE devices are able to + * search this device. Before calling this API, make sure that the adapter is + * enabled. There is no callback event for this API. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + * @see bt_adapter_start_advertising() + * @see bt_adapter_stop_advertising() + */ +int bt_adapter_clear_white_list(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Gets the manfucaturer specific data for advertising of local Bluetooth adapter. + * + * @details Use this function to get the manfucaturer specific data associated with Bluetooth + * device, retrieved by the remote Bluetooth devices. + * + * @remarks The @a data must be released with free() by you. + * + * @param[out] data The manufacturer specific data + * @param[out] len The length of @a data + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + * @see bt_adapter_set_advertising_manufacturer_data() + */ +int bt_adapter_get_advertising_manufacturer_data(char **data, int *len); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Sets the manufacturer specific data for advertising of local Bluetooth adapter. + * + * @param[in] data The manufacturer specific data of the Bluetooth device. + * @param[in] len The length of @a data. The maximum length is 26(bytes). + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @post bt_adapter_advertising_manufacturer_data_changed_cb() will be invoked + * if this function returns #BT_ERROR_NONE. + * + * @see bt_adapter_enable() + * @see bt_adapter_get_advertising_manufacturer_data() + * @see bt_adapter_advertising_manufacturer_data_changed_cb() + * @see bt_adapter_set_advertising_manufacturer_data_changed_cb() + * @see bt_adapter_unset_advertising_manufacturer_data_changed_cb() + */ +int bt_adapter_set_advertising_manufacturer_data(char *data, int len); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function to be invoked + * when the manufacturer specific data for advertising of Bluetooth adapter changes. + * + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_advertising_manufacturer_data_changed_cb() will be invoked. + * + * @see bt_initialize() + * @see bt_adapter_unset_advertising_manufacturer_data_changed_cb() + */ +int bt_adapter_set_advertising_manufacturer_data_changed_cb( + bt_adapter_advertising_manufacturer_data_changed_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters the callback function. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + * @see bt_adapter_set_advertising_manufacturer_data_changed_cb() + */ +int bt_adapter_unset_advertising_manufacturer_data_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Gets the manfucaturer specific data for LE scan response of local Bluetooth adapter. + * + * @details Use this function to get the manfucaturer specific data associated with Bluetooth + * device, retrieved by the remote Bluetooth devices. + * + * @remarks The @a data must be released with free() by you. + * + * @param[out] data The manufacturer specific data + * @param[out] len The length of @a data + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + * @see bt_adapter_set_scan_resp_manufacturer_data() + */ +int bt_adapter_get_scan_resp_manufacturer_data(char **data, int *len); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Sets the manufacturer specific data for LE scan response of local Bluetooth adapter. + * + * @param[in] data The manufacturer specific data of the Bluetooth device. + * @param[in] len The length of @a data. The maximum length is 26(bytes). + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @post bt_adapter_scan_resp_manufacturer_data_changed_cb() will be invoked + * if this function returns #BT_ERROR_NONE. + * + * @see bt_adapter_enable() + * @see bt_adapter_get_scan_resp_manufacturer_data() + * @see bt_adapter_scan_resp_manufacturer_data_changed_cb() + * @see bt_adapter_set_scan_resp_manufacturer_data_changed_cb() + * @see bt_adapter_unset_scan_resp_manufacturer_data_changed_cb() + */ +int bt_adapter_set_scan_resp_manufacturer_data(char *data, int len); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function to be invoked + * when the manufacturer specific data for LE scan response of Bluetooth adapter changes. + * + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_scan_resp_manufacturer_data_changed_cb() will be invoked. + * + * @see bt_initialize() + * @see bt_adapter_unset_scan_resp_manufacturer_data_changed_cb() + */ +int bt_adapter_set_scan_resp_manufacturer_data_changed_cb( + bt_adapter_scan_resp_manufacturer_data_changed_cb callback, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters the callback function. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + * @see bt_adapter_set_scan_resp_manufacturer_data_changed_cb() + */ +int bt_adapter_unset_scan_resp_manufacturer_data_changed_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Sets the scan parameters of local Bluetooth adapter. + * + * @param[in] interval Scan interval. + * @param[in] window Scan window. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + */ +int bt_adapter_set_scan_parameter(float interval, float window); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Sets the specific data for advertising of local Bluetooth adapter. + * + * @param[in] data The specific data of the Bluetooth device. + * @param[in] len The length of @a data. The maximum length is 31(bytes). + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * @post bt_adapter_advertising_manufacturer_data_changed_cb() will be invoked + * if this function returns #BT_ERROR_NONE. + * + * @see bt_adapter_enable() + */ +int bt_adapter_set_headless_advertising_data(char *data, int len); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @Open Mobile Headless DB + * + * @param[in] sdb Address of DB + + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BLUETOOTH_ERROR_INTERNAL Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + */ +int bt_headless_open_db(void **sdb); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @Close Mobile Headless DB + * + * @param[in] sdb Address of DB + + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BLUETOOTH_ERROR_INTERNAL Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + */ +void bt_mobileheadless_close_db(void **sdb); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @Add the BD address of Mobile in DB + * + * @param[in] remote_address BD Address of Mobile + + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + */ +int bt_bluetooth_add_headless_mobile_in_DB(void *db, const char *remote_address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @Add the BD address & Device Type of Mobile in DB + * + * @param[in] remote_address BD Address of Mobile + + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + */ +int bt_bluetooth_add_headless_device_in_DB(void *db, const char *remote_address,const char *dev_type); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @Delete the BD address of Mobile in DB + * + * @param[in] db sqlitedb + * @param[in] remote_address BD Address of Mobile + + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BLUETOOTH_ERROR_INTERNAL Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + */ +int bt_bluetooth_delete_headless_mobile_in_DB(void *db, const char *remote_address); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @Get the BD address of Mobile in Present in DB + * + * @param[in] db sqlitedb + * @param[in] dev_list List of BD Addresses of Mobile Present in DB + + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BLUETOOTH_ERROR_INTERNAL Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + */ +int bt_bluetooth_get_all_headless_mobile_in_DB(void *db, GSList **dev_list); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @Get the BD address and Dev type of Mobile in Present in DB + * + * @param[in] db sqlitedb + * @param[in] dev_list List of BD Addresses of Mobile Present in DB + + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BLUETOOTH_ERROR_INTERNAL Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + */ +int bt_bluetooth_get_all_headless_device_in_DB(void *db, GSList **dev_list); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @Delete the All BD address of Mobile in DB + * + * @param[in] db sqlitedb + * @param[in] void + + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BLUETOOTH_ERROR_INTERNAL Operation failed + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable(). + * + * @see bt_adapter_enable() + */ +int bt_bluetooth_delete_all_headless_mobile_in_DB(void *db); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief set the dut configure mode + * + * @param[in] mode The confiture mode + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + */ +int bt_dut_set_configure_mode(bool mode); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief send DUT mode data + * + * @param[in] opcode The opcode + * @param[in] data The mode data + * @param[in] length The data length + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + */ +int bt_dut_sent_mode(unsigned short opcode, unsigned char *data, unsigned short length); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief dut wakeup test + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + */ +int bt_dut_wakeup_test(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Set the callback for SmartRC throughput mode + * + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + */ +int bt_hid_set_smartrc_tput_mode_cb(bt_adapter_smartrc_tput_mode_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unset the callback for SmartRC throughput mode + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + */ +int bt_hid_unset_smartrc_tput_mode_cb(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Start the SmartRC throughput mode + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + */ +int bt_adapter_start_smartrc_tput_mode(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Stop the SmartRC throughput mode + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + */ +int bt_adapter_stop_smartrc_tput_mode(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Get BT chip version. + * + * @param[out] version BT chip version + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + */ +int bt_adapter_get_chip_version(int *version); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Update the firmware + * + * @param[in] type BT chip type + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + */ +int bt_adapter_update_firmware(int chip_type); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Set BT app ready + * + * @param[in] ready + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + */ +int bt_adapter_set_app_ready(bool ready); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief If BT chip update is required or not + * + * @param[out] is_required + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + */ +int bt_adapter_is_required_update_firmware(bool *is_required); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Cancel BT firmware update + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * + */ +int bt_adapter_cancel_firmware_update(void); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // __TIZEN_NETWORK_BLUETOOTH_PRODUCT_H__ diff --git a/include/tv/bluetooth_type.h b/include/tv/bluetooth_type.h new file mode 100644 index 0000000..d05a4ae --- /dev/null +++ b/include/tv/bluetooth_type.h @@ -0,0 +1,1829 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_NETWORK_BLUETOOTH_TYPE_H__ +#define __TIZEN_NETWORK_BLUETOOTH_TYPE_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** + * @file bluetooth_type.h + * @brief API to control the Bluetooth adapter, devices and communications. + * @ingroup CAPI_NETWORK_BLUETOOTH_TYPE_MODULE + */ + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_MODULE + * @brief Enumerations of Bluetooth error codes. + * @since_tizen 2.3 + */ + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Enumerations of connected Bluetooth service. + */ +typedef enum { + BT_HSP_SERVICE_MASK = 0x01, /**< Headset profile service mask */ + BT_A2DP_SERVICE_MASK = 0x02, /**< Audio distribution profile service mask */ + BT_HID_SERVICE_MASK = 0x04, /**< Human Interface Device profile service mask*/ +} bt_connected_service_mask_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_MODULE + * @brief Enumerations of Bluetooth error codes. + */ +typedef enum +{ + BT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful*/ + BT_ERROR_CANCELLED = TIZEN_ERROR_CANCELED, /**< Operation cancelled */ + BT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + BT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + BT_ERROR_RESOURCE_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Device or resource busy */ + BT_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< Timeout error */ + BT_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /**< Operation now in progress */ + BT_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< BT is Not Supported */ + BT_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + BT_ERROR_QUOTA_EXCEEDED = TIZEN_ERROR_QUOTA_EXCEEDED, /**< Quota exceeded */ + BT_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data available */ + BT_ERROR_NOT_INITIALIZED = TIZEN_ERROR_NETWORK_CLASS|0x0101, /**< Local adapter not initialized */ + BT_ERROR_NOT_ENABLED = TIZEN_ERROR_NETWORK_CLASS|0x0102, /**< Local adapter not enabled */ + BT_ERROR_ALREADY_DONE = TIZEN_ERROR_NETWORK_CLASS|0x0103, /**< Operation already done */ + BT_ERROR_OPERATION_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x0104, /**< Operation failed */ + BT_ERROR_NOT_IN_PROGRESS = TIZEN_ERROR_NETWORK_CLASS|0x0105, /**< Operation not in progress */ + BT_ERROR_REMOTE_DEVICE_NOT_BONDED = TIZEN_ERROR_NETWORK_CLASS|0x0106, /**< Remote device not bonded */ + BT_ERROR_AUTH_REJECTED = TIZEN_ERROR_NETWORK_CLASS|0x0107, /**< Authentication rejected */ + BT_ERROR_AUTH_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x0108, /**< Authentication failed */ + BT_ERROR_REMOTE_DEVICE_NOT_FOUND = TIZEN_ERROR_NETWORK_CLASS|0x0109, /**< Remote device not found */ + BT_ERROR_SERVICE_SEARCH_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x010A, /**< Service search failed */ + BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED = TIZEN_ERROR_NETWORK_CLASS|0x010B, /**< Remote device is not connected */ + BT_ERROR_MAX_CONNECTION_LIMIT_REACHED = TIZEN_ERROR_NETWORK_CLASS|0x010C, /**< Max Connection Limit Reached */ + BT_ERROR_AGAIN = TIZEN_ERROR_BLUETOOTH|0x010C, /**< Resource temporarily unavailable */ + BT_ERROR_SERVICE_NOT_FOUND = TIZEN_ERROR_BLUETOOTH|0x010D, /**< Service Not Found */ +} bt_error_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enumerations of the Bluetooth adapter state. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_ADAPTER_DISABLED = 0x00, /**< Bluetooth adapter is disabled */ + BT_ADAPTER_ENABLED, /**< Bluetooth adapter is enabled */ +} bt_adapter_state_e; + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Enumerations of the Bluetooth adapter le state. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_ADAPTER_LE_DISABLED = 0x00, /**< Bluetooth le is disabled */ + BT_ADAPTER_LE_ENABLED, /**< Bluetooth le is enabled */ +} bt_adapter_le_state_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enumerations of the Bluetooth visibility mode. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_ADAPTER_VISIBILITY_MODE_NON_CONNECTABLE = -1, /**< Non discoverable non connectable mode*/ + BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE, /**< Other devices cannot find your device via discovery */ + BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, /**< Discoverable mode */ + BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE, /**< Discoverable mode with time limit. After specific period, + it is changed to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE.*/ +} bt_adapter_visibility_mode_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enumerations of the discovery state of Bluetooth device. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_ADAPTER_DEVICE_DISCOVERY_STARTED, /**< Device discovery is started */ + BT_ADAPTER_DEVICE_DISCOVERY_FINISHED, /**< Device discovery is finished */ + BT_ADAPTER_DEVICE_DISCOVERY_FOUND, /**< The remote Bluetooth device is found */ +} bt_adapter_device_discovery_state_e; + +/** + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Enumerations of the discovery state of Bluetooth LE device. + * @since_tizen 2.3 + * + */ +typedef enum +{ + BT_ADAPTER_LE_DEVICE_DISCOVERY_STARTED, /**< LE device discovery is started */ + BT_ADAPTER_LE_DEVICE_DISCOVERY_FINISHED, /**< LE device discovery is finished */ + BT_ADAPTER_LE_DEVICE_DISCOVERY_FOUND, /**< The remote Bluetooth LE device is found */ +} bt_adapter_le_device_discovery_state_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Enumerations of the Bluetooth advertising state. + * @since_tizen 2.3 + */ +typedef enum { + BT_ADAPTER_LE_ADVERTISING_STOPPED = 0x00, /**< Bluetooth advertising is stopped */ + BT_ADAPTER_LE_ADVERTISING_STARTED, /**< Bluetooth advertising is started */ +} bt_adapter_le_advertising_state_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Enumerations of the Bluetooth advertising mode. + * @since_tizen 2.3.1 + */ +typedef enum +{ + BT_ADAPTER_LE_ADVERTISING_MODE_BALANCED, /**< Balanced advertising mode */ + BT_ADAPTER_LE_ADVERTISING_MODE_LOW_LATENCY, /**< Low latency advertising mode */ + BT_ADAPTER_LE_ADVERTISING_MODE_LOW_ENERGY /**< Low energy advertising mode */ +} bt_adapter_le_advertising_mode_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Enumerations of the Bluetooth advertising filter policy. + * @since_tizen 2.3 + */ +typedef enum { + BT_ADAPTER_LE_ADVERTISING_FILTER_DEFAULT = 0x00, /**< White list is not in use */ + BT_ADAPTER_LE_ADVERTISING_FILTER_ALLOW_SCAN_WL = 0x01, /**< Allow the scan + request that in the White list */ + BT_ADAPTER_LE_ADVERTISING_FILTER_ALLOW_CONN_WL = 0x02, /**< Allow the connectoin + request that in the White list */ + BT_ADAPTER_LE_ADVERTISING_FILTER_ALLOW_SCAN_CONN_WL = 0x03, /**< Allow the + scan and connectoin request that in the White list */ +} bt_adapter_le_advertising_filter_policy_e; + +/** + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Enumerations of the Bluetooth advertising type. + * @since_tizen 2.3 + */ +typedef enum { + BT_ADAPTER_LE_ADVERTISING_CONNECTABLE = 0x00, /**< Connectable undirected advertising (ADV_IND) */ + BT_ADAPTER_LE_ADVERTISING_CONNECTABLE_DIRECT_HIGH = 0x01, /**< Connectable high duty cycle directed advertising (ADV_DIRECT_IND) */ + BT_ADAPTER_LE_ADVERTISING_SCANNABLE = 0x02, /**< Scannable undirected advertising (ADV_SCAN_IND) */ + BT_ADAPTER_LE_ADVERTISING_NON_CONNECTABLE = 0x03, /**< Non connectable undirected advertising (ADV_NONCOND_IND) */ + BT_ADAPTER_LE_ADVERTISING_CONNECTABLE_DIRECT_LOW = 0x04, /**< Connectable low duty cycle directed advertising (ADV_DIRECT_IND) */ +} bt_adapter_le_advertising_type_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Enumerations of the Bluetooth LE packet type. + * @since_tizen 2.3 + */ +typedef enum { + BT_ADAPTER_LE_PACKET_ADVERTISING, /**< Advertising packet */ + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, /**< Sacn response packet */ +} bt_adapter_le_packet_type_e; + +/** + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Enumerations of the Bluetooth LE data type + * that can be included in LE packets. + * @since_tizen 2.3 + */ +typedef enum { + BT_ADAPTER_LE_PACKET_DATA_COMP_LIST_16_BIT_SERVICE_CLASS_UUIDS = 0x03, /**< Complete list of 16 bit UUIDs */ + BT_ADAPTER_LE_PACKET_DATA_MANUFACTURER_SPECIFIC_DATA = 0xff, /**< Manufacturer data */ +} bt_adapter_le_packet_data_type_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Enumerations of device disconnect reason. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_DEVICE_DISCONNECT_REASON_UNKNOWN, /**< Disconnected by unknown reason */ + BT_DEVICE_DISCONNECT_REASON_TIMEOUT, /**< Disconnected by timeout */ + BT_DEVICE_DISCONNECT_REASON_LOCAL_HOST, /**< Disconnected by local host */ + BT_DEVICE_DISCONNECT_REASON_REMOTE, /**< Disconnected by remote */ +} bt_device_disconnect_reason_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Enumerations of connection link type. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_DEVICE_CONNECTION_LINK_BREDR, /**< BR/EDR link */ + BT_DEVICE_CONNECTION_LINK_LE, /**< LE link */ + BT_DEVICE_CONNECTION_LINK_DEFAULT = 0xFF, /**< The connection type defualt */ +} bt_device_connection_link_type_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Enumerations of device authorization state. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_DEVICE_AUTHORIZED, /**< The remote Bluetooth device is authorized */ + BT_DEVICE_UNAUTHORIZED, /**< The remote Bluetooth device is unauthorized */ +} bt_device_authorization_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Enumerations of Bluetooth profile. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_PROFILE_RFCOMM = 0x01, /**< RFCOMM Profile */ + BT_PROFILE_A2DP = 0x02, /**< Advanced Audio Distribution Profile Source role */ + BT_PROFILE_HSP = 0x04, /**< Headset Profile */ + BT_PROFILE_HID = 0x08, /**< Human Interface Device Profile */ + BT_PROFILE_NAP = 0x10, /**< Network Access Point Profile */ + BT_PROFILE_AG = 0x20, /**< Audio Gateway Profile */ + BT_PROFILE_GATT = 0x40, /**< Generic Attribute Profile */ + BT_PROFILE_NAP_SERVER = 0x80, /**< NAP server Profile */ + BT_PROFILE_A2DP_SINK = 0x100, /**< Advanced Audio Distribution Profile Sink role */ +} bt_profile_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Enumerations of device address type. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_DEVICE_PUBLIC_ADDRESS = 0x00, /**< Public address */ + BT_DEVICE_RANDOM_ADDRESS, /**< Random address */ +} bt_device_address_type_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Enumerations of service class. + * @since_tizen 2.3 + */ +typedef enum { + BT_SC_NONE = 0, /**< No service class */ + BT_SC_RES_SERVICE_MASK = 0x00000001, /**< RES service class */ + BT_SC_SPP_SERVICE_MASK = 0x00000002, /**< SPP service class */ + BT_SC_DUN_SERVICE_MASK = 0x00000004, /**< DUN service class */ + BT_SC_FAX_SERVICE_MASK = 0x00000008, /**< FAX service class */ + BT_SC_LAP_SERVICE_MASK = 0x00000010, /**< LAP service class */ + BT_SC_HSP_SERVICE_MASK = 0x00000020, /**< HSP service class */ + BT_SC_HFP_SERVICE_MASK = 0x00000040, /**< HFP service class */ + BT_SC_OPP_SERVICE_MASK = 0x00000080, /**< OPP service class */ + BT_SC_FTP_SERVICE_MASK = 0x00000100, /**< FTP service class */ + BT_SC_CTP_SERVICE_MASK = 0x00000200, /**< CTP service class */ + BT_SC_ICP_SERVICE_MASK = 0x00000400, /**< ICP service class */ + BT_SC_SYNC_SERVICE_MASK = 0x00000800, /**< SYNC service class */ + BT_SC_BPP_SERVICE_MASK = 0x00001000, /**< BPP service class */ + BT_SC_BIP_SERVICE_MASK = 0x00002000, /**< BIP service class */ + BT_SC_PANU_SERVICE_MASK = 0x00004000, /**< PANU service class */ + BT_SC_NAP_SERVICE_MASK = 0x00008000, /**< NAP service class */ + BT_SC_GN_SERVICE_MASK = 0x00010000, /**< GN service class */ + BT_SC_SAP_SERVICE_MASK = 0x00020000, /**< SAP service class */ + BT_SC_A2DP_SERVICE_MASK = 0x00040000, /**< A2DP service class */ + BT_SC_AVRCP_SERVICE_MASK = 0x00080000, /**< AVRCP service class */ + BT_SC_PBAP_SERVICE_MASK = 0x00100000, /**< PBAP service class */ + BT_SC_HID_SERVICE_MASK = 0x00200000, /**< HID service class */ + BT_SC_A2DP_SOURCE_SERVICE_MASK = 0x00400000, /**< A2DP SOURCE service class */ + BT_SC_ALL_SERVICE_MASK = 0x00FFFFFF, /**< ALL service class */ + BT_SC_MAX /**< MAX service class */ +} bt_service_class_t; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Enumerations of major service class. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_MAJOR_SERVICE_CLASS_LIMITED_DISCOVERABLE_MODE = 0x002000, /**< Limited discoverable mode */ + BT_MAJOR_SERVICE_CLASS_POSITIONING = 0x010000, /**< Positioning class */ + BT_MAJOR_SERVICE_CLASS_NETWORKING = 0x020000, /**< Networking class */ + BT_MAJOR_SERVICE_CLASS_RENDERING = 0x040000, /**< Rendering class */ + BT_MAJOR_SERVICE_CLASS_CAPTURING = 0x080000, /**< Capturing class */ + BT_MAJOR_SERVICE_CLASS_OBJECT_TRANSFER = 0x100000, /**< Object transferring class */ + BT_MAJOR_SERVICE_CLASS_AUDIO = 0x200000, /**< Audio class*/ + BT_MAJOR_SERVICE_CLASS_TELEPHONY = 0x400000, /**< Telephony class */ + BT_MAJOR_SERVICE_CLASS_INFORMATION = 0x800000, /**< Information class */ +} bt_major_service_class_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Enumerations of major device class. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_MAJOR_DEVICE_CLASS_MISC = 0x00, /**< Miscellaneous major device class*/ + BT_MAJOR_DEVICE_CLASS_COMPUTER = 0x01, /**< Computer major device class */ + BT_MAJOR_DEVICE_CLASS_PHONE = 0x02, /**< Phone major device class */ + BT_MAJOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT = 0x03, /**< LAN/Network access point major device class */ + BT_MAJOR_DEVICE_CLASS_AUDIO_VIDEO = 0x04, /**< Audio/Video major device class */ + BT_MAJOR_DEVICE_CLASS_PERIPHERAL = 0x05, /**< Peripheral major device class */ + BT_MAJOR_DEVICE_CLASS_IMAGING = 0x06, /**< Imaging major device class */ + BT_MAJOR_DEVICE_CLASS_WEARABLE = 0x07, /**< Wearable device class */ + BT_MAJOR_DEVICE_CLASS_TOY = 0x08, /**< Toy device class */ + BT_MAJOR_DEVICE_CLASS_HEALTH = 0x09, /**< Health device class */ + BT_MAJOR_DEVICE_CLASS_UNCATEGORIZED = 0x1F, /**< Uncategorized major device class */ +} bt_major_device_class_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Enumerations of minor device class. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_MINOR_DEVICE_CLASS_COMPUTER_UNCATEGORIZED = 0x00, /**< Uncategorized minor device class of computer */ + BT_MINOR_DEVICE_CLASS_COMPUTER_DESKTOP_WORKSTATION = 0x04, /**< Desktop workstation minor device class of computer */ + BT_MINOR_DEVICE_CLASS_COMPUTER_SERVER_CLASS = 0x08, /**< Server minor device class of computer */ + BT_MINOR_DEVICE_CLASS_COMPUTER_LAPTOP = 0x0C, /**< Laptop minor device class of computer */ + BT_MINOR_DEVICE_CLASS_COMPUTER_HANDHELD_PC_OR_PDA = 0x10, /**< Handheld PC/PDA minor device class of computer */ + BT_MINOR_DEVICE_CLASS_COMPUTER_PALM_SIZED_PC_OR_PDA = 0x14, /**< Palm sized PC/PDA minor device class of computer */ + BT_MINOR_DEVICE_CLASS_COMPUTER_WEARABLE_COMPUTER = 0x18, /**< Wearable(watch sized) minor device class of computer */ + + BT_MINOR_DEVICE_CLASS_PHONE_UNCATEGORIZED = 0x00, /**< Uncategorized minor device class of phone */ + BT_MINOR_DEVICE_CLASS_PHONE_CELLULAR = 0x04, /**< Cellular minor device class of phone */ + BT_MINOR_DEVICE_CLASS_PHONE_CORDLESS = 0x08, /**< Cordless minor device class of phone */ + BT_MINOR_DEVICE_CLASS_PHONE_SMART_PHONE = 0x0C, /**< Smart phone minor device class of phone */ + BT_MINOR_DEVICE_CLASS_PHONE_WIRED_MODEM_OR_VOICE_GATEWAY = 0x10, /**< Wired modem or voice gateway minor device class of phone */ + BT_MINOR_DEVICE_CLASS_PHONE_COMMON_ISDN_ACCESS = 0x14, /**< Common ISDN minor device class of phone */ + + BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_FULLY_AVAILABLE = 0x04, /**< Fully available minor device class of LAN/Network access point */ + BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_1_TO_17_PERCENT_UTILIZED = 0x20, /**< 1-17% utilized minor device class of LAN/Network access point */ + BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_17_TO_33_PERCENT_UTILIZED = 0x40, /**< 17-33% utilized minor device class of LAN/Network access point */ + BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_33_TO_50_PERCENT_UTILIZED = 0x60, /**< 33-50% utilized minor device class of LAN/Network access point */ + BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_50_to_67_PERCENT_UTILIZED = 0x80, /**< 50-67% utilized minor device class of LAN/Network access point */ + BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_67_TO_83_PERCENT_UTILIZED = 0xA0, /**< 67-83% utilized minor device class of LAN/Network access point */ + BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_83_TO_99_PERCENT_UTILIZED = 0xC0, /**< 83-99% utilized minor device class of LAN/Network access point */ + BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_NO_SERVICE_AVAILABLE = 0xE0, /**< No service available minor device class of LAN/Network access point */ + + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_UNCATEGORIZED = 0x00, /**< Uncategorized minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_WEARABLE_HEADSET = 0x04, /**< Wearable headset minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_HANDS_FREE = 0x08, /**< Hands-free minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_MICROPHONE = 0x10, /**< Microphone minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_LOUDSPEAKER = 0x14, /**< Loudspeaker minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_HEADPHONES = 0x18, /**< Headphones minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_PORTABLE_AUDIO = 0x1C, /**< Portable audio minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_CAR_AUDIO = 0x20, /**< Car audio minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_SET_TOP_BOX = 0x24, /**< Set-top box minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_HIFI_AUDIO_DEVICE = 0x28, /**< Hifi audio minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VCR = 0x2C, /**< VCR minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_CAMERA = 0x30, /**< Video camera minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_CAMCORDER = 0x34, /**< Camcorder minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_MONITOR = 0x38, /**< Video monitor minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_DISPLAY_LOUDSPEAKER = 0x3C, /**< Video display and loudspeaker minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_CONFERENCING = 0x40, /**< Video conferencing minor device class of audio/video */ + BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_GAMING_TOY = 0x48, /**< Gaming/toy minor device class of audio/video */ + + BT_MINOR_DEVICE_CLASS_PERIPHERA_UNCATEGORIZED = 0x00, /**< Uncategorized minor device class of peripheral */ + BT_MINOR_DEVICE_CLASS_PERIPHERAL_KEY_BOARD = 0x40, /**< Key board minor device class of peripheral */ + BT_MINOR_DEVICE_CLASS_PERIPHERAL_POINTING_DEVICE = 0x80, /**< Pointing device minor device class of peripheral */ + BT_MINOR_DEVICE_CLASS_PERIPHERAL_COMBO_KEYBOARD_POINTING_DEVICE = 0xC0, /**< Combo keyboard or pointing device minor device class of peripheral */ + BT_MINOR_DEVICE_CLASS_PERIPHERAL_COMBO_KEYBOARD_REMOTE_CONTROL_DEVICE = 0xCC, /**< Combo keyboard remote control device class of peripheral */ + BT_MINOR_DEVICE_CLASS_PERIPHERAL_JOYSTICK = 0x04, /**< Joystick minor device class of peripheral */ + BT_MINOR_DEVICE_CLASS_PERIPHERAL_GAME_PAD = 0x08, /**< Game pad minor device class of peripheral */ + BT_MINOR_DEVICE_CLASS_PERIPHERAL_REMOTE_CONTROL = 0x0C, /**< Remote control minor device class of peripheral */ + BT_MINOR_DEVICE_CLASS_PERIPHERAL_SENSING_DEVICE = 0x10, /**< Sensing device minor device class of peripheral */ + BT_MINOR_DEVICE_CLASS_PERIPHERAL_DIGITIZER_TABLET = 0x14, /**< Digitizer minor device class of peripheral */ + BT_MINOR_DEVICE_CLASS_PERIPHERAL_CARD_READER = 0x18, /**< Card reader minor device class of peripheral */ + BT_MINOR_DEVICE_CLASS_PERIPHERAL_DIGITAL_PEN = 0x1C, /**< Digital pen minor device class of peripheral */ + BT_MINOR_DEVICE_CLASS_PERIPHERAL_HANDHELD_SCANNER = 0x20, /**< Handheld scanner minor device class of peripheral */ + BT_MINOR_DEVICE_CLASS_PERIPHERAL_HANDHELD_GESTURAL_INPUT_DEVICE = 0x24, /**< Handheld gestural input device minor device class of peripheral */ + + BT_MINOR_DEVICE_CLASS_IMAGING_DISPLAY = 0x10, /**< Display minor device class of imaging */ + BT_MINOR_DEVICE_CLASS_IMAGING_CAMERA = 0x20, /**< Camera minor device class of imaging */ + BT_MINOR_DEVICE_CLASS_IMAGING_SCANNER = 0x40, /**< Scanner minor device class of imaging */ + BT_MINOR_DEVICE_CLASS_IMAGING_PRINTER = 0x80, /**< Printer minor device class of imaging */ + + BT_MINOR_DEVICE_CLASS_WEARABLE_WRIST_WATCH = 0x04, /**< Wrist watch minor device class of wearable */ + BT_MINOR_DEVICE_CLASS_WEARABLE_PAGER = 0x08, /**< Pager minor device class of wearable */ + BT_MINOR_DEVICE_CLASS_WEARABLE_JACKET = 0x0C, /**< Jacket minor device class of wearable */ + BT_MINOR_DEVICE_CLASS_WEARABLE_HELMET = 0x10, /**< Helmet minor device class of wearable */ + BT_MINOR_DEVICE_CLASS_WEARABLE_GLASSES = 0x14, /**< Glasses minor device class of wearable */ + + BT_MINOR_DEVICE_CLASS_TOY_ROBOT = 0x04, /**< Robot minor device class of toy */ + BT_MINOR_DEVICE_CLASS_TOY_VEHICLE = 0x08, /**< Vehicle minor device class of toy */ + BT_MINOR_DEVICE_CLASS_TOY_DOLL_ACTION = 0x0C, /**< Doll/Action minor device class of toy */ + BT_MINOR_DEVICE_CLASS_TOY_CONTROLLER = 0x10, /**< Controller minor device class of toy */ + BT_MINOR_DEVICE_CLASS_TOY_GAME = 0x14, /**< Game minor device class of toy */ + + BT_MINOR_DEVICE_CLASS_HEALTH_UNCATEGORIZED = 0x00, /**< Uncategorized minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEALTH_BLOOD_PRESSURE_MONITOR = 0x04, /**< Blood pressure monitor minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEALTH_THERMOMETER = 0x08, /**< Thermometer minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEALTH_WEIGHING_SCALE = 0x0C, /**< Weighing scale minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEALTH_GLUCOSE_METER = 0x10, /**< Glucose minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEALTH_PULSE_OXIMETER = 0x14, /**< Pulse oximeter minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEALTH_HEART_PULSE_RATE_MONITOR = 0x18, /**< Heart/Pulse rate monitor minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEALTH_DATA_DISPLAY = 0x1C, /**< Health data display minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEALTH_STEP_COUNTER = 0x20, /**< Step counter minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEALTH_BODY_COMPOSITION_ANALYZER = 0x24, /**< Body composition analyzer minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEALTH_PEAK_FLOW_MONITOR = 0x28, /**< Peak flow monitor minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEALTH_MEDICATION_MONITOR = 0x2C, /**< Medication monitor minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEALTH_KNEE_PROSTHESIS = 0x30, /**< Knee prosthesis minor device class of health */ + BT_MINOR_DEVICE_CLASS_HEALTH_ANKLE_PROSTHESIS = 0x34, /**< Ankle prosthesis minor device class of health */ +} bt_minor_device_class_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Enumerations of gap appearance type. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_APPEARANCE_TYPE_UNKNOWN = 0x00, /**< Unknown appearance type */ + BT_APPEARANCE_TYPE_GENERIC_PHONE = 0x40, /**< Generic Phone type - Generic category */ + BT_APPEARANCE_TYPE_GENERIC_COMPUTER = 0x80, /**< Generic Computer type - Generic category */ + BT_APPEARANCE_TYPE_GENERIC_WATCH = 0xC0, /**< Generic Watch type - Generic category */ +} bt_appearance_type_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Enumerations of connected Bluetooth device event role. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_SOCKET_UNKNOWN = 0x00, /**< Unknown role*/ + BT_SOCKET_SERVER , /**< Server role*/ + BT_SOCKET_CLIENT, /**< Client role*/ +} bt_socket_role_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Enumerations of Bluetooth socket connection state. + * @since_tizen 2.3 + */ +typedef enum +{ + BT_SOCKET_CONNECTED, /**< RFCOMM is connected */ + BT_SOCKET_DISCONNECTED, /**< RFCOMM is disconnected */ +} bt_socket_connection_state_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Enumerations for the types of profiles related with audio + * @since_tizen 2.3 + */ +typedef enum { + BT_AUDIO_PROFILE_TYPE_ALL = 0, /**< All supported profiles related with audio */ + BT_AUDIO_PROFILE_TYPE_HSP_HFP, /**< HSP(Headset Profile) and HFP(Hands-Free Profile) */ + BT_AUDIO_PROFILE_TYPE_A2DP, /**< A2DP(Advanced Audio Distribution Profile) */ + BT_AUDIO_PROFILE_TYPE_AG, /**< AG(Audio Gateway) */ +} bt_audio_profile_type_e; + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Enumerations for the call handling event + * @since_tizen 2.3 + */ +typedef enum { + BT_AG_CALL_HANDLING_EVENT_ANSWER = 0x00, /**< Request to answer an incoming call */ + BT_AG_CALL_HANDLING_EVENT_RELEASE, /**< Request to release a call */ + BT_AG_CALL_HANDLING_EVENT_REJECT, /**< Request to reject an incoming call */ +} bt_ag_call_handling_event_e; + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Enumerations for the multi call handling event + * @since_tizen 2.3 + */ +typedef enum { + BT_AG_MULTI_CALL_HANDLING_EVENT_RELEASE_HELD_CALLS = 0x00, /**< Request to release held calls */ + BT_AG_MULTI_CALL_HANDLING_EVENT_RELEASE_ACTIVE_CALLS, /**< Request to release active calls */ + BT_AG_MULTI_CALL_HANDLING_EVENT_ACTIVATE_HELD_CALL, /**< Request to put active calls into hold state and activate another (held or waiting) call */ + BT_AG_MULTI_CALL_HANDLING_EVENT_MERGE_CALLS, /**< Request to add a held call to the conversation */ + BT_AG_MULTI_CALL_HANDLING_EVENT_EXPLICIT_CALL_TRANSFER, /**< Request to let a user who has two calls to connect these two calls together and release its connections to both other parties */ +} bt_ag_multi_call_handling_event_e; + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Enumerations for the call state + * @since_tizen 2.3 + */ +typedef enum { + BT_AG_CALL_EVENT_IDLE = 0x00, /**< Idle */ + BT_AG_CALL_EVENT_ANSWERED, /**< Answered */ + BT_AG_CALL_EVENT_HELD, /**< Held */ + BT_AG_CALL_EVENT_RETRIEVED, /**< Retrieved */ + BT_AG_CALL_EVENT_DIALING, /**< Dialing */ + BT_AG_CALL_EVENT_ALERTING, /**< Alerting */ + BT_AG_CALL_EVENT_INCOMING, /**< Incoming */ +} bt_ag_call_event_e; + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Enumerations for the call state + * @since_tizen 2.3 + */ +typedef enum { + BT_AG_CALL_STATE_IDLE = 0x00, /**< Idle state */ + BT_AG_CALL_STATE_ACTIVE, /**< Active state */ + BT_AG_CALL_STATE_HELD, /**< Held state */ + BT_AG_CALL_STATE_DIALING, /**< Dialing state */ + BT_AG_CALL_STATE_ALERTING, /**< Alerting state */ + BT_AG_CALL_STATE_INCOMING, /**< Incoming state */ + BT_AG_CALL_STATE_WAITING, /**< Waiting for connected indication event after answering an incoming call*/ +} bt_ag_call_state_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Enumerations for the equalizer state + * @since_tizen 2.4 + */ +typedef enum { + BT_AVRCP_EQUALIZER_STATE_OFF = 0x01, /**< Equalizer Off */ + BT_AVRCP_EQUALIZER_STATE_ON, /**< Equalizer On */ +} bt_avrcp_equalizer_state_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Enumerations for the repeat mode + * @since_tizen 2.4 + */ +typedef enum { + BT_AVRCP_REPEAT_MODE_OFF = 0x01, /**< Repeat Off */ + BT_AVRCP_REPEAT_MODE_SINGLE_TRACK, /**< Single track repeat */ + BT_AVRCP_REPEAT_MODE_ALL_TRACK, /**< All track repeat */ + BT_AVRCP_REPEAT_MODE_GROUP, /**< Group repeat */ +} bt_avrcp_repeat_mode_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Enumerations for the shuffle mode + * @since_tizen 2.4 + */ +typedef enum { + BT_AVRCP_SHUFFLE_MODE_OFF = 0x01, /**< Shuffle Off */ + BT_AVRCP_SHUFFLE_MODE_ALL_TRACK, /**< All tracks shuffle */ + BT_AVRCP_SHUFFLE_MODE_GROUP, /**< Group shuffle */ +} bt_avrcp_shuffle_mode_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Enumerations for the scan mode + * @since_tizen 2.4 + */ +typedef enum { + BT_AVRCP_SCAN_MODE_OFF = 0x01, /**< Scan Off */ + BT_AVRCP_SCAN_MODE_ALL_TRACK, /**< All tracks scan */ + BT_AVRCP_SCAN_MODE_GROUP, /**< Group scan */ +} bt_avrcp_scan_mode_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Enumerations for the player state + * @since_tizen 2.4 + */ +typedef enum { + BT_AVRCP_PLAYER_STATE_STOPPED = 0x00, /**< Stopped */ + BT_AVRCP_PLAYER_STATE_PLAYING, /**< Playing */ + BT_AVRCP_PLAYER_STATE_PAUSED, /**< Paused */ + BT_AVRCP_PLAYER_STATE_FORWARD_SEEK, /**< Seek Forward */ + BT_AVRCP_PLAYER_STATE_REWIND_SEEK, /**< Seek Rewind */ +} bt_avrcp_player_state_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HDP_MODULE + * @brief Enumerations for the data channel type + * @since_tizen 2.3 + */ +typedef enum { + BT_HDP_CHANNEL_TYPE_RELIABLE = 0x01, /**< Reliable Data Channel */ + BT_HDP_CHANNEL_TYPE_STREAMING, /**< Streaming Data Channel */ +} bt_hdp_channel_type_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Enumerations of the integer type for GATT handle's value + * @since_tizen 2.3.1 + */ +typedef enum { + BT_DATA_TYPE_SINT8, /**< 8 bit signed int type */ + BT_DATA_TYPE_SINT16, /**< 16 bit signed int type */ + BT_DATA_TYPE_SINT32, /**< 32 bit signed int type */ + BT_DATA_TYPE_UINT8, /**< 8 bit unsigned int type */ + BT_DATA_TYPE_UINT16, /**< 16 bit unsigned int type */ + BT_DATA_TYPE_UINT32 /**< 32 bit unsigned int type */ +} bt_data_type_int_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Enumerations of the float type for GATT handle's value + * @since_tizen 2.3.1 + */ +typedef enum { + BT_DATA_TYPE_FLOAT, /**< 32 bit float type */ + BT_DATA_TYPE_SFLOAT /**< 16 bit float type */ +} bt_data_type_float_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Enumerations of the write type + * @since_tizen 2.3.1 + */ +typedef enum { + BT_GATT_WRITE_TYPE_WRITE_NO_RESPONSE, /**< Write without response type */ + BT_GATT_WRITE_TYPE_WRITE /**< Write type */ +} bt_gatt_write_type_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Enumerations of the GATT handle's type + * @since_tizen 2.3.1 + */ +typedef enum { + BT_GATT_TYPE_SERVICE = 0x01, /**< GATT service type */ + BT_GATT_TYPE_CHARACTERISTIC = 0x02, /** GATT characteristic type */ + BT_GATT_TYPE_DESCRIPTOR = 0x03, /** GATT descriptor type */ +} bt_gatt_type_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Enumerations of the service type + * @since_tizen 2.3.1 + */ +typedef enum { + BT_GATT_SERVICE_TYPE_PRIMARY = 0x01, /**< GATT primary service type */ + BT_GATT_SERVICE_TYPE_SECONDARY = 0x02, /**< GATT secondary service type */ +} bt_gatt_service_type_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Enumerations of the characteristic's property + * @since_tizen 2.3.1 + */ +typedef enum { + BT_GATT_PROPERTY_BROADCAST = 0x01, /**< Broadcast property */ + BT_GATT_PROPERTY_READ = 0x02, /**< Read property */ + BT_GATT_PROPERTY_WRITE_WITHOUT_RESPONSE = 0x04, /**< Write without response property */ + BT_GATT_PROPERTY_WRITE = 0x08, /**< Write property */ + BT_GATT_PROPERTY_NOTIFY = 0x10, /**< Notify property */ + BT_GATT_PROPERTY_INDICATE = 0x20, /**< Indicate property */ + BT_GATT_PROPERTY_AUTHENTICATED_SIGNED_WRITES = 0x40, /**< Authenticated signed writes property */ + BT_GATT_PROPERTY_EXTENDED_PROPERTIES = 0x80, /**< Extended properties */ +} bt_gatt_property_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE + * @brief Enumerations for the types of PAN(Personal Area Networking) service + * @since_tizen 2.3 + */ +typedef enum { + BT_PANU_SERVICE_TYPE_NAP = 0, /**< Network Access Point */ +} bt_panu_service_type_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief The handle to control Bluetooth LE advertising + * @since_tizen 2.3 + */ +typedef void* bt_advertiser_h; + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_h instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief The attribute handle of GATT(Generic Attribute Profile) + * @since_tizen 2.3 + */ +typedef void* bt_gatt_attribute_h; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief The handle of a service, characteristic or descriptor + * @since_tizen 2.3.1 + */ +typedef void* bt_gatt_h; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief The handle of a GATT client which is associated with a remote device + * @since_tizen 2.3.1 + */ +typedef void* bt_gatt_client_h; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief The handle of calls state + * @since_tizen 2.3 + */ +typedef void* bt_call_list_h; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Class structure of device and service. + * @since_tizen 2.3 + * + * @see #bt_device_info_s + * @see #bt_adapter_device_discovery_info_s + * @see bt_device_bond_created_cb() + * @see bt_adapter_device_discovery_state_changed_cb() + */ +typedef struct +{ + bt_major_device_class_e major_device_class; /**< Major device class. */ + bt_minor_device_class_e minor_device_class; /**< Minor device class. */ + int major_service_class_mask; /**< Major service class mask. + This value can be a combination of #bt_major_service_class_e like #BT_MAJOR_SERVICE_CLASS_RENDERING | #BT_MAJOR_SERVICE_CLASS_AUDIO */ +} bt_class_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Structure of device discovery information. + * @since_tizen 2.3 + * + * @see #bt_class_s + * @see bt_adapter_device_discovery_state_changed_cb() + */ +typedef struct +{ + char *remote_address; /**< The address of remote device */ + char *remote_name; /**< The name of remote device */ + bt_class_s bt_class; /**< The Bluetooth classes */ + int rssi; /**< The strength indicator of received signal */ + unsigned short vendor_id; /**< Vendor Id */ + unsigned short product_id; /**< Product Id */ + bool is_bonded; /**< The bonding state */ + char **service_uuid; /**< The UUID list of service */ + int service_count; /**< The number of services */ + bt_appearance_type_e appearance; /**< The Bluetooth appearance */ + int adv_data_len; /**< advertising indication manafacturer specific data length */ + char *adv_data; /**< advertising indication manafacturer specific data */ + int scan_data_len; /**< scan response manafacturer specific data length */ + char *scan_data; /**< scan response manafacturer specific data */ + int manufacturer_data_len; /**< manufacturer specific data length */ + char *manufacturer_data; /**< manufacturer specific data */ +} bt_adapter_device_discovery_info_s; + +/** + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Structure of le device discovery information. + * @since_tizen 2.3 + * + * @see #bt_class_s + * @see bt_adapter_le_device_discovery_state_changed_cb() + */ +typedef struct +{ + char *remote_address; /**< The address of remote device */ + int address_type; /**< The address type of remote device */ + int rssi; /**< The strength indicator of received signal */ + int adv_data_len; /**< advertising indication data length */ + char *adv_data; /**< advertising indication data */ + int scan_data_len; /**< scan response data length */ + char *scan_data; /**< scan response data */ +} bt_adapter_le_device_discovery_info_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Structure of le scan result information. + * @since_tizen 2.3.1 + * + * @see bt_adapter_le_start_scan() + */ +typedef struct +{ + char *remote_address; /**< The address of remote device */ + bt_device_address_type_e address_type; /**< The address type of remote device */ + int rssi; /**< The strength indicator of received signal */ + int adv_data_len; /**< advertising indication data length */ + char *adv_data; /**< advertising indication data */ + int scan_data_len; /**< scan response data length */ + char *scan_data; /**< scan response data */ +} bt_adapter_le_device_scan_result_info_s; + +/** + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Structure of advertising parameters + * @since_tizen 2.3 + * + * @see bt_adapter_le_advertising_state_changed_cb() + * @see bt_adapter_le_start_advertising() + */ +typedef struct { + float interval_min; /**< Minimum advertising interval for non-directed advertising. + A multiple of 0.625ms is only allowed (Time range : 20ms to 10.24sec). */ + float interval_max; /**< Maximum advertising interval for non-directed advertising. + A multiple of 0.625ms is only allowed (Time range : 20ms to 10.24sec). */ + char filter_policy; /* Advertising filter policy */ + char type; /* Advertising type */ +} bt_adapter_le_advertising_params_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief LE service data structure + * @since_tizen 2.3.1 + * + * @see bt_adapter_le_get_scan_result_service_data() + */ +typedef struct +{ + char *service_uuid; /**< 16 bit UUID of the service data */ + char *service_data; /**< Service data */ + int service_data_len; /**< Service data length */ +} bt_adapter_le_service_data_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Device information structure used for identifying pear device. + * @since_tizen 2.3 + * + * @see #bt_class_s + * @see bt_device_bond_created_cb() + */ +typedef struct +{ + char *remote_address; /**< The address of remote device */ + char *remote_name; /**< The name of remote device */ + bt_class_s bt_class; /**< The Bluetooth classes */ + char **service_uuid; /**< The UUID list of service */ + int service_count; /**< The number of services */ + bool is_bonded; /**< The bonding state */ + bool is_connected; /**< The connection state */ + bool is_authorized; /**< The authorization state */ + unsigned short vid; /*<< The Vendor Id of the remote address */ + unsigned short pid; /**<< The Product Id of the remote address*/ + bt_connected_service_mask_e service_mask; /**< Service mask */ + int manufacturer_data_len; /**< manufacturer specific data length */ + char *manufacturer_data; /**< manufacturer specific data */ +} bt_device_info_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Service Discovery Protocol (SDP) data structure. + * @since_tizen 2.3 + * + * @details This protocol is used for discovering available services or pear device, + * and finding one to connect with. + * + * @see bt_device_service_searched_cb() + */ +typedef struct +{ + char *remote_address; /**< The address of remote device */ + char **service_uuid; /**< The UUID list of service */ + int service_count; /**< The number of services. */ +} bt_device_sdp_info_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Device connection information structure. + * @since_tizen 2.3 + * + * @see bt_device_connection_state_changed_cb() + */ +typedef struct +{ + char *remote_address; /**< The address of remote device */ + bt_device_connection_link_type_e link; /**< Link type */ + bt_device_disconnect_reason_e disconn_reason; /**< Disconnection reason */ +} bt_device_connection_info_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Device LE connection update structure. + * @since_tizen 2.3 + * + * @see bt_device_le_conn_update() + */ +typedef struct +{ + unsigned int interval_min; /**< Minimum value for the connection event interval (msec) */ + unsigned int interval_max; /**< Maximum value for the connection event interval (msec) */ + unsigned int latency; /**< Slave latency (msec) */ + unsigned int time_out; /**< Supervision timeout (msec) */ +} bt_le_conn_update_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Rfcomm connection data used for exchanging data between Bluetooth devices. + * @since_tizen 2.3 + * + * @see bt_socket_connection_state_changed_cb() + */ +typedef struct +{ + int socket_fd; /**< The file descriptor of connected socket */ + int server_fd; /**< The file descriptor of the server socket or -1 for client connection */ + bt_socket_role_e local_role; /**< The local device role in this connection */ + char *remote_address; /**< The remote device address */ + char *service_uuid; /**< The service UUId */ +} bt_socket_connection_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Structure of RFCOMM received data. + * @since_tizen 2.3 + * + * @remarks User can use standard linux functions for reading/writing + * data from/to sockets. + * + * @see bt_socket_data_received_cb() + */ +typedef struct +{ + int socket_fd; /**< The socket fd */ + int data_size; /**< The length of the received data */ + char *data; /**< The received data */ +} bt_socket_received_data_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when the Bluetooth adapter state changes. + * @since_tizen 2.3 + * + * @param[in] result The result of the adapter state changing + * @param[in] adapter_state The adapter state to be changed + * @param[in] user_data The user data passed from the callback registration function + * @see bt_adapter_set_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb() + */ +typedef void (*bt_adapter_state_changed_cb)(int result, bt_adapter_state_e adapter_state, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when adapter name changes. + * @since_tizen 2.3 + * + * @param[in] device_name The name of the Bluetooth device to be changed + * @param[in] user_data The user data passed from the callback registration function + * @pre This function will be invoked when the name of Bluetooth adapter changes + * if you register this callback using bt_adapter_set_name_changed_cb(). + * @see bt_adapter_set_name() + * @see bt_adapter_set_name_changed_cb() + * @see bt_adapter_unset_name_changed_cb() + */ +typedef void (*bt_adapter_name_changed_cb)(char *device_name, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when the visibility mode changes. + * @since_tizen 2.3 + * + * @param[in] result The result of the visibility mode changing + * @param[in] visibility_mode The visibility mode to be changed + * @param[in] user_data The user data passed from the callback registration function + * + * @pre This function will be invoked when the visibility of Bluetooth adapter changes + * if you register this callback using bt_adapter_set_visibility_mode_changed_cb(). + * + * @see bt_adapter_set_visibility_mode_changed_cb() + * @see bt_adapter_unset_visibility_mode_changed_cb() + */ +typedef void (*bt_adapter_visibility_mode_changed_cb) + (int result, bt_adapter_visibility_mode_e visibility_mode, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called every second until the visibility mode is changed to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE. + * @since_tizen 2.3 + * + * @remarks This callback function is called only if visibility mode is #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE. + * @param[in] duration The duration until the visibility mode is changed to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE (in seconds) + * @param[in] user_data The user data passed from the callback registration function + * @pre This function will be invoked if you register this callback using bt_adapter_set_visibility_duration_changed_cb(). + * @see bt_adapter_set_visibility_duration_changed_cb() + * @see bt_adapter_unset_visibility_duration_changed_cb() + */ +typedef void (*bt_adapter_visibility_duration_changed_cb)(int duration, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when the state of device discovery changes. + * @since_tizen 2.3 + * + * @remarks If \a discovery_state is #BT_ADAPTER_DEVICE_DISCOVERY_FOUND, + * then you can get some information, such as remote device address, remote device name, rssi, and bonding state. + * + * @param[in] result The result of the device discovery + * @param[in] discovery_state The discovery state to be changed + * @param[in] discovery_info The information of the discovered device \n + * If \a discovery_state is #BT_ADAPTER_DEVICE_DISCOVERY_STARTED or + * #BT_ADAPTER_DEVICE_DISCOVERY_FINISHED, then \a discovery_info is NULL. + * @param[in] user_data The user data passed from the callback registration function + * + * @pre Either bt_adapter_start_device_discovery() or bt_adapter_stop_device_discovery() will invoke this function + * if you register this callback using bt_adapter_set_device_discovery_state_changed_cb(). + * + * @see bt_adapter_start_device_discovery() + * @see bt_adapter_stop_device_discovery() + * @see bt_adapter_set_device_discovery_state_changed_cb() + * @see bt_adapter_unset_device_discovery_state_changed_cb() + * + */ +typedef void (*bt_adapter_device_discovery_state_changed_cb) + (int result, bt_adapter_device_discovery_state_e discovery_state, bt_adapter_device_discovery_info_s *discovery_info, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when you get bonded devices repeatedly. + * @since_tizen 2.3 + * + * @param[in] device_info The bonded device information + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, + * \n @c false to break out of the loop. + * @pre bt_adapter_foreach_bonded_device() will invoke this function. + * + * @see bt_adapter_foreach_bonded_device() + * + */ +typedef bool (*bt_adapter_bonded_device_cb)(bt_device_info_s *device_info, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when the connectable state changes. + * @since_tizen 2.3 + * + * @param[in] result The result of the connectable state changing + * @param[in] connectable The connectable to be changed + * @param[in] user_data The user data passed from the callback registration function + * + * @pre This function will be invoked when the connectable state of local Bluetooth adapter changes + * if you register this callback using bt_adapter_set_connectable_changed_cb(). + * + * @see bt_adapter_set_connectable() + * @see bt_adapter_set_connectable_changed_cb() + * @see bt_adapter_unset_connectable_changed_cb() + */ +typedef void (*bt_adapter_connectable_changed_cb) + (int result, bool connectable, void *user_data); + +/** + * @deprecated Deprecated since 2.3.1 + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Called when the state of LE device discovery changes. + * @since_tizen 2.3 + * + * @remarks If \a discovery_state is #BT_ADAPTER_LE_DEVICE_DISCOVERY_FOUND, + * then you can get some information, such as remote LE device address, remote device name, rssi, and bonding state. + * + * @param[in] result The result of the LE device discovery + * @param[in] discovery_state The discovery state to be changed + * @param[in] discovery_info The information of the discovered LE device \n + * If \a discovery_state is #BT_ADAPTER_LE_DEVICE_DISCOVERY_STARTED or + * #BT_ADAPTER_LE_DEVICE_DISCOVERY_FINISHED, then \a discovery_info is NULL. + * @param[in] user_data The user data passed from the callback registration function + * + * @pre Either bt_adapter_start_device_discovery() or bt_adapter_stop_device_discovery() will invoke this function + * if you register this callback using bt_adapter_set_device_discovery_state_changed_cb(). + * + * @see bt_adapter_le_start_device_discovery() + * @see bt_adapter_le_stop_device_discovery() + * @see bt_adapter_le_set_device_discovery_state_changed_cb() + * @see bt_adapter_le_unset_device_discovery_state_changed_cb() + * + */ +typedef void (*bt_adapter_le_device_discovery_state_changed_cb) + (int result, bt_adapter_le_device_discovery_state_e discovery_state, bt_adapter_device_discovery_info_s *discovery_info, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Called when the LE advertisement has been found. + * @since_tizen 2.3.1 + * + * @param[in] result The result of the LE scan + * @param[in] info The information of the found LE advertisement. + * @param[in] user_data The user data passed from the start function + * + * @see bt_adapter_le_start_scan() + * + */ +typedef void (*bt_adapter_le_scan_result_cb)(int result, + bt_adapter_le_device_scan_result_info_s *info, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Called when the state of advertiser changes. + * @since_tizen 2.3 + * + * @param[out] result The result of the requested state change of advertiser + * @param[out] advertiser The handle of the state changed advertiser + * @param[out] adv_state The advertiser state to be changed + * @param[out] user_data The user data passed from the start function + * + * @see bt_adapter_le_start_advertising_new() + * @see bt_adapter_le_stop_advertising() + */ +typedef void (*bt_adapter_le_advertising_state_changed_cb)(int result, + bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Called when the Bluetooth adapter le state changes. + * @since_tizen 2.3 + * + * @param[in] result The result of the adapter state changing + * @param[in] adapter_le_state The adapter le state to be changed + * @param[in] user_data The user data passed from the callback registration function + * @pre Either bt_adapter_le_enable() or bt_adapter_le_disable() will invoke this callback if you register this callback using bt_adapter_le_set_state_changed_cb(). + * @see bt_adapter_le_enable() + * @see bt_adapter_le_disable() + * @see bt_adapter_le_set_state_changed_cb() + * @see bt_adapter_le_unset_state_changed_cb() + */ +typedef void (*bt_adapter_le_state_changed_cb)(int result, bt_adapter_le_state_e adapter_le_state, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Called when the process of creating bond finishes. + * @since_tizen 2.3 + * + * @remarks If the remote user does not respond within 60 seconds, a time out will happen with #BT_ERROR_TIMED_OUT result code.\n + * If bt_device_cancel_bonding() is called and it returns #BT_ERROR_NONE, then this callback function will be called + * with #BT_ERROR_CANCELLED result. \n + * If creating a bond succeeds but service search fails, then this callback will be called with #BT_ERROR_SERVICE_SEARCH_FAILED. + * In this case, you should try service search again by bt_device_start_service_search() to get the supported service list. + * + * @param[in] result The result of the bonding device + * @param[in] device_info The device information which you creates bond with + * @param[in] user_data The user data passed from the callback registration function + * + * @pre Either bt_device_create_bond() will invoke this function + * if you register this callback using bt_device_set_bond_created_cb(). + * + * @see bt_device_create_bond() + * @see bt_device_cancel_bonding() + * @see bt_device_set_bond_created_cb() + * @see bt_device_unset_bond_created_cb() + */ +typedef void (*bt_device_bond_created_cb)(int result, bt_device_info_s *device_info, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Called when you get connected profiles repeatedly. + * @since_tizen 2.3 + * + * @param[in] profile The connected Bluetooth profile + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, + * \n @c false to break out of the loop. + * @pre bt_device_foreach_connected_profiles() will invoke this function. + * @see bt_device_foreach_connected_profiles() + */ +typedef bool (*bt_device_connected_profile)(bt_profile_e profile, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Called when the bond destroys. + * @since_tizen 2.3 + * + * @param[in] result The result that a bond is destroyed + * @param[in] remote_address The address of the remote Bluetooth device to destroy bond with + * @param[in] user_data The user data passed from the callback registration function + * @pre bt_device_destroy_bond() will invoke this function + * if you register this callback using bt_device_set_bond_destroyed_cb(). + * + * @see bt_device_destroy_bond() + * @see bt_device_set_bond_destroyed_cb() + * @see bt_device_unset_bond_destroyed_cb() + */ +typedef void (*bt_device_bond_destroyed_cb)(int result, char *remote_address, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Called when the authorization of device changes. + * @since_tizen 2.3 + * + * @param[in] authorization The authorization of device + * @param[in] remote_address The address of the remote Bluetooth device which is (un)authorized + * @param[in] user_data The user data passed from the callback registration function + * @pre bt_device_set_authorization() will invoke this function if you register this callback using bt_device_set_authorization_changed_cb(). + * + * @see bt_device_set_authorization() + * @see #bt_device_set_authorization_changed_cb() + * @see #bt_device_unset_authorization_changed_cb() + */ +typedef void (*bt_device_authorization_changed_cb) + (bt_device_authorization_e authorization, char *remote_address, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Called when the process of service search finishes. + * @since_tizen 2.3 + * + * @remark + * + * @param[in] result The result of the service searching + * @param[in] sdp_info The structure of service lists found on a device + * @param[in] user_data The user data passed from the callback registration function + * @pre Either bt_device_start_service_search() will invoke this function + * if you register this callback using bt_device_set_service_searched_cb(). + * + * @see bt_device_start_service_search() + * @see bt_device_set_service_searched_cb() + * @see bt_device_unset_service_searched_cb() + * + */ +typedef void (*bt_device_service_searched_cb)(int result, bt_device_sdp_info_s *sdp_info, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Called when the connection state is changed. + * @since_tizen 2.3 + * + * @param[in] connected The connection status: (@c true = connected, @c false = disconnected) + * @param[in] conn_info The connection information + * @param[in] user_data The user data passed from the callback registration function + * @see bt_device_set_connection_state_changed_cb() + * @see bt_device_unset_connection_state_changed_cb() + */ +typedef void (*bt_device_connection_state_changed_cb)(bool connected, bt_device_connection_info_s *conn_info, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Called when you receive data. + * @since_tizen 2.3 + * + * @param[in] data The received data from the remote device + * @param[in] user_data The user data passed from the callback registration function + * + * @pre When the connected remote Bluetooth device invokes bt_socket_send_data(), + * this function will be invoked if you register this function using bt_socket_set_data_received_cb(). + * + * @see bt_socket_set_data_received_cb() + * @see bt_socket_unset_data_received_cb() + * @see bt_socket_send_data() + */ +typedef void (*bt_socket_data_received_cb)(bt_socket_received_data_s *data, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Called when the socket connection state changes. + * @since_tizen 2.3 + * + * @param[in] result The result of connection state changing + * @param[in] connection_state The connection state + * @param[in] connection The connection information which is established or disconnected + * @param[in] user_data The user data passed from the callback registration function + * @pre Either bt_socket_connect_rfcomm() will invoke this function. + * In addtion, bt_socket_connection_state_changed_cb() will be invoked when the socket connection state is changed. + * @see bt_socket_listen_and_accept_rfcomm() + * @see bt_socket_connect_rfcomm() + * @see bt_socket_set_connection_state_changed_cb() + * @see bt_socket_unset_connection_state_changed_cb() + */ +typedef void (*bt_socket_connection_state_changed_cb) + (int result, bt_socket_connection_state_e connection_state, bt_socket_connection_s *connection, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Called when a RFCOMM connection is requested. + * @since_tizen 2.3 + * + * @param[in] socket_fd The file descriptor of socket on which a connection is requested + * @param[in] remote_address The address of remote device + * @param[in] user_data The user data passed from the callback registration function + * @pre If you register this callback function by bt_socket_set_connection_requested_cb(), + * bt_socket_connection_requested_cb() will be invoked. + */ +typedef void (*bt_socket_connection_requested_cb) (int socket_fd, const char *remote_address, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Called when the push is requested. + * @since_tizen 2.3 + * + * @details You must call bt_opp_server_accept() if you want to accept. + * Otherwise, you must call bt_opp_server_reject(). + * @param[in] file The path of file to be pushed + * @param[in] size The file size (bytes) + * @param[in] user_data The user data passed from the callback registration function + */ +typedef void (*bt_opp_server_push_requested_cb)(const char *file, int size, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Called when an OPP connection is requested. + * @since_tizen 2.3 + * + * @details You must call bt_opp_server_accept_connection() if you want to accept. + * Otherwise, you must call bt_opp_server_reject_connection(). + * @param[in] remote_address The address of remote device + * @param[in] user_data The user data passed from the callback registration function + * @see bt_opp_server_accept() + * @see bt_opp_server_reject() + */ +typedef void (*bt_opp_server_connection_requested_cb)(const char *remote_address, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Called when a file is being transfered. + * @since_tizen 2.3 + * + * @param[in] file The path of file to be pushed + * @param[in] size The file size (bytes) + * @param[in] percent The progress in percentage (1 ~ 100) + * @param[in] user_data The user data passed from the callback registration function + * @see bt_opp_server_accept() + * @see bt_opp_server_accept_connection() + */ +typedef void (*bt_opp_server_transfer_progress_cb) (const char *file, long long size, int percent, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Called when a transfer is finished. + * @since_tizen 2.3 + * + * @param[in] error_code The result of push + * @param[in] file The path of file to be pushed + * @param[in] size The file size (bytes) + * @param[in] user_data The user data passed from the callback registration function + * @see bt_opp_server_accept() + * @see bt_opp_server_accept_connection() + */ +typedef void (*bt_opp_server_transfer_finished_cb) (int result, const char *file, long long size, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_CLIENT_MODULE + * @brief Called when OPP server responds to the push request. + * @since_tizen 2.3 + * + * @param[in] result The result of OPP server response + * @param[in] remote_address The remote address + * @param[in] user_data The user data passed from the callback registration function + * @pre bt_opp_client_push_files() will invoke this function. + * @see bt_opp_client_push_files() + */ +typedef void (*bt_opp_client_push_responded_cb)(int result, const char *remote_address, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_CLIENT_MODULE + * @brief Called when each file is being transfered. + * @since_tizen 2.3 + * + * @param[in] file The path of file to be pushed + * @param[in] size The file size (bytes) + * @param[in] percent The progress in percentage (1 ~ 100). 100 means that a file is transfered completely. + * @param[in] user_data The user data passed from the callback registration function + * @pre bt_opp_client_push_files() will invoke this function. + * @see bt_opp_client_push_files() + */ +typedef void (*bt_opp_client_push_progress_cb)(const char *file, long long size, int percent, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_CLIENT_MODULE + * @brief Called when the push request is finished. + * @since_tizen 2.3 + * + * @param[in] result The result of the push request + * @param[in] remote_address The remote address + * @param[in] user_data The user data passed from the callback registration function + * @see bt_opp_client_push_files() + */ +typedef void (*bt_opp_client_push_finished_cb)(int result, const char *remote_address, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Called when the connection state is changed. + * @since_tizen 2.3 + * + * @details This callback is called when the connection state is changed. + * When you call bt_audio_connect() or bt_audio_disconnect(), this callback is also called with error result even though these functions fail. + * @param[in] result The result of changing the connection state + * @param[in] connected The state to be changed. @a true means connected state, Otherwise, @a false. + * @param[in] remote_address The remote address + * @param[in] type The type of audio profile except #BT_AUDIO_PROFILE_TYPE_ALL + * @param[in] user_data The user data passed from the callback registration function + * @see bt_audio_set_connection_state_changed_cb() + * @see bt_audio_unset_connection_state_changed_cb() + */ +typedef void (*bt_audio_connection_state_changed_cb) (int result, bool connected, const char *remote_address, bt_audio_profile_type_e type, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Called when a call handling event happened from Hands-Free. + * @since_tizen 2.3 + * + * @param[in] event The call handling event happened from Hands-Free + * @param[in] call_id The call ID + * @param[in] user_data The user data passed from the callback registration function + * @see bt_ag_set_call_handling_event_cb() + * @see bt_ag_unset_call_handling_event_cb() + */ +typedef void (*bt_ag_call_handling_event_cb) (bt_ag_call_handling_event_e event, unsigned int call_id, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Called when a multi call handling event happened from Hands-Free. + * @since_tizen 2.3 + * + * @param[in] event The call handling event happened from Hands-Free + * @param[in] user_data The user data passed from the callback registration function + * @see bt_ag_set_multi_call_handling_event_cb() + * @see bt_ag_unset_multi_call_handling_event_cb() + */ +typedef void (*bt_ag_multi_call_handling_event_cb) (bt_ag_multi_call_handling_event_e event, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Called when a DTMF(Dual Tone Multi Frequency) is transmitted from Hands-Free. + * @since_tizen 2.3 + * + * @param[in] dtmf The DTMF transmitted from Hands-Free + * @param[in] user_data The user data passed from the callback registration function + * @see bt_ag_set_dtmf_transmitted_cb() + * @see bt_ag_unset_dtmf_transmitted_cb() + */ +typedef void (*bt_ag_dtmf_transmitted_cb) (const char *dtmf, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Called when the speaker gain of the remote device is changed. + * @since_tizen 2.3 + * + * @param[in] gain The gain of speaker (0 ~ 15) + * @param[in] user_data The user data passed from the callback registration function + * @see bt_ag_set_speaker_gain_changed_cb() + * @see bt_ag_unset_speaker_gain_changed_cb() + */ +typedef void (*bt_ag_speaker_gain_changed_cb) (int gain, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Called when the microphone gain of the remote device is changed. + * @since_tizen 2.3 + * + * @param[in] gain The gain of microphone (0 ~ 15) + * @param[in] user_data The user data passed from the callback registration function + * @see bt_ag_set_microphone_gain_changed_cb() + * @see bt_ag_unset_microphone_gain_changed_cb() + */ +typedef void (*bt_ag_microphone_gain_changed_cb) (int gain, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Called when the connection state is changed. + * @since_tizen 2.3 + * + * @param[in] connected The state to be changed. @a true means connected state, Otherwise, @a false. + * @param[in] remote_address The remote address + * @param[in] user_data The user data passed from the callback registration function + * @see bt_avrcp_target_initialize() + * @see bt_avrcp_target_deinitialize() + */ +typedef void (*bt_avrcp_target_connection_state_changed_cb) (bool connected, const char *remote_address, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Called when the equalizer state is changed by the remote control device. + * @since_tizen 2.3 + * + * @param[in] equalizer The equalizer state + * @param[in] user_data The user data passed from the callback registration function + * @see bt_avrcp_set_equalizer_state_changed_cb() + * @see bt_avrcp_unset_equalizer_state_changed_cb() + */ +typedef void (*bt_avrcp_equalizer_state_changed_cb) (bt_avrcp_equalizer_state_e equalizer, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Called when the repeat mode is changed by the remote control device. + * @since_tizen 2.3 + * + * @param[in] repeat The repeat mode + * @param[in] user_data The user data passed from the callback registration function + * @see bt_avrcp_set_repeat_mode_changed_cb() + * @see bt_avrcp_unset_repeat_mode_changed_cb() + */ +typedef void (*bt_avrcp_repeat_mode_changed_cb) (bt_avrcp_repeat_mode_e repeat, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Called when the shuffle mode is changed by the remote control device. + * @since_tizen 2.3 + * + * @param[in] shuffle The shuffle mode + * @param[in] user_data The user data passed from the callback registration function + * @see bt_avrcp_set_shuffle_mode_changed_cb() + * @see bt_avrcp_unset_shuffle_mode_changed_cb() + */ +typedef void (*bt_avrcp_shuffle_mode_changed_cb) (bt_avrcp_shuffle_mode_e shuffle, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Called when the scan mode is changed by the remote control device. + * @since_tizen 2.3 + * + * @param[in] shuffle The shuffle mode + * @param[in] user_data The user data passed from the callback registration function + * @see bt_avrcp_set_scan_mode_changed_cb() + * @see bt_avrcp_unset_scan_mode_changed_cb() + */ +typedef void (*bt_avrcp_scan_mode_changed_cb) (bt_avrcp_scan_mode_e scan, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called when the connection state is changed. + * @since_tizen 2.3 + * + * @details This callback is called when the connection state is changed. + * When you call bt_hid_host_connect() or bt_hid_host_disconnect(), this callback is also called with error result even though these functions fail. + * @param[in] result The result of changing the connection state + * @param[in] connected The state to be changed. @a true means connected state, Otherwise, @a false. + * @param[in] remote_address The remote address + * @param[in] user_data The user data passed from the callback registration function + * @see bt_hid_host_connect() + * @see bt_hid_host_disconnect() + */ +typedef void (*bt_hid_host_connection_state_changed_cb) (int result, bool connected, const char *remote_address, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HDP_MODULE + * @brief Called when the connection is established. + * @since_tizen 2.3 + * + * @param[in] result The result of connecting to the remote device + * @param[in] remote_address The address of connected remote device + * @param[in] app_id The ID of application + * @param[in] type The type of HDP(Health Device Profile) channel + * @param[in] channel The connected data channel + * @param[in] user_data The user data passed from the callback registration function + * @see bt_hdp_disconnected_cb + * @see bt_hdp_set_connection_state_changed_cb() + * @see bt_hdp_unset_connection_state_changed_cb() + */ +typedef void (*bt_hdp_connected_cb) (int result, const char *remote_address, const char *app_id, + bt_hdp_channel_type_e type, unsigned int channel, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HDP_MODULE + * @brief Called when the connection is disconnected. + * @since_tizen 2.3 + * + * @param[in] result The result of disconnecting from the remote device + * @param[in] remote_address The address of disconnected remote device + * @param[in] channel The connected data channel + * @param[in] user_data The user data passed from the callback registration function + * @see bt_hdp_connected_cb + * @see bt_hdp_set_connection_state_changed_cb() + * @see bt_hdp_unset_connection_state_changed_cb() + */ +typedef void (*bt_hdp_disconnected_cb) (int result, const char *remote_address, unsigned int channel, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HDP_MODULE + * @brief Called when the you receive the data. + * @since_tizen 2.3 + * + * @param[in] channel The connected data channel + * @param[in] data The received data + * @param[in] size The size of received data (byte) + * @param[in] user_data The user data passed from the callback registration function + * @see bt_hdp_set_data_received_cb() + * @see bt_hdp_unset_data_received_cb() + */ +typedef void (*bt_hdp_data_received_cb) (unsigned int channel, const char *data, unsigned int size, void *user_data); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_foreach_cb instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Called when you get the primary services repeatedly. + * @since_tizen 2.3 + * + * @param[in] service The attribute handle of service + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, + * \n @c false to break out of the loop. + * @pre bt_gatt_foreach_primary_services() will invoke this function. + * @see bt_gatt_foreach_primary_services() + */ +typedef bool (*bt_gatt_primary_service_cb) (bt_gatt_attribute_h service, void *user_data); + +/** + * @deprecated Deprecated since 2.3.1. This is not required because characteristic discovery is happened automatically. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Called after the characteristics are discovered by bt_gatt_discover_characteristics(). + * @since_tizen 2.3 + * + * @remarks If bt_gatt_discover_characteristics() failed, then this callback function is called only once with 0 totla and NULL characteristic_handle. + * @param[in] result The result of discovering + * @param[in] index The index of characteristics in a service, starts from 0 + * @param[in] total The total number of characteristics in a service + * @param[in] characteristic The attribute handle of characteristic + * @param[in] user_data The user data passed from the request function + * @return @c true to continue with the next iteration of the loop, + * \n @c false to break out of the loop. + * @pre bt_gatt_discover_characteristics() will invoke this callback. + * @see bt_gatt_discover_characteristics() + */ +typedef bool (*bt_gatt_characteristics_discovered_cb) (int result, int index, int total, bt_gatt_attribute_h characteristic, void *user_data); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_foreach_cb instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Called when you get the included services repeatedly. + * @since_tizen 2.3 + * + * @param[in] service The attribute handle of service + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, + * \n @c false to break out of the loop. + * @pre bt_gatt_foreach_included_services() will invoke this function. + * @see bt_gatt_foreach_included_services() + */ +typedef bool (*bt_gatt_included_service_cb) (bt_gatt_attribute_h service, void *user_data); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_characteristic_value_changed_cb instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Called when a characteristic in service is changed. + * @since_tizen 2.3 + * + * @param[in] characteristic The attribute handle of characteristic + * @param[in] value The value of characteristic (byte array) + * @param[in] value_length The length of value + * @param[in] user_data The user data passed from the callback registration function + * @see bt_gatt_set_characteristic_changed_cb() + * @see bt_gatt_unset_characteristic_changed_cb() + */ +typedef void (*bt_gatt_characteristic_changed_cb) (bt_gatt_attribute_h characteristic, unsigned char *value, int value_length, void *user_data); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_request_completed_cb instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Called when a characteristic value is written. + * @since_tizen 2.3 + * + * @see bt_gatt_set_characteristic_value() + */ +typedef void (*bt_gatt_characteristic_write_cb) (void *user_data); + +/** + * @deprecated Deprecated since 2.3.1. Use bt_gatt_client_request_completed_cb instead. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Called when a characteristic value is read. + * @since_tizen 2.3 + * + * @param[in] value The value of characteristic (byte array) + * @param[in] value_length The length of value + * @param[in] user_data The user data passed from the foreach function + * @see bt_gatt_read_characteristic_value() + */ +typedef void (*bt_gatt_characteristic_read_cb) (unsigned char *value, + int value_length, void *user_data); + +/** + * @deprecated Deprecated since 2.3.1. This is not required because descriptor discovery is happened automatically. + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Called after the characteristics descriptors are discovered by bt_gatt_discover_characteristic_descriptor(). + * @since_tizen 2.3 + * + * @param[in] result The result of discovering + * @param[in] characteristic_format The format of the information data. + * characteristic_format = 0x01 indicates UUIDs are 16-bits + * characteristic_format = 0x02 indicates UUIDs are 128-bits + * @param[in] total The total number of elements in characteristic_descriptor + * @param[in] characteristic descriptor The attribute handle and the UUID of characteristic descriptor + * @param[in] user_data The user data passed from the request function + * @see bt_gatt_discover_characteristic_descriptor() + */ +typedef void (*bt_gatt_characteristic_descriptor_discovered_cb) (int result, + unsigned char characteristic_format, int total, + bt_gatt_attribute_h characteristic_descriptor, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Called when you get GATT handles repeatedly + * @since_tizen 2.3.1 + * + * @param[in] total The total number of GATT handles to be called + * @param[in] index The index of current GATT handle. It starts from 0. + * @param[in] gatt_handle The GATT handle + * @param[in] user_data The user data passed from the foreach function + * + * @see bt_gatt_service_foreach_characteristics() + * @see bt_gatt_service_foreach_included_services() + * @see bt_gatt_characteristic_foreach_descriptors() + * @see bt_gatt_server_foreach_services() + * @see bt_gatt_client_foreach_services() + */ +typedef bool (*bt_gatt_foreach_cb) (int total, int index, bt_gatt_h gatt_handle, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Called when the client request(e.g. read / write) has been completed + * @since_tizen 2.3.1 + * + * @param[in] result The result of a request + * @param[in] request_handle The requesting GATT handle + * @param[in] user_data The user data passed from the requesting function + * + * @see bt_gatt_client_read_value() + * @see bt_gatt_client_write_value() + */ +typedef void (*bt_gatt_client_request_completed_cb) (int result, + bt_gatt_h request_handle, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Called when a value of a watched characteristic's GATT handle has been changed + * @since_tizen 2.3.1 + * + * @remarks After this function is returned, a changed vlaue is automatically + * applied to @a characteristic. Before that, @a characteristic has an old value. + * + * @param[in] characteristic The characteristic's GATT handle of which value change is informed. It has an old value. + * @param[in] value The new value + * @param[in] len The length of @a value + * @param[in] user_data The user data passed from the registering function + * + * @see bt_gatt_client_set_characteristic_value_changed_cb() + */ +typedef void (*bt_gatt_client_characteristic_value_changed_cb) (bt_gatt_h characteristic, + char *value, int len, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Called when the connection state is changed. + * @since_tizen 2.3 + * + * @details This callback is called when the connection state is changed. + * When you called bt_gatt_connect() or bt_gatt_disconnect(), this callback is also called with error result even though these functions fail. + * + * @param[in] result The result of changing the connection state. + * @param[in] connected The state to be changed, @a true means connected state, Otherwise, @a false. + * @param[in] remote_address The remote_address + * @param[in] user_data The user data passed from the callback registration function. + * + * @see bt_gatt_connect() + * @see bt_gatt_disconnect() + * @see bt_gatt_set_connection_state_changed_cb() + * @see bt_gatt_unset_connection_state_changed_cb() + */ +typedef void (*bt_gatt_connection_state_changed_cb)(int result, bool connected, const char *remote_address, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Called when the connection state is changed. + * @since_tizen 2.3 + * + * @param[in] connected Indicates whether a client is connected or disconnected + * @param[in] remote_address The remote address + * @param[in] interface_name The interface name. For example, bnep0, bnep1. + * @param[in] user_data The user data passed from the callback registration function + * @see bt_nap_set_connection_state_changed_cb() + * @see bt_nap_unset_connection_state_changed_cb() + */ +typedef void (*bt_nap_connection_state_changed_cb) (bool connected, const char *remote_address, const char *interface_name, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE + * @brief Called when the connection state is changed. + * @since_tizen 2.3 + * + * @details This callback is called when the connection state is changed. + * When you call bt_panu_connect() or bt_panu_disconnect(), this callback is also called with error result even though these functions fail. + * @param[in] result The result of changing the connection state + * @param[in] connected The state to be changed. @a true means connected state, Otherwise, @a false. + * @param[in] remote_address The remote address + * @param[in] type The type of PAN service + * @param[in] user_data The user data passed from the callback registration function + * @see bt_nap_set_connection_state_changed_cb() + * @see bt_nap_unset_connection_state_changed_cb() + */ +typedef void (*bt_panu_connection_state_changed_cb) (int result, bool connected, const char *remote_address, bt_panu_service_type_e type, void *user_data); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // __TIZEN_NETWORK_BLUETOOTH_TYPE_H__ diff --git a/include/tv/bluetooth_type_extension.h b/include/tv/bluetooth_type_extension.h new file mode 100644 index 0000000..4018e6c --- /dev/null +++ b/include/tv/bluetooth_type_extension.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_NETWORK_BLUETOOTH_TYPE_EXTENSION_H__ +#define __TIZEN_NETWORK_BLUETOOTH_TYPE_EXTENSION_H__ + + #ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** + * @file bluetooth_type_extension.h + */ + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Called when the SCO(Synchronous Connection Oriented link) state is changed. + * @since_tizen 2.3 + * + * @details This callback is called when the SCO state is changed. + * When you call bt_ag_open_sco() or bt_ag_close_sco(), this callback is also called with error result even though these functions failed. + * @param[in] result The result of changing the connection state + * @param[in] opened The state to be changed: (@c true = opened, @c false = not opened) + * @param[in] user_data The user data passed from the callback registration function + * @see bt_ag_set_sco_state_changed_cb() + * @see bt_ag_unset_sco_state_changed_cb() + * @see bt_ag_open_sco() + * @see bt_ag_close_sco() + */ +typedef void (*bt_ag_sco_state_changed_cb) (int result, bool opened, void *user_data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // __TIZEN_NETWORK_BLUETOOTH_TYPE_EXTENSION_H__ diff --git a/include/tv/bluetooth_type_internal.h b/include/tv/bluetooth_type_internal.h new file mode 100644 index 0000000..cb20aa1 --- /dev/null +++ b/include/tv/bluetooth_type_internal.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_NETWORK_BLUETOOTH_TYPE_INTERNAL_H__ +#define __TIZEN_NETWORK_BLUETOOTH_TYPE_INTERNAL_H__ + + #ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** + * @file bluetooth_type_internal.h + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // __TIZEN_NETWORK_BLUETOOTH_TYPE_INTERNAL_H__ diff --git a/include/tv/bluetooth_type_product.h b/include/tv/bluetooth_type_product.h new file mode 100644 index 0000000..fd98ce3 --- /dev/null +++ b/include/tv/bluetooth_type_product.h @@ -0,0 +1,761 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_NETWORK_BLUETOOTH_TYPE_PRODUCT_H__ +#define __TIZEN_NETWORK_BLUETOOTH_TYPE_PRODUCT_H__ +#include <glib.h> +#include <stdlib.h> +#include <unistd.h> +#include <stdbool.h> +#include <tizen_error.h> + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** + * @file bluetooth_type_product.h + */ + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enumerations of the authentication event types. + * + */ +typedef enum { + BT_AUTH_KEYBOARD_PASSKEY_DISPLAY = 0, /**< PIN display event to user for entering PIN in keyboard */ + BT_AUTH_PIN_REQUEST, /**< Legacy PIN or PASSKEY request event */ + BT_AUTH_PASSKEY_CONFIRM_REQUEST, /**< PASSKEY confirmation event to match PASSKEY in remote device */ + BT_AUTH_SSP_CONSENT_REQUEST, /**< Event for requesting user Consent for SSP */ +} bt_authentication_type_info_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief enums for audio stream type + */ +typedef enum { + BT_AUDIO_MAIN_STREAM, + BT_AUDIO_SUB_STREAM, +} bt_audio_stream_type_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief enums for audio role type + */ +typedef enum { + BT_AUDIO_SOURCE_ROLE, + BT_AUDIO_SINK_ROLE, +} bt_audio_role_type_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief enums for a2dp sink audio states + */ + +typedef enum { + BT_A2DP_SINK_AUDIO_SUSPEND, + BT_A2DP_SINK_AUDIO_STOPPED, + BT_A2DP_SINK_AUDIO_STARTED, +} bt_a2dp_sink_audio_state_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Enumerations for sending AVRCP commands to remote audio dock. + */ +typedef enum +{ + BT_AVRCP_DEVICE_TURN_OFF = 0x40, /**< The remote audio dock is turned off */ + BT_AVRCP_DEVICE_SET_VOLUME_UP, /**< Volume is increased in remote audio dock */ + BT_AVRCP_DEVICE_SET_VOLUME_DOWN, /**< Volume is decreased in remote audio dock */ + BT_AVRCP_DEVICE_SET_MUTE, /**< Remote audio dock is put to mute */ +} bt_device_send_avrcp_cmd_e; + +typedef enum { + BT_SYNC3D_VIEW_TYPE_3D, + BT_SYNC3D_VIEW_TYPE_2D2D_120, + BT_SYNC3D_VIEW_TYPE_2D2D_240, + BT_SYNC3D_VIEW_TYPE_2D3D, + BT_SYNC3D_VIEW_TYPE_3D2D, + BT_SYNC3D_VIEW_TYPE_3D3D, + BT_SYNC3D_VIEW_TYPE_QUADVIEW, + BT_SYNC3D_VIEW_TYPE_NO_SHUTTERING, +} bt_sync3d_view_type; + +typedef enum { + BT_SYNC3D_DTV_MODE_IDLE, + BT_SYNC3D_DTV_MODE_MASTER, + BT_SYNC3D_DTV_MODE_SLAVE, + BT_SYNC3D_DTV_MODE_STANDALONE, +} bt_sync3d_dtv_mode; + +typedef enum { + BT_HAPTIC_EXPENDING = 0x08, /**< Soft Bump - 30% */ + BT_HAPTIC_SHRINKING = 0x08, + BT_HAPTIC_INITIALENTRY = 0x39, /**< Sharp Tick 1 - 100% */ + BT_HAPTIC_ARROWBUTTON = 0x1D, /**< Short Double Click Strong 3 - 60% */ + BT_HAPTIC_EDGE = 0x37, /**< Pulsing Medium 2 - 60% */ + BT_HAPTIC_MOUSEIN = 0x18, + BT_HAPTIC_LONGPRESS = 0x23, + BT_HAPTIC_WARNING = 0x34, /**< Pulsing Strong 1 - 100% */ + BT_HAPTIC_POPUP = 0x21, /**< Short Double Click Medium 3 - 60% */ + BT_HAPTIC_FINDREMOTE = 0x34, /**< Pulsing Strong 1 - 100% */ + BT_HAPTIC_NOKEYMODERATE = 0x39, /**< Pulsing Sharp 2 - 60% */ + BT_HAPTIC_NOKEYMINIMUM = 0x21, + + BT_HAPTIC_RESERVED1=0xC9, + BT_HAPTIC_RESERVED2=0xCA, + BT_HAPTIC_RESERVED3=0xCB, + BT_HAPTIC_RESERVED4=0xCC, + BT_HAPTIC_RESERVED5=0xCD, + BT_HAPTIC_NEWINITIALENTRY = 0x00 +} bt_hid_haptic_t; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE + * + * @brief enums for the sync3d event received data. + * + * + * @see bt_sync3d_event_cb() + */ +typedef enum { + SYNC3D_CODE_CHANGE_EVENT = 0, + SYNC3D_FRAME_PERIOD_CHANGE_EVENT +} bt_sync3d_event_type; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Class structure of Headless DB Device Info + * + */ +typedef struct headlessdb_device_info +{ + char*bdaddress; /**< BD Address. */ + char*dev_type; /**< BT Device Type for e.g Mobile,TV etc. */ +} bt_headlessdb_device_info; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Structure of one headless dev info data. + * + * @see int bt_adapter_foreach_headless_device_info(bt_adapter_headless_device_info_cb foreach_cb, + * void *user_data); + */ +typedef struct +{ + char *remote_address; + char *hexclass; + unsigned char null_pin_code; +} bt_adapter_headless_dev_info_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief enum for vendor specific TX Power class. + * + * @see #bt_class_s + * @see bt_adapter_set_tx_power(bt_adapter_tx_pwr_class tx_power_class); + */ +typedef enum { + BT_TX_PWR_CLASS_1_5 = 0x01, + BT_TX_PWR_CLASS_2, +} bt_adapter_tx_pwr_class; + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief HID Device information structure. + * + * @see #bt_class_s + * @see bt_device_bond_created_cb() + * battey_status can assume following values: + * 0x00 : Battery Level Monitoring is not supported + * 0x01 : Battey Level 1 + * 0x02 : Battery Level 2 + * 0x03 : Battery Level 3 + * 0x04 : Battery Full + * 0x05 : Low Battery + */ +typedef struct +{ + unsigned char device_type; /**< Device type of the remote device */ + unsigned short capability; /**< Capability of the remote device */ + unsigned char battery_status; /**< Battery Status of the remote device */ + short resolution_width; /**< Reslotion: width */ + short resolution_height; /**< Reslotion: height */ + short size_x; /**< Size: x-co-ordinate */ + short size_y; /**< Size: y-co-ordinate */ +} bt_hid_device_info_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief HID battery status call back structure. + * + * @see #battery_status; + * @see #remote_address; + */ +typedef struct +{ + unsigned char battery_status; /**< Battery status. */ + unsigned char* remote_address; /**< Remote device address. */ +} bt_hid_battery_status_info_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * + * @brief Structure of voice data received. + * + * @see bt_hid_audio_data_receive_cb() + */ +typedef struct +{ + unsigned short length; /**< buffer length */ + unsigned char *audio_buf; /**< audio data buffer */ +} bt_hid_voice_data_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * + * @brief Structure for mbr return received. + * + * @see bt_hid_mbr_return_receive_cb() + */ +typedef struct +{ + unsigned short length; /**< buffer length */ + unsigned char *mbr_return; /**< MBR Return buffer */ +} bt_hid_mbr_return_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * + * @brief Structure for smart remote sensor data. + * + * @see bt_hid_sensor_data_receive_cb() + */ +typedef struct { + short accel_data; + short gyro_data; +} sensor_info_s; + +typedef struct { + unsigned char sampling_time; + unsigned char sensor_type; + unsigned char touch_mode; /* 0 == Pressed, 2 == released */ + sensor_info_s x; + sensor_info_s y; + sensor_info_s z; +} bt_smart_rc_sensor_data_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE + * + * @brief Structure of Association notification received data. + * + * + * @see bt_sync3d_association_notified_cb() + */ +typedef struct { + unsigned short association_notification; + /* Association Notification status value */ + unsigned short battery_lvl; + /* Battery level of the remote 3D glass */ + unsigned char *dst_addr; +} bt_sync3d_association_notify_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE + * + * @brief structure for the sync3d event frame period change event. + * + * + * @see bt_sync3d_event_cb() + */ +typedef struct { + unsigned int frame_period; + unsigned short period_fraction; + unsigned short init_measurement; +} bt_sync3d_frame_period_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE + * + * @brief structure for the smartrc throughput data. + * + * + * @see bt_adapter_smartrc_tput_mode_cb() + */ +typedef struct bt_smartrc_throughput_data_s +{ + long total_bytes; + long total_msecs; + long throughput; +} bt_smartrc_throughput_data_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * + * @brief Structure of voice data received. + * + * @see bt_audio_data_receive_cb() + */ +typedef struct +{ + unsigned short length; /**< buffer length */ + unsigned char *audio_buf; /**< audio data buffer */ +} bt_audio_data_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * + * @brief Fetches a2dp stream information. + * + * @see bt_a2dp_sink_get_audio_info() + */ +typedef struct +{ + int info_status; + unsigned short sampling_freq; /**<sampling frquency */ + unsigned short num_channel; /**<channel number */ + int bits_per_sample; /**<bits per sample */ +} bt_a2dp_sink_audio_info_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when the smartRC throughput calculation is done. + * + * @remarks you can get some SmartRC information, such as Total bytes, total time, Total throughput. + * + * @param[in] tput_data Throughput calculation data like total bytes, time etc. + * @param[in] user_data The user data passed from the callback registration function + * + * @pre Either bt_adapter_start_smartrc_tput_mode() or bt_adapter_stop_smartrc_tput_mode() will invoke this function + * if you register this callback using bt_adapter_set_device_discovery_state_changed_cb(). + * + * @see bt_adapter_start_smartrc_tput_mode() + * @see bt_adapter_stop_smartrc_tput_mode() + * @see bt_hid_set_smartrc_tput_mode_cb() + * @see bt_hid_unset_smartrc_tput_mode_cb() + * + */ +typedef void (*bt_adapter_smartrc_tput_mode_cb) (bt_smartrc_throughput_data_s *tput_data, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when MaximunDeviceConnected event is received. + * @param[in] result + * @param[in] user_data The user data passed from the callback registration function + * @see bt_adapter_set_max_device_connected_cb() + */ +typedef void (*bt_adapter_max_conection_reached_cb)(int result, char *remote_address, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when remote device requests authentication. + * @param[in] result + * @param[in] auth_type + * typedef enum { + * BT_AUTH_KEYBOARD_PASSKEY_DISPLAY = 0, : PIN display event to user for entering PIN in keyboard + * BT_AUTH_PIN_REQUEST, : Legacy PIN or PASSKEY request event + * BT_AUTH_PASSKEY_CONFIRM_REQUEST, : PASSKEY confirmation event to match PASSKEY in remote device + * BT_AUTH_SSP_CONSENT_REQUEST, : Event for requesting user Consent for SSP + * } bt_authentication_type_info_e; + * @param[in] device_name Name of the remote device + * @param[in] remote_addr Remote BD address + * @param[in] pass_key PASSKEY string + * PASSKEY string is valid only if authentication types are following + * a/ BT_AUTH_KEYBOARD_PASSKEY_DISPLAY + * b/ BT_AUTH_PASSKEY_CONFIRM_REQUEST + * pass_key string will be invalid if authentication event is of type BT_AUTH_PIN_REQUEST + * as this event indicates that user MUST enter PIN or PASSKEY and perform authentication. + * + * Upon receiving BT_AUTH_KEYBOARD_PASSKEY_DISPLAY event, user should enter PASSKEY in keyboard + * Application can also call bt_device_cancel_bonding() Upon receiving BT_AUTH_KEYBOARD_PASSKEY_DISPLAY + * event which will fail the on-going pairing with remote device. + * @param[in] user_data The user data passed from the callback registration function + * @see bt_adapter_set_authentication_req_cb() + */ +typedef void (*bt_adapter_authentication_req_cb)(int result, bt_authentication_type_info_e auth_type, + char *device_name, char *remote_addr, + char *pass_key, void *user_data); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when you get headless devices repeatedly. + * + * @param[in] headless_device_info The registered headless device information + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, + * \n @c false to break out of the loop. + * @pre bt_adapter_foreach_headless_device_info() will invoke this function. + * + * @see bt_adapter_foreach_headless_device_info() + * + */ +typedef bool (*bt_adapter_headless_device_info_cb)(bt_adapter_headless_dev_info_s *headless_device_info, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when the BT Chip FW update status is ongoing + * @details This callback is called when BT Chip FW update progress is received + * @param[in] result of FW update progress: result must be checked first. + * If result is not BT_ERROR_NONE, progress percentage will not be valid + * @param[in] progress percentage + * @param[in] user_data The user data passed from the callback registration function + */ +typedef void (*bt_adapter_notify_bt_chip_fw_update_status_cb) (int result, + unsigned char progress, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Called when authorization event is received. + * @param[in] result The result of the authorization event. + * @param[in] remote_address The address of the remote Bluetooth device. + * @param[in] user_data The user data passed from the callback registration function. + * @pre bt_device_set_auth_event_state_changed_cb() will invoke this function + * + * @see bt_initialize() + */ +typedef void (*bt_device_auth_event_state_changed_cb) + (int result, const char *remote_address, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Called when authorization event is received. + * @param[in] result The result of the authorization event. + * @param[in] remote_address The address of the remote Bluetooth device. + * @param[in] name: Name of the remote Bluetooth device. + * @param[in] user_data The user data passed from the callback registration function. + * @pre bt_device_set_auth_event_cb() will invoke this function + * + * @see bt_initialize() + */ +typedef void (*bt_device_auth_event_cb) + (int result, char *remote_address, char *name, void *user_data); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called when the connection state is changed. + * @details This callback is called when the connection state is changed. + * When you call bt_hid_host_connect() or bt_hid_host_disconnect(), this callback is also called with error result even though these functions fail. + * @param[in] result The result of changing the connection state + * @param[in] connected The state to be changed. @a true means connected state, Otherwise, @a false. + * @param[in] remote_address The remote address + * @param[in] user_data The user data passed from the callback registration function + * @see bt_hid_host_connect() + * @see bt_hid_host_disconnect() + */ +typedef void (*bt_hid_host_connection_state_changed_cb) (int result, bool connected, const char *remote_address, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called when sound data from hid smart RC is received. + * @details This callback is called when the hid smart RC sends voice data. + * @param[in] pointer to bt_hid_voice_data_s. (contains raw pcm sample buffer and + * length of the buffer) + * @param[in] user_data The user data passed from the callback registration + * function + * @see bt_hid_set_audio_data_receive_cb() + * @see bt_hid_unset_audio_data_receive_cb() + */ +typedef void (*bt_hid_audio_data_receive_cb) + (bt_hid_voice_data_s *voice_data, void *user_data); + +/** +* @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE +* @brief Called on both hid Smart RC connection and disconnection. +* @details This callback is called on both smart RC connection or disconnection. +* @param[in] is smart RC connected. @a true means connection is Samrt RC connection, Otherwise, @a false. +* @param[in] device_info The bonded smart RC device information. +* @param[in] user_data The user data passed from the callback registration function +* @see bt_hid_set_smart_rc_connection_cb() +* @see bt_hid_unset_smart_rc_connection_cb() +*/ +typedef void (*bt_hid_notify_smart_rc_connection_cb)(bool is_smart_rc_connected, bt_device_info_s *device_info, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called when the sound button is pressed on hid smart RC. + * @details This callback is called when the user presses the sound button on + * hid smart RC. + * @param[in] sound button state. @a true means pressed state, Otherwise, @a false. + * @param[in] user_data The user data passed from the callback registration function + * @see bt_hid_set_sound_key_pressed_cb() + * @see bt_hid_unset_sound_key_pressed_cb() + */ +typedef void (*bt_hid_notify_sound_key_pressed_cb)(int btn_state, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called when the battery status is received from hid smart RC. + * @details This callback is called when the battery level is received + * from HID smart remote. + * @param[in] pointer to battery status info structure + * @param[in] user_data The user data passed from the callback registration function + */ +typedef void (*bt_hid_notify_battery_status_received_cb)(bt_hid_battery_status_info_s *battery_status, + void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called when the FW update status is received from hid smart RC. + * @details This callback is called when FW update progress is received + * from HID smart remote. + * @param[in] result of FW update progress: result must be checked first. + * If result is not BT_ERROR_NONE, progress percentage will not be valid + * @param[in] progress percentage + * @param[in] user_data The user data passed from the callback registration function + */ +typedef void (*bt_hid_notify_smart_rc_fw_update_status_cb) (int result, + unsigned char progress, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called when mbr return from hid smart RC is received. + * @details This callback is called when the hid smart RC sends mbr return. + * @param[in] pointer to bt_hid_mbr_return_s. (contains mbr return buffer + * and length of the buffer) + * @param[in] user_data The user data passed from the callback registration + * function + * @see bt_hid_set_mbr_return_receive_cb() + * @see bt_hid_unset_mbr_return_receive_cb() + */ +typedef void (*bt_hid_mbr_return_receive_cb) + (bt_hid_mbr_return_s *mbr_return, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called when 6-axis sensor data from hid smart RC is received. + * @details This callback is called when the hid smart RC sends sensor data. + * @param[in] pointer to bt_smart_rc_sensor_data_s. (contains sensor data) + * @param[in] user_data The user data passed from the callback registration + * function + * @see bt_hid_set_sensor_data_receive_cb() + * @see bt_hid_unset_sensor_data_receive_cb() + */ +typedef void (*bt_hid_sensor_data_receive_cb) + (bt_smart_rc_sensor_data_s *sensor_data, void *user_data); + + /** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Called when the connection state is changed. + * @details This callback is called when the connection state is changed. + * When you call bt_a2dp_sink_connect() or bt_a2dp_sink_disconnect(), this callback is also called with error result even though these functions fail. + * @param[in] result The result of changing the connection state + * @param[in] connected The state to be changed. @a true means connected state, Otherwise, @a false. + * @param[in] remote_address The remote address + * @param[in] user_data The user data passed from the callback registration function + * @see bt_a2dp_sink_set_connection_state_changed_cb() + * @see bt_a2dp_sink_unset_connection_state_changed_cb() + */ +typedef void (*bt_a2dp_sink_connection_state_changed_cb) (bool connected, const char *remote_address, void *user_data); + + + /** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Called when the connection state is changed. + * @details This callback is called when the audio state is changed. + * When you call bt_a2dp_sink_connect() or bt_a2dp_sink_disconnect(), this callback is also called with error result even though these functions fail. + * @param[in] result The result of changing the audio state + * @param[in] connected The state to be changed. @a true means connected state, Otherwise, @a false. + * @param[in] remote_address The remote address + * @param[in] user_data The user data passed from the callback registration function + * @see bt_a2dp_sink_set_audio_state_changed_cb() + * @see bt_a2dp_sink_unset_audio_state_changed_cb() + */ +typedef void (*bt_a2dp_sink_audio_state_changed_cb) (bt_a2dp_sink_audio_state_e audio_state, const char *remote_address, + bt_a2dp_sink_audio_info_s *audio_info, void *user_data); + + + /** + * @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE + * @brief Called when sound data from remote audio source is received. + * @details This callback is called when the remote source sends audio data. + * @param[in] pointer to bt_audio_data_s. (contains raw pcm sample buffer and + * length of the buffer) + * @param[in] user_data The user data passed from the callback registration + * function + * @see bt_audio_set_audio_data_receive_cb() + * @see bt_audio_unset_audio_data_receive_cb() + */ +typedef void (*bt_audio_data_receive_cb) + (bt_audio_data_s *audio_data, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Called when SetAbsoluteVolume event is received from the remote device. + * @param[in] volume the volume value received + * @param[in] user_data The user data passed from the callback registration function + * @see bt_avrcp_target_initialize() + * @see bt_set_avrcp_volume_changed_cb() + */ +typedef void (*bt_avrcp_volume_changed_cb) (unsigned short volume, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Called when mute/unmute event is received from the remote device. + * @param[in] mute status the current status mute status of remote device + * @param[in] user_data The user data passed from the callback registration function + * @see bt_avrcp_target_initialize() + * @see bt_avrcp_mute_state_changed_cb() + * @see bt_avrcp_unset_mute_status_changed_cb() + */ +typedef void (*bt_avrcp_mute_state_changed_cb) (bool mute_status, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE + * @brief Called when 3D Glasses are associated with teh 3D TV. + * @param[in] result The result of the associated status + * @param[in] associated_notified_info The Association notification information + * @param[in] user_data The user data passed from the callback registration function + * + * @pre This callback will be invokeed if you register this callback + * using bt_sync3d_set_association_notified_cb(). + * + */ +typedef void (*bt_sync3d_association_notified_cb)(bt_sync3d_association_notify_s *associated_notified_info, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_SYNC3D_MODULE + * @brief Called when chip sends sync3d events. + * @param[in] result The result of the event status + * @param[in] frame_period_info The frame period change event information + * @param[in] event event type + * @param[in] user_data The user data passed from the callback registration function + * + * @pre This callback will be invokeed if you register this callback + * using bt_sync3d_set_event_received_cb(). + * + */ +typedef void (*bt_sync3d_event_cb)(bt_sync3d_frame_period_s *frame_period_info, bt_sync3d_event_type event, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enumerations of the Bluetooth advertising state. + */ +typedef enum { + BT_ADAPTER_ADVERTISING_STOPPED = 0x00, /**< Bluetooth advertising is stopped */ + BT_ADAPTER_ADVERTISING_STARTED, /**< Bluetooth advertising is started */ +} bt_adapter_advertising_state_e; + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enumerations of the Bluetooth advertising filter policy. + */ +typedef enum { + BT_ADAPTER_ADVERTISING_FILTER_DEFAULT = 0x00, /**< White list is not in use */ + BT_ADAPTER_ADVERTISING_FILTER_ALLOW_SCAN_WL = 0x01, /**< Allow the scan + request that in the White list */ + BT_ADAPTER_ADVERTISING_FILTER_ALLOW_CONN_WL = 0x02, /**< Allow the connectoin + request that in the White list */ + BT_ADAPTER_ADVERTISING_FILTER_ALLOW_SCAN_CONN_WL = 0x03, /**< Allow the + scan and connectoin request that in the White list */ +} bt_adapter_advertising_filter_policy_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enumerations of the Bluetooth advertising type. + */ +typedef enum { + BT_ADAPTER_ADVERTISING_CONNECTABLE = 0x00, /**< Connectable undirected advertising (ADV_IND) */ + BT_ADAPTER_ADVERTISING_CONNECTABLE_DIRECT_HIGH = 0x01, /**< Connectable high duty cycle directed advertising (ADV_DIRECT_IND) */ + BT_ADAPTER_ADVERTISING_SCANNABLE = 0x02, /**< Scannable undirected advertising (ADV_SCAN_IND) */ + BT_ADAPTER_ADVERTISING_NON_CONNECTABLE = 0x03, /**< Non connectable undirected advertising (ADV_NONCOND_IND) */ + BT_ADAPTER_ADVERTISING_CONNECTABLE_DIRECT_LOW = 0x04, /**< Connectable low duty cycle directed advertising (ADV_DIRECT_IND) */ +} bt_adapter_advertising_type_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Structure of advertising parameters + * + * @see #bt_class_s + * @see bt_adapter_advertising_state_changed_cb() + * @see bt_adapter_start_advertising() + */ +typedef struct { + float interval_min; /**< Minimum advertising interval for non-directed advertising. + A multiple of 0.625ms is only allowed (Time range : 20ms to 10.24sec). */ + float interval_max; /**< Maximum advertising interval for non-directed advertising. + A multiple of 0.625ms is only allowed (Time range : 20ms to 10.24sec). */ + char filter_policy; /* Advertising filter policy */ + char type; /* Advertising type */ +} bt_adapter_advertising_params_s; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when the state of advertising changes. + * + * @param[in] result The result of the advertising + * @param[in] adv_state The advertising state to be changed + * @param[in] adv_params The parameters of advertising \n + * If \a adv_state is #BT_ADAPTER_ADVERTISING_STOPPED, then \a adv_params is NULL. + * @param[in] user_data The user data passed from the callback registration function + * + * @pre Either bt_adapter_start_advertising() or bt_adapter_stop_stop_advertising() will invoke this function + * if you register this callback using bt_adapter_set_advertising_state_changed_cb(). + * + * @see bt_adapter_start_advertising(bt_adapter_advertising_params_s *adv_params) + * @see bt_adapter_stop_advertising() + * @see bt_adapter_set_advertising_state_changed_cb() + * @see bt_adapter_unset_advertising_state_changed_cb() + * + */ +typedef void (*bt_adapter_advertising_state_changed_cb)(int result, + bt_adapter_advertising_state_e adv_state, + bt_adapter_advertising_params_s *adv_params, void *user_data); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when the manufacturer specific data for advertising changes. + * @param[in] data The manufacurer specific data of the Bluetooth device to be changed + * @param[in] len The length of @a data + * @param[in] user_data The user data passed from the callback registration function + * @pre This function will be invoked when the manufacturer specific data of Bluetooth adapter changes + * if you register this callback using bt_adapter_set_advertising_manufacturer_data_changed_cb(). + * @see bt_adapter_set_advertising_manufacturer_data() + * @see bt_adapter_set_advertising_manufacturer_data_changed_cb() + * @see bt_adapter_unset_advertising_manufacturer_data_changed_cb() + */ +typedef void (*bt_adapter_advertising_manufacturer_data_changed_cb)(char *data, + int len, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when the manufacturer specific data for LE scan response changes. + * @param[in] data The manufacurer specific data of the Bluetooth device to be changed + * @param[in] len The length of @a data + * @param[in] user_data The user data passed from the callback registration function + * @pre This function will be invoked when the manufacturer specific data of Bluetooth adapter changes + * if you register this callback using bt_adapter_set_scan_resp_manufacturer_data_changed_cb(). + * @see bt_adapter_set_scan_resp_manufacturer_data() + * @see bt_adapter_set_scan_resp_manufacturer_data_changed_cb() + * @see bt_adapter_unset_scan_resp_manufacturer_data_changed_cb() + */ +typedef void (*bt_adapter_scan_resp_manufacturer_data_changed_cb)(char *data, + int len, void *user_data); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // __TIZEN_NETWORK_BLUETOOTH_TYPE_PRODUCT_H__ diff --git a/include/wearable/bluetooth.h b/include/wearable/bluetooth.h index 6b5bf00..962012b 100755 --- a/include/wearable/bluetooth.h +++ b/include/wearable/bluetooth.h @@ -81,126 +81,6 @@ int bt_initialize(void); int bt_deinitialize(void); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Enables the local Bluetooth adapter, asynchronously. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @details This function enables Bluetooth protocol stack and hardware. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_ALREADY_DONE Already enabled - * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre Bluetooth service must be initialized with bt_initialize(). - * @pre The state of local Bluetooth must be #BT_ADAPTER_DISABLED - * @post This function invokes bt_adapter_state_changed_cb(). - * - * @see bt_initialize() - * @see bt_adapter_get_state() - * @see bt_adapter_set_state_changed_cb() - * @see bt_adapter_unset_state_changed_cb() - * @see bt_adapter_state_changed_cb() - * - */ -int bt_adapter_enable(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Disables the local Bluetooth adapter, asynchronously. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @details This function disables Bluetooth protocol stack and hardware. - * - * @remarks You should disable Bluetooth adapter, which is helpful for saving power. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED - * @post This function invokes bt_adapter_state_changed_cb(). - * - * @see bt_adapter_get_state() - * @see bt_adapter_state_changed_cb() - * @see bt_adapter_set_state_changed_cb() - * @see bt_adapter_unset_state_changed_cb () - * - */ -int bt_adapter_disable(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Recover the local Bluetooth adapter, asynchronously. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @details This function does recovery logic, disables Bluetooth protocol stack and hardware, then enables after a few seconds. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED - * @post This function invokes bt_adapter_state_changed_cb(). - * - * @see bt_adapter_get_state() - * @see bt_adapter_state_changed_cb() - * @see bt_adapter_set_state_changed_cb() - * @see bt_adapter_unset_state_changed_cb () - * - */ -int bt_adapter_recover(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Reset the local Bluetooth adapter, synchronously. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @details This function resets Bluetooth protocol and values. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre Bluetooth service must be initialized with bt_initialize(). - * @post bt_adapter_state_changed_cb() will be invoked if The state of local Bluetooth was #BT_ADAPTER_ENABLED. - * - * @see bt_initialize() - * @see bt_adapter_get_state() - * @see bt_adapter_set_state_changed_cb() - * @see bt_adapter_unset_state_changed_cb() - * @see bt_adapter_state_changed_cb() - * - */ -int bt_adapter_reset(void); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Gets the current state of local Bluetooth adapter. * @since_tizen 2.3.1 @@ -243,53 +123,6 @@ int bt_adapter_get_state(bt_adapter_state_e *adapter_state); int bt_adapter_get_address(char **local_address); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Gets the version of local Bluetooth adapter. - * @since_tizen 2.3.1 - * @remarks The @a local_version must be released with free() by you. - * - * @param[out] local_version The version of local Bluetooth adapter - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - */ -int bt_adapter_get_version(char **local_version); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Gets the information regarding local Bluetooth adapter. - * @since_tizen 2.3.1 - * @remarks The @a all parameters must be released with free() by you. - * - * @param[out] chipset Chipset name of local Bluetooth adapter - * @param[out] firmware Firmware info. of local Bluetooth adapter - * @param[out] stack_version Bluetooth stack version - * @param[out] profiles The profile list of local Bluetooth adapter - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - */ -int bt_adapter_get_local_info(char **chipset, char **firmware, char **stack_version, char **profiles); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Gets the name of local Bluetooth adapter. * @since_tizen 2.3.1 @@ -365,40 +198,6 @@ int bt_adapter_set_name(const char *local_name); int bt_adapter_get_visibility(bt_adapter_visibility_mode_e *mode, int *duration); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Sets the visibility mode. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @remarks #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE will change to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE - * after the given @a duration goes. - * - * @param[in] discoverable_mode The Bluetooth visibility mode to set - * @param[in] duration The duration until the visibility mode is changed to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE (in seconds). - * @a duration is used only for #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE mode. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * @post bt_adapter_visibility_mode_changed_cb() will be invoked if this function returns #BT_ERROR_NONE. - * - * @see bt_adapter_get_visibility() - * @see bt_adapter_visibility_mode_changed_cb() - * @see bt_adapter_set_visibility_mode_changed_cb() - * @see bt_adapter_unset_visibility_mode_changed_cb() - */ -int bt_adapter_set_visibility(bt_adapter_visibility_mode_e discoverable_mode, int duration); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Starts the device discovery, asynchronously. * @since_tizen 2.3.1 @@ -866,183 +665,6 @@ int bt_adapter_set_remote_oob_data(const char *remote_address, int bt_adapter_remove_remote_oob_data(const char *remote_address); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Registers a callback function to be invoked when the connectable state changes. - * @since_tizen 2.3.1 - * - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_adapter_connectable_changed_cb() will be invoked. - * - * @see bt_initialize() - * @see bt_adapter_connectable_changed_cb() - * @see bt_adapter_unset_connectable_changed_cb() - */ -int bt_adapter_set_connectable_changed_cb(bt_adapter_connectable_changed_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Unregisters the callback function. - * @since_tizen 2.3.1 - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * - * @see bt_initialize() - * @see bt_adapter_set_connectable_changed_cb() - */ -int bt_adapter_unset_connectable_changed_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Gets the connectable state of local Bluetooth adapter. - * @since_tizen 2.3.1 - * - * @remarks When connectable state is false, no device can connect to this device and visibility mode cannot be changed. - * - * @param[out] connectable The connectable state of local Bluetooth adapter - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * - * @see bt_adapter_set_connectable() - */ -int bt_adapter_get_connectable(bool *connectable); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Sets the connectable state of local Bluetooth adapter. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @remarks When connectable state is false, no device can connect to this device and visibility mode cannot be changed. - * - * @param[in] connectable The connectable state to set - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * @post bt_adapter_connectable_changed_cb() will be invoked if this function returns #BT_ERROR_NONE. - * - * @see bt_adapter_get_connectable() - * @see bt_adapter_connectable_changed_cb() - * @see bt_adapter_set_connectable_changed_cb() - * @see bt_adapter_unset_connectable_changed_cb() - */ -int bt_adapter_set_connectable(bool connectable); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Enables the local Bluetooth le adapter, asynchronously. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @details This function enables Bluetooth protocol stack and hardware. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_ALREADY_DONE Already enabled - * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre Bluetooth service must be initialized with bt_initialize(). - * @post This function invokes bt_adapter_le_state_changed_cb(). - * - * @see bt_initialize() - * @see bt_adapter_le_get_state() - * @see bt_adapter_le_set_state_changed_cb() - * @see bt_adapter_le_unset_state_changed_cb() - * @see bt_adapter_le_state_changed_cb() - * - */ -int bt_adapter_le_enable(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Disables the local Bluetooth le adapter, asynchronously. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @details This function disables Bluetooth le protocol stack and hardware. - * - * @remarks - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_LE_ENABLED - * @post This function invokes bt_adapter_le_state_changed_cb(). - * - * @see bt_adapter_le_get_state() - * @see bt_adapter_le_state_changed_cb() - * @see bt_adapter_le_set_state_changed_cb() - * @see bt_adapter_le_unset_state_changed_cb () - * - */ -int bt_adapter_le_disable(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Gets the current state of local Bluetooth adapter. - * @since_tizen 2.3.1 - * - * @param[out] adapter_le_state The current adapter le state - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre Bluetooth service must be initialized with bt_initialize(). - * - * @see bt_initialize() - */ -int bt_adapter_le_get_state(bt_adapter_le_state_e *adapter_le_state); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE * @brief Starts the LE scan to find LE advertisement. * @since_tizen 2.3.1 @@ -1291,112 +913,6 @@ int bt_adapter_le_get_scan_result_manufacturer_data(const bt_adapter_le_device_s bt_adapter_le_packet_type_e pkt_type, int *manufacturer_id, char **manufacturer_data, int *manufacturer_data_len); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Registers a callback function to be invoked when the Bluetooth adapter le state changes. - * @since_tizen 2.3.1 - * - * @param[in] callback The callback function to invoke - * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_adapter_le_state_changed_cb() will be invoked. - * - * @see bt_initialize() - * @see bt_adapter_le_state_changed_cb() - * @see bt_adapter_le_unset_state_changed_cb() - */ -int bt_adapter_le_set_state_changed_cb(bt_adapter_le_state_changed_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Unregisters the callback function. - * @since_tizen 2.3.1 - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * - * @see bt_initialize() - * @see bt_adapter_le_set_state_changed_cb() - */ -int bt_adapter_le_unset_state_changed_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief add address to whitelist for accepting scanning request. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @remarks If the adress is in the whitelist then other LE devices are able to - * search this device. Before calling this API, make sure that the adapter is - * enabled. There is no callback event for this API. - - * @param[in] address The other device's address - * @param[in] address_type The other device's address type - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled - * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * - * @see bt_adapter_le_start_advertising_new() - * @see bt_adapter_le_stop_advertising() - */ -int bt_adapter_le_add_white_list(const char *address, bt_device_address_type_e address_type); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief remove address from the whitelist for not accepting scanning request. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @remarks If the adress is in the whitelist then other LE devices are able to - * search this device. Before calling this API, make sure that the adapter is - * enabled. There is no callback event for this API. - * - * @param[in] address The other device's address - * @param[in] address_type The other device's address type - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled - * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * - * @see bt_adapter_le_start_advertising_new() - * @see bt_adapter_le_stop_advertising() - */ -int bt_adapter_le_remove_white_list(const char *address, bt_device_address_type_e address_type); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE * @brief Create advertiser to advertise device's existence or respond to LE scanning reqeust. * @since_tizen 2.3.1 @@ -1760,30 +1276,6 @@ int bt_adapter_le_set_advertising_mode(bt_advertiser_h advertiser, bt_adapter_le int bt_adapter_le_set_advertising_connectable(bt_advertiser_h advertiser, bool connectable); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Sets the Privacy feature state of local Bluetooth adapter. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @param[in] enable_privacy The privacy feature to set/unset. - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * @pre The state of local Bluetooth must be #BT_ADAPTER_LE_ENABLED. - * - */ -int bt_adapter_le_enable_privacy(bool enable_privacy); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Creates a bond with a remote Bluetooth device, asynchronously. * @since_tizen 2.3.1 @@ -1819,45 +1311,6 @@ int bt_adapter_le_enable_privacy(bool enable_privacy); int bt_device_create_bond(const char *remote_address); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Creates a bond with a remote Bluetooth device, asynchronously. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @remarks A bond can be destroyed by bt_device_destroy_bond().\n - * The bonding request can be cancelled by bt_device_cancel_bonding(). - * - * @param[in] remote_address The address of the remote Bluetooth device with which the bond should be created - * @param[in] conn_type The connection type(LE or BREDR) to create bond with remote device - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. - * @pre The remote device must be discoverable with bt_adapter_start_device_discovery(). - * @post This function invokes bt_device_bond_created_cb(). - * - * @see bt_adapter_start_device_discovery() - * @see bt_device_create_bond() - * @see bt_device_bond_created_cb() - * @see bt_device_cancel_bonding() - * @see bt_device_destroy_bond() - * @see bt_device_set_bond_created_cb() - * @see bt_device_unset_bond_created_cb() - */ -int bt_device_create_bond_by_type(const char *remote_address, - bt_device_connection_link_type_e conn_type); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Cancels the bonding process. * @since_tizen 2.3.1 @@ -2013,33 +1466,6 @@ int bt_device_set_authorization(const char *remote_address, bt_device_authorizat int bt_device_start_service_search(const char *remote_address); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Cancels service search process. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded - * @retval #BT_ERROR_NOT_IN_PROGRESS Operation not in progress - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The service search must be in progress by bt_device_start_service_search(). - * - * @see bt_device_start_service_search() - * @see bt_device_service_searched_cb() - * @see bt_device_set_service_searched_cb() - * @see bt_device_unset_service_searched_cb() - */ -int bt_device_cancel_service_search(void); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Gets the connected profiles. * @since_tizen 2.3.1 @@ -2344,87 +1770,6 @@ int bt_socket_destroy_rfcomm(int socket_fd); int bt_socket_listen_and_accept_rfcomm(int socket_fd, int max_pending_connections); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE - * @brief Starts listening on passed rfcomm socket. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @details bt_socket_connection_requested_cb() will be called when a RFCOMM connection is requested. - * - * @param[in] socket_fd The file descriptor socket on which start to listen - * @param[in] max_pending_connections The number of pending connections - * - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The socket must be created with bt_socket_create_rfcomm(). - * @post This function invokes bt_socket_connection_state_changed_cb(). - * - * @see bt_socket_create_rfcomm() - * @see bt_socket_set_connection_requested_cb() - * @see bt_socket_unset_connection_requested_cb() - * @see bt_socket_connection_requested_cb() - */ -int bt_socket_listen(int socket_fd, int max_pending_connections); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE - * @brief Accepts a connection request. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @param[in] requested_socket_fd The file descriptor of socket on which a connection is requested - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The connection is requested by bt_socket_connection_requested_cb(). - * @see bt_socket_create_rfcomm() - * @see bt_socket_connection_requested_cb() - * @see bt_socket_listen() - * @see bt_socket_reject() -*/ -int bt_socket_accept(int requested_socket_fd); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE - * @brief Rejects a connection request. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @param[in] socket_fd The file descriptor of socket on which a connection is requested - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The connection is requested by bt_socket_connection_requested_cb(). - * @see bt_socket_create_rfcomm() - * @see bt_socket_connection_requested_cb() - * @see bt_socket_listen() - * @see bt_socket_accept() - */ -int bt_socket_reject(int socket_fd); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE * @brief Connects to a specific RFCOMM based service on a remote Bluetooth device UUID, asynchronously. * @since_tizen 2.3.1 @@ -2560,8 +1905,7 @@ int bt_socket_unset_data_received_cb(void); * @retval #BT_ERROR_NOT_SUPPORTED Not supported * * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post If you listen and accept a socket by bt_socket_listen_and_accept_rfcomm(), - bt_socket_connection_requested_cb() will be invoked. + * @post bt_socket_connection_requested_cb() will be invoked. * @see bt_initialize() * @see bt_socket_unset_connection_requested_cb() */ @@ -2620,35 +1964,6 @@ int bt_socket_set_connection_state_changed_cb(bt_socket_connection_state_changed int bt_socket_unset_connection_state_changed_cb(void); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE - * @brief Initializes the Bluetooth OPP server requested by bt_opp_server_push_requested_cb(). - * @since_tizen 2.3.1 - * @details The popup appears when an OPP connection is requested from a remote device. - * If you accept the request, then connection will be established and bt_opp_server_push_requested_cb() will be called. - * At that time, you can call either bt_opp_server_accept() or bt_opp_server_reject(). - * @remarks This function must be called to start Bluetooth OPP server. You must free all resources of the Bluetooth service - * by calling bt_opp_server_deinitialize() if Bluetooth OPP service is no longer needed. - * @param[in] destination The destination path - * @param[in] push_requested_cb The callback called when a push is requested - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_opp_server_push_requested_cb() - * @see bt_opp_server_deinitialize() - * @see bt_opp_server_accept() - * @see bt_opp_server_reject() - */ -int bt_opp_server_initialize(const char *destination, bt_opp_server_push_requested_cb push_requested_cb, void *user_data); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE * @brief Initializes the Bluetooth OPP server requested by bt_opp_server_connection_requested_cb(). * @since_tizen 2.3.1 @@ -2773,7 +2088,6 @@ int bt_opp_server_cancel_transfer(int transfer_id); * @retval #BT_ERROR_OPERATION_FAILED Operation failed * @retval #BT_ERROR_PERMISSION_DENIED Permission denied * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * */ int bt_opp_server_set_destination(const char *destination); @@ -3103,506 +2417,9 @@ int bt_audio_set_connection_state_changed_cb(bt_audio_connection_state_changed_c int bt_audio_unset_connection_state_changed_cb(void); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Opens a SCO(Synchronous Connection Oriented link) to connected remote device, asynchronously. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_ALREADY_DONE Operation is already done - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio device must be connected with bt_audio_connect(). - * @post bt_ag_sco_state_changed_cb() will be invoked. - * @see bt_ag_close_sco() - * @see bt_ag_sco_state_changed_cb() - * @see bt_audio_connect() - */ -int bt_ag_open_sco(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Closes an opened SCO(Synchronous Connection Oriented link), asynchronously. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The SCO must be opened with bt_ag_open_sco(). - * @post bt_ag_sco_state_changed_cb() will be invoked. - * @see bt_ag_open_sco() - * @see bt_ag_sco_state_changed_cb() - */ -int bt_ag_close_sco(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Checks whether an opened SCO(Synchronous Connection Oriented link) exists or not. - * @since_tizen 2.3.1 - * @param[out] opened The SCO status: (@c true = opened, @c false = not opened) - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_ag_open_sco() - * @see bt_ag_close_sco() - */ -int bt_ag_is_sco_opened(bool *opened); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Registers a callback function that will be invoked when the SCO(Synchronous Connection Oriented link) state is changed. - * @since_tizen 2.3.1 - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_sco_state_changed_cb() - * @see bt_ag_unset_sco_state_changed_cb() - */ -int bt_ag_set_sco_state_changed_cb(bt_ag_sco_state_changed_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Unregisters a callback function that will be invoked when the SCO(Synchronous Connection Oriented link) state is changed. - * @since_tizen 2.3.1 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_sco_state_changed_cb() - * @see bt_ag_set_sco_state_changed_cb() - */ -int bt_ag_unset_sco_state_changed_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Notifies the call event to the remote bluetooth device. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @remarks Before notifying #BT_AG_CALL_EVENT_ANSWERED or #BT_AG_CALL_EVENT_DIALING, you should open SCO(Synchronous Connection Oriented link) - * if Bluetooth Hands-Free need SCO connection. - * @param[in] event The call event - * @param[in] call_id The call ID - * @param[in] phone_number The phone number. You must set this value in case of #BT_AG_CALL_EVENT_DIALING and #BT_AG_CALL_EVENT_INCOMING. - * In other cases, this value can be NULL. - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio device must be connected with bt_audio_connect(). - * @see bt_audio_connect() - */ -int bt_ag_notify_call_event(bt_ag_call_event_e event, unsigned int call_id, const char *phone_number); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Notifies the call list to the remote bluetooth device. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @param[in] list The call list - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio device must be connected with bt_audio_connect(). - * @see bt_audio_connect() - */ -int bt_ag_notify_call_list(bt_call_list_h list); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Notifies the state of voice recognition. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @param[in] state The state of voice recognition: (@c true = enabled, @c false = disabled) - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio device must be connected with bt_audio_connect(). - * @see bt_audio_connect() - */ -int bt_ag_notify_voice_recognition_state(bool state); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Registers a callback function that will be invoked when a call handling event happened from Hands-Free. - * @since_tizen 2.3.1 - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_call_handling_event_cb() - * @see bt_ag_unset_call_handling_event_cb() - */ -int bt_ag_set_call_handling_event_cb(bt_ag_call_handling_event_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Unregisters a callback function that will be invoked when a call handling event happened from Hands-Free. - * @since_tizen 2.3.1 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_call_handling_event_cb() - * @see bt_ag_set_call_handling_event_cb() - */ -int bt_ag_unset_call_handling_event_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Registers a callback function that will be invoked when a multi call handling event happened from Hands-Free. - * @since_tizen 2.3.1 - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_multi_call_handling_event_cb() - * @see bt_ag_unset_multi_call_handling_event_cb() - */ -int bt_ag_set_multi_call_handling_event_cb(bt_ag_multi_call_handling_event_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Unregisters a callback function that will be invoked when a multi call handling event happened from Hands-Free. - * @since_tizen 2.3.1 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_multi_call_handling_event_cb() - * @see bt_ag_set_multi_call_handling_event_cb() - */ -int bt_ag_unset_multi_call_handling_event_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Registers a callback function that will be invoked when a DTMF(Dual Tone Multi Frequency) is transmitted from Hands-Free. - * @since_tizen 2.3.1 - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_dtmf_transmitted_cb() - * @see bt_ag_unset_dtmf_transmitted_cb() - */ -int bt_ag_set_dtmf_transmitted_cb(bt_ag_dtmf_transmitted_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Unregisters a callback function that will be invoked when a DTMF(Dual Tone Multi Frequency) is transmitted from Hands-Free. - * @since_tizen 2.3.1 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_dtmf_transmitted_cb() - * @see bt_ag_set_dtmf_transmitted_cb() - */ -int bt_ag_unset_dtmf_transmitted_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Notifies the speaker gain to the remote device. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @details This function sends a signal to the remote device. This signal has the gain value. - * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. - * When the speaker gain of remote device is changed to the requested gain, bt_audio_speaker_gain_changed_cb() will be called. - * @param[in] gain The gain of speaker (0 ~ 15) - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. - * @see bt_ag_get_speaker_gain() - * @see bt_ag_set_speaker_gain_changed_cb() - * @see bt_ag_unset_speaker_gain_changed_cb() - */ -int bt_ag_notify_speaker_gain(int gain); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Gets the current speaker gain of the remote device. - * @since_tizen 2.3.1 - * @details This function gets the value of speaker gain of the remote device. - * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. - * @param[out] gain The gain of speaker (0 ~ 15) - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. - * @see bt_ag_notify_speaker_gain() - * @see bt_ag_set_speaker_gain_changed_cb() - * @see bt_ag_unset_speaker_gain_changed_cb() - */ -int bt_ag_get_speaker_gain(int *gain); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Checks whether the remoted device enables NREC(Noise Reduction and Echo Canceling) or not. - * @since_tizen 2.3.1 - * @param[out] enabled The NREC status: (@c true = enabled, @c false = not enabled) - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. - * @see bt_audio_connect() - */ -int bt_ag_is_nrec_enabled(bool *enabled); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Registers a callback function that will be invoked when the speaker gain of the remote device is changed. - * @since_tizen 2.3.1 - * @details This function let you know the change of the speaker gain of the remote device. - * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_unset_speaker_gain_changed_cb() - */ -int bt_ag_set_speaker_gain_changed_cb(bt_ag_speaker_gain_changed_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Unregisters a callback function that will be invoked when the speaker gain of the remote device is changed. - * @since_tizen 2.3.1 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_set_speaker_gain_changed_cb() - */ -int bt_ag_unset_speaker_gain_changed_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Registers a callback function that will be invoked when the microphone gain of the remote device is changed. - * @since_tizen 2.3.1 - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_unset_microphone_gain_changed_cb() - */ -int bt_ag_set_microphone_gain_changed_cb(bt_ag_microphone_gain_changed_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Unregisters a callback function that will be invoked when the microphone gain of the remote device is changed. - * @since_tizen 2.3.1 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). - * @see bt_audio_initialize() - * @see bt_ag_set_microphone_gain_changed_cb() - */ -int bt_ag_unset_microphone_gain_changed_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE - * @brief Creates a handle of call list. - * @since_tizen 2.3.1 - * @param[out] list The handle of call list - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_call_list_destroy() - */ -int bt_call_list_create(bt_call_list_h *list); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE - * @brief Destroys the handle of call list. - * @since_tizen 2.3.1 - * @param[in] list The handle of call list - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_call_list_create() - */ -int bt_call_list_destroy(bt_call_list_h list); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE - * @brief Resets the handle of call list. - * @since_tizen 2.3.1 - * @param[in] list The handle of call list - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_call_list_create() - */ -int bt_call_list_reset(bt_call_list_h list); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE - * @brief Adds a call to the handle of call list. - * @since_tizen 2.3.1 - * @param[in] list The handle of call list - * @param[in] call_id The call ID - * @param[in] state The state of audio gate call - * @param[in] phone_number The phone number. You must set this value in case of #BT_AG_CALL_EVENT_DIALING and #BT_AG_CALL_EVENT_INCOMING. - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @see bt_call_list_create() - */ -int bt_call_list_add(bt_call_list_h list, unsigned int call_id, bt_ag_call_state_e state, const char *phone_number); - -/** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Initializes the Bluetooth AVRCP(Audio/Video Remote Control Profile) service. - * @since_tizen 2.3.1 + * @since_tizen 2.4 * @remarks This function must be called before Bluetooth AVRCP service. \n * You must free all resources of the this service by calling bt_avrcp_target_deinitialize() * if Bluetooth AVRCP service is no longer needed. @@ -3622,10 +2439,9 @@ int bt_call_list_add(bt_call_list_h list, unsigned int call_id, bt_ag_call_state int bt_avrcp_target_initialize(bt_avrcp_target_connection_state_changed_cb callback, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Deinitializes the Bluetooth AVRCP(Audio/Video Remote Control Profile) service. - * @since_tizen 2.3.1 + * @since_tizen 2.4 * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized @@ -3637,12 +2453,11 @@ int bt_avrcp_target_initialize(bt_avrcp_target_connection_state_changed_cb callb int bt_avrcp_target_deinitialize(void); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Notifies the equalize state to the remote device. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth * @param[in] state The state of equalizer * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -3661,12 +2476,11 @@ int bt_avrcp_target_deinitialize(void); int bt_avrcp_target_notify_equalizer_state(bt_avrcp_equalizer_state_e state); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Notifies the repeat mode to the remote device. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth * @param[in] mode The repeat mode * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -3685,12 +2499,11 @@ int bt_avrcp_target_notify_equalizer_state(bt_avrcp_equalizer_state_e state); int bt_avrcp_target_notify_repeat_mode(bt_avrcp_repeat_mode_e mode); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Notifies the shuffle mode to the remote device. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth * @param[in] mode The repeat mode * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -3709,12 +2522,11 @@ int bt_avrcp_target_notify_repeat_mode(bt_avrcp_repeat_mode_e mode); int bt_avrcp_target_notify_shuffle_mode(bt_avrcp_shuffle_mode_e mode); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Notifies the scan mode to the remote device. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth * @param[in] mode The scan mode * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -3733,12 +2545,11 @@ int bt_avrcp_target_notify_shuffle_mode(bt_avrcp_shuffle_mode_e mode); int bt_avrcp_target_notify_scan_mode(bt_avrcp_scan_mode_e mode); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Notifies the player state to the remote device. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth * @param[in] state The player state * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -3757,12 +2568,11 @@ int bt_avrcp_target_notify_scan_mode(bt_avrcp_scan_mode_e mode); int bt_avrcp_target_notify_player_state(bt_avrcp_player_state_e state); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Notifies the current position of song to the remote device. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth * @param[in] position The current position in milliseconds * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful @@ -3781,12 +2591,11 @@ int bt_avrcp_target_notify_player_state(bt_avrcp_player_state_e state); int bt_avrcp_target_notify_position(unsigned int position); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Notifies the track to the remote device. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth * @param[in] title The title of track * @param[in] artist The artist of track * @param[in] album The album of track @@ -3811,10 +2620,9 @@ int bt_avrcp_target_notify_position(unsigned int position); int bt_avrcp_target_notify_track(const char *title, const char *artist, const char *album, const char *genre, unsigned int track_num, unsigned int total_tracks, unsigned int duration); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Registers a callback function that will be invoked when the equalizer state is changed by the remote control device. - * @since_tizen 2.3.1 + * @since_tizen 2.4 * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function * @return 0 on success, otherwise a negative error value. @@ -3830,10 +2638,9 @@ int bt_avrcp_target_notify_track(const char *title, const char *artist, const ch int bt_avrcp_set_equalizer_state_changed_cb(bt_avrcp_equalizer_state_changed_cb callback, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Unregisters a callback function that will be invoked when the equalizer state is changed by the remote control device. - * @since_tizen 2.3.1 + * @since_tizen 2.4 * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized @@ -3846,10 +2653,9 @@ int bt_avrcp_set_equalizer_state_changed_cb(bt_avrcp_equalizer_state_changed_cb int bt_avrcp_unset_equalizer_state_changed_cb(void); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Registers a callback function that will be invoked when the repeat mode is changed by the remote control device. - * @since_tizen 2.3.1 + * @since_tizen 2.4 * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function * @return 0 on success, otherwise a negative error value. @@ -3865,10 +2671,9 @@ int bt_avrcp_unset_equalizer_state_changed_cb(void); int bt_avrcp_set_repeat_mode_changed_cb(bt_avrcp_repeat_mode_changed_cb callback, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Unregisters a callback function that will be invoked when the repeat mode is changed by the remote control device. - * @since_tizen 2.3.1 + * @since_tizen 2.4 * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized @@ -3881,10 +2686,9 @@ int bt_avrcp_set_repeat_mode_changed_cb(bt_avrcp_repeat_mode_changed_cb callback int bt_avrcp_unset_repeat_mode_changed_cb(void); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Registers a callback function that will be invoked when the shuffle mode is changed by the remote control device. - * @since_tizen 2.3.1 + * @since_tizen 2.4 * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function * @return 0 on success, otherwise a negative error value. @@ -3900,10 +2704,9 @@ int bt_avrcp_unset_repeat_mode_changed_cb(void); int bt_avrcp_set_shuffle_mode_changed_cb(bt_avrcp_shuffle_mode_changed_cb callback, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Unregisters a callback function that will be invoked when the shuffle mode is changed by the remote control device. - * @since_tizen 2.3.1 + * @since_tizen 2.4 * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized @@ -3916,10 +2719,9 @@ int bt_avrcp_set_shuffle_mode_changed_cb(bt_avrcp_shuffle_mode_changed_cb callba int bt_avrcp_unset_shuffle_mode_changed_cb(void); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Registers a callback function that will be invoked when the scan mode is changed by the remote control device. - * @since_tizen 2.3.1 + * @since_tizen 2.4 * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function * @return 0 on success, otherwise a negative error value. @@ -3935,10 +2737,9 @@ int bt_avrcp_unset_shuffle_mode_changed_cb(void); int bt_avrcp_set_scan_mode_changed_cb(bt_avrcp_scan_mode_changed_cb callback, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Unregisters a callback function that will be invoked when the scan mode is changed by the remote control device. - * @since_tizen 2.3.1 + * @since_tizen 2.4 * @return 0 on success, otherwise a negative error value. * @retval #BT_ERROR_NONE Successful * @retval #BT_ERROR_NOT_INITIALIZED Not initialized @@ -4795,239 +3596,6 @@ int bt_gatt_set_connection_state_changed_cb(bt_gatt_connection_state_changed_cb int bt_gatt_unset_connection_state_changed_cb(void); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE - * @brief Activates the NAP(Network Access Point). - * @since_tizen 2.3.1 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_ALREADY_DONE Operation is already done - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED - * @see bt_nap_deactivate() - */ -int bt_nap_activate(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE - * @brief Deactivates the NAP(Network Access Point). - * @since_tizen 2.3.1 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_ALREADY_DONE Operation is already done - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). - * @see bt_nap_activate() - */ -int bt_nap_deactivate(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE - * @brief Disconnects the all PANUs(Personal Area Networking User) which are connected to you. - * @since_tizen 2.3.1 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). - * @see bt_nap_activate() - */ -int bt_nap_disconnect_all(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE - * @brief Disconnects the specified PANU(Personal Area Networking User) which is connected to you. - * @since_tizen 2.3.1 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * @param[in] remote_address The remote address - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). - * @see bt_nap_activate() - */ -int bt_nap_disconnect(const char *remote_address); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE - * @brief Registers a callback function that will be invoked when the connection state changes. - * @since_tizen 2.3.1 - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_nap_connection_state_changed_cb() will be invoked. - * @see bt_initialize() - * @see bt_nap_connection_state_changed_cb() - * @see bt_nap_unset_connection_state_changed_cb() - */ -int bt_nap_set_connection_state_changed_cb(bt_nap_connection_state_changed_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE - * @brief Unregisters a callback function that will be invoked when the connection state changes. - * @since_tizen 2.3.1 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_nap_connection_state_changed_cb() will be invoked. - * @see bt_initialize() - * @see bt_nap_connection_state_changed_cb() - * @see bt_nap_set_connection_state_changed_cb() - */ -int bt_nap_unset_connection_state_changed_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE - * @brief Registers a callback function that will be invoked when the connection state changes. - * @since_tizen 2.3.1 - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_nap_connection_state_changed_cb() will be invoked. - * @see bt_initialize() - * @see bt_panu_connection_state_changed_cb() - * @see bt_panu_unset_connection_state_changed_cb() - */ -int bt_panu_set_connection_state_changed_cb(bt_panu_connection_state_changed_cb callback, void *user_data); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE - * @brief Unregisters a callback function that will be invoked when the connection state changes. - * @since_tizen 2.3.1 - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized with bt_initialize(). - * @post bt_nap_connection_state_changed_cb() will be invoked. - * @see bt_initialize() - * @see bt_panu_connection_state_changed_cb() - * @see bt_panu_set_connection_state_changed_cb() - */ -int bt_panu_unset_connection_state_changed_cb(void); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE - * @brief Connects the remote device with the PAN(Personal Area Networking) service, asynchronously. - * @since_tizen 2.3.1 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * @param[in] remote_address The remote address - * @param[in] type The type of PAN service - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The local device must be bonded with the remote device by bt_device_create_bond(). - * @post bt_panu_connection_state_changed_cb() will be invoked. - * @see bt_panu_disconnect() - * @see bt_panu_connection_state_changed_cb() - */ -int bt_panu_connect(const char *remote_address, bt_panu_service_type_e type); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE - * @brief Disconnects the remote device with the PAN(Personal Area Networking) service, asynchronously. - * @since_tizen 2.3.1 - * @privlevel public - * @privilege %http://tizen.org/privilege/bluetooth - * @param[in] remote_address The remote address - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #BT_ERROR_NOT_ENABLED Not enabled - * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected - * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #BT_ERROR_OPERATION_FAILED Operation failed - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The remote device must be connected by bt_panu_connect(). - * @post bt_panu_connection_state_changed_cb() will be invoked. - * @see bt_panu_connect() - * @see bt_panu_connection_state_changed_cb() - */ -int bt_panu_disconnect(const char *remote_address); - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief update LE connection. - * @since_tizen 2.3.1 - * @privlevel platform - * @privilege %http://tizen.org/privilege/bluetooth.admin - * @return 0 on success, otherwise a negative error value. - * @retval #BT_ERROR_NONE Successful - * @retval #BT_ERROR_NOT_INITIALIZED Not initialized - * @retval #BT_ERROR_PERMISSION_DENIED Permission denied - * @retval #BT_ERROR_NOT_SUPPORTED Not supported - * - * @pre The Bluetooth service must be initialized by bt_initialize(). - * @pre The remote device must be connected with bt_gatt_connect(). - */ -int bt_device_le_conn_update(const char *device_address, - const bt_le_conn_update_s *parameters); - - -/** * @} */ diff --git a/include/wearable/bluetooth_extension.h b/include/wearable/bluetooth_extension.h new file mode 100644 index 0000000..dac46e5 --- /dev/null +++ b/include/wearable/bluetooth_extension.h @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_NETWORK_BLUETOOTH_EXTENSION_H__ +#define __TIZEN_NETWORK_BLUETOOTH_EXTENSION_H__ + +#include "bluetooth_type.h" +#include "bluetooth_type_extension.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** + * @file bluetooth_extension.h + */ + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Opens a SCO(Synchronous Connection Oriented link) to connected remote device, asynchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @post bt_ag_sco_state_changed_cb() will be invoked. + * @see bt_ag_close_sco() + * @see bt_ag_sco_state_changed_cb() + * @see bt_audio_connect() + */ +int bt_ag_open_sco(void); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Closes an opened SCO(Synchronous Connection Oriented link), asynchronously. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The SCO must be opened with bt_ag_open_sco(). + * @post bt_ag_sco_state_changed_cb() will be invoked. + * @see bt_ag_open_sco() + * @see bt_ag_sco_state_changed_cb() + */ +int bt_ag_close_sco(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Checks whether an opened SCO(Synchronous Connection Oriented link) exists or not. + * @since_tizen 2.3 + * @param[out] opened The SCO status: (@c true = opened, @c false = not opened) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_ag_open_sco() + * @see bt_ag_close_sco() + */ +int bt_ag_is_sco_opened(bool *opened); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when the SCO(Synchronous Connection Oriented link) state is changed. + * @since_tizen 2.3 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_sco_state_changed_cb() + * @see bt_ag_unset_sco_state_changed_cb() + */ +int bt_ag_set_sco_state_changed_cb(bt_ag_sco_state_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when the SCO(Synchronous Connection Oriented link) state is changed. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_sco_state_changed_cb() + * @see bt_ag_set_sco_state_changed_cb() + */ +int bt_ag_unset_sco_state_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the state of voice recognition. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] state The state of voice recognition: (@c true = enabled, @c false = disabled) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @see bt_audio_connect() + */ +int bt_ag_notify_voice_recognition_state(bool state); + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // __TIZEN_NETWORK_BLUETOOTH_EXTENSION_H__ + diff --git a/include/wearable/bluetooth_internal.h b/include/wearable/bluetooth_internal.h index c00233d..26a4c21 100644 --- a/include/wearable/bluetooth_internal.h +++ b/include/wearable/bluetooth_internal.h @@ -34,6 +34,303 @@ extern "C" /** * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Enables the local Bluetooth adapter, asynchronously. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function enables Bluetooth protocol stack and hardware. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_ALREADY_DONE Already enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre Bluetooth service must be initialized with bt_initialize(). + * @pre The state of local Bluetooth must be #BT_ADAPTER_DISABLED + * @post This function invokes bt_adapter_state_changed_cb(). + * + * @see bt_initialize() + * @see bt_adapter_get_state() + * @see bt_adapter_set_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb() + * @see bt_adapter_state_changed_cb() + * + */ +int bt_adapter_enable(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Disables the local Bluetooth adapter, asynchronously. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function disables Bluetooth protocol stack and hardware. + * + * @remarks You should disable Bluetooth adapter, which is helpful for saving power. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED + * @post This function invokes bt_adapter_state_changed_cb(). + * + * @see bt_adapter_get_state() + * @see bt_adapter_state_changed_cb() + * @see bt_adapter_set_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb () + * + */ +int bt_adapter_disable(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Recover the local Bluetooth adapter, asynchronously. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function does recovery logic, disables Bluetooth protocol stack and hardware, then enables after a few seconds. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED + * @post This function invokes bt_adapter_state_changed_cb(). + * + * @see bt_adapter_get_state() + * @see bt_adapter_state_changed_cb() + * @see bt_adapter_set_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb () + * + */ +int bt_adapter_recover(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Reset the local Bluetooth adapter, synchronously. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function resets Bluetooth protocol and values. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_state_changed_cb() will be invoked if The state of local Bluetooth was #BT_ADAPTER_ENABLED. + * + * @see bt_initialize() + * @see bt_adapter_get_state() + * @see bt_adapter_set_state_changed_cb() + * @see bt_adapter_unset_state_changed_cb() + * @see bt_adapter_state_changed_cb() + * + */ +int bt_adapter_reset(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Gets the version of local Bluetooth adapter. + * @since_tizen 2.3.1 + * @remarks The @a local_version must be released with free() by you. + * + * @param[out] local_version The version of local Bluetooth adapter + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + */ +int bt_adapter_get_version(char **local_version); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Gets the information regarding local Bluetooth adapter. + * @since_tizen 2.3.1 + * @remarks The @a all parameters must be released with free() by you. + * + * @param[out] chipset Chipset name of local Bluetooth adapter + * @param[out] firmware Firmware info. of local Bluetooth adapter + * @param[out] stack_version Bluetooth stack version + * @param[out] profiles The profile list of local Bluetooth adapter + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + */ +int bt_adapter_get_local_info(char **chipset, char **firmware, char **stack_version, char **profiles); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Sets the visibility mode. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @remarks #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE will change to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE + * after the given @a duration goes. + * + * @param[in] discoverable_mode The Bluetooth visibility mode to set + * @param[in] duration The duration until the visibility mode is changed to #BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE (in seconds). + * @a duration is used only for #BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE mode. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post bt_adapter_visibility_mode_changed_cb() will be invoked if this function returns #BT_ERROR_NONE. + * + * @see bt_adapter_get_visibility() + * @see bt_adapter_visibility_mode_changed_cb() + * @see bt_adapter_set_visibility_mode_changed_cb() + * @see bt_adapter_unset_visibility_mode_changed_cb() + */ +int bt_adapter_set_visibility(bt_adapter_visibility_mode_e discoverable_mode, int duration); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Registers a callback function to be invoked when the connectable state changes. + * @since_tizen 2.3.1 + * + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_connectable_changed_cb() will be invoked. + * + * @see bt_initialize() + * @see bt_adapter_connectable_changed_cb() + * @see bt_adapter_unset_connectable_changed_cb() + */ +int bt_adapter_set_connectable_changed_cb(bt_adapter_connectable_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3.1 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + * @see bt_adapter_set_connectable_changed_cb() + */ +int bt_adapter_unset_connectable_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Gets the connectable state of local Bluetooth adapter. + * @since_tizen 2.3.1 + * + * @remarks When connectable state is false, no device can connect to this device and visibility mode cannot be changed. + * + * @param[out] connectable The connectable state of local Bluetooth adapter + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * + * @see bt_adapter_set_connectable() + */ +int bt_adapter_get_connectable(bool *connectable); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Sets the connectable state of local Bluetooth adapter. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @remarks When connectable state is false, no device can connect to this device and visibility mode cannot be changed. + * + * @param[in] connectable The connectable state to set + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @post bt_adapter_connectable_changed_cb() will be invoked if this function returns #BT_ERROR_NONE. + * + * @see bt_adapter_get_connectable() + * @see bt_adapter_connectable_changed_cb() + * @see bt_adapter_set_connectable_changed_cb() + * @see bt_adapter_unset_connectable_changed_cb() + */ +int bt_adapter_set_connectable(bool connectable); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Sets the manufacturer data of local Bluetooth adapter. * @since_tizen 2.3 * @privlevel platform @@ -106,6 +403,217 @@ int bt_adapter_set_manufacturer_data_changed_cb( int bt_adapter_unset_manufacturer_data_changed_cb(void); /** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Enables the local Bluetooth le adapter, asynchronously. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function enables Bluetooth protocol stack and hardware. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_ALREADY_DONE Already enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre Bluetooth service must be initialized with bt_initialize(). + * @post This function invokes bt_adapter_le_state_changed_cb(). + * + * @see bt_initialize() + * @see bt_adapter_le_get_state() + * @see bt_adapter_le_set_state_changed_cb() + * @see bt_adapter_le_unset_state_changed_cb() + * @see bt_adapter_le_state_changed_cb() + * + */ +int bt_adapter_le_enable(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Disables the local Bluetooth le adapter, asynchronously. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @details This function disables Bluetooth le protocol stack and hardware. + * + * @remarks + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_NOW_IN_PROGRESS Operation now in progress + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_LE_ENABLED + * @post This function invokes bt_adapter_le_state_changed_cb(). + * + * @see bt_adapter_le_get_state() + * @see bt_adapter_le_state_changed_cb() + * @see bt_adapter_le_set_state_changed_cb() + * @see bt_adapter_le_unset_state_changed_cb () + * + */ +int bt_adapter_le_disable(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Gets the current state of local Bluetooth adapter. + * @since_tizen 2.3.1 + * + * @param[out] adapter_le_state The current adapter le state + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + */ +int bt_adapter_le_get_state(bt_adapter_le_state_e *adapter_le_state); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Registers a callback function to be invoked when the Bluetooth adapter le state changes. + * @since_tizen 2.3.1 + * + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_adapter_le_state_changed_cb() will be invoked. + * + * @see bt_initialize() + * @see bt_adapter_le_state_changed_cb() + * @see bt_adapter_le_unset_state_changed_cb() + */ +int bt_adapter_le_set_state_changed_cb(bt_adapter_le_state_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Unregisters the callback function. + * @since_tizen 2.3.1 + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * + * @see bt_initialize() + * @see bt_adapter_le_set_state_changed_cb() + */ +int bt_adapter_le_unset_state_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief add address to whitelist for accepting scanning request. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @remarks If the adress is in the whitelist then other LE devices are able to + * search this device. Before calling this API, make sure that the adapter is + * enabled. There is no callback event for this API. + + * @param[in] address The other device's address + * @param[in] address_type The other device's address type + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * + * @see bt_adapter_le_start_advertising_new() + * @see bt_adapter_le_stop_advertising() + */ +int bt_adapter_le_add_white_list(const char *address, bt_device_address_type_e address_type); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief remove address from the whitelist for not accepting scanning request. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @remarks If the adress is in the whitelist then other LE devices are able to + * search this device. Before calling this API, make sure that the adapter is + * enabled. There is no callback event for this API. + * + * @param[in] address The other device's address + * @param[in] address_type The other device's address type + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Adapter is not enabled + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * + * @see bt_adapter_le_start_advertising_new() + * @see bt_adapter_le_stop_advertising() + */ +int bt_adapter_le_remove_white_list(const char *address, bt_device_address_type_e address_type); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Sets the Privacy feature state of local Bluetooth adapter. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @param[in] enable_privacy The privacy feature to set/unset. + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @pre The state of local Bluetooth must be #BT_ADAPTER_LE_ENABLED. + * + */ +int bt_adapter_le_enable_privacy(bool enable_privacy); + +/** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE * @brief Set Bluetooth LE scan mode * @since_tizen 2.3 @@ -466,6 +974,72 @@ int bt_adapter_le_set_advertising_filter_policy(bt_advertiser_h advertiser, bt_a /** * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Creates a bond with a remote Bluetooth device, asynchronously. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @remarks A bond can be destroyed by bt_device_destroy_bond().\n + * The bonding request can be cancelled by bt_device_cancel_bonding(). + * + * @param[in] remote_address The address of the remote Bluetooth device with which the bond should be created + * @param[in] conn_type The connection type(LE or BREDR) to create bond with remote device + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED. + * @pre The remote device must be discoverable with bt_adapter_start_device_discovery(). + * @post This function invokes bt_device_bond_created_cb(). + * + * @see bt_adapter_start_device_discovery() + * @see bt_device_create_bond() + * @see bt_device_bond_created_cb() + * @see bt_device_cancel_bonding() + * @see bt_device_destroy_bond() + * @see bt_device_set_bond_created_cb() + * @see bt_device_unset_bond_created_cb() + */ +int bt_device_create_bond_by_type(const char *remote_address, + bt_device_connection_link_type_e conn_type); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Cancels service search process. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED Remote device not bonded + * @retval #BT_ERROR_NOT_IN_PROGRESS Operation not in progress + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The service search must be in progress by bt_device_start_service_search(). + * + * @see bt_device_start_service_search() + * @see bt_device_service_searched_cb() + * @see bt_device_set_service_searched_cb() + * @see bt_device_unset_service_searched_cb() + */ +int bt_device_cancel_service_search(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Gets a connection state * @since_tizen 2.4 * @@ -578,6 +1152,509 @@ int bt_socket_destroy_rfcomm_ex(const char *uuid); int bt_socket_listen_and_accept_rfcomm_ex(const char *uuid, int max_pending_connections, const char* bus_name, const char *object_path); /** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Starts listening on passed rfcomm socket. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @details bt_socket_connection_requested_cb() will be called when a RFCOMM connection is requested. + * + * @param[in] socket_fd The file descriptor socket on which start to listen + * @param[in] max_pending_connections The number of pending connections + * + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The socket must be created with bt_socket_create_rfcomm(). + * @post This function invokes bt_socket_connection_state_changed_cb(). + * + * @see bt_socket_create_rfcomm() + * @see bt_socket_set_connection_requested_cb() + * @see bt_socket_unset_connection_requested_cb() + * @see bt_socket_connection_requested_cb() + */ +int bt_socket_listen(int socket_fd, int max_pending_connections); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Accepts a connection request. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] requested_socket_fd The file descriptor of socket on which a connection is requested + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The connection is requested by bt_socket_connection_requested_cb(). + * @see bt_socket_create_rfcomm() + * @see bt_socket_connection_requested_cb() + * @see bt_socket_listen() + * @see bt_socket_reject() +*/ +int bt_socket_accept(int requested_socket_fd); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE + * @brief Rejects a connection request. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] socket_fd The file descriptor of socket on which a connection is requested + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The connection is requested by bt_socket_connection_requested_cb(). + * @see bt_socket_create_rfcomm() + * @see bt_socket_connection_requested_cb() + * @see bt_socket_listen() + * @see bt_socket_accept() + */ +int bt_socket_reject(int socket_fd); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Initializes the Bluetooth OPP server requested by bt_opp_server_push_requested_cb(). + * @since_tizen 2.3.1 + * @details The popup appears when an OPP connection is requested from a remote device. + * If you accept the request, then connection will be established and bt_opp_server_push_requested_cb() will be called. + * At that time, you can call either bt_opp_server_accept() or bt_opp_server_reject(). + * @remarks This function must be called to start Bluetooth OPP server. You must free all resources of the Bluetooth service + * by calling bt_opp_server_deinitialize() if Bluetooth OPP service is no longer needed. + * @param[in] destination The destination path + * @param[in] push_requested_cb The callback called when a push is requested + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_opp_server_push_requested_cb() + * @see bt_opp_server_deinitialize() + * @see bt_opp_server_accept() + * @see bt_opp_server_reject() + */ +int bt_opp_server_initialize(const char *destination, bt_opp_server_push_requested_cb push_requested_cb, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the call event to the remote bluetooth device. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @remarks Before notifying #BT_AG_CALL_EVENT_ANSWERED or #BT_AG_CALL_EVENT_DIALING, you should open SCO(Synchronous Connection Oriented link) + * if Bluetooth Hands-Free need SCO connection. + * @param[in] event The call event + * @param[in] call_id The call ID + * @param[in] phone_number The phone number. You must set this value in case of #BT_AG_CALL_EVENT_DIALING and #BT_AG_CALL_EVENT_INCOMING. + * In other cases, this value can be NULL. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @see bt_audio_connect() + */ +int bt_ag_notify_call_event(bt_ag_call_event_e event, unsigned int call_id, const char *phone_number); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the call list to the remote bluetooth device. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] list The call list + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @see bt_audio_connect() + */ +int bt_ag_notify_call_list(bt_call_list_h list); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the state of voice recognition. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] state The state of voice recognition: (@c true = enabled, @c false = disabled) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio device must be connected with bt_audio_connect(). + * @see bt_audio_connect() + */ +int bt_ag_notify_voice_recognition_state(bool state); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when a call handling event happened from Hands-Free. + * @since_tizen 2.3.1 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_call_handling_event_cb() + * @see bt_ag_unset_call_handling_event_cb() + */ +int bt_ag_set_call_handling_event_cb(bt_ag_call_handling_event_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when a call handling event happened from Hands-Free. + * @since_tizen 2.3.1 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_call_handling_event_cb() + * @see bt_ag_set_call_handling_event_cb() + */ +int bt_ag_unset_call_handling_event_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when a multi call handling event happened from Hands-Free. + * @since_tizen 2.3.1 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_multi_call_handling_event_cb() + * @see bt_ag_unset_multi_call_handling_event_cb() + */ +int bt_ag_set_multi_call_handling_event_cb(bt_ag_multi_call_handling_event_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when a multi call handling event happened from Hands-Free. + * @since_tizen 2.3.1 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_multi_call_handling_event_cb() + * @see bt_ag_set_multi_call_handling_event_cb() + */ +int bt_ag_unset_multi_call_handling_event_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when a DTMF(Dual Tone Multi Frequency) is transmitted from Hands-Free. + * @since_tizen 2.3.1 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_dtmf_transmitted_cb() + * @see bt_ag_unset_dtmf_transmitted_cb() + */ +int bt_ag_set_dtmf_transmitted_cb(bt_ag_dtmf_transmitted_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when a DTMF(Dual Tone Multi Frequency) is transmitted from Hands-Free. + * @since_tizen 2.3.1 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_dtmf_transmitted_cb() + * @see bt_ag_set_dtmf_transmitted_cb() + */ +int bt_ag_unset_dtmf_transmitted_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Notifies the speaker gain to the remote device. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @details This function sends a signal to the remote device. This signal has the gain value. + * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. + * When the speaker gain of remote device is changed to the requested gain, bt_audio_speaker_gain_changed_cb() will be called. + * @param[in] gain The gain of speaker (0 ~ 15) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. + * @see bt_ag_get_speaker_gain() + * @see bt_ag_set_speaker_gain_changed_cb() + * @see bt_ag_unset_speaker_gain_changed_cb() + */ +int bt_ag_notify_speaker_gain(int gain); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Gets the current speaker gain of the remote device. + * @since_tizen 2.3.1 + * @details This function gets the value of speaker gain of the remote device. + * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. + * @param[out] gain The gain of speaker (0 ~ 15) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. + * @see bt_ag_notify_speaker_gain() + * @see bt_ag_set_speaker_gain_changed_cb() + * @see bt_ag_unset_speaker_gain_changed_cb() + */ +int bt_ag_get_speaker_gain(int *gain); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Checks whether the remoted device enables NREC(Noise Reduction and Echo Canceling) or not. + * @since_tizen 2.3.1 + * @param[out] enabled The NREC status: (@c true = enabled, @c false = not enabled) + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device is connected by bt_audio_connect() with #BT_AUDIO_PROFILE_TYPE_HSP_HFP service. + * @see bt_audio_connect() + */ +int bt_ag_is_nrec_enabled(bool *enabled); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when the speaker gain of the remote device is changed. + * @since_tizen 2.3.1 + * @details This function let you know the change of the speaker gain of the remote device. + * @a gain is represented on a scale from 0 to 15. This value is absolute value relating to a particular volume level. + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_unset_speaker_gain_changed_cb() + */ +int bt_ag_set_speaker_gain_changed_cb(bt_ag_speaker_gain_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when the speaker gain of the remote device is changed. + * @since_tizen 2.3.1 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_set_speaker_gain_changed_cb() + */ +int bt_ag_unset_speaker_gain_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Registers a callback function that will be invoked when the microphone gain of the remote device is changed. + * @since_tizen 2.3.1 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_unset_microphone_gain_changed_cb() + */ +int bt_ag_set_microphone_gain_changed_cb(bt_ag_microphone_gain_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Unregisters a callback function that will be invoked when the microphone gain of the remote device is changed. + * @since_tizen 2.3.1 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_audio_initialize() + * @see bt_ag_set_microphone_gain_changed_cb() + */ +int bt_ag_unset_microphone_gain_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE + * @brief Creates a handle of call list. + * @since_tizen 2.3.1 + * @param[out] list The handle of call list + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_call_list_destroy() + */ +int bt_call_list_create(bt_call_list_h *list); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE + * @brief Destroys the handle of call list. + * @since_tizen 2.3.1 + * @param[in] list The handle of call list + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_call_list_create() + */ +int bt_call_list_destroy(bt_call_list_h list); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE + * @brief Resets the handle of call list. + * @since_tizen 2.3.1 + * @param[in] list The handle of call list + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_call_list_create() + */ +int bt_call_list_reset(bt_call_list_h list); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_CALL_MODULE + * @brief Adds a call to the handle of call list. + * @since_tizen 2.3.1 + * @param[in] list The handle of call list + * @param[in] call_id The call ID + * @param[in] state The state of audio gate call + * @param[in] phone_number The phone number. You must set this value in case of #BT_AG_CALL_EVENT_DIALING and #BT_AG_CALL_EVENT_INCOMING. + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_call_list_create() + */ +int bt_call_list_add(bt_call_list_h list, unsigned int call_id, bt_ag_call_state_e state, const char *phone_number); + +/** * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE * @brief Checks whether the remoted device is wbs (Wide Band Speech) mode or not. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif @@ -1487,6 +2564,22 @@ int bt_gatt_characteristic_add_descriptor(bt_gatt_h characteristic, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Updates the properties which a characteristic's GATT handle has + * @since_tizen 2.4 + * + * @param[in] characteristic The characteristic's GATT handle + * @param[in] properties The properties to be updated + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_property_e + */ +int bt_gatt_characteristic_set_properties(bt_gatt_h characteristic, int properties); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE * @brief Creates the GATT characteristic descriptor * @since_tizen 2.4 * @@ -1594,6 +2687,26 @@ int bt_gatt_server_set_read_value_requested_cb(bt_gatt_h gatt_handle, bt_gatt_server_read_value_requested_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Registers a callback function to be invoked when the remote device enables or disables the Notification/Indication for particular characteristics. + * @since_tizen 2.4 + * + * @param[in] gatt_handle The GATT handle of a characteristic or descriptor + * @param[in] callback The callback to be invoked + * @param[in] user_data The user data to be passed to @a callback function + * @return 0 on success, otherwise a negative error value + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @see bt_gatt_server_notification_state_change_cb() + */ +int bt_gatt_server_set_notification_state_change_cb(bt_gatt_h gatt_handle, + bt_gatt_server_notification_state_change_cb callback, + void *user_data); + /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE * @brief Registers a callback function to be invoked when a value of a characteristic or descriptor has been changed by a remote device(GATT client)'s request @@ -2265,6 +3378,239 @@ int bt_avrcp_control_get_track_info(bt_avrcp_metadata_attributes_info_s **track) int bt_avrcp_control_free_track_info(bt_avrcp_metadata_attributes_info_s *track); /** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Activates the NAP(Network Access Point). + * @since_tizen 2.3.1 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED + * @see bt_nap_deactivate() + */ +int bt_nap_activate(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Deactivates the NAP(Network Access Point). + * @since_tizen 2.3.1 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_ALREADY_DONE Operation is already done + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). + * @see bt_nap_activate() + */ +int bt_nap_deactivate(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Disconnects the all PANUs(Personal Area Networking User) which are connected to you. + * @since_tizen 2.3.1 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). + * @see bt_nap_activate() + */ +int bt_nap_disconnect_all(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Disconnects the specified PANU(Personal Area Networking User) which is connected to you. + * @since_tizen 2.3.1 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] remote_address The remote address + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth NAP service must be activated with bt_nap_activate(). + * @see bt_nap_activate() + */ +int bt_nap_disconnect(const char *remote_address); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Registers a callback function that will be invoked when the connection state changes. + * @since_tizen 2.3.1 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_nap_connection_state_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_nap_connection_state_changed_cb() + * @see bt_nap_unset_connection_state_changed_cb() + */ +int bt_nap_set_connection_state_changed_cb(bt_nap_connection_state_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE + * @brief Unregisters a callback function that will be invoked when the connection state changes. + * @since_tizen 2.3.1 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_nap_connection_state_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_nap_connection_state_changed_cb() + * @see bt_nap_set_connection_state_changed_cb() + */ +int bt_nap_unset_connection_state_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE + * @brief Registers a callback function that will be invoked when the connection state changes. + * @since_tizen 2.3.1 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_nap_connection_state_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_panu_connection_state_changed_cb() + * @see bt_panu_unset_connection_state_changed_cb() + */ +int bt_panu_set_connection_state_changed_cb(bt_panu_connection_state_changed_cb callback, void *user_data); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE + * @brief Unregisters a callback function that will be invoked when the connection state changes. + * @since_tizen 2.3.1 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @post bt_nap_connection_state_changed_cb() will be invoked. + * @see bt_initialize() + * @see bt_panu_connection_state_changed_cb() + * @see bt_panu_set_connection_state_changed_cb() + */ +int bt_panu_unset_connection_state_changed_cb(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE + * @brief Connects the remote device with the PAN(Personal Area Networking) service, asynchronously. + * @since_tizen 2.3.1 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] remote_address The remote address + * @param[in] type The type of PAN service + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The local device must be bonded with the remote device by bt_device_create_bond(). + * @post bt_panu_connection_state_changed_cb() will be invoked. + * @see bt_panu_disconnect() + * @see bt_panu_connection_state_changed_cb() + */ +int bt_panu_connect(const char *remote_address, bt_panu_service_type_e type); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_PAN_PANU_MODULE + * @brief Disconnects the remote device with the PAN(Personal Area Networking) service, asynchronously. + * @since_tizen 2.3.1 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @param[in] remote_address The remote address + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected by bt_panu_connect(). + * @post bt_panu_connection_state_changed_cb() will be invoked. + * @see bt_panu_connect() + * @see bt_panu_connection_state_changed_cb() + */ +int bt_panu_disconnect(const char *remote_address); + +/** + * @internal + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief update LE connection. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The Bluetooth service must be initialized by bt_initialize(). + * @pre The remote device must be connected with bt_gatt_connect(). + */ +int bt_device_le_conn_update(const char *device_address, + const bt_le_conn_update_s *parameters); + + +/** * @} */ diff --git a/include/wearable/bluetooth_type.h b/include/wearable/bluetooth_type.h index 6690427..3b62e4e 100644 --- a/include/wearable/bluetooth_type.h +++ b/include/wearable/bluetooth_type.h @@ -75,18 +75,6 @@ typedef enum } bt_adapter_state_e; /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Enumerations of the Bluetooth adapter le state. - * @since_tizen 2.3.1 - */ -typedef enum -{ - BT_ADAPTER_LE_DISABLED = 0x00, /**< Bluetooth le is disabled */ - BT_ADAPTER_LE_ENABLED, /**< Bluetooth le is enabled */ -} bt_adapter_le_state_e; - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Enumerations of the Bluetooth visibility mode. * @since_tizen 2.3.1 @@ -439,7 +427,6 @@ typedef enum { } bt_audio_profile_type_e; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE * @brief Enumerations for the call handling event * @since_tizen 2.3.1 @@ -451,7 +438,6 @@ typedef enum { } bt_ag_call_handling_event_e; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE * @brief Enumerations for the multi call handling event * @since_tizen 2.3.1 @@ -465,42 +451,9 @@ typedef enum { } bt_ag_multi_call_handling_event_e; /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Enumerations for the call state - * @since_tizen 2.3.1 - */ -typedef enum { - BT_AG_CALL_EVENT_IDLE = 0x00, /**< Idle */ - BT_AG_CALL_EVENT_ANSWERED, /**< Answered */ - BT_AG_CALL_EVENT_HELD, /**< Held */ - BT_AG_CALL_EVENT_RETRIEVED, /**< Retrieved */ - BT_AG_CALL_EVENT_DIALING, /**< Dialing */ - BT_AG_CALL_EVENT_ALERTING, /**< Alerting */ - BT_AG_CALL_EVENT_INCOMING, /**< Incoming */ -} bt_ag_call_event_e; - -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Enumerations for the call state - * @since_tizen 2.3.1 - */ -typedef enum { - BT_AG_CALL_STATE_IDLE = 0x00, /**< Idle state */ - BT_AG_CALL_STATE_ACTIVE, /**< Active state */ - BT_AG_CALL_STATE_HELD, /**< Held state */ - BT_AG_CALL_STATE_DIALING, /**< Dialing state */ - BT_AG_CALL_STATE_ALERTING, /**< Alerting state */ - BT_AG_CALL_STATE_INCOMING, /**< Incoming state */ - BT_AG_CALL_STATE_WAITING, /**< Waiting for connected indication event after answering an incoming call*/ -} bt_ag_call_state_e; - -/** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Enumerations for the equalizer state - * @since_tizen 2.3.1 + * @since_tizen 2.4 */ typedef enum { BT_AVRCP_EQUALIZER_STATE_OFF = 0x01, /**< Equalizer Off */ @@ -508,10 +461,9 @@ typedef enum { } bt_avrcp_equalizer_state_e; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Enumerations for the repeat mode - * @since_tizen 2.3.1 + * @since_tizen 2.4 */ typedef enum { BT_AVRCP_REPEAT_MODE_OFF = 0x01, /**< Repeat Off */ @@ -521,10 +473,9 @@ typedef enum { } bt_avrcp_repeat_mode_e; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Enumerations for the shuffle mode - * @since_tizen 2.3.1 + * @since_tizen 2.4 */ typedef enum { BT_AVRCP_SHUFFLE_MODE_OFF = 0x01, /**< Shuffle Off */ @@ -533,10 +484,9 @@ typedef enum { } bt_avrcp_shuffle_mode_e; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Enumerations for the scan mode - * @since_tizen 2.3.1 + * @since_tizen 2.4 */ typedef enum { BT_AVRCP_SCAN_MODE_OFF = 0x01, /**< Scan Off */ @@ -545,10 +495,9 @@ typedef enum { } bt_avrcp_scan_mode_e; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Enumerations for the player state - * @since_tizen 2.3.1 + * @since_tizen 2.4 */ typedef enum { BT_AVRCP_PLAYER_STATE_STOPPED = 0x00, /**< Stopped */ @@ -802,22 +751,6 @@ typedef struct } bt_device_connection_info_s; /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE - * @brief Device LE connection update structure. - * @since_tizen 2.3.1 - * - * @see bt_device_le_conn_update() - */ -typedef struct -{ - unsigned int interval_min; /**< Minimum value for the connection event interval (msec) */ - unsigned int interval_max; /**< Maximum value for the connection event interval (msec) */ - unsigned int latency; /**< Slave latency (msec) */ - unsigned int time_out; /**< Supervision timeout (msec) */ -} bt_le_conn_update_s; - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE * @brief Rfcomm connection data used for exchanging data between Bluetooth devices. * @since_tizen 2.3.1 @@ -954,26 +887,6 @@ typedef void (*bt_adapter_device_discovery_state_changed_cb) typedef bool (*bt_adapter_bonded_device_cb)(bt_device_info_s *device_info, void *user_data); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE - * @brief Called when the connectable state changes. - * @since_tizen 2.3.1 - * - * @param[in] result The result of the connectable state changing - * @param[in] connectable The connectable to be changed - * @param[in] user_data The user data passed from the callback registration function - * - * @pre This function will be invoked when the connectable state of local Bluetooth adapter changes - * if you register this callback using bt_adapter_set_connectable_changed_cb(). - * - * @see bt_adapter_set_connectable() - * @see bt_adapter_set_connectable_changed_cb() - * @see bt_adapter_unset_connectable_changed_cb() - */ -typedef void (*bt_adapter_connectable_changed_cb) - (int result, bool connectable, void *user_data); - -/** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE * @brief Called when the LE advertisement has been found. * @since_tizen 2.3.1 @@ -1004,22 +917,6 @@ typedef void (*bt_adapter_le_scan_result_cb)(int result, typedef void (*bt_adapter_le_advertising_state_changed_cb)(int result, bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, void *user_data); -/** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE - * @brief Called when the Bluetooth adapter le state changes. - * @since_tizen 2.3.1 - * - * @param[in] result The result of the adapter state changing - * @param[in] adapter_le_state The adapter le state to be changed - * @param[in] user_data The user data passed from the callback registration function - * @pre Either bt_adapter_le_enable() or bt_adapter_le_disable() will invoke this callback if you register this callback using bt_adapter_le_set_state_changed_cb(). - * @see bt_adapter_le_enable() - * @see bt_adapter_le_disable() - * @see bt_adapter_le_set_state_changed_cb() - * @see bt_adapter_le_unset_state_changed_cb() - */ -typedef void (*bt_adapter_le_state_changed_cb)(int result, bt_adapter_le_state_e adapter_le_state, void *user_data); /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE @@ -1078,7 +975,6 @@ typedef bool (*bt_device_connected_profile)(bt_profile_e profile, void *user_dat typedef void (*bt_device_bond_destroyed_cb)(int result, char *remote_address, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Called when the authorization of device changes. * @since_tizen 2.3.1 @@ -1165,40 +1061,19 @@ typedef void (*bt_socket_connection_state_changed_cb) (int result, bt_socket_connection_state_e connection_state, bt_socket_connection_s *connection, void *user_data); /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE * @brief Called when a RFCOMM connection is requested. * @since_tizen 2.3.1 * - * @details You must call bt_socket_accept() if you want to accept. Otherwise, you must call bt_socket_reject(). * @param[in] socket_fd The file descriptor of socket on which a connection is requested * @param[in] remote_address The address of remote device * @param[in] user_data The user data passed from the callback registration function - * @pre If you register this callback function by bt_socket_set_connection_requested_cb() and listen a socket by bt_socket_listen(), + * @pre If you register this callback function by bt_socket_set_connection_requested_cb(), * bt_socket_connection_requested_cb() will be invoked. - * @see bt_socket_listen() - * @see bt_socket_accept() - * @see bt_socket_reject() */ typedef void (*bt_socket_connection_requested_cb) (int socket_fd, const char *remote_address, void *user_data); /** - * @internal - * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE - * @brief Called when the push is requested. - * @since_tizen 2.3.1 - * - * @details You must call bt_opp_server_accept() if you want to accept. - * Otherwise, you must call bt_opp_server_reject(). - * @param[in] file The path of file to be pushed - * @param[in] size The file size (bytes) - * @param[in] user_data The user data passed from the callback registration function - * @see bt_opp_server_initialize() - */ -typedef void (*bt_opp_server_push_requested_cb)(const char *file, int size, void *user_data); - -/** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE * @brief Called when an OPP connection is requested. * @since_tizen 2.3.1 @@ -1298,23 +1173,6 @@ typedef void (*bt_audio_connection_state_changed_cb) (int result, bool connected /** * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE - * @brief Called when the SCO(Synchronous Connection Oriented link) state is changed. - * @since_tizen 2.3.1 - * - * @details This callback is called when the SCO state is changed. - * When you call bt_ag_open_sco() or bt_ag_close_sco(), this callback is also called with error result even though these functions failed. - * @param[in] result The result of changing the connection state - * @param[in] opened The state to be changed: (@c true = opened, @c false = not opened) - * @param[in] user_data The user data passed from the callback registration function - * @see bt_ag_set_sco_state_changed_cb() - * @see bt_ag_unset_sco_state_changed_cb() - * @see bt_ag_open_sco() - * @see bt_ag_close_sco() - */ -typedef void (*bt_ag_sco_state_changed_cb) (int result, bool opened, void *user_data); - -/** - * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE * @brief Called when a call handling event happened from Hands-Free. * @since_tizen 2.3.1 * diff --git a/include/wearable/bluetooth_type_extension.h b/include/wearable/bluetooth_type_extension.h new file mode 100644 index 0000000..03e314a --- /dev/null +++ b/include/wearable/bluetooth_type_extension.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_NETWORK_BLUETOOTH_TYPE_EXTENSION_H__ +#define __TIZEN_NETWORK_BLUETOOTH_TYPE_EXTENSION_H__ + + #ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** + * @file bluetooth_type_extension.h + */ + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Called when the SCO(Synchronous Connection Oriented link) state is changed. + * @since_tizen 2.3.1 + * + * @details This callback is called when the SCO state is changed. + * When you call bt_ag_open_sco() or bt_ag_close_sco(), this callback is also called with error result even though these functions failed. + * @param[in] result The result of changing the connection state + * @param[in] opened The state to be changed: (@c true = opened, @c false = not opened) + * @param[in] user_data The user data passed from the callback registration function + * @see bt_ag_set_sco_state_changed_cb() + * @see bt_ag_unset_sco_state_changed_cb() + * @see bt_ag_open_sco() + * @see bt_ag_close_sco() + */ +typedef void (*bt_ag_sco_state_changed_cb) (int result, bool opened, void *user_data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // __TIZEN_NETWORK_BLUETOOTH_TYPE_EXTENSION_H__ diff --git a/include/wearable/bluetooth_type_internal.h b/include/wearable/bluetooth_type_internal.h index 80e1f5b..3f18d7c 100644 --- a/include/wearable/bluetooth_type_internal.h +++ b/include/wearable/bluetooth_type_internal.h @@ -18,6 +18,8 @@ #ifndef __TIZEN_NETWORK_BLUETOOTH_TYPE_INTERNAL_H__ #define __TIZEN_NETWORK_BLUETOOTH_TYPE_INTERNAL_H__ +#include <glib.h> + #ifdef __cplusplus extern "C" { @@ -65,6 +67,97 @@ extern "C" /** * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Enumerations of the Bluetooth adapter le state. + * @since_tizen 2.3.1 + */ +typedef enum +{ + BT_ADAPTER_LE_DISABLED = 0x00, /**< Bluetooth le is disabled */ + BT_ADAPTER_LE_ENABLED, /**< Bluetooth le is enabled */ +} bt_adapter_le_state_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE + * @brief Called when the Bluetooth adapter le state changes. + * @since_tizen 2.3.1 + * + * @param[in] result The result of the adapter state changing + * @param[in] adapter_le_state The adapter le state to be changed + * @param[in] user_data The user data passed from the callback registration function + * @pre Either bt_adapter_le_enable() or bt_adapter_le_disable() will invoke this callback if you register this callback using bt_adapter_le_set_state_changed_cb(). + * @see bt_adapter_le_enable() + * @see bt_adapter_le_disable() + * @see bt_adapter_le_set_state_changed_cb() + * @see bt_adapter_le_unset_state_changed_cb() + */ +typedef void (*bt_adapter_le_state_changed_cb)(int result, bt_adapter_le_state_e adapter_le_state, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Enumerations for the call state + * @since_tizen 2.3.1 + */ +typedef enum { + BT_AG_CALL_EVENT_IDLE = 0x00, /**< Idle */ + BT_AG_CALL_EVENT_ANSWERED, /**< Answered */ + BT_AG_CALL_EVENT_HELD, /**< Held */ + BT_AG_CALL_EVENT_RETRIEVED, /**< Retrieved */ + BT_AG_CALL_EVENT_DIALING, /**< Dialing */ + BT_AG_CALL_EVENT_ALERTING, /**< Alerting */ + BT_AG_CALL_EVENT_INCOMING, /**< Incoming */ +} bt_ag_call_event_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE + * @brief Enumerations for the call state + * @since_tizen 2.3.1 + */ +typedef enum { + BT_AG_CALL_STATE_IDLE = 0x00, /**< Idle state */ + BT_AG_CALL_STATE_ACTIVE, /**< Active state */ + BT_AG_CALL_STATE_HELD, /**< Held state */ + BT_AG_CALL_STATE_DIALING, /**< Dialing state */ + BT_AG_CALL_STATE_ALERTING, /**< Alerting state */ + BT_AG_CALL_STATE_INCOMING, /**< Incoming state */ + BT_AG_CALL_STATE_WAITING, /**< Waiting for connected indication event after answering an incoming call*/ +} bt_ag_call_state_e; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE + * @brief Called when the connectable state changes. + * @since_tizen 2.3.1 + * + * @param[in] result The result of the connectable state changing + * @param[in] connectable The connectable to be changed + * @param[in] user_data The user data passed from the callback registration function + * + * @pre This function will be invoked when the connectable state of local Bluetooth adapter changes + * if you register this callback using bt_adapter_set_connectable_changed_cb(). + * + * @see bt_adapter_set_connectable() + * @see bt_adapter_set_connectable_changed_cb() + * @see bt_adapter_unset_connectable_changed_cb() + */ +typedef void (*bt_adapter_connectable_changed_cb) + (int result, bool connectable, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_OPP_SERVER_MODULE + * @brief Called when the push is requested. + * @since_tizen 2.3.1 + * + * @details You must call bt_opp_server_accept() if you want to accept. + * Otherwise, you must call bt_opp_server_reject(). + * @param[in] file The path of file to be pushed + * @param[in] size The file size (bytes) + * @param[in] user_data The user data passed from the callback registration function + * @see bt_opp_server_initialize() + */ +typedef void (*bt_opp_server_push_requested_cb)(const char *file, int size, void *user_data); + + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE * @brief Enumerations of the Bluetooth adapter le scan type. * @since_tizen 2.3 */ @@ -202,7 +295,6 @@ typedef enum } bt_pbap_filter_sort_order_e; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Enumerations for the player control command * @since_tizen 2.3 @@ -217,8 +309,7 @@ typedef enum BT_AVRCP_CONTROL_REWIND /**< Rewind */ } bt_avrcp_player_command_e; - /** - * @internal +/** * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Structure of Track metadata information. * @since_tizen 2.3 @@ -236,7 +327,6 @@ typedef struct { } bt_avrcp_metadata_attributes_info_s; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE * @brief Called when the connection state is changed. * @since_tizen 2.3 @@ -298,7 +388,6 @@ typedef struct { } bt_hf_call_status_info_s; /** - * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE * @brief Called when the manufacturer dat changes. * @since_tizen 2.3 @@ -552,6 +641,20 @@ typedef void (*bt_gatt_server_read_value_requested_cb) (char *remote_address, /** * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE + * @brief Called when the remote device enables or disables the Notification/Indication for particular characteristics. + * @since_tizen 2.4 + * + * @param[in] server The GATT server handle + * @param[in] gatt_handle The characteristic's GATT handle to be read + * @param[in] user_data The user data passed from the registration function + * + * @see bt_gatt_server_set_read_value_requested_cb() + */ +typedef void (*bt_gatt_server_notification_state_change_cb) (bool notify, + bt_gatt_server_h server, bt_gatt_h gatt_handle, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE * @brief Called when the sending notification / indication is done * @since_tizen 2.4 * @@ -571,6 +674,20 @@ typedef void (*bt_gatt_server_read_value_requested_cb) (char *remote_address, typedef void (*bt_gatt_server_notification_sent_cb) (int result, char *remote_address, bt_gatt_server_h server, bt_gatt_h characteristic, bool completed, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE + * @brief Device LE connection update structure. + * @since_tizen 2.3.1 + */ +typedef struct +{ + unsigned int interval_min; /**< Minimum value for the connection event interval (msec) */ + unsigned int interval_max; /**< Maximum value for the connection event interval (msec) */ + unsigned int latency; /**< Slave latency (msec) */ + unsigned int time_out; /**< Supervision timeout (msec) */ +} bt_le_conn_update_s; + /** * @} */ diff --git a/packaging/capi-network-bluetooth.spec b/packaging/capi-network-bluetooth.spec index 774dc0f..5cb0740 100644 --- a/packaging/capi-network-bluetooth.spec +++ b/packaging/capi-network-bluetooth.spec @@ -6,13 +6,19 @@ Release: 1 Group: TO_BE/FILLED_IN License: Apache-2.0 Source0: %{name}-%{version}.tar.gz + Requires(post): eglibc Requires(postun): eglibc BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(vconf) +%if "%{?tizen_profile_name}" == "tv" +BuildRequires: pkgconfig(bluetooth-tv-api) +BuildRequires: pkgconfig(db-util) +%else BuildRequires: pkgconfig(bluetooth-api) +%endif BuildRequires: pkgconfig(capi-base-common) %if "%{?tizen_profile_name}" == "wearable" BuildRequires: pkgconfig(privacy-manager-client) @@ -21,7 +27,6 @@ BuildRequires: pkgconfig(privacy-manager-client) BuildRequires: cmake BuildRequires: model-build-features - %description Network Bluetooth Framework @@ -79,30 +84,39 @@ export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE -DTIZEN_ENGINEER_MODE" export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE -DTIZEN_ENGINEER_MODE" %if "%{?tizen_profile_name}" == "wearable" -export CFLAGS="$CFLAGS -DTIZEN_WEARABLE" -export CXXFLAGS="$CXXFLAGS -DTIZEN_WEARABLE" -export FFLAGS="$FFLAGS -DTIZEN_WEARABLE" +export CFLAGS="$CFLAGS -DTIZEN_WEARABLE -DTIZEN_AUDIO_HF_DISABLE" +export CXXFLAGS="$CXXFLAGS -DTIZEN_WEARABLE -DTIZEN_AUDIO_HF_DISABLE" +export FFLAGS="$FFLAGS -DTIZEN_WEARABLE -DTIZEN_AUDIO_HF_DISABLE" %endif %if "%{?tizen_profile_name}" == "mobile" -export CFLAGS="$CFLAGS -DBT_ENABLE_LEGACY_GATT_CLIENT" -export CXXFLAGS="$CXXFLAGS -DBT_ENABLE_LEGACY_GATT_CLIENT" -export FFLAGS="$FFLAGS -DBT_ENABLE_LEGACY_GATT_CLIENT" +export CFLAGS="$CFLAGS -DBT_ENABLE_LEGACY_GATT_CLIENT -DTIZEN_AUDIO_HF_DISABLE -DTIZEN_IPSP_SUPPORT" +export CXXFLAGS="$CXXFLAGS -DBT_ENABLE_LEGACY_GATT_CLIENT -DTIZEN_AUDIO_HF_DISABLE -DTIZEN_IPSP_SUPPORT" +export FFLAGS="$FFLAGS -DBT_ENABLE_LEGACY_GATT_CLIENT -DTIZEN_AUDIO_HF_DISABLE -DTIZEN_IPSP_SUPPORT" +%endif + +%if "%{?tizen_profile_name}" == "tv" +export CFLAGS="$CFLAGS -DTIZEN_GATT_DISABLE -DTIZEN_OPP_SERVER_DISABLE -DTIZEN_OPP_CLIENT_DISABLE \ + -DTIZEN_PAN_DISABLE -DTELEPHONY_DISABLED -DTIZEN_HDP_DISABLE -DTIZEN_AUDIO_HF_DISABLE" +export CXXFLAGS="$CXXFLAGS -DTIZEN_GATT_DISABLE -DTIZEN_OPP_SERVER_DISABLE -DTIZEN_OPP_CLIENT_DISABLE \ + -DTIZEN_PAN_DISABLE -DTELEPHONY_DISABLED -DTIZEN_HDP_DISABLE -DTIZEN_AUDIO_HF_DISABLE" +export FFLAGS="$FFLAGS -DTIZEN_GATT_DISABLE -DTIZEN_OPP_SERVER_DISABLE -DTIZEN_OPP_CLIENT_DISABLE \ + -DTIZEN_PAN_DISABLE -DTELEPHONY_DISABLED -DTIZEN_HDP_DISABLE -DTIZEN_AUDIO_HF_DISABLE" %endif %if %{?model_build_feature_bt_disable_all} export CFLAGS="$CFLAGS -DTIZEN_BT_DISABLE -DTIZEN_LE_DISABLE -DTIZEN_GATT_DISABLE -DTIZEN_OPP_SERVER_DISABLE -DTIZEN_OPP_CLIENT_DISABLE - -DTIZEN_PAN_DISABLE -DTIZEN_HID_DISABLE -DTELEPHONY_DISABLED - -DTIZEN_AVRCP_DISABLE -DTIZEN_HDP_DISABLE" + -DTIZEN_PAN_DISABLE -DTIZEN_HID_HOST_DISABLE -DTIZEN_HID_DEVICE_DISABLE + -DTELEPHONY_DISABLED -DTIZEN_AVRCP_DISABLE -DTIZEN_HDP_DISABLE -DTIZEN_AUDIO_HF_DISABLE" export CXXFLAGS="$CXXFLAGS -DTIZEN_BT_DISABLE -DTIZEN_LE_DISABLE -DTIZEN_GATT_DISABLE -DTIZEN_OPP_SERVER_DISABLE -DTIZEN_OPP_CLIENT_DISABLE - -DTIZEN_PAN_DISABLE -DTIZEN_HID_DISABLE -DTELEPHONY_DISABLED - -DTIZEN_AVRCP_DISABLE -DTIZEN_HDP_DISABLE" + -DTIZEN_PAN_DISABLE -DTIZEN_HID_HOST_DISABLE -DTIZEN_HID_DEVICE_DISABLE + -DTELEPHONY_DISABLED -DTIZEN_AVRCP_DISABLE -DTIZEN_HDP_DISABLE -DTIZEN_AUDIO_HF_DISABLE" export FFLAGS="$FFLAGS -DTIZEN_BT_DISABLE -DTIZEN_LE_DISABLE -DTIZEN_GATT_DISABLE -DTIZEN_OPP_SERVER_DISABLE -DTIZEN_OPP_CLIENT_DISABLE - -DTIZEN_PAN_DISABLE -DTIZEN_HID_DISABLE -DTELEPHONY_DISABLED - -DTIZEN_AVRCP_DISABLE -DTIZEN_HDP_DISABLE" + -DTIZEN_PAN_DISABLE -DTIZEN_HID_HOST_DISABLE -DTIZEN_HID_DEVICE_DISABLE + -DTELEPHONY_DISABLED -DTIZEN_AVRCP_DISABLE -DTIZEN_HDP_DISABLE -DTIZEN_AUDIO_HF_DISABLE" %else %if %{?model_build_feature_bt_disable_le} export CFLAGS="$CFLAGS -DTIZEN_LE_DISABLE -DTIZEN_GATT_DISABLE" @@ -123,9 +137,9 @@ export FFLAGS="$FFLAGS -DTIZEN_PAN_DISABLE" %endif %if %{?model_build_feature_bt_disable_hid} -export CFLAGS="$CFLAGS -DTIZEN_HID_DISABLE" -export CXXFLAGS="$CXXFLAGS -DTIZEN_HID_DISABLE" -export FFLAGS="$FFLAGS -DTIZEN_HID_DISABLE" +export CFLAGS="$CFLAGS -DTIZEN_HID_HOST_DISABLE -DTIZEN_HID_DEVICE_DISABLE" +export CXXFLAGS="$CXXFLAGS -DTIZEN_HID_HOST_DISABLE -DTIZEN_HID_DEVICE_DISABLE" +export FFLAGS="$FFLAGS -DTIZEN_HID_HOST_DISABLE -DTIZEN_HID_DEVICE_DISABLE" %endif %if %{?model_build_feature_bt_disable_audio_call} @@ -151,8 +165,12 @@ export FFLAGS="$FFLAGS -DTIZEN_HDP_DISABLE" %if "%{?tizen_profile_name}" == "wearable" -DTIZEN_WEARABLE=YES \ %else +%if "%{?tizen_profile_name}" == "tv" + -DTIZEN_TV=YES \ +%else -DTIZEN_WEARABLE=NO \ %endif +%endif MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} @@ -164,11 +182,14 @@ rm -rf %{buildroot} %make_install install -D -m 0644 LICENSE %{buildroot}%{_datadir}/license/capi-network-bluetooth install -D -m 0644 LICENSE %{buildroot}%{_datadir}/license/capi-network-bluetooth-devel + +%if "%{?tizen_profile_name}" != "tv" install -D -m 0644 test_scripts/bt_on_test_while_infinite.service %{buildroot}%{_libdir}/systemd/system/bt_on_test_while_infinite.service install -D -m 0644 test/bt_infinite_spp_test_server.service %{buildroot}%{_libdir}/systemd/system/bt_infinite_spp_test_server.service install -D -m 0644 test/bt_infinite_spp_test_client.service %{buildroot}%{_libdir}/systemd/system/bt_infinite_spp_test_client.service install -D -m 0755 test_scripts/check_bt_during_infinite_boot.sh %{buildroot}/%{_prefix}/etc/bluetooth/check_bt_during_infinite_boot.sh +%endif %post -p /sbin/ldconfig @@ -180,19 +201,25 @@ install -D -m 0755 test_scripts/check_bt_during_infinite_boot.sh %{buildroot}/%{ %{_datadir}/license/capi-network-bluetooth %files test +%if "%{?tizen_profile_name}" != "tv" %manifest bluetooth-test.manifest %{_bindir}/bt_unit_test %{_bindir}/bt_onoff /etc/smack/accesses2.d/capi.network.bluetooth.test.rule +%endif %files gatt-test +%if "%{?tizen_profile_name}" != "tv" %manifest bluetooth-gatt-test.manifest %{_bindir}/bt_unit_test_gatt /etc/smack/accesses2.d/capi.network.bluetooth.test.gatt.rule +%endif %files infinite-boot-test +%if "%{?tizen_profile_name}" != "tv" %{_libdir}/systemd/system/bt_on_test_while_infinite.service %attr(755,-,-) %{_prefix}/etc/bluetooth/check_bt_during_infinite_boot.sh +%endif %post infinite-boot-test /usr/bin/systemctl daemon-reload @@ -202,10 +229,12 @@ install -D -m 0755 test_scripts/check_bt_during_infinite_boot.sh %{buildroot}/%{ /usr/bin/systemctl disable bt_on_test_while_infinite.service %files infinite-spp-test-server +%if "%{?tizen_profile_name}" != "tv" %manifest bluetooth-infinite-spp-test-server.manifest %{_bindir}/bt_infinite_spp_test %{_libdir}/systemd/system/bt_infinite_spp_test_server.service /etc/smack/accesses2.d/capi.network.bluetooth.infinite.spp.test.rule +%endif %post infinite-spp-test-server /usr/bin/systemctl daemon-reload @@ -215,10 +244,12 @@ install -D -m 0755 test_scripts/check_bt_during_infinite_boot.sh %{buildroot}/%{ /usr/bin/systemctl disable bt_infinite_spp_test_server.service %files infinite-spp-test-client +%if "%{?tizen_profile_name}" != "tv" %manifest bluetooth-infinite-spp-test-client.manifest %{_bindir}/bt_infinite_spp_test %{_libdir}/systemd/system/bt_infinite_spp_test_client.service /etc/smack/accesses2.d/capi.network.bluetooth.infinite.spp.test.rule +%endif %post infinite-spp-test-client /usr/bin/systemctl daemon-reload @@ -230,8 +261,21 @@ install -D -m 0755 test_scripts/check_bt_during_infinite_boot.sh %{buildroot}/%{ %files devel %{_includedir}/network/bluetooth.h %{_includedir}/network/bluetooth_type.h + +%if "%{?tizen_profile_name}" == "tv" +%{_includedir}/network/bluetooth_product.h +%{_includedir}/network/bluetooth_type_product.h +%{_includedir}/network/BTLogger.h +%{_includedir}/network/BTLogger_interface.h +%exclude %{_includedir}/network/bluetooth_private.h +%endif + +%{_includedir}/network/bluetooth_extension.h +%{_includedir}/network/bluetooth_type_extension.h + %{_includedir}/network/bluetooth_internal.h %{_includedir}/network/bluetooth_type_internal.h + %{_libdir}/pkgconfig/capi-network-bluetooth.pc %{_libdir}/libcapi-network-bluetooth.so %{_datadir}/license/capi-network-bluetooth-devel diff --git a/src/bluetooth-adapter.c b/src/bluetooth-adapter.c index 400375e..1c5ff8c 100644..100755 --- a/src/bluetooth-adapter.c +++ b/src/bluetooth-adapter.c @@ -205,9 +205,13 @@ int bt_adapter_get_version(char **version) #define BT_ADAPTER_FIRMWARE_INFO_FILE_PATH "/var/lib/bluetooth/bcmtool_log" #define BT_ADAPTER_STACK_INFO_FILE_PATH "/usr/etc/bluetooth/stack_info" +#define BT_ADAPTER_MAX_BUFFER_SIZE (32767 * 1000) int bt_adapter_get_local_info(char **chipset, char **firmware, char **stack_version, char **profiles) { + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + int ret = BT_ERROR_NONE; FILE *fp = NULL; char *buf = NULL; @@ -353,6 +357,12 @@ int bt_adapter_get_local_info(char **chipset, char **firmware, char **stack_vers } info_size = info_end - info_start; + if (info_size < 0 || info_size > BT_ADAPTER_MAX_BUFFER_SIZE) { + BT_ERR("info size is incorrect: %ld", info_size); + ret = BT_ERROR_OPERATION_FAILED; + goto ERROR; + } + local_stack_version = (char *)malloc(sizeof(char) * (info_size + 1)); if (local_stack_version == NULL) { ret = BT_ERROR_OUT_OF_MEMORY; @@ -366,6 +376,12 @@ int bt_adapter_get_local_info(char **chipset, char **firmware, char **stack_vers info_start = info_end + 2; info_size = lsize - info_size - 3; + if (info_size < 0 || info_size > BT_ADAPTER_MAX_BUFFER_SIZE) { + BT_ERR("info size is incorrect: %ld", info_size); + ret = BT_ERROR_OPERATION_FAILED; + goto ERROR; + } + local_profiles = (char *)malloc(sizeof(char) * (info_size + 1)); if (local_profiles == NULL) { ret = BT_ERROR_OUT_OF_MEMORY; @@ -974,7 +990,7 @@ int bt_adapter_set_remote_oob_data(const char *remote_address, int ret = BT_ERROR_NONE; bluetooth_device_address_t addr_hex = { {0,} }; bt_oob_data_t oob_data = { {0},}; - + BT_CHECK_BT_SUPPORT(); BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(remote_address); @@ -1229,8 +1245,8 @@ static int __bt_remove_ad_data_by_type(char *in_data, unsigned int in_len, BT_ERR("Invalid advertising data"); return BT_ERROR_OPERATION_FAILED; } else if (len == 0 && - in_type != BT_ADAPTER_LE_ADVERTISING_DATA_LOCAL_NAME && - in_type != BT_ADAPTER_LE_ADVERTISING_DATA_TX_POWER_LEVEL) { + in_type != BT_ADAPTER_LE_ADVERTISING_DATA_LOCAL_NAME && + in_type != BT_ADAPTER_LE_ADVERTISING_DATA_TX_POWER_LEVEL) { BT_INFO("AD Type 0x%02x data is not set", in_type); return BT_ERROR_OPERATION_FAILED; } @@ -1253,13 +1269,14 @@ int bt_adapter_le_add_advertising_data(bt_advertiser_h advertiser, bt_adapter_le_packet_type_e pkt_type, bt_adapter_le_packet_data_type_e data_type, void *data, unsigned int data_size) { - int ret = BT_ERROR_NONE; bt_advertiser_s *__adv = (bt_advertiser_s *)advertiser; char **p; unsigned int *len; unsigned int *system_data_len; char *new_p; bt_adapter_le_advertising_data_type_e adv_type; + int adv_flag_len = 0; + int adv_ext_len = 0; adv_type = (bt_adapter_le_advertising_data_type_e)data_type; @@ -1278,6 +1295,7 @@ int bt_adapter_le_add_advertising_data(bt_advertiser_h advertiser, p = &__adv->adv_data; len = &__adv->adv_data_len; system_data_len = &__adv->adv_system_data_len; + adv_flag_len = 3; } else if (pkt_type == BT_ADAPTER_LE_PACKET_SCAN_RESPONSE) { p = &__adv->scan_rsp_data; len = &__adv->scan_rsp_data_len; @@ -1287,11 +1305,11 @@ int bt_adapter_le_add_advertising_data(bt_advertiser_h advertiser, if (adv_type == BT_ADAPTER_LE_ADVERTISING_DATA_LOCAL_NAME || adv_type == BT_ADAPTER_LE_ADVERTISING_DATA_TX_POWER_LEVEL) - *system_data_len += 1; + adv_ext_len = *system_data_len + 1; /* 2 bytes are required for Length and AD Type */ - if (*len + *system_data_len + data_size + 2 > 31) { - BT_ERR("Quota exceeded.(0x%08x)", ret); + if (adv_flag_len + *len + adv_ext_len + data_size + 2 > 31) { + BT_ERR("Quota exceeded"); return BT_ERROR_QUOTA_EXCEEDED; } @@ -1310,7 +1328,12 @@ int bt_adapter_le_add_advertising_data(bt_advertiser_h advertiser, *p = new_p; *len += data_size + 2; - return ret; + + if (adv_type == BT_ADAPTER_LE_ADVERTISING_DATA_LOCAL_NAME || + adv_type == BT_ADAPTER_LE_ADVERTISING_DATA_TX_POWER_LEVEL) + *system_data_len += 1; + + return BT_ERROR_NONE; } int bt_adapter_le_remove_advertising_data(bt_advertiser_h advertiser, @@ -1373,6 +1396,9 @@ static int __bt_convert_string_to_uuid(const char *string, char **uuid, int *bit unsigned short val; char *stop; data = g_malloc0(sizeof(char) * 2); + if (data == NULL) + return BT_ERROR_OUT_OF_MEMORY; + val = strtol(string, &stop, 16); val = htons(val); memcpy(data, &val, 2); @@ -1491,14 +1517,19 @@ static int __bt_append_adv_type_data(bt_advertiser_h advertiser, char *new_adv = NULL; char *adv_data = NULL; int adv_len = 0; + int adv_flag_len = 0; + int system_data_len = 0; bt_advertiser_s *__adv = (bt_advertiser_s *)advertiser; if (pkt_type == BT_ADAPTER_LE_PACKET_ADVERTISING) { adv_data = __adv->adv_data; adv_len = __adv->adv_data_len; + system_data_len = __adv->adv_system_data_len; + adv_flag_len = 3; } else if (pkt_type == BT_ADAPTER_LE_PACKET_SCAN_RESPONSE) { adv_data = __adv->scan_rsp_data; adv_len = __adv->scan_rsp_data_len; + system_data_len = __adv->scan_rsp_system_data_len; } else return BT_ERROR_INVALID_PARAMETER; @@ -1512,6 +1543,11 @@ static int __bt_append_adv_type_data(bt_advertiser_h advertiser, return BT_ERROR_INVALID_PARAMETER; } + if (adv_flag_len + adv_len + system_data_len + new_data_len > 31) { + BT_ERR("Quota exceeded"); + return BT_ERROR_QUOTA_EXCEEDED; + } + new_adv = g_malloc0(adv_len + new_data_len); if (!new_adv) return BT_ERROR_OUT_OF_MEMORY; @@ -2372,7 +2408,8 @@ int bt_adapter_le_get_scan_result_device_name(const bt_adapter_le_device_scan_re while (adv_length > 0) { field_len = adv_data[0]; - if (adv_data[1] == BT_ADAPTER_LE_ADVERTISING_DATA_LOCAL_NAME) { + if (adv_data[1] == BT_ADAPTER_LE_ADVERTISING_DATA_LOCAL_NAME || + adv_data[1] == BT_ADAPTER_LE_ADVERTISING_DATA_SHORT_LOCAL_NAME) { *name = g_malloc0(sizeof(char) * field_len); /* Fix : NULL_RETURNS */ if (*name == NULL) @@ -2416,7 +2453,10 @@ int bt_adapter_le_get_scan_result_tx_power_level(const bt_adapter_le_device_scan while (adv_length > 0) { field_len = adv_data[0]; if (adv_data[1] == BT_ADAPTER_LE_ADVERTISING_DATA_TX_POWER_LEVEL) { - *power_level = (int)adv_data[2]; + if (adv_data[2] & 0x80) + *power_level = 0xffffff00 | adv_data[2]; + else + *power_level = (int)adv_data[2]; return BT_ERROR_NONE; } @@ -2638,8 +2678,9 @@ int bt_adapter_le_get_scan_result_appearance(const bt_adapter_le_device_scan_res while (adv_length > 0) { field_len = adv_data[0]; if (adv_data[1] == BT_ADAPTER_LE_ADVERTISING_DATA_APPEARANCE) { - *appearance = (int)adv_data[2]; - *appearance |= (int)adv_data[3] << 8; + *appearance = adv_data[3] << 8; + *appearance += adv_data[2]; + return BT_ERROR_NONE; } @@ -3056,3 +3097,95 @@ int bt_adapter_le_unregister_all_scan_filters(void) return BT_ERROR_NONE; } + +int bt_adapter_le_read_maximum_data_length( + int *max_tx_octets, int *max_tx_time, + int *max_rx_octets, int *max_rx_time) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + bluetooth_le_read_maximum_data_length_t max_le_datalength; + + ret = _bt_get_error_code( + bluetooth_le_read_maximum_data_length(&max_le_datalength)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + return ret; + } + + *max_tx_octets = max_le_datalength.max_tx_octets; + *max_tx_time = max_le_datalength.max_tx_time; + *max_rx_octets = max_le_datalength.max_rx_octets; + *max_rx_time = max_le_datalength.max_rx_time; + + return ret; +} + +int bt_adapter_le_write_host_suggested_default_data_length( + const unsigned int def_tx_Octets, const unsigned int def_tx_Time) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + /*Range for host suggested txtime is 0x001B-0x00FB and + txocets is 0x0148- 0x0848 as per BT 4.2 spec*/ + if (((def_tx_Octets < 27 || def_tx_Octets > 251) || + (def_tx_Time < 328 || def_tx_Time > 2120)) || + ((def_tx_Octets < 0x001B || def_tx_Octets > 0x00FB) || + (def_tx_Time < 0x0148 || def_tx_Time > 0x0848))) { + return BT_ERROR_INVALID_PARAMETER; + } + + ret = _bt_get_error_code( + bluetooth_le_write_host_suggested_default_data_length( + def_tx_Octets, def_tx_Time)); + + if (ret != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + + return ret; +} + +int bt_adapter_le_read_suggested_default_data_length( + unsigned int *def_tx_Octets, unsigned int *def_tx_Time) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + bluetooth_le_read_host_suggested_data_length_t data_values; + + ret = _bt_get_error_code( + bluetooth_le_read_suggested_default_data_length(&data_values)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + return ret; + } + + *def_tx_Octets = data_values.def_tx_octets; + *def_tx_Time = data_values.def_tx_time; + + return ret; +} + +int bt_adapter_set_authentication_req_cb(bt_adapter_authentication_req_cb callback, void *user_data) +{ + BT_CHECK_INIT_STATUS(); + _bt_set_cb(BT_EVENT_AUTHENTICATION_REQUEST, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_adapter_unset_authentication_req_cb(void) +{ + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_AUTHENTICATION_REQUEST); + return BT_ERROR_NONE; +} diff --git a/src/bluetooth-audio.c b/src/bluetooth-audio.c index 369c727..9801a26 100644 --- a/src/bluetooth-audio.c +++ b/src/bluetooth-audio.c @@ -20,6 +20,7 @@ #include <string.h> #include "bluetooth.h" #include "bluetooth_internal.h" +#include "bluetooth_extension.h" #include "bluetooth_private.h" #include "bluetooth-audio-api.h" #include "bluetooth-telephony-api.h" @@ -29,7 +30,11 @@ typedef struct _call_list_s { GList *list; } call_list_s; -static bool is_audio_initialized = false; +static bool is_audio_a2dp_initialized = false; +#ifdef TIZEN_WEARABLE +static bool is_audio_hf_initialized = false; +#endif +static bool is_audio_ag_initialized = false; #if defined (TIZEN_HFP_DISABLE) && defined (TIZEN_A2DP_DISABLE) #define BT_CHECK_AUDIO_SUPPORT() \ @@ -64,22 +69,44 @@ static bool is_audio_initialized = false; #define BT_CHECK_A2DP_SUPPORT() #endif +#ifdef TIZEN_AUDIO_HF_DISABLE +#define BT_CHECK_HF_SUPPORT() \ + { \ + BT_CHECK_BT_SUPPORT(); \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_HF_SUPPORT() +#endif + #define BT_CHECK_AUDIO_INIT_STATUS() \ - if (__bt_check_audio_init_status() == BT_ERROR_NOT_INITIALIZED) \ + if (is_audio_a2dp_initialized != true && is_audio_ag_initialized != true) \ { \ LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \ return BT_ERROR_NOT_INITIALIZED; \ } -int __bt_check_audio_init_status(void) -{ - if (is_audio_initialized != true) { - BT_ERR("NOT_INITIALIZED(0x%08x)", BT_ERROR_NOT_INITIALIZED); - return BT_ERROR_NOT_INITIALIZED; +#define BT_CHECK_A2DP_INIT_STATUS() \ + if (is_audio_a2dp_initialized != true) \ + { \ + LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \ + return BT_ERROR_NOT_INITIALIZED; \ } - return BT_ERROR_NONE; -} +#define BT_CHECK_HF_INIT_STATUS() \ + if (is_audio_hf_initialized != true) \ + { \ + LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \ + return BT_ERROR_NOT_INITIALIZED; \ + } + +#define BT_CHECK_AG_INIT_STATUS() \ + if (is_audio_ag_initialized != true) \ + { \ + LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \ + return BT_ERROR_NOT_INITIALIZED; \ + } /*The below API is just to convert the error from Telephony API's to CAPI error codes, * this is temporary change and changes to proper error code will be done in @@ -124,32 +151,41 @@ int bt_audio_initialize(void) BT_CHECK_AUDIO_SUPPORT(); BT_CHECK_INIT_STATUS(); + error = bluetooth_audio_init(_bt_audio_event_proxy, NULL); error = _bt_get_error_code(error); - if (BT_ERROR_NONE != error) { + if (BT_ERROR_NONE != error) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); - return error; - } + else + is_audio_a2dp_initialized = true; #ifdef TIZEN_WEARABLE error = bluetooth_hf_init(_bt_hf_event_proxy, NULL); error = _bt_get_error_code(error); - if (BT_ERROR_NONE != error) { + if (BT_ERROR_NONE != error) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); - return error; - } + else + is_audio_hf_initialized = true; #endif #ifndef TELEPHONY_DISABLED /* B2_3G */ error = bluetooth_telephony_init((void *)_bt_telephony_event_proxy, NULL); error = _bt_convert_telephony_error_code(error); - if (BT_ERROR_NONE != error) { + if (BT_ERROR_NONE != error) BT_ERR("[%s] (0x%08x)", _bt_convert_error_to_string(error), error); - return error; - } + else + is_audio_ag_initialized = true; #endif - is_audio_initialized = true; + /* There is no success case for 3 profiles */ + if (!is_audio_a2dp_initialized && +#ifdef TIZEN_WEARABLE + !is_audio_hf_initialized && +#endif + !is_audio_ag_initialized) { + return BT_ERROR_OPERATION_FAILED; + } + return BT_ERROR_NONE; } @@ -159,34 +195,32 @@ int bt_audio_deinitialize(void) BT_CHECK_AUDIO_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); -#ifdef TIZEN_WEARABLE - error = bluetooth_hf_deinit(); + error = bluetooth_audio_deinit(); error = _bt_get_error_code(error); - if (BT_ERROR_NONE != error) { + if (BT_ERROR_NONE != error) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); - return error; - } -#endif - error = bluetooth_audio_deinit(); + is_audio_a2dp_initialized = false; + +#ifdef TIZEN_WEARABLE + error = bluetooth_hf_deinit(); error = _bt_get_error_code(error); - if (BT_ERROR_NONE != error) { + if (BT_ERROR_NONE != error) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); - return error; - } + + is_audio_hf_initialized = false; +#endif #ifndef TELEPHONY_DISABLED /* B2_3G */ error = bluetooth_telephony_deinit(); error = _bt_convert_telephony_error_code(error); - if (BT_ERROR_NONE != error) { + if (BT_ERROR_NONE != error) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); - return error; - } + + is_audio_ag_initialized = false; #endif - is_audio_initialized = false; return BT_ERROR_NONE; } @@ -197,22 +231,21 @@ int bt_audio_connect(const char *remote_address, bt_audio_profile_type_e type) BT_CHECK_AUDIO_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); if (type == BT_AUDIO_PROFILE_TYPE_HSP_HFP) { BT_CHECK_HFP_SUPPORT(); -#ifdef TELEPHONY_DISABLED - BT_ERR("NOT SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif + BT_CHECK_AG_INIT_STATUS(); } else if (type == BT_AUDIO_PROFILE_TYPE_A2DP) { BT_CHECK_A2DP_SUPPORT(); + BT_CHECK_A2DP_INIT_STATUS(); } else if (type == BT_AUDIO_PROFILE_TYPE_ALL) { #if defined (TIZEN_HFP_DISABLE) || defined (TELEPHONY_DISABLED) + BT_CHECK_A2DP_INIT_STATUS(); BT_ERR("HSP NOT SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); type = BT_AUDIO_PROFILE_TYPE_A2DP; #else - BT_ERR("ALL SUPPORTED"); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_ERR("HSP and A2DP SUPPORTED"); type = BT_AUDIO_PROFILE_TYPE_ALL; #endif } @@ -252,16 +285,23 @@ int bt_audio_disconnect(const char *remote_address, bt_audio_profile_type_e type BT_CHECK_AUDIO_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); if (type == BT_AUDIO_PROFILE_TYPE_HSP_HFP) { BT_CHECK_HFP_SUPPORT(); -#ifdef TELEPHONY_DISABLED - BT_ERR("NOT SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif + BT_CHECK_AG_INIT_STATUS(); } else if (type == BT_AUDIO_PROFILE_TYPE_A2DP) { BT_CHECK_A2DP_SUPPORT(); + BT_CHECK_A2DP_INIT_STATUS(); + } else if (type == BT_AUDIO_PROFILE_TYPE_ALL) { +#if defined (TIZEN_HFP_DISABLE) || defined (TELEPHONY_DISABLED) + BT_CHECK_A2DP_INIT_STATUS(); + BT_ERR("HSP NOT SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); + type = BT_AUDIO_PROFILE_TYPE_A2DP; +#else + BT_CHECK_AUDIO_INIT_STATUS(); + BT_ERR("HSP and A2DP SUPPORTED"); + type = BT_AUDIO_PROFILE_TYPE_ALL; +#endif } BT_CHECK_INPUT_PARAMETER(remote_address); @@ -312,34 +352,13 @@ int bt_audio_unset_connection_state_changed_cb(void) return BT_ERROR_NONE; } -int bt_a2dp_source_audio_set_connection_state_changed_cb(bt_audio_connection_state_changed_cb callback, void *user_data) -{ - BT_CHECK_AUDIO_SUPPORT(); - BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); - BT_CHECK_INPUT_PARAMETER(callback); - _bt_set_cb(BT_EVENT_A2DP_SOURCE_CONNECTION_STATUS, callback, user_data); - return BT_ERROR_NONE; - -} - -int bt_a2dp_source_audio_unset_connection_state_changed_cb(void) -{ - BT_CHECK_AUDIO_SUPPORT(); - BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); - if (_bt_check_cb(BT_EVENT_A2DP_SOURCE_CONNECTION_STATUS) == true) - _bt_unset_cb(BT_EVENT_A2DP_SOURCE_CONNECTION_STATUS); - return BT_ERROR_NONE; -} - int bt_ag_notify_speaker_gain(int gain) { int error; BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); error = bluetooth_telephony_set_speaker_gain((unsigned short)gain); error = _bt_convert_telephony_error_code(error); if (BT_ERROR_NONE != error) { @@ -354,7 +373,7 @@ int bt_ag_get_speaker_gain(int *gain) BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(gain); error = bluetooth_telephony_get_headset_volume((unsigned int *)gain); error = _bt_convert_telephony_error_code(error); @@ -371,7 +390,7 @@ int bt_ag_is_nrec_enabled(bool *enabled) BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(enabled); error = bluetooth_telephony_is_nrec_enabled(&is_enabled); @@ -394,7 +413,7 @@ int bt_ag_is_wbs_mode(bool *wbs_mode) BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(wbs_mode); error = bluetooth_telephony_is_wbs_mode(&is_wbs_mode); @@ -415,7 +434,7 @@ int bt_ag_set_microphone_gain_changed_cb(bt_ag_microphone_gain_changed_cb callba BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); _bt_set_cb(BT_EVENT_AG_MICROPHONE_GAIN_CHANGE, callback, user_data); return BT_ERROR_NONE; @@ -425,7 +444,7 @@ int bt_ag_unset_microphone_gain_changed_cb(void) { BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); if (_bt_check_cb(BT_EVENT_AG_MICROPHONE_GAIN_CHANGE) == true) _bt_unset_cb(BT_EVENT_AG_MICROPHONE_GAIN_CHANGE); return BT_ERROR_NONE; @@ -436,7 +455,7 @@ int bt_ag_set_speaker_gain_changed_cb(bt_ag_speaker_gain_changed_cb callback, { BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); _bt_set_cb(BT_EVENT_AG_SPEAKER_GAIN_CHANGE, callback, user_data); return BT_ERROR_NONE; @@ -447,7 +466,7 @@ int bt_ag_unset_speaker_gain_changed_cb(void) BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); if (_bt_check_cb(BT_EVENT_AG_SPEAKER_GAIN_CHANGE) == true) _bt_unset_cb(BT_EVENT_AG_SPEAKER_GAIN_CHANGE); return BT_ERROR_NONE; @@ -459,7 +478,7 @@ int bt_ag_open_sco(void) BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); error = bluetooth_telephony_audio_open(); error = _bt_convert_telephony_error_code(error); if (error != BT_ERROR_NONE) { @@ -474,7 +493,7 @@ int bt_ag_close_sco(void) BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); error = bluetooth_telephony_audio_close(); error = _bt_convert_telephony_error_code(error); if (error != BT_ERROR_NONE) { @@ -487,7 +506,7 @@ int bt_ag_is_sco_opened(bool *opened) { BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(opened); if (bluetooth_telephony_is_sco_connected()) *opened = true; @@ -501,7 +520,7 @@ int bt_ag_set_sco_state_changed_cb(bt_ag_sco_state_changed_cb callback, { BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); _bt_set_cb(BT_EVENT_AG_SCO_CONNECTION_STATUS, callback, user_data); return BT_ERROR_NONE; @@ -511,7 +530,7 @@ int bt_ag_unset_sco_state_changed_cb(void) { BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); if (_bt_check_cb(BT_EVENT_AG_SCO_CONNECTION_STATUS) == true) _bt_unset_cb(BT_EVENT_AG_SCO_CONNECTION_STATUS); return BT_ERROR_NONE; @@ -523,7 +542,7 @@ int bt_ag_notify_call_event(bt_ag_call_event_e event, unsigned int call_id, cons BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_INFO("call_id [%d] / event [%d]", call_id, event); switch(event) { @@ -570,7 +589,7 @@ int bt_ag_notify_call_list(bt_call_list_h list) BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(list); handle = (call_list_s *)list; call_count = g_list_length(handle->list); @@ -588,7 +607,7 @@ int bt_ag_notify_voice_recognition_state(bool state) BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); if (state) error = bluetooth_telephony_start_voice_recognition(); else @@ -605,7 +624,7 @@ int bt_ag_set_call_handling_event_cb(bt_ag_call_handling_event_cb callback, { BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); _bt_set_cb(BT_EVENT_AG_CALL_HANDLING_EVENT, callback, user_data); return BT_ERROR_NONE; @@ -615,7 +634,7 @@ int bt_ag_unset_call_handling_event_cb(void) { BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); if (_bt_check_cb(BT_EVENT_AG_CALL_HANDLING_EVENT) == true) _bt_unset_cb(BT_EVENT_AG_CALL_HANDLING_EVENT); return BT_ERROR_NONE; @@ -627,7 +646,7 @@ int bt_ag_set_multi_call_handling_event_cb( { BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); _bt_set_cb(BT_EVENT_AG_MULTI_CALL_HANDLING_EVENT, callback, user_data); return BT_ERROR_NONE; @@ -637,7 +656,7 @@ int bt_ag_unset_multi_call_handling_event_cb(void) { BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); if (_bt_check_cb(BT_EVENT_AG_MULTI_CALL_HANDLING_EVENT) == true) _bt_unset_cb(BT_EVENT_AG_MULTI_CALL_HANDLING_EVENT); return BT_ERROR_NONE; @@ -648,7 +667,7 @@ int bt_ag_set_dtmf_transmitted_cb(bt_ag_dtmf_transmitted_cb callback, { BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(callback); _bt_set_cb(BT_EVENT_AG_DTMF_TRANSMITTED, callback, user_data); return BT_ERROR_NONE; @@ -658,7 +677,7 @@ int bt_ag_unset_dtmf_transmitted_cb(void) { BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); if (_bt_check_cb(BT_EVENT_AG_DTMF_TRANSMITTED) == true) _bt_unset_cb(BT_EVENT_AG_DTMF_TRANSMITTED); return BT_ERROR_NONE; @@ -671,6 +690,7 @@ int bt_ag_is_connected(bool *connected) BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(connected); error = bluetooth_telephony_is_connected(&is_connected); @@ -692,7 +712,7 @@ int bt_call_list_create(bt_call_list_h *list) BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(list); if (*list != NULL) { BT_ERR("BT_ERROR_ALREADY_DONE(0x%08x)", BT_ERROR_ALREADY_DONE); @@ -715,7 +735,7 @@ int bt_call_list_destroy(bt_call_list_h list) BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(list); handle = (call_list_s *)list; result = bt_call_list_reset(list); @@ -730,7 +750,7 @@ int bt_call_list_reset(bt_call_list_h list) BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(list); handle = (call_list_s *)list; do { @@ -754,7 +774,7 @@ int bt_call_list_add(bt_call_list_h list, unsigned int call_id, bt_ag_call_state BT_CHECK_HFP_SUPPORT(); BT_CHECK_INIT_STATUS(); - BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_AG_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(list); BT_CHECK_INPUT_PARAMETER(phone_number); @@ -772,10 +792,29 @@ int bt_call_list_add(bt_call_list_h list, unsigned int call_id, bt_ag_call_state return BT_ERROR_NONE; } +int bt_a2dp_set_content_protection(bool status) +{ + int error; + + BT_CHECK_A2DP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_A2DP_INIT_STATUS(); + + error = bluetooth_a2dp_set_content_protection(status); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } + return error; +} + #ifdef TIZEN_WEARABLE int bt_hf_initialize(void) { -#ifdef TIZEN_AUDIO_HF_SUPPORT + BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); + int error; BT_CHECK_INIT_STATUS(); @@ -786,15 +825,13 @@ int bt_hf_initialize(void) return error; } return error; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_deinitialize(void) { -#ifdef TIZEN_AUDIO_HF_SUPPORT + BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); + int error; BT_CHECK_INIT_STATUS(); @@ -805,18 +842,15 @@ int bt_hf_deinitialize(void) return error; } return error; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_notify_call_event(bt_hf_call_event_e event, char *phone_number) { -#ifdef TIZEN_AUDIO_HF_SUPPORT + BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); + int error = BT_ERROR_NONE; - BT_CHECK_INIT_STATUS(); BT_INFO("event [%d]", event); switch(event) { @@ -858,145 +892,117 @@ int bt_hf_notify_call_event(bt_hf_call_event_e event, char *phone_number) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); } return error; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_notify_speaker_gain(int gain) { -#ifdef TIZEN_AUDIO_HF_SUPPORT + BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); + int error; - BT_CHECK_INIT_STATUS(); error = bluetooth_hf_set_speaker_gain((unsigned int)gain); error = _bt_get_error_code(error); if (BT_ERROR_NONE != error) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); return error; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_set_speaker_gain_changed_cb(bt_hf_speaker_gain_changed_cb callback, void *user_data) { -#ifdef TIZEN_AUDIO_HF_SUPPORT BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_HF_SPEAKER_GAIN_CHANGE, callback, user_data); return BT_ERROR_NONE; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_unset_speaker_gain_changed_cb(void) { -#ifdef TIZEN_AUDIO_HF_SUPPORT BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); + if (_bt_check_cb(BT_EVENT_HF_SPEAKER_GAIN_CHANGE) == true) _bt_unset_cb(BT_EVENT_HF_SPEAKER_GAIN_CHANGE); return BT_ERROR_NONE; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_notify_voice_recognition_state(bool state) { -#ifdef TIZEN_AUDIO_HF_SUPPORT + BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); + int error; - BT_CHECK_INIT_STATUS(); error = bluetooth_hf_voice_recognition(state); error = _bt_get_error_code(error); if (error != BT_ERROR_NONE) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); return error; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_set_call_status_updated_event_cb(bt_hf_call_status_updated_event_cb callback, void *user_data) { -#ifdef TIZEN_AUDIO_HF_SUPPORT BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); + BT_CHECK_INPUT_PARAMETER(callback); _bt_set_cb(BT_EVENT_HF_CALL_STATUS_UPDATED_EVENT, callback, user_data); return BT_ERROR_NONE; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_unset_call_status_updated_event_cb(void) { -#ifdef TIZEN_AUDIO_HF_SUPPORT BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); + if (_bt_check_cb(BT_EVENT_HF_CALL_STATUS_UPDATED_EVENT) == true) _bt_unset_cb(BT_EVENT_HF_CALL_STATUS_UPDATED_EVENT); return BT_ERROR_NONE; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_close_sco(void) { -#ifdef TIZEN_AUDIO_HF_SUPPORT + BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); + int error; - BT_CHECK_INIT_STATUS(); error = bluetooth_hf_audio_disconnect(); error = _bt_get_error_code(error); if (error != BT_ERROR_NONE) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); return error; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_send_dtmf(char *dtmf) { -#ifdef TIZEN_AUDIO_HF_SUPPORT + BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); + int error; - BT_CHECK_INIT_STATUS(); error = bluetooth_hf_send_dtmf(dtmf); error = _bt_get_error_code(error); if (error != BT_ERROR_NONE) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); return error; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_is_connected(bool *connected) { -#ifdef TIZEN_AUDIO_HF_SUPPORT - int error; - gboolean is_connected = false; - BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); BT_CHECK_INPUT_PARAMETER(connected); + int error; + gboolean is_connected = false; + error = bluetooth_hf_is_connected(&is_connected); error = _bt_get_error_code(error); if (error != BT_ERROR_NONE) @@ -1008,21 +1014,17 @@ int bt_hf_is_connected(bool *connected) *connected = false; return error; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_is_sco_opened(bool *opened) { -#ifdef TIZEN_AUDIO_HF_SUPPORT - int error; - unsigned int audio_connected = BLUETOOTH_HF_AUDIO_DISCONNECTED; - BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); BT_CHECK_INPUT_PARAMETER(opened); + int error; + unsigned int audio_connected = BLUETOOTH_HF_AUDIO_DISCONNECTED; + error = bluetooth_hf_get_audio_connected(&audio_connected); error = _bt_get_error_code(error); if (error != BT_ERROR_NONE) @@ -1034,42 +1036,34 @@ int bt_hf_is_sco_opened(bool *opened) *opened = false; return error; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_get_codec_id(unsigned int *codec_id) { -#ifdef TIZEN_AUDIO_HF_SUPPORT - int error; - BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); BT_CHECK_INPUT_PARAMETER(codec_id); + int error; + error = bluetooth_hf_get_codec(codec_id); error = _bt_get_error_code(error); if (error != BT_ERROR_NONE) BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); return error; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_get_call_status_info_list(GSList **call_list) { -#ifdef TIZEN_AUDIO_HF_SUPPORT + BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); + BT_CHECK_INPUT_PARAMETER(call_list); + int error; bt_hf_call_list_s *hf_call_list = NULL; GList *l; - BT_CHECK_INIT_STATUS(); - BT_CHECK_INPUT_PARAMETER(call_list); - error = bluetooth_hf_request_call_list(&hf_call_list); error = _bt_get_error_code(error); if (error != BT_ERROR_NONE) { @@ -1094,115 +1088,86 @@ int bt_hf_get_call_status_info_list(GSList **call_list) bluetooth_hf_free_call_list(hf_call_list); return error; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } -#ifdef TIZEN_AUDIO_HF_SUPPORT static void __bt_hf_free_call_status_info(void *data) { bt_hf_call_status_info_s *call_info = (bt_hf_call_status_info_s*)data; g_free(call_info->number); g_free(call_info); } -#endif int bt_hf_free_call_status_info_list(GSList *call_list) { -#ifdef TIZEN_AUDIO_HF_SUPPORT BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); BT_CHECK_INPUT_PARAMETER(call_list); g_slist_free_full(call_list, __bt_hf_free_call_status_info); return BT_ERROR_NONE; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_set_sco_state_changed_cb(bt_hf_sco_state_changed_cb callback, void *user_data) { -#ifdef TIZEN_AUDIO_HF_SUPPORT BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); BT_CHECK_INPUT_PARAMETER(callback); _bt_set_cb(BT_EVENT_HF_SCO_CONNECTION_STATUS, callback, user_data); return BT_ERROR_NONE; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_unset_sco_state_changed_cb(void) { -#ifdef TIZEN_AUDIO_HF_SUPPORT BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); + if (_bt_check_cb(BT_EVENT_HF_SCO_CONNECTION_STATUS) == true) _bt_unset_cb(BT_EVENT_HF_SCO_CONNECTION_STATUS); return BT_ERROR_NONE; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_set_call_handling_event_cb(bt_hf_call_handling_event_cb callback, void *user_data) { -#ifdef TIZEN_AUDIO_HF_SUPPORT BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_HF_CALL_HANDLING_EVENT, callback, user_data); return BT_ERROR_NONE; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_unset_call_handling_event_cb(void) { -#ifdef TIZEN_AUDIO_HF_SUPPORT BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); + if (_bt_check_cb(BT_EVENT_HF_CALL_HANDLING_EVENT) == true) _bt_unset_cb(BT_EVENT_HF_CALL_HANDLING_EVENT); return BT_ERROR_NONE; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_set_multi_call_handling_event_cb( bt_hf_multi_call_handling_event_cb callback, void *user_data) { -#ifdef TIZEN_AUDIO_HF_SUPPORT BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_HF_MULTI_CALL_HANDLING_EVENT, callback, user_data); return BT_ERROR_NONE; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } int bt_hf_unset_multi_call_handling_event_cb(void) { -#ifdef TIZEN_AUDIO_HF_SUPPORT BT_CHECK_INIT_STATUS(); + BT_CHECK_HF_SUPPORT(); + if (_bt_check_cb(BT_EVENT_HF_MULTI_CALL_HANDLING_EVENT) == true) _bt_unset_cb(BT_EVENT_HF_MULTI_CALL_HANDLING_EVENT); return BT_ERROR_NONE; -#else - BT_ERR("NOT_SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); - return BT_ERROR_NOT_SUPPORTED; -#endif } #endif diff --git a/src/bluetooth-avrcp.c b/src/bluetooth-avrcp.c index d737a10..1898050 100644 --- a/src/bluetooth-avrcp.c +++ b/src/bluetooth-avrcp.c @@ -372,6 +372,7 @@ int bt_avrcp_control_get_equalizer_state(bt_avrcp_equalizer_state_e *state) BT_CHECK_AVRCP_SUPPORT(); BT_CHECK_INIT_STATUS(); BT_CHECK_AVRCP_CONTROL_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(state); error = bluetooth_media_control_get_property(EQUALIZER, state); error = _bt_convert_avrcp_error_code(error); error = _bt_get_error_code(error); @@ -404,6 +405,7 @@ int bt_avrcp_control_get_repeat_mode(bt_avrcp_repeat_mode_e *mode) BT_CHECK_AVRCP_SUPPORT(); BT_CHECK_INIT_STATUS(); BT_CHECK_AVRCP_CONTROL_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(mode); error = bluetooth_media_control_get_property(REPEAT, mode); error = _bt_convert_avrcp_error_code(error); error = _bt_get_error_code(error); @@ -436,6 +438,7 @@ int bt_avrcp_control_get_shuffle_mode(bt_avrcp_shuffle_mode_e *mode) BT_CHECK_AVRCP_SUPPORT(); BT_CHECK_INIT_STATUS(); BT_CHECK_AVRCP_CONTROL_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(mode); error = bluetooth_media_control_get_property(SHUFFLE, mode); error = _bt_convert_avrcp_error_code(error); error = _bt_get_error_code(error); @@ -467,6 +470,7 @@ int bt_avrcp_control_get_scan_mode(bt_avrcp_scan_mode_e *mode) BT_CHECK_AVRCP_SUPPORT(); BT_CHECK_INIT_STATUS(); BT_CHECK_AVRCP_CONTROL_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(mode); error = bluetooth_media_control_get_property(SCAN, mode); error = _bt_convert_avrcp_error_code(error); error = _bt_get_error_code(error); @@ -483,6 +487,7 @@ int bt_avrcp_control_get_position(unsigned int *position) BT_CHECK_AVRCP_SUPPORT(); BT_CHECK_INIT_STATUS(); BT_CHECK_AVRCP_CONTROL_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(position); error = bluetooth_media_control_get_property(POSITION, position); error = _bt_convert_avrcp_error_code(error); error = _bt_get_error_code(error); @@ -499,6 +504,7 @@ int bt_avrcp_control_get_play_status(bt_avrcp_player_state_e *status) BT_CHECK_AVRCP_SUPPORT(); BT_CHECK_INIT_STATUS(); BT_CHECK_AVRCP_CONTROL_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(status); error = bluetooth_media_control_get_property(STATUS, status); error = _bt_convert_avrcp_error_code(error); error = _bt_get_error_code(error); @@ -512,7 +518,7 @@ int bt_avrcp_control_get_track_info(bt_avrcp_metadata_attributes_info_s **track) { int error; media_metadata_attributes_t metadata = {0,}; - bt_avrcp_metadata_attributes_info_s *tr_info; + bt_avrcp_metadata_attributes_info_s *tr_info = NULL; BT_CHECK_AVRCP_SUPPORT(); BT_CHECK_INIT_STATUS(); @@ -526,14 +532,16 @@ int bt_avrcp_control_get_track_info(bt_avrcp_metadata_attributes_info_s **track) } else { tr_info = (bt_avrcp_metadata_attributes_info_s *)g_malloc0( sizeof(bt_avrcp_metadata_attributes_info_s)); - tr_info->title = metadata.title; - tr_info->artist = metadata.artist; - tr_info->album = metadata.album; - tr_info->genre = metadata.genre; - tr_info->total_tracks = metadata.total_tracks; - tr_info->number = metadata.number; - tr_info->duration = metadata.duration; - *track = tr_info; + if (tr_info) { + tr_info->title = metadata.title; + tr_info->artist = metadata.artist; + tr_info->album = metadata.album; + tr_info->genre = metadata.genre; + tr_info->total_tracks = metadata.total_tracks; + tr_info->number = metadata.number; + tr_info->duration = metadata.duration; + *track = tr_info; + } } return error; } diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c index 81e6778..06f199b 100644 --- a/src/bluetooth-common.c +++ b/src/bluetooth-common.c @@ -25,6 +25,7 @@ #include "bluetooth.h" #include "bluetooth_internal.h" +#include "bluetooth_extension.h" #include "bluetooth_private.h" #include "bluetooth-media-control.h" #include "bluetooth-telephony-api.h" @@ -524,6 +525,91 @@ static bt_gatt_server_read_value_requested_cb __bt_gatt_attribute_get_read_cb( return NULL; } +static bt_gatt_server_value_changed_cb __bt_gatt_attribute_get_value_change_cb( + bt_gatt_h service, bt_gatt_h attribute, void **user_data) +{ + gchar *svc_path = (gchar *)service; + gchar *att_path = (gchar *)attribute; + const GSList *gatt_server_list = NULL; + const GSList *l1, *l2, *l3, *l4; + + gatt_server_list = _bt_gatt_get_server_list(); + + for (l1 = gatt_server_list; l1 != NULL; l1 = l1->next) { + bt_gatt_server_s *serv = l1->data; + + if (!serv) + return NULL; + + for (l2 = serv->services; l2 != NULL; l2 = l2->next) { + bt_gatt_service_s *svc = l2->data; + + if (g_strcmp0(svc->path, svc_path) == 0) { + for (l3 = svc->characteristics; l3 != NULL; l3 = l3->next) { + bt_gatt_characteristic_s *chr = l3->data; + + if (chr) { + if (g_strcmp0(chr->path, att_path) == 0) { + if (chr->server_value_changed_cb) { + *user_data = chr->server_value_changed_user_data; + return chr->server_value_changed_cb; + } else + return NULL; + } else { + for (l4 = chr->descriptors; l4 != NULL; l4 = l4->next) { + bt_gatt_descriptor_s *desc = l4->data; + + if (desc && g_strcmp0(desc->path, att_path) == 0) { + /* TODO: Call value changed callback registerd for the descriptor */ + return NULL; + } + } + } + } + } + } + } + } + return NULL; +} + +static bt_gatt_server_notification_state_change_cb __bt_gatt_attribute_get_notification_change_cb( + bt_gatt_h service, bt_gatt_h attribute, void **user_data) +{ + gchar *svc_path = (gchar *)service; + gchar *att_path = (gchar *)attribute; + const GSList *gatt_server_list = NULL; + const GSList *l1, *l2, *l3; + + gatt_server_list = _bt_gatt_get_server_list(); + + for (l1 = gatt_server_list; l1 != NULL; l1 = l1->next) { + bt_gatt_server_s *serv = l1->data; + + if (!serv) + return NULL; + + for (l2 = serv->services; l2 != NULL; l2 = l2->next) { + bt_gatt_service_s *svc = l2->data; + + if (g_strcmp0(svc->path, svc_path) == 0) { + for (l3 = svc->characteristics; l3 != NULL; l3 = l3->next) { + bt_gatt_characteristic_s *chr = l3->data; + + if (chr && g_strcmp0(chr->path, att_path) == 0) { + if (chr->notification_changed_cb) { + *user_data = chr->notification_changed_user_data; + return chr->notification_changed_cb; + } else + return NULL; + } + } + } + } + } + return NULL; +} + static void __bt_free_bt_device_connection_info_s(bt_device_connection_info_s *conn_info) { if (conn_info == NULL) @@ -596,6 +682,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us int *adv_handle; bluetooth_rfcomm_connection_t *connection_ind = NULL; bluetooth_rfcomm_disconnection_t *disconnection_ind = NULL; + bluetooth_hid_request_t *hid_connection_status = NULL; bt_socket_connection_s rfcomm_connection; bt_device_sdp_info_s *sdp_info = NULL; bt_device_connection_info_s *conn_info = NULL; @@ -619,6 +706,8 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us bt_hdp_data_ind_t *hdp_data_ind = NULL; bt_gatt_char_value_t *char_val = NULL; media_metadata_attributes_t *metadata = NULL; + bluetooth_authentication_request_info_t *auth_information = NULL; + bt_le_data_length_params_t *data_length_info = NULL; event_index = __bt_get_cb_index(event); @@ -650,8 +739,9 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us device_addr = NULL; } - if (event == BLUETOOTH_EVENT_GATT_SERVER_CHARACTERISTIC_VALUE_CHANGED || - event == BLUETOOTH_EVENT_ADVERTISING_STARTED || event == BLUETOOTH_EVENT_ADVERTISING_STOPPED) + if (event == BLUETOOTH_EVENT_GATT_SERVER_VALUE_CHANGED || event == BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED || + event == BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED || event == BLUETOOTH_EVENT_ADVERTISING_STARTED || + event == BLUETOOTH_EVENT_ADVERTISING_STOPPED) BT_INFO("NOT use bt_event_slot_container"); else if (event_index == -1 || bt_event_slot_container[event_index].callback == NULL) return; @@ -729,6 +819,58 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us free(device_addr); device_addr = NULL; break; + case BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY: + BT_INFO("bt_adapter_authentication_req_cb() will be called with \ + BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY"); + auth_information = (bluetooth_authentication_request_info_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, &auth_information->device_address); + BT_DBG("BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY: name = %s address = %s passkey = %s", auth_information->device_name.name, + device_addr, auth_information->str_passkey); + + ((bt_adapter_authentication_req_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_AUTH_KEYBOARD_PASSKEY_DISPLAY, auth_information->device_name.name, + device_addr, auth_information->str_passkey, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_PIN_REQUEST: + BT_INFO("bt_adapter_authentication_req_cb() will be called with \ + BLUETOOTH_EVENT_PIN_REQUEST"); + auth_information = (bluetooth_authentication_request_info_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, &auth_information->device_address); + + BT_DBG("BUETOOTH_EVENT_PIN_REQUEST: name = %s address = %s", auth_information->device_name, + device_addr); + + ((bt_adapter_authentication_req_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_AUTH_PIN_REQUEST, auth_information->device_name.name, device_addr, + auth_information->str_passkey, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_PASSKEY_REQUEST: + BT_INFO("bt_adapter_authentication_req_cb will be called with \ + BLUETOOTH_EVENT_PASSKEY_REQUEST"); + + auth_information = (bluetooth_authentication_request_info_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, &auth_information->device_address); + + BT_DBG("BLUETOOTH_EVENT_PASSKEY_REQUEST: name = %s address = %s", auth_information->device_name, + device_addr); + + ((bt_adapter_authentication_req_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_AUTH_PIN_REQUEST, auth_information->device_name.name, device_addr, + auth_information->str_passkey, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST: + BT_INFO("bt_adapter_authentication_req_cb will be called with \ + BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST"); + + auth_information = (bluetooth_authentication_request_info_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, &auth_information->device_address); + + BT_DBG("BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST: name = %s address = %s passkey = %s ", + auth_information->device_name.name, device_addr, auth_information->str_passkey); + ((bt_adapter_authentication_req_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_AUTH_PASSKEY_CONFIRM_REQUEST, auth_information->device_name.name, device_addr, + auth_information->str_passkey, bt_event_slot_container[event_index].user_data); + break; case BLUETOOTH_EVENT_DEVICE_AUTHORIZED: BT_INFO("bt_device_authorization_changed_cb() will be called with BT_DEVICE_AUTHORIZED"); _bt_convert_address_to_string(&device_addr, (bluetooth_device_address_t *)(param->param_data)); @@ -1147,7 +1289,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us bt_event_slot_container[event_index].user_data); break; case BLUETOOTH_EVENT_AV_DISCONNECTED: - BT_INFO("BLUETOOTH_EVENT_Av_DISCONNECTED "); + BT_INFO("BLUETOOTH_EVENT_AV_DISCONNECTED "); device_addr = (char *)(param->param_data); ((bt_audio_connection_state_changed_cb)bt_event_slot_container[event_index].callback) (_bt_get_error_code(param->result), FALSE, device_addr, BT_AUDIO_PROFILE_TYPE_A2DP, @@ -1271,13 +1413,42 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us if (device_addr != NULL) free(device_addr); break; - case BLUETOOTH_EVENT_GATT_CONNECTED: + case BLUETOOTH_HID_DEVICE_CONNECTED: + BT_INFO("BLUETOOTH_HID_DEVICE_CONNECTED"); + hid_connection_status = (bluetooth_hid_request_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, + &(hid_connection_status->device_addr)); + ((bt_hid_device_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), TRUE, device_addr, bt_event_slot_container[event_index].user_data); + + g_free(device_addr); + break; + case BLUETOOTH_HID_DEVICE_DISCONNECTED: + BT_INFO("BLUETOOTH_HID_DEVICE_DISCONNECTED"); + hid_connection_status = (bluetooth_hid_request_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, + &(hid_connection_status->device_addr)); + ((bt_hid_device_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), FALSE, device_addr, bt_event_slot_container[event_index].user_data); + + g_free(device_addr); + break; + case BLUETOOTH_HID_DEVICE_DATA_RECEIVED: + BT_INFO("HID Device Data"); + ((bt_hid_device_data_received_cb)bt_event_slot_container[event_index].callback) + ((bt_hid_device_received_data_s *)(param->param_data), bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_GATT_CONNECTED: { BT_INFO("BLUETOOTH_EVENT_GATT_CONNECTED"); + gboolean connected = TRUE; bd_addr = (bluetooth_device_address_t *)(param->param_data); _bt_convert_address_to_string(&device_addr, bd_addr); + if (_bt_get_error_code(param->result) != BT_ERROR_NONE) + connected = FALSE; ((bt_gatt_connection_state_changed_cb)bt_event_slot_container[event_index].callback) - (_bt_get_error_code(param->result), TRUE, device_addr, - bt_event_slot_container[event_index].user_data); + (_bt_get_error_code(param->result), connected, device_addr, + bt_event_slot_container[event_index].user_data); + } break; case BLUETOOTH_EVENT_GATT_DISCONNECTED: BT_INFO("BLUETOOTH_EVENT_GATT_DISCONNECTED"); @@ -1422,17 +1593,61 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us bt_gatt_server_read_value_requested_cb cb; void *user_data = NULL; cb = __bt_gatt_attribute_get_read_cb(read_req->service_handle, - read_req->char_handle, &user_data); + read_req->att_handle, &user_data); BT_INFO("BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED"); - if (cb == NULL) + if (cb == NULL) { + bluetooth_gatt_send_response(read_req->req_id, + BLUETOOTH_GATT_ATT_REQUEST_TYPE_READ, + BLUETOOTH_ERROR_INTERNAL, 0, NULL, 0); return; + } cb(read_req->address, read_req->req_id, read_req->service_handle, - read_req->char_handle, read_req->offset, + read_req->att_handle, read_req->offset, user_data); break; } + case BLUETOOTH_EVENT_GATT_SERVER_VALUE_CHANGED: { + bt_gatt_value_change_t *value_change = param->param_data; + bt_gatt_server_value_changed_cb cb; + void *user_data = NULL; + cb = __bt_gatt_attribute_get_value_change_cb(value_change->service_handle, + value_change->att_handle, &user_data); + + BT_INFO("BLUETOOTH_EVENT_GATT_SERVER_VALUE_CHANGE"); + if (cb == NULL) { + bluetooth_gatt_send_response(value_change->req_id, + BLUETOOTH_GATT_ATT_REQUEST_TYPE_WRITE, + BLUETOOTH_ERROR_INTERNAL, 0, NULL, 0); + return; + } + + bluetooth_gatt_send_response(value_change->req_id, + BLUETOOTH_GATT_ATT_REQUEST_TYPE_WRITE, + BLUETOOTH_ERROR_NONE, 0, NULL, 0); + + cb(value_change->address, value_change->service_handle, + value_change->att_handle, value_change->offset, + (char *)value_change->att_value, value_change->val_len, user_data); + break; + } + case BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED: { + bt_gatt_char_notify_change_t *value_change = param->param_data; + bt_gatt_server_notification_state_change_cb cb; + void *user_data = NULL; + cb = __bt_gatt_attribute_get_notification_change_cb(value_change->service_handle, + value_change->att_handle, &user_data); + + BT_INFO("BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED"); + if (cb == NULL) + return; + + cb(value_change->att_notify, value_change->service_handle, + value_change->att_handle, user_data); + break; + } + #ifdef BT_ENABLE_LEGACY_GATT_CLIENT case BLUETOOTH_EVENT_GATT_SVC_CHAR_DESC_DISCOVERED: { BT_INFO("BLUETOOTH_EVENT_GATT_SVC_CHAR_DESC_DISCOVERED"); @@ -1522,6 +1737,35 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us bt_event_slot_container[event_index].user_data); break; + case BLUETOOTH_EVENT_IPSP_CONNECTED: + BT_INFO("BLUETOOTH_EVENT_IPSP_CONNECTED"); + bd_addr = (bluetooth_device_address_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, bd_addr); + ((_bt_le_ipsp_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), TRUE, device_addr, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_IPSP_DISCONNECTED: + BT_INFO("BLUETOOTH_EVENT_IPSP_DISCONNECTED"); + bd_addr = (bluetooth_device_address_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, bd_addr); + ((_bt_le_ipsp_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), FALSE, device_addr, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_LE_DATA_LENGTH_CHANGED: + BT_INFO("__bt_le_set_data_length_changed_cb() will be called"); + data_length_info = (bt_le_data_length_params_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, &data_length_info->device_address); + + ((_bt_le_set_data_length_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), device_addr, data_length_info->max_tx_octets, + data_length_info->max_tx_time, data_length_info->max_rx_octets, data_length_info->max_rx_time, + bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + break; #ifdef TIZEN_WEARABLE case BLUETOOTH_PBAP_CONNECTED: { bt_pbap_enabled_cb cb = bt_event_slot_container[event_index].callback; @@ -1740,6 +1984,13 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us break; } #endif + case BLUETOOTH_EVENT_IPSP_INIT_STATE_CHANGED: { + BT_DBG("BLUETOOTH_EVENT_IPSP_INIT_STATE_CHANGED"); + ((bt_le_ipsp_init_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), *(bool *)(param->param_data), + bt_event_slot_container[event_index].user_data); + break; + } default: break; } @@ -2062,6 +2313,11 @@ static int __bt_get_cb_index(int event) return BT_EVENT_BOND_CREATED; case BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED: return BT_EVENT_BOND_DESTROYED; + case BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY: + case BLUETOOTH_EVENT_PASSKEY_REQUEST: + case BLUETOOTH_EVENT_PIN_REQUEST: + case BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST: + return BT_EVENT_AUTHENTICATION_REQUEST; case BLUETOOTH_EVENT_DEVICE_AUTHORIZED: case BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED: return BT_EVENT_AUTHORIZATION_CHANGED; @@ -2144,8 +2400,9 @@ static int __bt_get_cb_index(int event) case BLUETOOTH_EVENT_AV_DISCONNECTED: return BT_EVENT_AUDIO_CONNECTION_STATUS; case BLUETOOTH_EVENT_AV_SOURCE_CONNECTED: + return BT_EVENT_AUDIO_CONNECTION_STATUS; case BLUETOOTH_EVENT_AV_SOURCE_DISCONNECTED: - return BT_EVENT_A2DP_SOURCE_CONNECTION_STATUS; + return BT_EVENT_AUDIO_CONNECTION_STATUS; case BLUETOOTH_EVENT_AVRCP_CONNECTED: case BLUETOOTH_EVENT_AVRCP_DISCONNECTED: case BLUETOOTH_EVENT_AVRCP_CONTROL_CONNECTED: @@ -2173,6 +2430,12 @@ static int __bt_get_cb_index(int event) return BT_EVENT_HID_CONNECTION_STATUS; case BLUETOOTH_HID_DISCONNECTED: return BT_EVENT_HID_CONNECTION_STATUS; + case BLUETOOTH_HID_DEVICE_CONNECTED: + return BT_EVENT_HID_DEVICE_CONNECTION_STATUS; + case BLUETOOTH_HID_DEVICE_DISCONNECTED: + return BT_EVENT_HID_DEVICE_CONNECTION_STATUS; + case BLUETOOTH_HID_DEVICE_DATA_RECEIVED: + return BT_EVENT_HID_DEVICE_DATA_RECEIVED; #ifdef BT_ENABLE_LEGACY_GATT_CLIENT case BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED: return BT_EVENT_GATT_CLIENT_CHARACTERISTIC_DISCOVERED_LEGACY; @@ -2194,8 +2457,6 @@ static int __bt_get_cb_index(int event) return BT_EVENT_GATT_CLIENT_READ_DESCRIPTOR; case BLUETOOTH_EVENT_GATT_WRITE_DESC: return BT_EVENT_GATT_CLIENT_WRITE_DESCRIPTOR; - case BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED: - return BT_EVENT_GATT_SERVER_READ_REQUESTED; case BLUETOOTH_EVENT_ADVERTISING_STARTED: case BLUETOOTH_EVENT_ADVERTISING_STOPPED: return BT_EVENT_ADVERTISING_STATE_CHANGED; @@ -2203,6 +2464,11 @@ static int __bt_get_cb_index(int event) return BT_EVENT_MANUFACTURER_DATA_CHANGED; case BLUETOOTH_EVENT_CONNECTABLE_CHANGED: return BT_EVENT_CONNECTABLE_CHANGED_EVENT; + case BLUETOOTH_EVENT_IPSP_CONNECTED: + case BLUETOOTH_EVENT_IPSP_DISCONNECTED: + return BT_EVENT_IPSP_CONNECTION_STATUS; + case BLUETOOTH_EVENT_LE_DATA_LENGTH_CHANGED: + return BT_EVENT_LE_DATA_LENGTH_CHANGED; #ifdef TIZEN_WEARABLE case BLUETOOTH_PBAP_CONNECTED: return BT_EVENT_PBAP_CONNECTION_STATUS; @@ -2240,6 +2506,8 @@ static int __bt_get_cb_index(int event) case BLUETOOTH_EVENT_HF_CALL_STATUS: return BT_EVENT_HF_CALL_STATUS_UPDATED_EVENT; #endif + case BLUETOOTH_EVENT_IPSP_INIT_STATE_CHANGED: + return BT_EVENT_IPSP_INIT_STATE_CHANGED; default: return -1; } diff --git a/src/bluetooth-device.c b/src/bluetooth-device.c index 15ab193..3900930 100644..100755 --- a/src/bluetooth-device.c +++ b/src/bluetooth-device.c @@ -238,6 +238,8 @@ int bt_device_set_bond_created_cb(bt_device_bond_created_cb callback, void *user BT_CHECK_INPUT_PARAMETER(callback); _bt_set_cb(BT_EVENT_BOND_CREATED, callback, user_data); + BT_DBG("+"); + return BT_ERROR_NONE; } @@ -248,6 +250,8 @@ int bt_device_set_bond_destroyed_cb(bt_device_bond_destroyed_cb callback, void * BT_CHECK_INPUT_PARAMETER(callback); _bt_set_cb(BT_EVENT_BOND_DESTROYED, callback, user_data); + BT_DBG("+"); + return BT_ERROR_NONE; } @@ -331,6 +335,9 @@ int bt_device_unset_bond_created_cb(void) BT_CHECK_BT_SUPPORT(); BT_CHECK_INIT_STATUS(); _bt_unset_cb(BT_EVENT_BOND_CREATED); + + BT_DBG("+"); + return BT_ERROR_NONE; } @@ -339,6 +346,9 @@ int bt_device_unset_bond_destroyed_cb(void) BT_CHECK_BT_SUPPORT(); BT_CHECK_INIT_STATUS(); _bt_unset_cb(BT_EVENT_BOND_DESTROYED); + + BT_DBG("+"); + return BT_ERROR_NONE; } @@ -370,7 +380,7 @@ int bt_device_le_conn_update(const char *device_address, const bt_le_conn_update_s *parameters) { bluetooth_device_address_t addr_hex = { {0,} }; - bluetooth_le_conn_update_t param= { 0 }; + bluetooth_le_connection_param_t param = { 0 }; int ret = BT_ERROR_NONE; BT_CHECK_BT_SUPPORT(); @@ -382,7 +392,7 @@ int bt_device_le_conn_update(const char *device_address, param.interval_min = parameters->interval_min; param.interval_max = parameters->interval_max; param.latency = parameters->latency; - param.time_out = parameters->time_out; + param.timeout = parameters->time_out; ret = _bt_get_error_code(bluetooth_le_conn_update(&addr_hex, ¶m)); @@ -403,9 +413,9 @@ int bt_device_get_service_mask_from_uuid_list(char **uuids, bt_service_class_t service_mask = 0; BT_CHECK_BT_SUPPORT(); - BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(uuids); BT_CHECK_INPUT_PARAMETER(service_mask_list); + BT_CHECK_INIT_STATUS(); BT_DBG("Get service mask from uuid list"); BT_DBG("no_of_service = %d", no_of_service); @@ -474,10 +484,6 @@ int bt_device_get_service_mask_from_uuid_list(char **uuids, service_mask |= BT_SC_NONE; break; - case BLUETOOTH_ADVANCED_AUDIO_PROFILE_UUID: - service_mask |= BT_SC_A2DP_SERVICE_MASK; - break; - case BLUETOOTH_AV_REMOTE_CONTROL_UUID: service_mask |= BT_SC_AVRCP_SERVICE_MASK; break; @@ -578,3 +584,67 @@ int bt_device_get_service_mask_from_uuid_list(char **uuids, return BT_ERROR_NONE; } + +int bt_passkey_reply(char *passkey, bool authentication_reply) +{ + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(passkey); + int error_code = BT_ERROR_NONE; + error_code = _bt_get_error_code(bluetooth_passkey_reply(passkey, authentication_reply)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_passkey_confirmation_reply(bool confirmation_reply) +{ + BT_CHECK_INIT_STATUS(); + + int error_code = BT_ERROR_NONE; + error_code = _bt_get_error_code(bluetooth_passkey_confirmation_reply(confirmation_reply)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} +int bt_device_le_set_data_length(const char *remote_address, + unsigned int max_tx_Octets, unsigned int max_tx_Time) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + + bluetooth_device_address_t addr_hex = {{0,}}; + + //Range for host suggested txtime is 0x001B-0x00FB and + // txocets is 0x0148- 0x0848 as per BT 4.2 spec + if ((max_tx_Octets < 0x001B || max_tx_Octets > 0x00FB) + && (max_tx_Time < 0x0148 || max_tx_Time > 0x0848)) { + return BT_ERROR_INVALID_PARAMETER; + } + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + ret = _bt_get_error_code(bluetooth_le_set_data_length( + &addr_hex, + max_tx_Octets, + max_tx_Time)); + + if (ret != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + + return ret; +} + +int bt_device_le_set_data_length_change_cb( + _bt_le_set_data_length_changed_cb callback, void *user_data) +{ + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_LE_DATA_LENGTH_CHANGED, callback, user_data); + + return BT_ERROR_NONE; +} diff --git a/src/bluetooth-gatt.c b/src/bluetooth-gatt.c index aa8ae45..8e497bf 100755..100644 --- a/src/bluetooth-gatt.c +++ b/src/bluetooth-gatt.c @@ -567,6 +567,8 @@ int bt_gatt_unset_connection_state_changed_cb(void) int bt_gatt_get_uuid_specification_name(const char *uuid, char **name) { + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(uuid); BT_CHECK_INPUT_PARAMETER(name); @@ -838,6 +840,8 @@ int bt_gatt_destroy(bt_gatt_h gatt_handle) { bt_gatt_common_s *handle = (bt_gatt_common_s*)gatt_handle; + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(gatt_handle); if (handle->type == BT_GATT_TYPE_SERVICE) @@ -861,6 +865,8 @@ int bt_gatt_get_value(bt_gatt_h gatt_handle, char **value, int *value_length) bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s*)gatt_handle; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(gatt_handle); BT_CHECK_INPUT_PARAMETER(value); BT_CHECK_INPUT_PARAMETER(value_length); @@ -890,6 +896,8 @@ int bt_gatt_get_int_value(bt_gatt_h gatt_handle, bt_data_type_int_e type, int of bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s*)gatt_handle; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(gatt_handle); BT_CHECK_INPUT_PARAMETER(value); @@ -950,6 +958,7 @@ int bt_gatt_get_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type, in bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s*)gatt_handle; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(gatt_handle); BT_CHECK_INPUT_PARAMETER(value); @@ -995,6 +1004,8 @@ int bt_gatt_set_value(bt_gatt_h gatt_handle, const char *value, int value_length bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s*)gatt_handle; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(gatt_handle); BT_CHECK_INPUT_PARAMETER(value); @@ -1010,7 +1021,7 @@ int bt_gatt_set_value(bt_gatt_h gatt_handle, const char *value, int value_length } if (handle->role == BT_GATT_ROLE_SERVER && handle->path) { - ret = _bt_get_error_code(bluetooth_gatt_update_characteristic(handle->path, value, value_length)); + ret = _bt_get_error_code(bluetooth_gatt_notify_characteristics_value_change(handle->path, value, value_length, NULL)); if (ret != BT_ERROR_NONE) { BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); return ret; @@ -1039,6 +1050,8 @@ int bt_gatt_set_int_value(bt_gatt_h gatt_handle, bt_data_type_int_e type, int va bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s*)gatt_handle; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(gatt_handle); if (handle->type == BT_GATT_TYPE_CHARACTERISTIC) { @@ -1118,7 +1131,7 @@ int bt_gatt_set_int_value(bt_gatt_h gatt_handle, bt_data_type_int_e type, int va } if (handle->role == BT_GATT_ROLE_SERVER && handle->path) { - ret = _bt_get_error_code(bluetooth_gatt_update_characteristic(handle->path, *val, *val_len)); + ret = _bt_get_error_code(bluetooth_gatt_notify_characteristics_value_change(handle->path, *val, *val_len, NULL)); if (ret != BT_ERROR_NONE) { BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); return ret; @@ -1144,6 +1157,8 @@ int bt_gatt_set_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type, bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s*)gatt_handle; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(gatt_handle); if (handle->type == BT_GATT_TYPE_CHARACTERISTIC) { @@ -1221,7 +1236,7 @@ int bt_gatt_set_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type, } if (handle->role == BT_GATT_ROLE_SERVER && handle->path) { - ret = _bt_get_error_code(bluetooth_gatt_update_characteristic(handle->path, *val, *val_len)); + ret = _bt_get_error_code(bluetooth_gatt_notify_characteristics_value_change(handle->path, *val, *val_len, NULL)); if (ret != BT_ERROR_NONE) { BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); return ret; @@ -1237,6 +1252,9 @@ int bt_gatt_get_permissions(bt_gatt_h gatt_handle, int *permissions) bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s*)gatt_handle; bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s*)gatt_handle; + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(gatt_handle); BT_CHECK_INPUT_PARAMETER(permissions); @@ -1258,6 +1276,9 @@ int bt_gatt_set_permissions(bt_gatt_h gatt_handle, int permissions) bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s*)gatt_handle; bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s*)gatt_handle; + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(gatt_handle); if (handle->type == BT_GATT_TYPE_CHARACTERISTIC) @@ -1277,6 +1298,8 @@ int bt_gatt_get_uuid(bt_gatt_h gatt_handle, char **uuid) bt_gatt_common_s *handle = (bt_gatt_common_s*)gatt_handle; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(gatt_handle); BT_CHECK_INPUT_PARAMETER(uuid); @@ -1290,6 +1313,8 @@ int bt_gatt_get_type(bt_gatt_h gatt_handle, bt_gatt_type_e *gatt_type) bt_gatt_common_s *handle = (bt_gatt_common_s*)gatt_handle; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(gatt_handle); BT_CHECK_INPUT_PARAMETER(gatt_type); @@ -1303,6 +1328,9 @@ int bt_gatt_service_create(const char *uuid, bt_gatt_service_type_e type, { bt_gatt_service_s *svc; + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(uuid); BT_CHECK_INPUT_PARAMETER(service); @@ -1333,6 +1361,9 @@ int bt_gatt_service_add_characteristic(bt_gatt_h service, bt_gatt_service_s *svc = (bt_gatt_service_s*)service; bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s*)characteristic; + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(service); BT_CHECK_INPUT_PARAMETER(characteristic); if (chr->parent) { @@ -1352,6 +1383,9 @@ int bt_gatt_service_add_included_service(bt_gatt_h service, bt_gatt_service_s *svc = (bt_gatt_service_s*)service; bt_gatt_service_s *included_svc = (bt_gatt_service_s*)included_service; + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(service); BT_CHECK_INPUT_PARAMETER(included_service); if (included_svc->parent) { @@ -1369,6 +1403,9 @@ int bt_gatt_service_get_server(bt_gatt_h service, bt_gatt_server_h *server) { bt_gatt_service_s *svc = (bt_gatt_service_s *)service; + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(service); BT_CHECK_INPUT_PARAMETER(server); @@ -1392,6 +1429,8 @@ int bt_gatt_service_get_client(bt_gatt_h service, bt_gatt_client_h *client) bt_gatt_service_s *svc = (bt_gatt_service_s *)service; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(service); BT_CHECK_INPUT_PARAMETER(client); @@ -1418,6 +1457,8 @@ int bt_gatt_service_get_characteristic(bt_gatt_h service, const char *uuid, int ret; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(service); BT_CHECK_INPUT_PARAMETER(uuid); BT_CHECK_INPUT_PARAMETER(characteristic); @@ -1442,6 +1483,8 @@ int bt_gatt_service_foreach_characteristics(bt_gatt_h service, int index = 1; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(service); BT_CHECK_INPUT_PARAMETER(callback); @@ -1464,6 +1507,8 @@ int bt_gatt_service_get_included_service(bt_gatt_h service, const char *uuid, int ret; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(service); BT_CHECK_INPUT_PARAMETER(uuid); BT_CHECK_INPUT_PARAMETER(included_service); @@ -1488,6 +1533,8 @@ int bt_gatt_service_foreach_included_services(bt_gatt_h service, int index = 1; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(service); BT_CHECK_INPUT_PARAMETER(callback); @@ -1509,6 +1556,9 @@ int bt_gatt_characteristic_create(const char *uuid, int permissions, int ret = BT_ERROR_NONE; bt_gatt_characteristic_s *chr = NULL; + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(uuid); BT_CHECK_INPUT_PARAMETER(characteristic); if (value_length > 0) @@ -1560,6 +1610,9 @@ int bt_gatt_characteristic_add_descriptor(bt_gatt_h characteristic, bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)characteristic; bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s *)descriptor; + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(characteristic); BT_CHECK_INPUT_PARAMETER(descriptor); @@ -1585,6 +1638,8 @@ int bt_gatt_characteristic_get_service(bt_gatt_h characteristic, bt_gatt_h *serv bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)characteristic; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(characteristic); BT_CHECK_INPUT_PARAMETER(service); @@ -1598,6 +1653,8 @@ int bt_gatt_characteristic_get_properties(bt_gatt_h characteristic, int *propert bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)characteristic; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(characteristic); BT_CHECK_INPUT_PARAMETER(properties); @@ -1615,6 +1672,9 @@ int bt_gatt_characteristic_set_properties(bt_gatt_h characteristic, int properti { bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)characteristic; + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(characteristic); if (chr->type != BT_GATT_TYPE_CHARACTERISTIC) { @@ -1633,6 +1693,8 @@ int bt_gatt_characteristic_get_write_type(bt_gatt_h characteristic, bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)characteristic; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(characteristic); BT_CHECK_INPUT_PARAMETER(write_type); @@ -1652,6 +1714,8 @@ int bt_gatt_characteristic_set_write_type(bt_gatt_h characteristic, bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)characteristic; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(characteristic); if (chr->type != BT_GATT_TYPE_CHARACTERISTIC) { @@ -1672,6 +1736,8 @@ int bt_gatt_characteristic_get_descriptor(bt_gatt_h characteristic, const char * int ret; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(characteristic); BT_CHECK_INPUT_PARAMETER(uuid); BT_CHECK_INPUT_PARAMETER(descriptor); @@ -1695,6 +1761,8 @@ int bt_gatt_characteristic_foreach_descriptors(bt_gatt_h characteristic, int i; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(characteristic); BT_CHECK_INPUT_PARAMETER(callback); @@ -1721,6 +1789,9 @@ int bt_gatt_descriptor_create(const char *uuid, int permissions, int ret = BT_ERROR_NONE; bt_gatt_descriptor_s *desc = NULL; + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(uuid); BT_CHECK_INPUT_PARAMETER(descriptor); if (value_length > 0) @@ -1769,6 +1840,8 @@ int bt_gatt_descriptor_get_characteristic(bt_gatt_h descriptor, bt_gatt_h *chara bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s *)descriptor; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(descriptor); BT_CHECK_INPUT_PARAMETER(characteristic); @@ -1838,6 +1911,7 @@ int bt_gatt_server_create(bt_gatt_server_h *server) { bt_gatt_server_s *serv = NULL; + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(server); serv = g_malloc0(sizeof(bt_gatt_server_s)); @@ -1855,6 +1929,7 @@ int bt_gatt_server_destroy(bt_gatt_server_h server) { bt_gatt_server_s *serv = (bt_gatt_server_s*)server; + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(server); g_slist_free_full(serv->services, __bt_gatt_free_service); @@ -1878,7 +1953,22 @@ int bt_gatt_server_set_read_value_requested_cb(bt_gatt_h gatt_handle, chr->read_requested_cb = callback; chr->read_requested_user_data = user_data; - _bt_set_cb(BT_EVENT_GATT_SERVER_READ_REQUESTED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_gatt_server_set_notification_state_change_cb(bt_gatt_h gatt_handle, + bt_gatt_server_notification_state_change_cb callback, + void *user_data) +{ + bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s*)gatt_handle; + + BT_CHECK_INIT_STATUS(); + BT_CHECK_GATT_SERVER_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(gatt_handle); + BT_CHECK_INPUT_PARAMETER(callback); + + chr->notification_changed_cb = callback; + chr->notification_changed_user_data = user_data; return BT_ERROR_NONE; } @@ -2007,7 +2097,12 @@ int bt_gatt_server_send_response(int request_id, if (value_length <= 0) return BT_ERROR_INVALID_PARAMETER; - ret = _bt_get_error_code(bluetooth_gatt_send_response(request_id, offset, value, value_length)); + /* By Default the response is sent for read requests, + * once the new parameters available to CAPI API, the below + * code be made generic for both read and write */ + ret = _bt_get_error_code(bluetooth_gatt_send_response(request_id, + BLUETOOTH_GATT_ATT_REQUEST_TYPE_READ, BT_ERROR_NONE, + offset, value, value_length)); if (ret != BT_ERROR_NONE) { BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); @@ -2019,6 +2114,9 @@ int bt_gatt_server_send_response(int request_id, int bt_gatt_server_notify(bt_gatt_h characteristic, bool need_confirm, bt_gatt_server_notification_sent_cb callback, void *user_data) { + BT_CHECK_INIT_STATUS(); + BT_CHECK_GATT_SERVER_INIT_STATUS(); + return BT_ERROR_NONE; } @@ -2029,6 +2127,8 @@ int bt_gatt_server_set_value_changed_cb(bt_gatt_h characteristic, bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s *)characteristic; BT_CHECK_INIT_STATUS(); + BT_CHECK_GATT_SERVER_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(characteristic); BT_CHECK_INPUT_PARAMETER(callback); @@ -2045,6 +2145,9 @@ int bt_gatt_server_get_service(bt_gatt_server_h server, const char *uuid, bt_gatt_h gatt_handle = NULL; int ret; + BT_CHECK_INIT_STATUS(); + BT_CHECK_GATT_SERVER_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(server); BT_CHECK_INPUT_PARAMETER(uuid); BT_CHECK_INPUT_PARAMETER(service); @@ -2067,6 +2170,9 @@ int bt_gatt_server_foreach_services(bt_gatt_server_h server, int total = 0; int index = 1; + BT_CHECK_INIT_STATUS(); + BT_CHECK_GATT_SERVER_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(server); BT_CHECK_INPUT_PARAMETER(callback); @@ -2271,7 +2377,8 @@ int bt_gatt_client_write_value(bt_gatt_h gatt_handle, g_free(cb_data); BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); } else { - _bt_set_cb(BT_EVENT_GATT_CLIENT_WRITE_CHARACTERISTIC, callback, cb_data); + if (chr->write_type != BT_GATT_WRITE_TYPE_WRITE_NO_RESPONSE) + _bt_set_cb(BT_EVENT_GATT_CLIENT_WRITE_CHARACTERISTIC, callback, cb_data); } } else if (c->type == BT_GATT_TYPE_DESCRIPTOR) { bt_gatt_descriptor_s *desc = (bt_gatt_descriptor_s *)gatt_handle; @@ -2405,7 +2512,7 @@ int bt_gatt_client_set_characteristic_value_changed_cb(bt_gatt_h characteristic, ret = BT_ERROR_NOT_SUPPORTED; } - return BT_ERROR_NONE; + return ret; } int bt_gatt_client_unset_characteristic_value_changed_cb(bt_gatt_h characteristic) @@ -2443,6 +2550,7 @@ int bt_gatt_client_get_service(bt_gatt_client_h client, const char *uuid, int ret; BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(client); BT_CHECK_INPUT_PARAMETER(uuid); BT_CHECK_INPUT_PARAMETER(service); diff --git a/src/bluetooth-hid.c b/src/bluetooth-hid.c index a00fb72..3bf7d3c 100644 --- a/src/bluetooth-hid.c +++ b/src/bluetooth-hid.c @@ -27,15 +27,26 @@ static bool is_hid_host_initialized = false; -#ifdef TIZEN_HID_DISABLE -#define BT_CHECK_HID_SUPPORT() \ +#ifdef TIZEN_HID_HOST_DISABLE +#define BT_CHECK_HID_HOST_SUPPORT() \ { \ BT_CHECK_BT_SUPPORT(); \ LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ return BT_ERROR_NOT_SUPPORTED; \ } #else -#define BT_CHECK_HID_SUPPORT() +#define BT_CHECK_HID_HOST_SUPPORT() +#endif + +#ifdef TIZEN_HID_DEVICE_DISABLE +#define BT_CHECK_HID_DEVICE_SUPPORT() \ + { \ + BT_CHECK_BT_SUPPORT(); \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_HID_DEVICE_SUPPORT() #endif #define BT_CHECK_HID_HOST_INIT_STATUS() \ @@ -60,7 +71,7 @@ int bt_hid_host_initialize(bt_hid_host_connection_state_changed_cb connection_cb { int error; - BT_CHECK_HID_SUPPORT(); + BT_CHECK_HID_HOST_SUPPORT(); BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(connection_cb); @@ -81,7 +92,7 @@ int bt_hid_host_deinitialize() { int error; - BT_CHECK_HID_SUPPORT(); + BT_CHECK_HID_HOST_SUPPORT(); BT_CHECK_INIT_STATUS(); BT_CHECK_HID_HOST_INIT_STATUS(); @@ -103,7 +114,7 @@ int bt_hid_host_connect(const char *remote_address) int error; bluetooth_device_address_t addr_hex = { {0,} }; - BT_CHECK_HID_SUPPORT(); + BT_CHECK_HID_HOST_SUPPORT(); BT_CHECK_INIT_STATUS(); BT_CHECK_HID_HOST_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(remote_address); @@ -123,7 +134,7 @@ int bt_hid_host_disconnect(const char *remote_address) int error; bluetooth_device_address_t addr_hex = { {0,} }; - BT_CHECK_HID_SUPPORT(); + BT_CHECK_HID_HOST_SUPPORT(); BT_CHECK_INIT_STATUS(); BT_CHECK_HID_HOST_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(remote_address); @@ -137,3 +148,192 @@ int bt_hid_host_disconnect(const char *remote_address) } return error; } + +int bt_hid_device_activate(bt_hid_device_connection_state_changed_cb callback, void * user_data) +{ + int error; + BT_CHECK_HID_DEVICE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + + error = bluetooth_hid_device_init(_bt_hid_event_proxy, user_data); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } + + error = bluetooth_hid_device_activate(); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } + + _bt_set_cb(BT_EVENT_HID_DEVICE_CONNECTION_STATUS, callback, user_data); + + return BT_ERROR_NONE; +} + +int bt_hid_device_deactivate(void) +{ + int error; + BT_CHECK_HID_DEVICE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + error = bluetooth_hid_device_deinit(); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } + + error = bluetooth_hid_device_deactivate(); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } + + _bt_unset_cb(BT_EVENT_HID_DEVICE_CONNECTION_STATUS); + + return BT_ERROR_NONE; +} + +int bt_hid_device_connect(const char *remote_address) +{ + int error; + BT_CHECK_HID_DEVICE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + error = bluetooth_hid_device_connect(remote_address); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } + return BT_ERROR_NONE; +} +int bt_hid_device_disconnect(const char *remote_address) +{ + int error; + BT_CHECK_HID_DEVICE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + error = bluetooth_hid_device_disconnect(remote_address); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; +} + +int bt_hid_device_send_mouse_event(const char *remote_address, + const bt_hid_mouse_data_s *mouse_data) +{ + int ret; + BT_CHECK_HID_DEVICE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + BT_CHECK_INPUT_PARAMETER(mouse_data); + + ret = bluetooth_hid_device_send_mouse_event(remote_address, + *(hid_send_mouse_event_t*)mouse_data); + if (ret <= 0) { + if (ret == -1) { + /* write fail case */ + if (errno == EACCES || errno == EPERM) + set_last_result(BT_ERROR_PERMISSION_DENIED); + else if (errno == EAGAIN || errno == EWOULDBLOCK) + set_last_result(BT_ERROR_AGAIN); + else + set_last_result(BT_ERROR_OPERATION_FAILED); + } else { + ret = _bt_get_error_code(ret); + set_last_result(ret); + } + + BT_ERR("Write failed, ret = %d", ret); + } + + return ret; +} + +int bt_hid_device_send_key_event(const char *remote_address, + const bt_hid_key_data_s *key_data) +{ + int ret; + BT_CHECK_HID_DEVICE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + BT_CHECK_INPUT_PARAMETER(key_data); + + ret = bluetooth_hid_device_send_key_event(remote_address, + *(hid_send_key_event_t*)key_data); + if (ret <= 0) { + if (ret == -1) { + /* write fail case */ + if (errno == EACCES || errno == EPERM) + set_last_result(BT_ERROR_PERMISSION_DENIED); + else if (errno == EAGAIN || errno == EWOULDBLOCK) + set_last_result(BT_ERROR_AGAIN); + else + set_last_result(BT_ERROR_OPERATION_FAILED); + } else { + ret = _bt_get_error_code(ret); + set_last_result(ret); + } + + BT_ERR("Write failed, ret = %d", ret); + } + + return ret; +} + +int bt_hid_device_reply_to_report(const char *remote_address, + bluetooth_hid_header_type_t htype, + bluetooth_hid_param_type_t ptype, + const char *data, unsigned int data_len) +{ + int ret; + BT_CHECK_HID_DEVICE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + + ret = bluetooth_hid_device_reply_to_report(remote_address, htype, + ptype, data, data_len); + if (ret <= 0) { + if (ret == -1) { + /* write fail case */ + if (errno == EACCES || errno == EPERM) + set_last_result(BT_ERROR_PERMISSION_DENIED); + else if (errno == EAGAIN || errno == EWOULDBLOCK) + set_last_result(BT_ERROR_AGAIN); + else + set_last_result(BT_ERROR_OPERATION_FAILED); + } else { + ret = _bt_get_error_code(ret); + set_last_result(ret); + } + + BT_ERR("Write failed, ret = %d", ret); + } + + return ret; +} + +int bt_hid_device_set_data_received_cb(bt_hid_device_data_received_cb callback, void *user_data) +{ + BT_CHECK_HID_DEVICE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_HID_DEVICE_DATA_RECEIVED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_hid_device_unset_data_received_cb(void) +{ + BT_CHECK_HID_DEVICE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_HID_DEVICE_DATA_RECEIVED); + return BT_ERROR_NONE; +} diff --git a/src/bluetooth-ipsp.c b/src/bluetooth-ipsp.c new file mode 100644 index 0000000..87a7913 --- /dev/null +++ b/src/bluetooth-ipsp.c @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <glib.h> +#include <dlog.h> +#include <stdio.h> +#include <stdbool.h> +#include <string.h> +#include <bluetooth-api.h> +#include <bluetooth-ipsp-api.h> + +#include "bluetooth.h" +#include "bluetooth_private.h" + +static bool is_ipsp_initialized = false; + +#ifdef TIZEN_IPSP_SUPPORT +#define BT_CHECK_IPSP_SUPPORT() +#else +#define BT_CHECK_IPSP_SUPPORT() \ + { \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#endif + +#define BT_CHECK_IPSP_INIT_STATUS() \ + if (__bt_check_ipsp_init_status() == BT_ERROR_NOT_INITIALIZED) \ + { \ + LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \ + return BT_ERROR_NOT_INITIALIZED; \ + } + +int __bt_check_ipsp_init_status(void) +{ + if (is_ipsp_initialized != true) { + BT_ERR("NOT_INITIALIZED(0x%08x)", BT_ERROR_NOT_INITIALIZED); + return BT_ERROR_NOT_INITIALIZED; + } + + return BT_ERROR_NONE; +} + +int _bt_le_ipsp_is_initialized(void) +{ + BT_CHECK_IPSP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_IPSP_INIT_STATUS(); + return BT_ERROR_NONE; +} + +int _bt_le_ipsp_initialize(bt_le_ipsp_init_state_changed_cb callback, + void *user_data) +{ + int error; + + if (is_ipsp_initialized) + return BT_ERROR_ALREADY_DONE; + + BT_CHECK_IPSP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + + error = bluetooth_le_ipsp_init(); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } + + _bt_set_cb(BT_EVENT_IPSP_INIT_STATE_CHANGED, callback, user_data); + + is_ipsp_initialized = true; + return BT_ERROR_NONE; +} + +int _bt_le_ipsp_deinitialize(void) +{ + int error; + + BT_CHECK_IPSP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_IPSP_INIT_STATUS(); + + error = bluetooth_le_ipsp_deinit(); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } + + is_ipsp_initialized = false; + return BT_ERROR_NONE; +} + +int _bt_le_ipsp_connect(const char *address) +{ + int ret; + bluetooth_device_address_t bd_addr = { {0,} }; + + BT_CHECK_IPSP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(address); + + _bt_convert_address_to_hex(&bd_addr, address); + + ret = _bt_get_error_code(bluetooth_le_ipsp_connect((ipsp_device_address_t *)&bd_addr)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + return ret; +} + +int _bt_le_ipsp_disconnect(const char *address) +{ + int ret; + bluetooth_device_address_t bd_addr = { {0,} }; + + BT_CHECK_IPSP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(address); + + _bt_convert_address_to_hex(&bd_addr, address); + + ret = _bt_get_error_code(bluetooth_le_ipsp_disconnect((ipsp_device_address_t *)&bd_addr)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + return ret; +} + +int _bt_le_ipsp_set_connection_state_changed_cb(_bt_le_ipsp_connection_state_changed_cb callback, void *user_data) +{ + BT_CHECK_IPSP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_IPSP_CONNECTION_STATUS, callback, user_data); + + return BT_ERROR_NONE; +} + +int _bt_le_ipsp_unset_connection_state_changed_cb(void) +{ + BT_CHECK_IPSP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + _bt_unset_cb(BT_EVENT_IPSP_CONNECTION_STATUS); + return BT_ERROR_NONE; +} diff --git a/src/bluetooth-pan.c b/src/bluetooth-pan.c index a00cd7f..1312780 100644 --- a/src/bluetooth-pan.c +++ b/src/bluetooth-pan.c @@ -24,8 +24,6 @@ #include "bluetooth.h" #include "bluetooth_private.h" -GList *sending_files; - #ifdef TIZEN_PAN_DISABLE #define BT_CHECK_PAN_SUPPORT() \ { \ @@ -116,6 +114,8 @@ int bt_nap_set_connection_state_changed_cb( int bt_nap_unset_connection_state_changed_cb(void) { + BT_CHECK_PAN_SUPPORT(); + BT_CHECK_INIT_STATUS(); _bt_unset_cb(BT_EVENT_NAP_CONNECTION_STATE_CHANGED); return BT_ERROR_NONE; } @@ -133,6 +133,8 @@ int bt_panu_set_connection_state_changed_cb( int bt_panu_unset_connection_state_changed_cb(void) { + BT_CHECK_PAN_SUPPORT(); + BT_CHECK_INIT_STATUS(); _bt_unset_cb(BT_EVENT_PAN_CONNECTION_STATE_CHANGED); return BT_ERROR_NONE; } diff --git a/src/bluetooth-socket.c b/src/bluetooth-socket.c index 52c6a69..7f4fcb3 100644 --- a/src/bluetooth-socket.c +++ b/src/bluetooth-socket.c @@ -231,6 +231,7 @@ int bt_socket_send_data(int socket_fd, const char *data, int length) BT_CHECK_BT_SUPPORT(); BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(data); ret = bluetooth_rfcomm_write(socket_fd, data, length); if (ret <= 0) { diff --git a/test/bt_onoff.c b/test/bt_onoff.c index f95106a..c4d7592 100644 --- a/test/bt_onoff.c +++ b/test/bt_onoff.c @@ -23,6 +23,7 @@ #include <glib.h> #include "bluetooth.h" +#include "bluetooth_internal.h" #define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) #define TC_PRT(format, args...) PRT(format"\n", ##args) diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c index 8415988..22c6fb4 100644 --- a/test/bt_unit_test.c +++ b/test/bt_unit_test.c @@ -26,28 +26,46 @@ * @brief This is the source file for capi unit test. */ +#include <sys/time.h> #include <stdio.h> #include <string.h> #include <fcntl.h> #include <unistd.h> #include <glib.h> #include <ctype.h> -#include <time.h> #include "bluetooth.h" #include "bluetooth_internal.h" +#include "bluetooth_extension.h" #include "bluetooth_private.h" #include "bluetooth-telephony-api.h" #include "bt_unit_test.h" -const char *spp_uuid = "00001101-0000-1000-8000-00805F9B34FB"; +const char *spp_uuid = "00001101-0000-1000-8000-00805F9B7777"; +//const char *spp_uuid = "00001101-0000-1000-8000-00805F9B34FB"; +const char *hid_uuid = "00001124-0000-1000-8000-00805f9b34fb"; const char *opp_uuid = "00001105-0000-1000-8000-00805f9b34fb"; const char *custom_uuid = "fa87c0d0-afac-11de-8a39-0800200c9a66"; +// Temporary HPS UUIDs. SIG has to define the UUIDs yet. +#define HPS_UUID "00001900-0000-1000-8000-00805f9b34fb" +#define HTTP_URI_UUID "00001901-0000-1000-8000-00805f9b34fb" +#define HTTP_HDR_UUID "00001902-0000-1000-8000-00805f9b34fb" +#define HTTP_ENTITY_UUID "00001903-0000-1000-8000-00805f9b34fb" +#define HTTP_CP_UUID "00001904-0000-1000-8000-00805f9b34fb" +#define HTTP_STATUS_UUID "00001905-0000-1000-8000-00805f9b34fb" +#define HTTP_SECURITY_UUID "00001906-0000-1000-8000-00805f9b34fb" +#define HTTP_STATUS_DESC_UUID "2902" + static bt_unit_test_table_e current_tc_table; static char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; static bool input_automated_test_delay = false; +/* For HDP profile TEST */ +static char *appid = "/org/bluez/health_app_2"; +static char* data_hdp = "aaa"; +static unsigned channel_hdp = 0; + static bool need_to_set_params = false; static int g_test_id = -1; static tc_params_t g_test_param = {0,}; @@ -60,7 +78,8 @@ static int custom_client_fd; static int bt_onoff_cnt = 0; static int bt_onoff_cnt_success = 0; static int bt_onoff_cnt_fail = 0; -static time_t bt_onoff_timer; +static int total_time = 0; +static struct timeval check_time = {0,}; static gboolean is_sub_index = FALSE; #ifdef BT_ENABLE_LEGACY_GATT_CLIENT @@ -75,6 +94,7 @@ static bt_advertiser_h advertiser_list[3] = {NULL, }; static int advertiser_index = 0; bt_gatt_client_h client = NULL; +bt_gatt_client_h hps_client = NULL; bt_gatt_server_h server = NULL; typedef struct { @@ -86,6 +106,7 @@ gatt_handle_t battery_h; gatt_handle_t heart_rate_h; gatt_handle_t thermometer_h; gatt_handle_t custom_h; +gatt_handle_t ipsp_h; #ifdef BT_ENABLE_LEGACY_GATT_CLIENT bt_gatt_attribute_h service_clone[MAX_SERVICES]; @@ -114,8 +135,11 @@ tc_table_t tc_main[] = { {"Audio(ag, a2dp, call)" , BT_UNIT_TEST_TABLE_AUDIO}, {"Pan(nap, panu)" , BT_UNIT_TEST_TABLE_PAN}, {"Gatt" , BT_UNIT_TEST_TABLE_GATT}, + {"HPS" , BT_UNIT_TEST_TABLE_HPS}, {"Avrcp" , BT_UNIT_TEST_TABLE_AVRCP}, {"Hid" , BT_UNIT_TEST_TABLE_HID}, + {"IPSP" , BT_UNIT_TEST_TABLE_IPSP}, + {"HDP" , BT_UNIT_TEST_TABLE_HDP}, #ifdef TIZEN_WEARABLE {"HF Role" , BT_UNIT_TEST_TABLE_HF}, {"PBAP Client" , BT_UNIT_TEST_TABLE_PBAP_CLIENT}, @@ -158,6 +182,12 @@ tc_table_t tc_adapter[] = { {"bt_adapter_set_manufacturer_data_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA_CHANGED_CB}, {"bt_adapter_unset_manufacturer_data_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_MANUFACTURER_DATA_CHANGED_CB}, {"bt_adapter_set_manufacturer_data" , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA}, + {"bt_adapter_set_authentication_req_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUSET_CB}, + {"bt_adapter_unset_authentication_req_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUSET_CB}, + {"bt_passkey_reply(passkey, TRUE)" , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_ACCEPT}, + {"bt_passkey_reply(passkey, FALSE)" , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_CANCEL}, + {"bt_passkey_confirmation_reply(TRUE)" , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_ACCEPT}, + {"bt_passkey_confirmation_reply(FALSE)" , BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_REJECT}, {"Select this menu to set parameters and then select the function again." , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, {NULL , 0x0000}, }; @@ -198,6 +228,9 @@ tc_table_t tc_adapter_le[] = { {"bt_adapter_le_set_device_discovery_state_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB}, {"bt_adapter_le_unset_device_discovery_state_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB}, #endif + {"bt_adater_le_read_maximum_data_length", BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_MAXIMUM_DATA_LENGTH}, + {"bt_adater_le_wite_host_suggested_def_data_length", BT_UNIT_TEST_FUNCTION_ADAPTER_LE_WRITE_HOST_SUGGESTED_DEFAULT_DATA_LENGTH}, + {"bt_adater_le_read_host_suggested_def_data_length", BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_HOST_SUGGESTED_DEFAULT_DATA_LENGTH}, {"Select this menu to set parameters and then select the function again." , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, {NULL , 0x0000}, }; @@ -218,6 +251,8 @@ tc_table_t tc_device[] = { {"bt_device_create_bond" , BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND}, {"bt_device_create_bond_by_type" , BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE}, {"bt_device_destroy_bond" , BT_UNIT_TEST_FUNCTION_DEVICE_DESTROY_BOND}, + {"bt_device_le_set_data_length" , BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH}, + {"bt_device_le_data_length_changed_cb", BT_UNIT_TEST_FUNCTION_LE_DEVICE_DATA_LENGTH_CHANGED_CB}, {"Select this menu to set parameters and then select the function again." , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, {NULL , 0x0000}, }; @@ -270,12 +305,10 @@ tc_table_t tc_audio[] = { {"bt_audio_deinitialize" , BT_UNIT_TEST_FUNCTION_AUDIO_DEINITIALIZE}, {"bt_audio_connect" , BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT}, {"bt_audio_disconnect" , BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT}, - {"bt_audio_source_connect" , BT_UNIT_TEST_FUNCTION_AUDIO_SOURCE_CONNECT}, - {"bt_audio_source_disconnect" , BT_UNIT_TEST_FUNCTION_AUDIO_SOURCE_DISCONNECT}, + {"bt_audio_sink_connect" , BT_UNIT_TEST_FUNCTION_AUDIO_SINK_CONNECT}, + {"bt_audio_sink_disconnect" , BT_UNIT_TEST_FUNCTION_AUDIO_SINK_DISCONNECT}, {"bt_audio_set_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_AUDIO_SET_CONNECTION_STATE_CHANGED_CB}, {"bt_audio_unset_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_CONNECTION_STATE_CHANGED_CB}, - {"bt_a2dp_source_audio_set_connection_state_cb", BT_UNIT_TEST_FUNCTION_A2DP_AUDIO_SET_CONNECTION_STATE_CB}, - {"bt_a2dp_source_audio_unset_connection_state_cb", BT_UNIT_TEST_FUNCTION_A2DP_AUDIO_UNSET_CONNECTION_STATE_CB}, {"bt_ag_open_sco" , BT_UNIT_TEST_FUNCTION_AG_OPEN_SCO}, {"bt_ag_close_sco" , BT_UNIT_TEST_FUNCTION_AG_CLOSE_SCO}, {"bt_ag_is_sco_opened" , BT_UNIT_TEST_FUNCTION_AG_IS_SCO_OPENED}, @@ -366,6 +399,28 @@ tc_table_t tc_gatt[] = { {NULL , 0x0000}, }; +tc_table_t tc_hps[] = { + /* HPS functions */ + {"BACK" , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_hps_client_create" , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_CREATE}, + {"bt_hps_client_destroy" , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_DESTROY}, + {"bt_hps_client_print_all" , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_PRINT_ALL}, + {"bt_hps_client_read_value" , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_READ_VALUE}, + {"bt_hps_client_set_uri" , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_URI}, + {"bt_hps_client_set_hdr" , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_HDR}, + {"bt_hps_client_set_entity" , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_ENTITY}, + {"bt_hps_client_set_cp" , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_CP}, + {"bt_hps_client_get_uri" , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_URI}, + {"bt_hps_client_get_hdr" , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_HDR}, + {"bt_hps_client_get_entity" , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_ENTITY}, + {"bt_hps_client_get_security" , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_SECURITY}, + {"bt_hps_client_set_status_notification" , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_STATUS_NOTIFICATION}, + {"bt_hps_client_unset_status_notification" , BT_UNIT_TEST_FUNCTION_HPS_CLIENT_UNSET_STATUS_NOTIFICATION}, + {"Select this menu to set parameters and then select the function again." , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + + tc_table_t tc_avrcp[] = { /* AVRCP functions */ {"BACK" , BT_UNIT_TEST_FUNCTION_BACK}, @@ -418,6 +473,38 @@ tc_table_t tc_hid[] = { {NULL , 0x0000}, }; +tc_table_t tc_ipsp[] = { + /* IPSP functions */ + {"BACK" , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_le_ipsp_register" , BT_UNIT_TEST_FUNCTION_IPSP_REGISTER}, + {"bt_le_ipsp_unregister" , BT_UNIT_TEST_FUNCTION_IPSP_UNREGISTER}, + {"bt_le_ipsp_initialize" , BT_UNIT_TEST_FUNCTION_IPSP_INITIALIZE}, + {"bt_le_ipsp_deinitialize" , BT_UNIT_TEST_FUNCTION_IPSP_DEINITIALIZE}, + {"bt_le_ipsp_connect" , BT_UNIT_TEST_FUNCTION_IPSP_CONNECT}, + {"bt_le_ipsp_disconnect" , BT_UNIT_TEST_FUNCTION_IPSP_DISCONNECT}, + {"bt_le_ipsp_start_advertising" , BT_UNIT_TEST_FUNCTION_IPSP_START_ADVERTISING}, + {"bt_ipsp_set_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_IPSP_SET_CONNECTION_STATE_CHANGED_CB}, + {"bt_ipsp_nsset_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_IPSP_UNSET_CONNECTION_STATE_CHANGED_CB}, + {"Select this menu to set parameters and then select the function again." , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + +tc_table_t tc_HDP[] = { + /* HDP functions */ + {"BACK" , BT_UNIT_TEST_FUNCTION_BACK}, + {"bt_hdp_register_sink_app" , BT_UNIT_TEST_FUNCTION_HDP_REGISTER_SINK_APP}, + {"bt_hdp_unregister_sink_app" , BT_UNIT_TEST_FUNCTION_HDP_UNREGISTER_SINK_APP}, + {"bt_hdp_connect_to_source" , BT_UNIT_TEST_FUNCTION_HDP_CONNECT_TO_SOURCE}, + {"bt_hdp_disconnect" , BT_UNIT_TEST_FUNCTION_HDP_DISCONNECT}, + {"bt_hdp_send_data" , BT_UNIT_TEST_FUNCTION_HDP_SEND_DATA}, + {"bt_hdp_set_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_HDP_SET_CONNECTION_CB}, + {"bt_hdp_unset_connection_state_changed_cb" , BT_UNIT_TEST_FUNCTION_HDP_UNSET_CONNECTION_CB}, + {"bt_hdp_set_data_received_cb" , BT_UNIT_TEST_FUNCTION_HDP_SET_DATA_RECEIVED_CB}, + {"bt_hdp_unset_data_received_cb" , BT_UNIT_TEST_FUNCTION_HDP_UNSET_DATA_RECEIVED_CB}, + {"Select this menu to set parameters and then select the function again." , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, + {NULL , 0x0000}, +}; + #ifdef TIZEN_WEARABLE tc_table_t tc_hf[] = { /* Handsfree role functions */ @@ -512,12 +599,21 @@ void tc_usage_print(void) case BT_UNIT_TEST_TABLE_GATT: tc_table = tc_gatt; break; + case BT_UNIT_TEST_TABLE_HPS: + tc_table = tc_hps; + break; case BT_UNIT_TEST_TABLE_AVRCP: tc_table = tc_avrcp; break; case BT_UNIT_TEST_TABLE_HID: tc_table = tc_hid; break; + case BT_UNIT_TEST_TABLE_IPSP: + tc_table = tc_ipsp; + break; + case BT_UNIT_TEST_TABLE_HDP: + tc_table = tc_HDP; + break; #ifdef TIZEN_WEARABLE case BT_UNIT_TEST_TABLE_HF: tc_table = tc_hf; @@ -764,6 +860,24 @@ static void __bt_adapter_manufacturer_data_changed_cb(char *data, } } +static void __bt_adapter_authentication_req_cb( + int result, bt_authentication_type_info_e auth_type, + char *device_name, char *remote_addr, char *pass_key, void *user_data) +{ + TC_PRT("__bt_adapter_authentication_req_cb: device name = %s", device_name); + TC_PRT("__bt_adapter_authentication_req_cb: device address = %s", remote_addr); + + if (auth_type == BT_AUTH_PIN_REQUEST) { + TC_PRT("Auth Type = BT_AUTH_PIN_REQUEST"); + } else if (auth_type == BT_AUTH_PASSKEY_CONFIRM_REQUEST) { + TC_PRT("Auth Type = BT_AUTH_PASSKEY_CONFIRM_REQUEST"); + TC_PRT("Passkey: [%s]", pass_key); + } else if (auth_type == BT_AUTH_KEYBOARD_PASSKEY_DISPLAY) { + TC_PRT("Auth Type = BT_AUTH_KEYBOARD_PASSKEY_DISPLAY"); + TC_PRT("Passkey: [%s]", pass_key); + } +} + static bool __bt_adapter_bonded_device_cb(bt_device_info_s *device_info, void *user_data) { int i; @@ -911,14 +1025,25 @@ void __bt_gatt_server_read_value_requested_cb (char *remote_address, char char_value_1[3] = {0, 1, 2}; TC_PRT("__bt_gatt_server_read_value_requested_cb"); + TC_PRT("remote_address %s", remote_address); TC_PRT("req_id %d", request_id); TC_PRT("server %s", (char *)server); - TC_PRT("server %s", (char *)gatt_handle); + TC_PRT("gatt_handle %s", (char *)gatt_handle); TC_PRT("Offset %d", offset); /* Get the attribute new values here */ bt_gatt_server_send_response(request_id, offset, char_value_1, 3 - offset); } +void __bt_gatt_server_notification_state_change_cb (bool notify, + bt_gatt_server_h server, bt_gatt_h gatt_handle, void *user_data) +{ + TC_PRT("__bt_gatt_server_notification_state_change_cb"); + TC_PRT("notify %d", notify); + TC_PRT("server %s", (char *)server); + TC_PRT("gatt_handle %s", (char *)gatt_handle); +} + + #ifndef TIZEN_WEARABLE static void __bt_adapter_le_device_discovery_state_changed_cb(int result, bt_adapter_le_device_discovery_state_e discovery_state, @@ -1054,6 +1179,24 @@ static void __bt_socket_connection_state_changed_cb(int result, } } +static void __bt_adapter_le_state_changed_cb(int result, bt_adapter_le_state_e adapter_le_state, void *user_data) +{ + TC_PRT("__bt_adapter_le_state_changed_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("state: %s", + (adapter_le_state == BT_ADAPTER_LE_ENABLED)? + "ENABLED" : "DISABLED"); +} + +static void __bt_le_set_data_length_changed_cb(int result, const char *remote_address, int max_tx_octets, + int max_tx_time, int max_rx_octets, int max_rx_time,void *user_data) +{ + TC_PRT("__bt_le_set_data_length_changed_cb \n"); + TC_PRT("max_tx_octets: %d max_tx_time: %d max_rx_octets: %d max_rx_time: %d", + max_tx_octets, max_tx_time, max_rx_octets, max_rx_time); + TC_PRT("result: %s", __bt_get_error_message(result)); +} + void __bt_opp_client_push_responded_cb(int result, const char *remote_address, void *user_data) @@ -1164,24 +1307,36 @@ void __bt_device_bond_destroyed_cb(int result, char *remote_address, void *user_ } } -void __bt_repeat_test_onoff_count_time_summary() +void __bt_print_repeat_test_summary(void) { - time_t ctimer; - struct tm *_tm; + static struct timeval current_time = {0,}; + static struct timeval diff_time = {0,}; + int time_diff; - ctimer = time(NULL); - ctimer -= bt_onoff_timer; - _tm = gmtime(&ctimer); + gettimeofday(¤t_time, NULL); - if (_tm == NULL) { - /* Fix : NULL_RETURNS */ - TC_PRT("gmtime failed error "); - return; + diff_time.tv_sec = current_time.tv_sec - check_time.tv_sec; + diff_time.tv_usec = current_time.tv_usec - check_time.tv_usec; + if(diff_time.tv_usec < 0) + { + diff_time.tv_sec = diff_time.tv_sec - 1; + diff_time.tv_usec = diff_time.tv_usec + 1000000; } + time_diff = (diff_time.tv_sec * 1000); + time_diff += diff_time.tv_usec / 1000; + + TC_PRT("try: %d, success: %d, fail: %d, time(%d msec)\n", + bt_onoff_cnt/2, bt_onoff_cnt_success/2, bt_onoff_cnt_fail, + time_diff); + + total_time += time_diff; +} - TC_PRT("try: %d, success: %d, fail: %d, time(%dd,%d:%d:%d)\n", +void __bt_print_repeat_test_final_summary() +{ + TC_PRT("try: %d, success: %d, fail: %d, Total_time(%d msec), Average_time(%d msec)\n", bt_onoff_cnt/2, bt_onoff_cnt_success/2, bt_onoff_cnt_fail, - _tm->tm_mday-1, _tm->tm_hour, _tm->tm_min, _tm->tm_sec); + total_time, total_time / bt_onoff_cnt); } void __bt_gatt_connection_state_changed_cb(int result, bool connected, const char *remote_address, void *user_data) @@ -1196,6 +1351,26 @@ void __bt_gatt_connection_state_changed_cb(int result, bool connected, const cha } } +void __bt_hps_connection_state_changed_cb(int result, bool connected, const char *remote_address, void *user_data) +{ + int ret; + TC_PRT("result: %s", __bt_get_error_message(result)); + if (connected) { + TC_PRT("HPS connected(address = %s)", remote_address); + /* Fix : STRING_OVERFLOW */ + strncpy(remote_addr, remote_address, strlen(remote_addr)); + if (hps_client) { + bt_gatt_client_destroy(hps_client); + hps_client = NULL; + } + ret = bt_gatt_client_create(remote_addr, &hps_client); + TC_PRT("returns bt_gatt_client_create %s\n", __bt_get_error_message(ret)); + + } else { + TC_PRT("HPS DISconnected"); + } +} + int __bt_gatt_client_set_value(char *type, char *value, bt_gatt_h h) { int ret; @@ -1410,6 +1585,33 @@ bool __bt_gatt_client_foreach_svc_cb(int total, int index, bt_gatt_h svc_handle, return true; } +bool __bt_hps_client_svc_cb(int total, int index, bt_gatt_h svc_handle, void *data) +{ + int test_id = (int)data; + int ret; + char *uuid = NULL; + char *str = NULL; + + bt_gatt_get_uuid(svc_handle, &uuid); + bt_gatt_get_uuid_specification_name(uuid, &str); + + if (!g_strcmp0(uuid, HPS_UUID)) { + + TC_PRT("[%d / %d] %s (%s)", index, total, str ? str : "Unknown", uuid); + + g_free(str); + g_free(uuid); + + if (test_id == BT_UNIT_TEST_FUNCTION_HPS_CLIENT_PRINT_ALL) { + ret = bt_gatt_service_foreach_characteristics(svc_handle, + __bt_gatt_client_foreach_chr_cb, (void *)test_id); + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_service_foreach_characteristics is failed : %d", ret); + } + } + return true; +} + static void __ancs_write_completed_cb(int result, bt_gatt_h request_handle, void *user_data) { @@ -1485,6 +1687,25 @@ void __bt_gatt_client_value_changed_cb(bt_gatt_h chr, char *value, int len, return; } +void __bt_HP_client_cp_req_status_changed_cb(bt_gatt_h chr, char *value, int len, + void *user_data) +{ + char *uuid = NULL; + int i; + + bt_gatt_get_uuid(chr, &uuid); + + TC_PRT("Value changed for [%s]", uuid); + TC_PRT("len [%d]", len); + for (i = 0; i < len; i++) { + TC_PRT("value %u", value[i]); + } + + g_free(uuid); + + return; +} + void __bt_gatt_server_notification_sent_cb(int result, char *remote_address, bt_gatt_server_h server, bt_gatt_h characteristic, bool completed, void *user_data) @@ -1495,6 +1716,21 @@ void __bt_gatt_server_notification_sent_cb(int result, TC_PRT("characteristic : %p", characteristic); } +void __bt_gatt_server_value_changed_cb(char *remote_address, + bt_gatt_server_h server, bt_gatt_h gatt_handle, + int offset, char *value, int len, + void *user_data) +{ + int i; + TC_PRT("remote_address : %s", remote_address); + TC_PRT("offset : %d", offset); + TC_PRT("len [%d] : ", len); + for (i = 0; i < len; i++) { + printf("%d ", value[i]); + } + printf("\n"); +} + #ifdef BT_ENABLE_LEGACY_GATT_CLIENT bool __bt_gatt_primary_service_cb(bt_gatt_attribute_h service, void *user_data) { @@ -1684,6 +1920,57 @@ void __bt_hid_host_connection_state_changed_cb(int result, TC_PRT("result: %s", __bt_get_error_message(result)); } +void __bt_hdp_connected_cb(int result, const char *remote_address, const char *app_id, + bt_hdp_channel_type_e type, unsigned int channel, void *user_data) +{ + TC_PRT("__bt_hdp_connected_cb: called"); + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("remote_address: %s", remote_address); + TC_PRT("app_id: %s", app_id); + TC_PRT("type: %x", type); + TC_PRT("channel: %d", channel); + + channel_hdp = channel; +} + +void __bt_hdp_disconnected_cb(int result, const char *remote_address, unsigned int channel, void *user_data) +{ + TC_PRT("__bt_hdp_connected_cb: called"); + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("remote_address: %s", remote_address); + TC_PRT("channel: %d", channel); + + channel_hdp = channel; +} + +void __bt_hdp_data_received_cb(unsigned int channel, const char *data, unsigned int size, void *user_data) +{ + TC_PRT("__bt_hdp_data_received_cb: called"); + TC_PRT("data: %s", data); + TC_PRT("size: %d", size); + TC_PRT("channel: %d", channel); +} + +void __bt_le_ipsp_init_state_changed_cb(int result, + bool ipsp_initialized, void *user_data) +{ + TC_PRT("result: %s", __bt_get_error_message(result)); + if (ipsp_initialized) { + TC_PRT("IPSP Init state: INITIALIZED"); + } else { + TC_PRT("IPSP Init state: UN-INITIALIZED"); + _bt_unset_cb(BT_EVENT_IPSP_INIT_STATE_CHANGED); + } +} + +void __bt_le_ipsp_connection_state_changed_cb(int result, + bool connected, const char *remote_address, void *user_data) +{ + TC_PRT("__bt_le_ipsp_connection_state_changed_cb: called"); + TC_PRT("result: %s", __bt_get_error_message(result)); + TC_PRT("Connected: %d", connected); +} + #ifdef TIZEN_WEARABLE void __bt_hf_sco_state_changed_cb(int result, bool opened, void *user_data) { @@ -1801,6 +2088,8 @@ void __bt_repeat_test_adapter_state_changed_cb(int result, bt_adapter_state_e ad (adapter_state == BT_ADAPTER_ENABLED)? "ENABLED" : "DISABLED", delay); + __bt_print_repeat_test_summary(); + if (result != BT_ERROR_NONE) { char *argv[] = {NULL}; @@ -1815,13 +2104,13 @@ void __bt_repeat_test_adapter_state_changed_cb(int result, bt_adapter_state_e ad sleep(delay); } + gettimeofday(&check_time, NULL); if (adapter_state == BT_ADAPTER_DISABLED) bt_adapter_enable(); else bt_adapter_disable(); bt_onoff_cnt++; - __bt_repeat_test_onoff_count_time_summary(); } static void __bt_initialize_all(void) @@ -1859,6 +2148,9 @@ static void __bt_initialize_all(void) if (ret != BT_ERROR_NONE) TC_PRT("returns %s\n", __bt_get_error_message(ret)); + ret = bt_adapter_le_set_state_changed_cb(__bt_adapter_le_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); return; } @@ -2470,6 +2762,101 @@ int test_set_params(int test_id, char *param) break; } + case BT_UNIT_TEST_TABLE_HPS: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_CREATE: { + if (param_index == 0) { + g_test_param.param_count = 1; + g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count); + param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; + } + + if (param_index > 0) { + g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); + strcpy(g_test_param.params[param_index - 1], param); + } + + if (param_index == g_test_param.param_count) { + need_to_set_params = false; + test_input_callback((void *)test_id); + param_index = 0; + return 0; + } + + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + param_index++; + + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_HDR: + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_ENTITY: + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_URI: { + if (param_index == 0) { + g_test_param.param_count = 1; + g_test_param.params = g_malloc0(sizeof(char *) * g_test_param.param_count); + } + + if (param_index > 0) { + int len = strlen(param); + g_test_param.params[param_index - 1] = g_malloc0(len + 1); + /* Remove new line character */ + param[len - 1] = '\0'; + strcpy(g_test_param.params[param_index - 1], param); + } + + if (param_index == g_test_param.param_count) { + need_to_set_params = false; + test_input_callback((void *)test_id); + param_index = 0; + return 0; + } + + switch (param_index) { + case 0: + TC_PRT("Input Value in string"); + break; + } + + param_index++; + + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_CP: { + if (param_index == 0) { + g_test_param.param_count = 1; + g_test_param.params = g_malloc0(sizeof(char *) * g_test_param.param_count); + param_type = BT_UNIT_TEST_PARAM_TYPE_INT; + } + if (param_index > 0) { + g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); + strcpy(g_test_param.params[param_index - 1], param); + } + + if (param_index == g_test_param.param_count) { + need_to_set_params = false; + test_input_callback((void *)test_id); + param_index = 0; + return 0; + } + + switch (param_index) { + case 0: + TC_PRT("Input Value Type (avail. : \n1.HTTP_GET, \n2.HTTP_HEAD, \n3.HTTP_POST, \n4.HTTP_PUT, \n5.HTTP_DELETE, \n6.HTTPS_GET, \n7.HTTPS_HEAD, \n8.HTTPS_POST, \n9.HTTPS_PUT, \n10.HTTPS_DELETE, \n11.HTTP_CANCEL"); + break; + } + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + param_index++; + + break; + } + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + break; + } + case BT_UNIT_TEST_TABLE_AVRCP: { switch (test_id) { default: @@ -2490,6 +2877,27 @@ int test_set_params(int test_id, char *param) break; } + case BT_UNIT_TEST_TABLE_IPSP: { + switch (test_id) { + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_HDP: { + switch (test_id) { + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + } + + break; + } #ifdef TIZEN_WEARABLE case BT_UNIT_TEST_TABLE_HF: { switch (test_id) { @@ -2795,7 +3203,62 @@ int test_input_callback(void *data) TC_PRT("returns %s\n", __bt_get_error_message(ret)); break; } - + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUSET_CB: + { + ret = bt_adapter_set_authentication_req_cb(__bt_adapter_authentication_req_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUSET_CB: + { + ret = bt_adapter_unset_authentication_req_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_ACCEPT: + { + char *passkey = NULL; + TC_PRT("bt_passkey_reply: Authenticate Logitech Mouse: reply = Accept"); + passkey = g_strdup("0000"); //Passkey - "0000" for mouse + ret = bt_passkey_reply(passkey, TRUE); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else + TC_PRT("bt_passkey_reply: accept authentication result = %d", ret); + g_free(passkey); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_CANCEL: + { + char *passkey = NULL; + TC_PRT("bt_passkey_reply: cancel authentication reply"); + passkey = g_strdup("0000"); //Passkey - "0000" + ret = bt_passkey_reply(passkey, FALSE); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else + TC_PRT("bt_passkey_reply: Logitech Mouse cancel authentication result = %d", ret); + g_free(passkey); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_ACCEPT: + { + ret = bt_passkey_confirmation_reply(TRUE); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else + TC_PRT("bt_passkey_confirmation_reply accept, result = %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_REJECT: + { + ret = bt_passkey_confirmation_reply(FALSE); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + else + TC_PRT("bt_passkey_confirmation_reply reject, result = %d", ret); + break; + } case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: need_to_set_params = true; TC_PRT("Select the function again"); @@ -3122,7 +3585,6 @@ int test_input_callback(void *data) adv_params.interval_min= 500; adv_params.interval_max= 500; - adv_params.type = BT_ADAPTER_LE_ADVERTISING_CONNECTABLE; if (advertiser == NULL) { ret = bt_adapter_le_create_advertiser(&advertiser); @@ -3132,8 +3594,6 @@ int test_input_callback(void *data) advertiser_index++; advertiser_index %= 3; - TC_PRT("type: %d", adv_params.type); - ret = bt_adapter_le_start_advertising(advertiser, &adv_params, cb, NULL); if (ret < BT_ERROR_NONE) TC_PRT("failed with [0x%04x]", ret); @@ -3292,7 +3752,74 @@ int test_input_callback(void *data) TC_PRT("returns %s\n", __bt_get_error_message(ret)); break; #endif + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_MAXIMUM_DATA_LENGTH: { + + TC_PRT("Read Maximum LE Data length"); + + int max_tx_octects = 0; + int max_rx_octects = 0; + int max_tx_time = 0; + int max_rx_time = 0; + ret = bt_adapter_le_read_maximum_data_length( + &max_tx_octects, &max_tx_time, + &max_rx_octects, &max_rx_time); + TC_PRT("max data length values are %d %d %d %d", + max_tx_octects, max_tx_time, + max_rx_octects, max_rx_time); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_WRITE_HOST_SUGGESTED_DEFAULT_DATA_LENGTH: { + + TC_PRT("Testing: Write Host suggested default LE Data length"); + + unsigned int def_tx_octects = 30; + unsigned int def_tx_time = 330; + ret = bt_adapter_le_write_host_suggested_default_data_length( + def_tx_octects, def_tx_time); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + break; + } + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_HOST_SUGGESTED_DEFAULT_DATA_LENGTH: { + + TC_PRT("Read host suggested default LE Data length"); + + unsigned int def_tx_octets = 0; + unsigned int def_tx_time = 0; + ret = bt_adapter_le_read_suggested_default_data_length( + &def_tx_octets, &def_tx_time); + TC_PRT("host suggested default le data length values are %d %d", + def_tx_octets, def_tx_time); + break; + } + + case BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH: { + + TC_PRT("Set LE Data length paramters cmd"); + + unsigned int tx_octets = 50; + unsigned int tx_time = 500; + + TC_PRT("settting le data length values tx octects: %d tx time: %d", + tx_octets, tx_time); + ret = bt_device_le_set_data_length(remote_addr, + tx_octets, tx_time); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + break; + } + case BT_UNIT_TEST_FUNCTION_LE_DEVICE_DATA_LENGTH_CHANGED_CB: { + + TC_PRT("Setting LE Data length change callback"); + ret = bt_device_le_set_data_length_change_cb(__bt_le_set_data_length_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + break; + } case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: need_to_set_params = true; TC_PRT("Select the function again"); @@ -3666,15 +4193,6 @@ int test_input_callback(void *data) ret = bt_audio_unset_connection_state_changed_cb(); TC_PRT("returns %s\n", __bt_get_error_message(ret)); break; - case BT_UNIT_TEST_FUNCTION_A2DP_AUDIO_SET_CONNECTION_STATE_CB: - ret = bt_a2dp_source_audio_set_connection_state_changed_cb( - __bt_audio_connection_state_changed_cb, NULL); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; - case BT_UNIT_TEST_FUNCTION_A2DP_AUDIO_UNSET_CONNECTION_STATE_CB: - ret = bt_a2dp_source_audio_unset_connection_state_changed_cb(); - TC_PRT("returns %s\n", __bt_get_error_message(ret)); - break; case BT_UNIT_TEST_FUNCTION_AG_OPEN_SCO: ret = bt_ag_open_sco(); TC_PRT("returns %s\n", __bt_get_error_message(ret)); @@ -4193,6 +4711,8 @@ int test_input_callback(void *data) char_value, sizeof(char_value), &characteristic); TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb, NULL); + bt_gatt_server_set_notification_state_change_cb(characteristic, __bt_gatt_server_notification_state_change_cb, NULL); ret = bt_gatt_service_add_characteristic(service, characteristic); TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); @@ -4253,6 +4773,7 @@ int test_input_callback(void *data) heart_rate_h.chr = characteristic; bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb, NULL); + bt_gatt_server_set_notification_state_change_cb(characteristic, __bt_gatt_server_notification_state_change_cb, NULL); ret = bt_gatt_service_add_characteristic(service, characteristic); TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); @@ -4271,6 +4792,7 @@ int test_input_callback(void *data) &char_value_2, sizeof(char_value_2), &characteristic); TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb, NULL); ret = bt_gatt_service_add_characteristic(service, characteristic); TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); @@ -4323,6 +4845,8 @@ int test_input_callback(void *data) char_value, sizeof(char_value), &characteristic); TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb, NULL); + bt_gatt_server_set_notification_state_change_cb(characteristic, __bt_gatt_server_notification_state_change_cb, NULL); ret = bt_gatt_service_add_characteristic(service, characteristic); TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); @@ -4379,6 +4903,7 @@ int test_input_callback(void *data) TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); g_free(char_value); + bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb, NULL); ret = bt_gatt_service_add_characteristic(service, characteristic); TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); @@ -4389,6 +4914,7 @@ int test_input_callback(void *data) TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); g_free(char_value); + bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb, NULL); ret = bt_gatt_service_add_characteristic(service, characteristic); TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); @@ -4399,6 +4925,7 @@ int test_input_callback(void *data) TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); g_free(char_value); + bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb, NULL); ret = bt_gatt_service_add_characteristic(service, characteristic); TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); @@ -4409,6 +4936,7 @@ int test_input_callback(void *data) TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); g_free(char_value); + bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb, NULL); ret = bt_gatt_service_add_characteristic(service, characteristic); TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); @@ -4441,6 +4969,10 @@ int test_input_callback(void *data) char_value, value_length, &characteristic); TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + ret = bt_gatt_server_set_value_changed_cb(characteristic, __bt_gatt_server_value_changed_cb, NULL); + TC_PRT("bt_gatt_server_set_value_changed_cb : %s\n", __bt_get_error_message(ret)); + + bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb, NULL); ret = bt_gatt_service_add_characteristic(service, characteristic); TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); @@ -4478,6 +5010,7 @@ int test_input_callback(void *data) char_value, value_length, &characteristic); TC_PRT("bt_gatt_characteristic_create : %s\n", __bt_get_error_message(ret)); + bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb, NULL); ret = bt_gatt_service_add_characteristic(service, characteristic); TC_PRT("bt_gatt_service_add_characteristic : %s\n", __bt_get_error_message(ret)); @@ -4809,6 +5342,373 @@ int test_input_callback(void *data) break; } + case BT_UNIT_TEST_TABLE_HPS: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_CREATE : { + bool auto_connect = false; + + if (g_test_param.param_count > 0) { + if (g_strrstr(g_test_param.params[0], "true")) + auto_connect = true; + else + auto_connect = false; + + __bt_free_test_param(&g_test_param); + } + + ret = bt_gatt_connect(remote_addr, auto_connect); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + ret = bt_gatt_set_connection_state_changed_cb(__bt_hps_connection_state_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_DESTROY: { + if (!hps_client) + break; + + ret = bt_gatt_client_destroy(hps_client); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + hps_client = NULL; + ret = bt_gatt_disconnect(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_PRINT_ALL: { + ret = bt_gatt_client_foreach_services(hps_client, + __bt_hps_client_svc_cb, (void *)test_id); + if (ret != BT_ERROR_NONE) { + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + } + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_URI: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + char *uri = NULL; + + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + uri = g_test_param.params[0]; + ret = bt_gatt_client_get_service(hps_client, HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, HTTP_URI_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = __bt_gatt_client_set_value("str", uri, chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_set_value is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_client_write_value(chr, + __bt_gatt_client_write_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_write_value is failed : %d", ret); + } + + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_HDR: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + char *hdr = NULL; + + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + hdr = g_test_param.params[0]; + + ret = bt_gatt_client_get_service(hps_client, HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, HTTP_HDR_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = __bt_gatt_client_set_value("str", hdr, chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_set_value is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_client_write_value(chr, + __bt_gatt_client_write_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_write_value is failed : %d", ret); + } + + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_ENTITY: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + char *entity = NULL; + + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + entity = g_test_param.params[0]; + + ret = bt_gatt_client_get_service(hps_client, HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, HTTP_ENTITY_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = __bt_gatt_client_set_value("str", entity, chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_set_value is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_client_set_characteristic_value_changed_cb(chr, + __bt_HP_client_cp_req_status_changed_cb, NULL); + + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_write_value is failed : %d", ret); + } + + ret = bt_gatt_client_write_value(chr, + __bt_gatt_client_write_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_write_value is failed : %d", ret); + } + + __bt_free_test_param(&g_test_param); + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_CP: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + + ret = bt_gatt_client_get_service(hps_client, HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, HTTP_CP_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = __bt_gatt_client_set_value("uint8", g_test_param.params[0], chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_set_value is failed : %d", ret); + __bt_free_test_param(&g_test_param); + break; + } + + ret = bt_gatt_client_write_value(chr, + __bt_gatt_client_write_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_write_value is failed : %d", ret); + } + __bt_free_test_param(&g_test_param); + break; + } + + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_URI: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + ret = bt_gatt_client_get_service(hps_client, HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, HTTP_URI_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + break; + } + + ret = bt_gatt_client_read_value(chr, + __bt_gatt_client_read_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_read_value is failed : %d", ret); + } + break; + } + + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_HDR: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + ret = bt_gatt_client_get_service(hps_client, HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, HTTP_HDR_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + break; + } + + ret = bt_gatt_client_read_value(chr, + __bt_gatt_client_read_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_read_value is failed : %d", ret); + } + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_ENTITY: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + ret = bt_gatt_client_get_service(hps_client, HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, HTTP_ENTITY_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + break; + } + + ret = bt_gatt_client_read_value(chr, + __bt_gatt_client_read_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_read_value is failed : %d", ret); + } + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_SECURITY: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + ret = bt_gatt_client_get_service(hps_client, HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, HTTP_SECURITY_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + break; + } + + ret = bt_gatt_client_read_value(chr, + __bt_gatt_client_read_complete_cb, NULL); + + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_read_value is failed : %d", ret); + } + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_STATUS_NOTIFICATION: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + ret = bt_gatt_client_get_service(hps_client, HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, HTTP_STATUS_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + break; + } + + ret = bt_gatt_client_set_characteristic_value_changed_cb(chr, + __bt_gatt_client_value_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_set_characteristic_value_changed_cb is failed : %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_UNSET_STATUS_NOTIFICATION: { + bt_gatt_h svc = NULL; + bt_gatt_h chr = NULL; + + ret = bt_gatt_client_get_service(hps_client, HPS_UUID, &svc); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_client_get_service is failed : %d", ret); + break; + } + + ret = bt_gatt_service_get_characteristic(svc, HTTP_STATUS_UUID, &chr); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_gatt_service_get_characteristic is failed : %d", ret); + break; + } + + ret = bt_gatt_client_unset_characteristic_value_changed_cb(chr); + if (ret != BT_ERROR_NONE) + TC_PRT("bt_gatt_client_unset_characteristic_value_changed_cb is failed : %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + + break; + } + + case BT_UNIT_TEST_TABLE_AVRCP: { switch (test_id) { case BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_INITIALIZE: @@ -5036,7 +5936,132 @@ int test_input_callback(void *data) TC_PRT("returns %s\n", __bt_get_error_message(ret)); break; } + case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: + need_to_set_params = true; + TC_PRT("Select the function again"); + break; + + default: + break; + } + break; + } + + case BT_UNIT_TEST_TABLE_IPSP: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_IPSP_REGISTER: { + bt_gatt_h service = NULL; + char *service_uuid = "1820"; // IPSP Service + + ret = bt_gatt_server_initialize(); + TC_PRT("bt_gatt_server_initialize : %s \n", __bt_get_error_message(ret)); + + if (server == NULL) { + ret = bt_gatt_server_create(&server); + TC_PRT("bt_gatt_server_create : %s \n", __bt_get_error_message(ret)); + } + + ret = bt_gatt_service_create(service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &service); + TC_PRT("bt_gatt_service_create : %s \n", __bt_get_error_message(ret)); + + ret = bt_gatt_server_register_service(server, service); + TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret)); + ipsp_h.svc = service; + + break; + } + case BT_UNIT_TEST_FUNCTION_IPSP_UNREGISTER: + if (server != NULL && ipsp_h.svc != NULL) { + ret = bt_gatt_server_unregister_service(server, ipsp_h.svc); + TC_PRT("bt_gatt_server_unregister_service : returns %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) + ipsp_h.svc = NULL; + } else { + TC_PRT("Gatt Server or IPSP not registered !"); + } + break; + case BT_UNIT_TEST_FUNCTION_IPSP_INITIALIZE: + /* Initialize IPSP server */ + if (server != NULL && ipsp_h.svc != NULL) { + ret = _bt_le_ipsp_initialize(&__bt_le_ipsp_init_state_changed_cb, NULL); + TC_PRT("bt_le_ipsp_initialize : returns %s\n", __bt_get_error_message(ret)); + } else { + TC_PRT("Gatt Server or IPSP not registered !"); + } + break; + case BT_UNIT_TEST_FUNCTION_IPSP_DEINITIALIZE: + /* De-Initialize IPSP server */ + ret = _bt_le_ipsp_deinitialize(); + TC_PRT("bt_le_ipsp_deinitialize : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_IPSP_CONNECT: + ret = _bt_le_ipsp_connect(remote_addr); + break; + case BT_UNIT_TEST_FUNCTION_IPSP_DISCONNECT: + ret = _bt_le_ipsp_disconnect(remote_addr); + break; + case BT_UNIT_TEST_FUNCTION_IPSP_START_ADVERTISING: { + const char *ipsp_svc_uuid_16 = "1820"; + ret = _bt_le_ipsp_is_initialized(); + if (ret != BT_ERROR_NONE) { + TC_PRT("bt_le_ipsp_add_advertising_data: returns %s\n", __bt_get_error_message(ret)); + break; + } + /* Add IPSP service in advertising data */ + advertiser = advertiser_list[advertiser_index]; + if (advertiser == NULL) { + ret = bt_adapter_le_create_advertiser(&advertiser); + if (ret != BT_ERROR_NONE) { + TC_PRT("created le advertiser(%d)", ret); + break; + } + + advertiser_list[advertiser_index] = advertiser; + ret = bt_adapter_le_set_advertising_device_name(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); + if (ret != BT_ERROR_NONE) { + TC_PRT("set device name [0x%04x]", ret); + break; + } + } + + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, ipsp_svc_uuid_16); + if (ret != BT_ERROR_NONE) { + TC_PRT("add service_solicitation_uuid [0x%04x]", ret); + break; + } + + /* Start advertising IPSP service */ + bt_adapter_le_advertising_state_changed_cb cb; + + if (advertiser_index == 0) cb = __bt_adapter_le_advertising_state_changed_cb; + else if (advertiser_index == 1) cb = __bt_adapter_le_advertising_state_changed_cb_2; + else cb = __bt_adapter_le_advertising_state_changed_cb_3; + + advertiser = advertiser_list[advertiser_index]; + + advertiser_index++; + advertiser_index %= 3; + + TC_PRT("advertiser: %p", advertiser); + + ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL); + if (ret < BT_ERROR_NONE) + TC_PRT("failed with [0x%04x]", ret); + + break; + } + case BT_UNIT_TEST_FUNCTION_IPSP_SET_CONNECTION_STATE_CHANGED_CB: + ret = _bt_le_ipsp_set_connection_state_changed_cb(__bt_le_ipsp_connection_state_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + + case BT_UNIT_TEST_FUNCTION_IPSP_UNSET_CONNECTION_STATE_CHANGED_CB: + ret = _bt_le_ipsp_unset_connection_state_changed_cb(); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: need_to_set_params = true; TC_PRT("Select the function again"); @@ -5048,6 +6073,50 @@ int test_input_callback(void *data) break; } + + case BT_UNIT_TEST_TABLE_HDP : { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_HDP_REGISTER_SINK_APP: + ret = bt_hdp_register_sink_app(0x1007, &appid); + TC_PRT("bt_hdp_register_sink_app : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_UNREGISTER_SINK_APP: + ret = bt_hdp_unregister_sink_app(appid); + TC_PRT("bt_hdp_unregister_sink_app : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_CONNECT_TO_SOURCE: + ret = bt_hdp_connect_to_source(remote_addr, appid); + TC_PRT("bt_hdp_connect_to_source : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_DISCONNECT: + ret = bt_hdp_disconnect(remote_addr, channel_hdp); + TC_PRT("bt_hdp_disconnect : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_SEND_DATA: + ret = bt_hdp_send_data(channel_hdp, data_hdp, strlen(data_hdp)); + TC_PRT("bt_hdp_send_data : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_SET_CONNECTION_CB: + ret = bt_hdp_set_connection_state_changed_cb(__bt_hdp_connected_cb, __bt_hdp_disconnected_cb, NULL); + TC_PRT("bt_hdp_set_connection_state_changed_cb : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_UNSET_CONNECTION_CB: + ret = bt_hdp_unset_connection_state_changed_cb(); + TC_PRT("bt_hdp_unset_connection_state_changed_cb : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_SET_DATA_RECEIVED_CB: + ret = bt_hdp_set_data_received_cb(__bt_hdp_data_received_cb, NULL); + TC_PRT("bt_hdp_set_data_received_cb : returns %s\n", __bt_get_error_message(ret)); + break; + case BT_UNIT_TEST_FUNCTION_HDP_UNSET_DATA_RECEIVED_CB: + ret = bt_hdp_unset_data_received_cb(); + TC_PRT("bt_hdp_unset_data_received_cb : returns %s\n", __bt_get_error_message(ret)); + break; + default: + break; + } + break; + } #ifdef TIZEN_WEARABLE case BT_UNIT_TEST_TABLE_HF: { switch (test_id) { @@ -5300,7 +6369,9 @@ int test_input_callback(void *data) bt_onoff_cnt = 0; bt_onoff_cnt_success = 0; bt_onoff_cnt_fail = 0; - bt_onoff_timer = time(NULL); + + total_time = 0; + gettimeofday(&check_time, NULL); if (input_automated_test_delay == true) { delay = test_id; @@ -5444,7 +6515,7 @@ void sig_handler(int signo) { if (signo == SIGINT) { if (bt_onoff_cnt > 0) - __bt_repeat_test_onoff_count_time_summary(); + __bt_print_repeat_test_final_summary(); bt_deinitialize(); exit(0); diff --git a/test/bt_unit_test.h b/test/bt_unit_test.h index cc02183..6718701 100644..100755 --- a/test/bt_unit_test.h +++ b/test/bt_unit_test.h @@ -41,8 +41,11 @@ typedef enum BT_UNIT_TEST_TABLE_AUDIO, BT_UNIT_TEST_TABLE_PAN, BT_UNIT_TEST_TABLE_GATT, + BT_UNIT_TEST_TABLE_HPS, BT_UNIT_TEST_TABLE_AVRCP, BT_UNIT_TEST_TABLE_HID, + BT_UNIT_TEST_TABLE_IPSP, + BT_UNIT_TEST_TABLE_HDP, #ifdef TIZEN_WEARABLE BT_UNIT_TEST_TABLE_HF, BT_UNIT_TEST_TABLE_PBAP_CLIENT, @@ -87,6 +90,12 @@ typedef enum BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA_CHANGED_CB, BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_MANUFACTURER_DATA_CHANGED_CB, BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_SET_AUTHENTICATION_REQUSET_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_AUTHENTICATION_REQUSET_CB, + BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_ACCEPT, + BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_REPLY_CANCEL, + BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_ACCEPT, + BT_UNIT_TEST_FUNCTION_ADAPTER_PASSKEY_CONFIRMATION_REPLY_REJECT, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_STATE = 1, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_DISABLE, @@ -120,6 +129,11 @@ typedef enum BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB, #endif + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_MAXIMUM_DATA_LENGTH, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_WRITE_HOST_SUGGESTED_DEFAULT_DATA_LENGTH, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_READ_HOST_SUGGESTED_DEFAULT_DATA_LENGTH, + BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH, + BT_UNIT_TEST_FUNCTION_LE_DEVICE_DATA_LENGTH_CHANGED_CB, BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_TRUE = 1, BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_FALSE, BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_CHANGED_CB, @@ -168,12 +182,10 @@ typedef enum BT_UNIT_TEST_FUNCTION_AUDIO_DEINITIALIZE, BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT, BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT, - BT_UNIT_TEST_FUNCTION_AUDIO_SOURCE_CONNECT, - BT_UNIT_TEST_FUNCTION_AUDIO_SOURCE_DISCONNECT, + BT_UNIT_TEST_FUNCTION_AUDIO_SINK_CONNECT, + BT_UNIT_TEST_FUNCTION_AUDIO_SINK_DISCONNECT, BT_UNIT_TEST_FUNCTION_AUDIO_SET_CONNECTION_STATE_CHANGED_CB, BT_UNIT_TEST_FUNCTION_AUDIO_UNSET_CONNECTION_STATE_CHANGED_CB, - BT_UNIT_TEST_FUNCTION_A2DP_AUDIO_SET_CONNECTION_STATE_CB, - BT_UNIT_TEST_FUNCTION_A2DP_AUDIO_UNSET_CONNECTION_STATE_CB, BT_UNIT_TEST_FUNCTION_AG_OPEN_SCO, BT_UNIT_TEST_FUNCTION_AG_CLOSE_SCO, BT_UNIT_TEST_FUNCTION_AG_IS_SCO_OPENED, @@ -250,6 +262,20 @@ typedef enum BT_UNIT_TEST_FUNCTION_GATT_WATCH_CHARACTERISTIC_CHANGES, BT_UNIT_TEST_FUNCTION_GATT_UNWATCH_CHARACTERISTIC_CHANGES, #endif + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_CREATE = 1, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_DESTROY, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_PRINT_ALL, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_READ_VALUE, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_URI, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_HDR, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_ENTITY, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_CP, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_URI, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_HDR, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_ENTITY, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_GET_SECURITY, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_STATUS_NOTIFICATION, + BT_UNIT_TEST_FUNCTION_HPS_CLIENT_UNSET_STATUS_NOTIFICATION, BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_INITIALIZE = 1, BT_UNIT_TEST_FUNCTION_AVRCP_TARGET_DEINITIALIZE, BT_UNIT_TEST_FUNCTION_AVRCP_SET_EQUALIZER_STATE_CHANGED_CB, @@ -288,6 +314,32 @@ typedef enum BT_UNIT_TEST_FUNCTION_HID_HOST_DEINITIALIZE, BT_UNIT_TEST_FUNCTION_HID_HOST_CONNECT, BT_UNIT_TEST_FUNCTION_HID_HOST_DISCONNECT, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_ACTIVATE, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_CONNECT, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_DISCONNECT, + BT_UNIT_TEST_FUCNTION_HID_DEVICE_DEACTIVATE, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_MOUSE_EVENT, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_KEY_EVENT, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_SET_DATA_RECEIVED_CB, + BT_UNIT_TEST_FUNCTION_HID_DEVICE_UNSET_DATA_RECEIVED_CB, + BT_UNIT_TEST_FUNCTION_IPSP_REGISTER = 1, + BT_UNIT_TEST_FUNCTION_IPSP_UNREGISTER, + BT_UNIT_TEST_FUNCTION_IPSP_INITIALIZE, + BT_UNIT_TEST_FUNCTION_IPSP_DEINITIALIZE, + BT_UNIT_TEST_FUNCTION_IPSP_CONNECT, + BT_UNIT_TEST_FUNCTION_IPSP_DISCONNECT, + BT_UNIT_TEST_FUNCTION_IPSP_START_ADVERTISING, + BT_UNIT_TEST_FUNCTION_IPSP_SET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_IPSP_UNSET_CONNECTION_STATE_CHANGED_CB, + BT_UNIT_TEST_FUNCTION_HDP_REGISTER_SINK_APP = 1, + BT_UNIT_TEST_FUNCTION_HDP_UNREGISTER_SINK_APP, + BT_UNIT_TEST_FUNCTION_HDP_CONNECT_TO_SOURCE, + BT_UNIT_TEST_FUNCTION_HDP_DISCONNECT, + BT_UNIT_TEST_FUNCTION_HDP_SEND_DATA, + BT_UNIT_TEST_FUNCTION_HDP_SET_CONNECTION_CB, + BT_UNIT_TEST_FUNCTION_HDP_UNSET_CONNECTION_CB, + BT_UNIT_TEST_FUNCTION_HDP_SET_DATA_RECEIVED_CB, + BT_UNIT_TEST_FUNCTION_HDP_UNSET_DATA_RECEIVED_CB, #ifdef TIZEN_WEARABLE BT_UNIT_TEST_FUNCTION_HF_INITIALIZE = 1, BT_UNIT_TEST_FUNCTION_HF_DEINITIALIZE, diff --git a/test/gatt_profile_test_suite/CMakeLists.txt b/test/gatt_profile_test_suite/CMakeLists.txt index dccbadd..b4b1ae8 100644 --- a/test/gatt_profile_test_suite/CMakeLists.txt +++ b/test/gatt_profile_test_suite/CMakeLists.txt @@ -12,6 +12,9 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall") SET(SOURCES bt_unit_test_gatt.c bt_unit_test_gatt_hr_profile.c +bt_unit_test_gatt_time_profile_client.c +bt_unit_test_gatt_time_profile_server.c +bt_unit_test_gatt_custom_profile_server.c ) ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES}) diff --git a/test/gatt_profile_test_suite/bt_unit_test_gatt.c b/test/gatt_profile_test_suite/bt_unit_test_gatt.c index db2c966..3a1dd07 100644 --- a/test/gatt_profile_test_suite/bt_unit_test_gatt.c +++ b/test/gatt_profile_test_suite/bt_unit_test_gatt.c @@ -19,6 +19,8 @@ void sig_handler(int signo) static struct option main_options[] = { { "heart-rate-profile", optional_argument, NULL, 'H' }, + { "time-profile", optional_argument, NULL, 'T' }, + { "custom-profile", optional_argument, NULL, 'C' }, { "client", no_argument, NULL, 'c' }, { "server", no_argument, NULL, 's' }, { "help", no_argument, NULL, 'h' }, @@ -34,6 +36,8 @@ void usage() "\t -s server role\n\n"\ "\t [option..]:\n"\ "\t -H <bd-addr> Heart rate Profile\n"\ + "\t -T <bd-addr> Time Profile\n"\ + "\t -C <bd-addr> Custom Profile\n"\ "\t -d Debug enable\n"\ "\t -h Help Menu\n"); } @@ -52,7 +56,7 @@ int main(int argc, char *argv[]) g_io_channel_set_flags(key_io, G_IO_FLAG_NONBLOCK, NULL); while ((opt = getopt_long(argc, argv, - "H:hcsd", main_options, NULL)) != -1) { + "H:T:C:hcsd", main_options, NULL)) != -1) { switch(opt) { case 'c': if (role == GATT_ROLE_SERVER) { @@ -90,6 +94,53 @@ int main(int argc, char *argv[]) profile_selected = true; } break; + case 'T': + if (role == GATT_ROLE_INVALID) { + USR_PRT("<role> parameter is missing"); + usage(); + exit(0); + }else if(role == GATT_ROLE_CLIENT) { + time_client_initialize(); + USR_PRT("Launching Time profile server test-suite"); + memcpy(buf, optarg, sizeof(buf)); + time_client_accept_input(buf); + g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, + time_client_key_event_cb, NULL); + g_io_channel_unref(key_io); + profile_selected = true; + profile_signal_handler_cb = time_client_signal_handler; + } else { + time_server_initialize(); + USR_PRT("Launching Time profile server test-suite"); + memcpy(buf, optarg, sizeof(buf)); + time_server_accept_input(buf); + g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, + time_server_key_event_cb, NULL); + g_io_channel_unref(key_io); + profile_selected = true; + profile_signal_handler_cb = time_server_signal_handler; + } + break; + case 'C': + if (role == GATT_ROLE_INVALID) { + USR_PRT("<role> parameter is missing"); + usage(); + exit(0); + }else if(role == GATT_ROLE_CLIENT) { + //Custom profile client + profile_selected = true; + } else { + custom_server_initialize(); + USR_PRT("Launching Custom profile test-suite"); + memcpy(buf, optarg, sizeof(buf)); + custom_server_accept_input(buf); + g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, + custom_server_key_event_cb, NULL); + g_io_channel_unref(key_io); + profile_selected = true; + profile_signal_handler_cb = custom_server_signal_handler; + } + break; case 'd': gatt_debug = true; break; diff --git a/test/gatt_profile_test_suite/bt_unit_test_gatt.h b/test/gatt_profile_test_suite/bt_unit_test_gatt.h index 76df892..9547f03 100644 --- a/test/gatt_profile_test_suite/bt_unit_test_gatt.h +++ b/test/gatt_profile_test_suite/bt_unit_test_gatt.h @@ -9,6 +9,7 @@ extern "C" { #include <glib.h> #include <ctype.h> #include <time.h> +#include <glib-object.h> #include "bluetooth.h" #include "bluetooth_internal.h" @@ -33,6 +34,7 @@ typedef enum int hr_client_initialize(void); + void hr_client_signal_handler(int); void hr_client_accept_input(char *buf); @@ -40,4 +42,30 @@ void hr_client_accept_input(char *buf); gboolean hr_client_key_event_cb(GIOChannel *chan, GIOCondition cond, gpointer data); +int time_server_initialize(void); + +void time_server_signal_handler(int signno); + +void time_server_accept_input(char *buf); + +gboolean time_server_key_event_cb(GIOChannel *chan, GIOCondition cond, + gpointer data); + +int time_client_initialize(void); + +void time_client_signal_handler(int signno); + +void time_client_accept_input(char *buf); + +gboolean time_client_key_event_cb(GIOChannel *chan, GIOCondition cond, + gpointer data); + +int custom_server_initialize(void); + +void custom_server_signal_handler(int signno); + +void custom_server_accept_input(char *buf); + +gboolean custom_server_key_event_cb(GIOChannel *chan, GIOCondition cond, + gpointer data); diff --git a/test/gatt_profile_test_suite/bt_unit_test_gatt_custom_profile_server.c b/test/gatt_profile_test_suite/bt_unit_test_gatt_custom_profile_server.c new file mode 100755 index 0000000..5866345 --- /dev/null +++ b/test/gatt_profile_test_suite/bt_unit_test_gatt_custom_profile_server.c @@ -0,0 +1,223 @@ +#include "bt_unit_test_gatt_custom_profile_server.h" + + +#define service_uuid "F2819041-529C-11E3-A67F-0002A5d5C51C" // Android Unlock Gear +#define characteristic_uuid "F2819043-529C-11E3-A67F-0002A5d5C51C" + +typedef struct { + bt_gatt_h svc; + bt_gatt_h chr; + bt_gatt_h desc; +} gatt_handle_t; + +extern bool gatt_debug; + +static custom_test_gatt_state_e test_cursor = BT_GATT_TEST_CUSTOM_INITIALIZATION; +static gatt_handle_t custom_h; +static bt_gatt_server_h server = NULL; + + +void __custom_server_connection_state_changed_cb(int result, bool connected, const char *remote_address, void *user_data) +{ + if (connected) { + DBG_PRT("Remote device connected [%s]", remote_address); + g_strlcpy(remote_addr, remote_address, BT_ADDR_LENGTH); + } +} + +static void __custom_server_advertising_state_changed_cb(int result, + bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, void *user_data) +{ + DBG_PRT("Result : %d", result); + DBG_PRT("Advertiser : %p", advertiser); + DBG_PRT("Advertising %s [%d]", adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? + "started" : "stopped", adv_state); +} + +static int __custom_server_start_advertising(void) +{ + int ret; + bt_advertiser_h advertiser = NULL; + + DBG_PRT("Start advertising"); + + ret = bt_adapter_le_create_advertiser(&advertiser); + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, + BT_ADAPTER_LE_PACKET_ADVERTISING, service_uuid); + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_adapter_le_set_advertising_device_name(advertiser, + BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_adapter_le_start_advertising_new(advertiser, + __custom_server_advertising_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + goto fail; + + return ret; + +fail: + DBG_PRT("Advertising failed [0x%04x]", ret); + return ret; +} + +static int __custom_server_register_gatt(void) +{ + int ret; + bt_gatt_h service = NULL; + bt_gatt_h characteristic = NULL; + char char_value[4] = {10, 20, 30, 40}; + int value_length = 4; + int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + int properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_WRITE | + BT_GATT_PROPERTY_WRITE_WITHOUT_RESPONSE; + + DBG_PRT("Register gatt server"); + + ret = bt_gatt_server_initialize(); + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_gatt_server_create(&server); + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_gatt_service_create(service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &service); + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_gatt_characteristic_create(characteristic_uuid, permissions, properties, + char_value, value_length, &characteristic); + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_gatt_service_add_characteristic(service, characteristic); + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) + goto fail; + + custom_h.svc = service; + custom_h.chr = characteristic; + + return ret; + +fail: + DBG_PRT("Register gatt server failed [0x%04x]", ret); + return ret; +} + +static int __custom_profile_server_launch(void) +{ + int ret = BT_ERROR_NONE; + test_cursor = BT_GATT_TEST_CUSTOM_SERVER_INITIALIZING; + + DBG_PRT("Initialize gatt server"); + + ret = __custom_server_register_gatt(); + if (ret != BT_ERROR_NONE) + return ret; + + ret = __custom_server_start_advertising(); + if (ret != BT_ERROR_NONE) + return ret; + + test_cursor = BT_GATT_TEST_CUSTOM_SERVER_INITIALIZED; + return ret; +} + +int custom_server_initialize(void) +{ + int ret = BT_ERROR_NONE; + test_cursor = BT_GATT_TEST_CUSTOM_INITIALIZATION; + + ret = bt_initialize(); + if (ret == BT_ERROR_NONE || ret == BT_ERROR_ALREADY_DONE) + DBG_PRT("Initialized"); + else + goto fail; + + ret = bt_adapter_enable(); + if (ret == BT_ERROR_NONE || ret == BT_ERROR_ALREADY_DONE) + DBG_PRT("Adapter enabled"); + else + goto fail; + + ret = bt_gatt_set_connection_state_changed_cb(__custom_server_connection_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + goto fail; + + test_cursor = BT_GATT_TEST_CUSTOM_INITIALIZED; + return ret; + +fail: + DBG_PRT("Initiailization error returns %d", ret); + return ret; +} + +void custom_server_accept_input(char *buf) +{ +// DBG_PRT("test_cursor %d", test_cursor); + + //ignore the other options for server + if (test_cursor == BT_GATT_TEST_CUSTOM_INITIALIZED) { + if (__custom_profile_server_launch() != BT_ERROR_NONE) + test_cursor = BT_GATT_TEST_UNRECOVERABLE; + } +} + +void custom_server_signal_handler(int signno) +{ + DBG_PRT("Terminate custom gatt server"); + + bt_gatt_disconnect(remote_addr); + bt_gatt_unset_connection_state_changed_cb(); +} + +gboolean custom_server_key_event_cb(GIOChannel *chan, + GIOCondition cond, + gpointer data) +{ + char buf[BUFFER_LEN] = { 0 }; + unsigned int len = 0; + + if (g_io_channel_read_chars(chan, buf, sizeof(buf), + &len, NULL) == G_IO_STATUS_ERROR) { + DBG_PRT("IO Channel read error"); + return FALSE; + } + +// DBG_PRT("test_cursor %d", test_cursor); + + if (test_cursor == BT_GATT_TEST_UNRECOVERABLE) { + USR_PRT("Unrecoverable error, please reboot"); + } else if (test_cursor == BT_GATT_TEST_CUSTOM_INITIALIZATION) { + if(custom_server_initialize() != BT_ERROR_NONE) { + USR_PRT("Initialization failed please reboot"); + } else { + DBG_PRT("Initialization is successfull"); + if (__custom_profile_server_launch() != BT_ERROR_NONE) { + test_cursor = BT_GATT_TEST_UNRECOVERABLE; + USR_PRT("Custom profile server launch failed"); + } + } + } else if (test_cursor == BT_GATT_TEST_CUSTOM_INITIALIZED) { + if (__custom_profile_server_launch() != BT_ERROR_NONE) { + test_cursor = BT_GATT_TEST_UNRECOVERABLE; + USR_PRT("Custom profile server launch failed"); + } + } else if (test_cursor == BT_GATT_TEST_CUSTOM_SERVER_INITIALIZED) { + USR_PRT("Custom profile server initialized. Ready to accept the connections"); + } + + return TRUE; +} + diff --git a/test/gatt_profile_test_suite/bt_unit_test_gatt_custom_profile_server.h b/test/gatt_profile_test_suite/bt_unit_test_gatt_custom_profile_server.h new file mode 100755 index 0000000..075b88c --- /dev/null +++ b/test/gatt_profile_test_suite/bt_unit_test_gatt_custom_profile_server.h @@ -0,0 +1,15 @@ +#include "bt_unit_test_gatt.h" + +#define BT_ADDR_LENGTH 18 + +typedef enum +{ + BT_GATT_TEST_UNRECOVERABLE = 1, + BT_GATT_TEST_CUSTOM_INITIALIZATION, + BT_GATT_TEST_CUSTOM_INITIALIZED, + BT_GATT_TEST_CUSTOM_SERVER_INITIALIZING, + BT_GATT_TEST_CUSTOM_SERVER_INITIALIZED, + BT_UNIT_TEST_TABLE_FINISH = 0xFF, +} custom_test_gatt_state_e; + +static char remote_addr[BT_ADDR_LENGTH] = "00:11:22:33:44:55";
\ No newline at end of file diff --git a/test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.c b/test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.c index 41bea37..77046cd 100644 --- a/test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.c +++ b/test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.c @@ -205,15 +205,18 @@ void __hr_client_dev_inf_read_complete_cb(int result, bt_gatt_h gatt_handle, voi if (hex_format) { str = g_malloc0(len * 5 + 1); - for (i = 0; i < len; i++) { - if (i > 0) - str[i * 5 - 1] = ' '; + if (str) { + for (i = 0; i < len; i++) { + if (i > 0) + str[i * 5 - 1] = ' '; - snprintf(&str[i * 5], 5, "0x%02X", value[i]); + snprintf(&str[i * 5], 5, "0x%02X", value[i]); + } } } else { str = g_malloc0(len + 1); - memcpy(str, value, len); + if (str) + memcpy(str, value, len); } USR_PRT("Value : %s", str); @@ -375,6 +378,7 @@ void hr_client_accept_input(char *buf) } } + int hr_client_initialize(void) { int ret = BT_ERROR_NONE; @@ -387,7 +391,7 @@ int hr_client_initialize(void) goto fail; ret = bt_adapter_enable(); - if(ret == BT_ERROR_NONE || ret == BT_ERROR_ALREADY_DONE) + if (ret == BT_ERROR_NONE || ret == BT_ERROR_ALREADY_DONE) DBG_PRT("Adapter enabled"); else goto fail; diff --git a/test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.h b/test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.h index fc31f18..9fd8397 100644 --- a/test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.h +++ b/test/gatt_profile_test_suite/bt_unit_test_gatt_hr_profile.h @@ -2,7 +2,7 @@ #include "bt_unit_test_gatt.h" bt_gatt_client_h gatt_client = NULL; -char remote_addr[18] = "00:11:22:33:44:55"; +static char remote_addr[18] = "00:11:22:33:44:55"; /* Mandatory Services for HR profile*/ diff --git a/test/gatt_profile_test_suite/bt_unit_test_gatt_time_profile.h b/test/gatt_profile_test_suite/bt_unit_test_gatt_time_profile.h new file mode 100755 index 0000000..8cfd0a6 --- /dev/null +++ b/test/gatt_profile_test_suite/bt_unit_test_gatt_time_profile.h @@ -0,0 +1,109 @@ +#include "bt_unit_test_gatt.h" + +#define BT_ADDR_LENGTH 18 + +static char remote_addr[BT_ADDR_LENGTH] = "00:11:22:33:44:55"; + +typedef enum +{ + BT_GATT_TEST_UNRECOVERABLE = 1, + BT_GATT_TEST_TIME_INITIALIZATION, + BT_GATT_TEST_TIME_INITIALIZED, + BT_GATT_TEST_TIME_SERVER_INITIALIZING, + BT_GATT_TEST_TIME_SERVER_INITIALIZED, + BT_GATT_TEST_TIME_CLIENT_SET_ADDRESS, + BT_GATT_TEST_TIME_CLIENT_CONNECT, + BT_GATT_TEST_TIME_CLIENT_CONNECTING, + BT_GATT_TEST_TIME_CLIENT_BONDING, + BT_GATT_TEST_TIME_CLIENT_BROWSE_SERVICES, + BT_GATT_TEST_TIME_CLIENT_MONITOR_SERVICES, + BT_GATT_TEST_TIME_CLIENT_READ_VALUES, + BT_GATT_TEST_TIME_CLIENT_READ_ONGOING, + BT_UNIT_TEST_TABLE_FINISH = 0xFF, +} time_test_gatt_state_e; + +typedef enum +{ + DST_STANDARD_TIME = 0x00, // +0h + DST_HALF_AN_HOUR_DAYLIGHT_TIME = 0x02, //+0.5h + DST_DAYLIGHT_TIME = 0x04, //+1h + DST_DOUBLE_DAYLIGHT_TIME = 0x08, //+2h + DST_UNKNOWN = 0xff, //unknown +}gatt_tip_dst_offset_e; + +typedef enum +{ + TUCP_RESERVED = 0x00, + TUCP_GET_REFERENCE_UPDATE = 0x01, + TUCP_CANCEL_REFERENCE_UPDATE = 0x02, +}gatt_tip_tucp_e; + +typedef enum +{ + TUS_CURRENT_STATE_IDLE = 0x00, + TUS_CURRENTSTATE_UPDATE_PENDING = 0x01, +}gatt_tip_tus_current_state_e; + +typedef enum +{ + TUS_RESULT_SUCCESSFULL = 0x00, + TUS_RESULT_CANCELLED = 0x01, + TUS_RESULT_NO_CONNECTION_TO_REFERENCE = 0x02, + TUS_RESULT_REFERENCE_RESP_WITH_ERROR = 0x03, + TUS_RESULT_TIMEOUT = 0x04, + TUS_RESULT_UPDATE_NOT_ATTEMPTED_AFTER_RESET = 0x05, +}gatt_tip_tus_result_e; + +typedef enum +{ + DAY_UNKNOWN = 0x00, + MONDAY = 0x01, + TUESDAY = 0x02, + WEDNESDAY = 0x03, + THURSDAY = 0x04, + FRIDAY = 0x05, + SATURDAY = 0x06, + SUNDAY = 0x07, +}gatt_tip_dow_e; + +typedef enum +{ + MANUAL_TIME_UPDATE = 0x01, + EXTERNAL_REFERENCE_TIME_UPDATE = 0x02, + CHANGE_OF_TIME_ZONE = 0x04, + CHANGE_OF_DST = 0x08, +}gatt_tip_current_time_adj_reason_mask_e; + +typedef enum +{ + SOURCE_UNKNOWN = 0x00, + NETWORK_TIME_PROTOCOL = 0x01, + GPS = 0x02, + RADIO_TIME_SINGAL = 0x03, + MANUAL = 0x04, + ATOMIC_CLOCK = 0x05, + CELLULAR_NETWORK = 0x06, +}gatt_tip_time_source_e; + + +typedef void (*time_client_char_read_interpretter) (bt_gatt_h characteristic, char *value, int length); + + +typedef struct { + bt_gatt_h char_handle; + time_client_char_read_interpretter read_cb; +} time_client_read_list_s; + +void current_time_read_value_requested_cb(char *remote_address, int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, int offset, void *user_data); +void lti_read_value_requested_cb(char *remote_address, int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, int offset, void *user_data); +void rti_read_value_requested_cb(char *remote_address, int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, int offset, void *user_data); +void twdst_read_value_requested_cb(char *remote_address, int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, int offset, void *user_data); +void tus_read_value_requested_cb(char *remote_address, int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, int offset, void *user_data); + +void tucp_value_changed_cb(char *remote_address, bt_gatt_server_h server, bt_gatt_h gatt_handle, int offset, char *value, int len, + void *user_data); diff --git a/test/gatt_profile_test_suite/bt_unit_test_gatt_time_profile_client.c b/test/gatt_profile_test_suite/bt_unit_test_gatt_time_profile_client.c new file mode 100755 index 0000000..8f3ad90 --- /dev/null +++ b/test/gatt_profile_test_suite/bt_unit_test_gatt_time_profile_client.c @@ -0,0 +1,605 @@ +/* + +Time-Profile version (TIP) 1.0 +Current Time Service (CTS)1.1 +Next DST Change Service (NDCS) 1.0 +Reference Time Update Service (RTUS) 1.0 + +TIP, CTS, NDCS, RTUS are standard abbreviations. + +*/ + + +#include "bt_unit_test_gatt_time_profile.h" + +extern bool gatt_debug; + +static bool input_valid = false; +static bool notification_possible = false; + +bt_gatt_client_h time_gatt_client = NULL; + +static time_test_gatt_state_e test_cursor = BT_GATT_TEST_TIME_INITIALIZATION; + +char *cts_service_uuid = "00001805-0000-1000-8000-00805F9B34FB"; // Current Time Service +char *current_time_char_uuid = "00002a2b-0000-1000-8000-00805F9B34FB"; // Current Time characteristic +char *lti_char_uuid = "00002a0f-0000-1000-8000-00805F9B34FB"; // Local Time Information +char *rti_char_uuid = "00002a14-0000-1000-8000-00805F9B34FB"; // Reference Time Information + + +char *ndcs_service_uuid = "00001807-0000-1000-8000-00805F9B34FB"; // Next DST Change Service +char *twdst_char_uuid = "00002a11-0000-1000-8000-00805F9B34FB"; // Time with DST + + +char *rtus_service_uuid = "00001806-0000-1000-8000-00805F9B34FB"; // Reference Time Update Service +char *tucp_char_uuid = "00002a16-0000-1000-8000-00805F9B34FB"; // Time Update Control Point +char *tus_char_uuid = "00002a17-0000-1000-8000-00805F9B34FB"; // Time Update Control Point. + +//handles collection, +static bt_gatt_h time_cti_handle = NULL; +static bt_gatt_h time_lti_handle = NULL; +static bt_gatt_h time_rti_handle = NULL; +static bt_gatt_h time_twdst_handle = NULL; +static bt_gatt_h time_tucp_handle = NULL; +static bt_gatt_h time_tus_handle = NULL; + + +GSList *read_all_list = NULL; + +static int __time_client_validate_input_bd_addr (char *bd_addr); +static void __time_client_scan_result_cb(int result, bt_adapter_le_device_scan_result_info_s *info, void *user_data); +static void __time_client_search_and_connect(); +static void __time_client_initiate_connection(); +static void __time_client_connection_state_changed_cb(int result, bool connected, const char *remote_address, void *user_data); +static bool __time_client_monitor_svc_cb(int total, int index, bt_gatt_h svc_handle, void *data); +bool __time_client_cts_service_cb(int total, int index, bt_gatt_h chr_handle, void *data); +bool __time_client_ndcs_service_cb(int total, int index, bt_gatt_h chr_handle, void *data); +bool __time_client_rtus_service_cb(int total, int index, bt_gatt_h chr_handle, void *data); +void __time_client_cts_notify_cb(bt_gatt_h chr, char *value, int len, void *user_data); +void __time_client_read_all(); +void __cti_read_cb(bt_gatt_h characteristic, char *value, int length); +void __lti_read_cb(bt_gatt_h characteristic, char *value, int length); +void __rti_read_cb(bt_gatt_h characteristic, char *value, int length); +void __ndcs_read_cb(bt_gatt_h characteristic, char *value, int length); + +int time_client_initialize(void) +{ + int ret = BT_ERROR_NONE; + test_cursor = BT_GATT_TEST_TIME_INITIALIZATION; + + ret = bt_initialize(); + if (ret == BT_ERROR_NONE || ret == BT_ERROR_ALREADY_DONE) + DBG_PRT("Initialized"); + else + goto fail; + + ret = bt_adapter_enable(); + if (ret == BT_ERROR_NONE || ret == BT_ERROR_ALREADY_DONE) + DBG_PRT("Adapter enabled"); + else + goto fail; + + ret = bt_gatt_set_connection_state_changed_cb(__time_client_connection_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + goto fail; + + test_cursor = BT_GATT_TEST_TIME_INITIALIZED; + return ret; +fail: + DBG_PRT("Initiailization error returns %d", ret); + return ret; +} + +void time_client_accept_input(char *buf) +{ + if (__time_client_validate_input_bd_addr(buf) != BT_ERROR_NONE) { + USR_PRT("invalid bluetooth address"); + } else { + memcpy (remote_addr, buf, 17); + remote_addr[17] = 0; + if (test_cursor == BT_GATT_TEST_TIME_INITIALIZED) + __time_client_initiate_connection(); + } +} + +void time_client_signal_handler(int signno) +{ + bt_gatt_disconnect(remote_addr); + bt_gatt_unset_connection_state_changed_cb(); +} + + +gboolean time_client_key_event_cb(GIOChannel *chan, + GIOCondition cond, + gpointer data) +{ + char buf[BUFFER_LEN] = { 0 }; + unsigned int len = 0; + + if (g_io_channel_read_chars(chan, buf, sizeof(buf), + &len, NULL) == G_IO_STATUS_ERROR) { + DBG_PRT("IO Channel read error"); + return FALSE; + } + + if (test_cursor == BT_GATT_TEST_UNRECOVERABLE) { + USR_PRT("Unrecoverable error, please reboot"); + } else if (test_cursor == BT_GATT_TEST_TIME_INITIALIZATION) { + if(time_server_initialize() != BT_ERROR_NONE) { + USR_PRT("Initialization failed please reboot"); + } else { + DBG_PRT("Initialization is successfull"); + if(!input_valid) { + USR_PRT("In-put remote BD-ADDR in the below format"); + USR_PRT("00:11:22:33:44:55"); + test_cursor = BT_GATT_TEST_TIME_CLIENT_SET_ADDRESS; + } else { + __time_client_initiate_connection(); + } + } + + } else if (test_cursor == BT_GATT_TEST_TIME_INITIALIZED) { + if(!input_valid) { + USR_PRT("In-put remote BD-ADDR in the below format"); + USR_PRT("00:11:22:33:44:55"); + test_cursor = BT_GATT_TEST_TIME_CLIENT_SET_ADDRESS; + } else { + __time_client_initiate_connection(); + } + } else if (test_cursor == BT_GATT_TEST_TIME_CLIENT_SET_ADDRESS) { + if (__time_client_validate_input_bd_addr(buf) != BT_ERROR_NONE) { + USR_PRT("invalid bluetooth address"); + USR_PRT("In-put remote BD-ADDR in the below format"); + USR_PRT("00:11:22:33:44:55"); + test_cursor = BT_GATT_TEST_TIME_CLIENT_SET_ADDRESS; + } else { + memcpy (remote_addr, buf, 17); + remote_addr[17] = 0; + __time_client_initiate_connection(); + } + } else if (test_cursor == BT_GATT_TEST_TIME_CLIENT_CONNECT) { + __time_client_initiate_connection(); + USR_PRT("Please wait.. while we connect the device"); + } else if (test_cursor == BT_GATT_TEST_TIME_CLIENT_CONNECTING) { + USR_PRT("Please wait.. while we connect the device"); + } else if (test_cursor == BT_GATT_TEST_TIME_CLIENT_BONDING) { + USR_PRT("Please wait.. Bonding is ongoing. If asked for pairing confirmation, take action"); + } else if (test_cursor == BT_GATT_TEST_TIME_CLIENT_BROWSE_SERVICES) { + USR_PRT("Quering supported services.."); + } else if (test_cursor == BT_GATT_TEST_TIME_CLIENT_MONITOR_SERVICES) { + USR_PRT("Press enter to refresh the Values"); + test_cursor = BT_GATT_TEST_TIME_CLIENT_READ_VALUES; + } else if (test_cursor == BT_GATT_TEST_TIME_CLIENT_READ_VALUES) { + DBG_PRT("Reading values, please wait"); + __time_client_read_all(); + test_cursor = BT_GATT_TEST_TIME_CLIENT_READ_ONGOING; + } else if (test_cursor == BT_GATT_TEST_TIME_CLIENT_READ_ONGOING) { + DBG_PRT("Reading values, please wait"); + } + + return TRUE; +} + +static int __time_client_validate_input_bd_addr (char *bd_addr) +{ + /*have to design better check for validity check of the input*/ + if (bd_addr == NULL || strlen(bd_addr) < 16) { + input_valid = false; + return BT_ERROR_INVALID_PARAMETER; + } + input_valid = true; + return BT_ERROR_NONE; +} + +static void __time_client_scan_result_cb(int result, + bt_adapter_le_device_scan_result_info_s *info, void *user_data) +{ + if (info == NULL) { + DBG_PRT("No discovery_info!"); + return; + } + if(!strcmp(info->remote_address, remote_addr)) { + bt_adapter_le_stop_scan(); + if(bt_gatt_connect(remote_addr, false) != BT_ERROR_NONE) + test_cursor = BT_GATT_TEST_UNRECOVERABLE; + } +} +static void __time_client_search_and_connect() +{ + int ret; + ret = bt_adapter_le_start_scan(__time_client_scan_result_cb, NULL); + if(ret != BT_ERROR_NONE) + test_cursor = BT_GATT_TEST_UNRECOVERABLE; +} + +static void __time_client_initiate_connection() +{ + int ret; + USR_PRT("Make sure the remote device is turned on and visible"); + USR_PRT("Please wait.. while we connect the device"); + + test_cursor = BT_GATT_TEST_TIME_CLIENT_CONNECTING; + + ret = bt_gatt_connect(remote_addr, false); + if(ret != BT_ERROR_NONE) + __time_client_search_and_connect(); +} + +void __time_client_bond_created_cb(int result, bt_device_info_s *device_info, void *user_data) +{ + if(result == BT_ERROR_NONE) + { + DBG_PRT("bond Creation successfull."); + + DBG_PRT("Callback: is_bonded - %d.", device_info->is_bonded); + DBG_PRT("Callback: is_connected - %d.", device_info->is_connected); + notification_possible = true; + + } else { + DBG_PRT("bond creation failed."); + notification_possible = false; + } + test_cursor = BT_GATT_TEST_TIME_CLIENT_BROWSE_SERVICES; + if (time_gatt_client) { + bt_gatt_client_destroy(time_gatt_client); + time_gatt_client = NULL; + } + if(bt_gatt_client_create(remote_addr, &time_gatt_client) != BT_ERROR_NONE) { + test_cursor = BT_GATT_TEST_UNRECOVERABLE; + DBG_PRT("GATT_Client creation failed"); + return; + } + if(bt_gatt_client_foreach_services(time_gatt_client, + __time_client_monitor_svc_cb, NULL) != BT_ERROR_NONE) { + test_cursor = BT_GATT_TEST_UNRECOVERABLE; + return; + } + test_cursor = BT_GATT_TEST_TIME_CLIENT_MONITOR_SERVICES; +} + + +static void __time_client_connection_state_changed_cb(int result, bool connected, const char *remote_address, void *user_data) +{ + int ret = BT_ERROR_NONE; + if (test_cursor == BT_GATT_TEST_UNRECOVERABLE) + return; + + if(!strcmp(remote_address, remote_addr)) { + if (connected) { + DBG_PRT("Connected to the remote device"); + bt_device_info_s *device_info = NULL; + + ret = bt_adapter_get_bonded_device_info(remote_addr, + &device_info); + if(ret == BT_ERROR_NONE) { + if (device_info) { + DBG_PRT("address: %s", device_info->remote_address); + DBG_PRT("bonded status: %d", device_info->is_bonded); + if(device_info->is_bonded == false) { + ret = bt_device_create_bond_by_type(remote_addr, BT_DEVICE_CONNECTION_LINK_LE); + if(ret == BT_ERROR_NONE) { + bt_device_set_bond_created_cb(__time_client_bond_created_cb, NULL); + bt_adapter_free_device_info(device_info); + test_cursor = BT_GATT_TEST_TIME_CLIENT_BONDING; + return; + } + } + } + } + else if(ret == BT_ERROR_REMOTE_DEVICE_NOT_BONDED) { + ret = bt_device_create_bond_by_type(remote_addr, BT_DEVICE_CONNECTION_LINK_LE); + if(ret == BT_ERROR_NONE) { + bt_device_set_bond_created_cb(__time_client_bond_created_cb, NULL); + bt_adapter_free_device_info(device_info); + test_cursor = BT_GATT_TEST_TIME_CLIENT_BONDING; + return; + } + } + bt_adapter_free_device_info(device_info); + test_cursor = BT_GATT_TEST_TIME_CLIENT_BROWSE_SERVICES; + if (time_gatt_client) { + bt_gatt_client_destroy(time_gatt_client); + time_gatt_client = NULL; + } + if(bt_gatt_client_create(remote_addr, &time_gatt_client) != BT_ERROR_NONE) { + test_cursor = BT_GATT_TEST_UNRECOVERABLE; + DBG_PRT("GATT_Client creation failed"); + return; + } + if(bt_gatt_client_foreach_services(time_gatt_client, + __time_client_monitor_svc_cb, NULL) != BT_ERROR_NONE) { + test_cursor = BT_GATT_TEST_UNRECOVERABLE; + return; + } + test_cursor = BT_GATT_TEST_TIME_CLIENT_MONITOR_SERVICES; + } else { + USR_PRT("Connection to the remote device is removed"); + USR_PRT("Attempting to re-connect to the device"); + USR_PRT("Make sure the remote device is turned on and in range"); + test_cursor = BT_GATT_TEST_TIME_CLIENT_CONNECTING; + notification_possible = false; + if (time_gatt_client) + bt_gatt_client_destroy(time_gatt_client); + bt_gatt_connect(remote_addr, true); + } + } + +} + +static bool __time_client_monitor_svc_cb(int total, int index, bt_gatt_h svc_handle, void *data) +{ + char *svc_str = NULL; + char *uuid = NULL; + + bt_gatt_get_uuid(svc_handle, &uuid); + bt_gatt_get_uuid_specification_name(uuid, &svc_str); + DBG_PRT("%s (uuid = %s)", svc_str ? svc_str : uuid, uuid); + + if(!strcasecmp(uuid, cts_service_uuid)){ + DBG_PRT("%s service", svc_str ? svc_str : uuid); + bt_gatt_service_foreach_characteristics(svc_handle, + __time_client_cts_service_cb, NULL); + } else if(!strcasecmp(uuid, ndcs_service_uuid)){ + DBG_PRT("%s service", svc_str ? svc_str : uuid); + bt_gatt_service_foreach_characteristics(svc_handle, + __time_client_ndcs_service_cb, NULL); + } else if(!strcasecmp(uuid, rtus_service_uuid)){ + DBG_PRT("%s service", svc_str ? svc_str : uuid); + bt_gatt_service_foreach_characteristics(svc_handle, + __time_client_rtus_service_cb, NULL); + } + + g_free(svc_str); + g_free(uuid); + + return true; +} + +bool __time_client_cts_service_cb(int total, int index, bt_gatt_h chr_handle, void *data) +{ + char *uuid = NULL; + char *str = NULL; + int ret; + + bt_gatt_get_uuid(chr_handle, &uuid); + bt_gatt_get_uuid_specification_name(uuid, &str); + + if(!strcasecmp(uuid, current_time_char_uuid)){ + USR_PRT("CurrentTime Information feature is supported"); + if(time_cti_handle) + g_free(time_cti_handle); + time_cti_handle = chr_handle; + if(notification_possible) { + ret = bt_gatt_client_set_characteristic_value_changed_cb(chr_handle, + __time_client_cts_notify_cb, NULL); + if(ret != BT_ERROR_NONE) + DBG_PRT("registerinig Notification failed, error = %d", ret); + if(ret == BT_ERROR_PERMISSION_DENIED) + DBG_PRT("Probably pairing information doesn't exist in either devices"); + } + } else if(!strcasecmp(uuid, lti_char_uuid)){ + USR_PRT("Local Time Information feature is supported"); + if(time_lti_handle) + g_free(time_lti_handle); + time_lti_handle = chr_handle; + } else if(!strcasecmp(uuid, rti_char_uuid)){ + USR_PRT("Reference Time Information feature is supported"); + if(time_rti_handle) + g_free(time_rti_handle); + time_rti_handle = chr_handle; + } + g_free(str); + g_free(uuid); + + return true; +} + + +bool __time_client_ndcs_service_cb(int total, int index, bt_gatt_h chr_handle, void *data) +{ + char *uuid = NULL; + char *str = NULL; + + bt_gatt_get_uuid(chr_handle, &uuid); + bt_gatt_get_uuid_specification_name(uuid, &str); + + if(!strcasecmp(uuid, twdst_char_uuid)){ + USR_PRT("TWDST feature is supported"); + if(time_twdst_handle) + g_free(time_twdst_handle); + time_twdst_handle = chr_handle; + } + + g_free(str); + g_free(uuid); + + return true; +} + +bool __time_client_rtus_service_cb(int total, int index, bt_gatt_h chr_handle, void *data) +{ + char *uuid = NULL; + char *str = NULL; + + bt_gatt_get_uuid(chr_handle, &uuid); + bt_gatt_get_uuid_specification_name(uuid, &str); + + if(!strcasecmp(uuid, tucp_char_uuid)){ + USR_PRT("CurrentTime Information feature is supported"); + if(time_tucp_handle) + g_free(time_tucp_handle); + time_tucp_handle = chr_handle; + } else if(!strcasecmp(uuid, tus_char_uuid)){ + USR_PRT("Local Time Information feature is supported"); + if(time_tus_handle) + g_free(time_tus_handle); + time_tus_handle = chr_handle; + } + + g_free(str); + g_free(uuid); + + return true; +} + +void __time_client_cts_notify_cb(bt_gatt_h chr, char *value, int len, + void *user_data) +{ + DBG_PRT("+"); +} + +void __time_client_read_all_cb(int result, bt_gatt_h gatt_handle, void *data) +{ + int ret = BT_ERROR_NONE; + char *value = NULL; + int len = 0; + time_client_char_read_interpretter read_cb = (time_client_char_read_interpretter)data; + DBG_PRT("Read %s", result == BT_ERROR_NONE ? "Success" : "Fail"); + + if (result == BT_ERROR_NONE) { + ret = bt_gatt_get_value(gatt_handle, &value, &len); + if (ret == BT_ERROR_NONE) { + read_cb(gatt_handle, value, len); + } + } + + if(read_all_list) { + time_client_read_list_s *read_list = (time_client_read_list_s *)read_all_list->data; + bt_gatt_client_read_value(read_list->char_handle, __time_client_read_all_cb, read_list->read_cb); + read_all_list = g_slist_remove(read_all_list, read_list); + } + else { + test_cursor = BT_GATT_TEST_TIME_CLIENT_MONITOR_SERVICES; + } +} +void __time_client_read_all() +{ + if(read_all_list) + g_slist_free(read_all_list); + read_all_list = NULL; + + if(time_cti_handle) { + time_client_read_list_s *cti_read = NULL; + cti_read = g_malloc0(sizeof(time_client_read_list_s)); + if (cti_read) { + cti_read->char_handle = time_cti_handle; + cti_read->read_cb = __cti_read_cb; + read_all_list = g_slist_append(read_all_list, cti_read); + } + } + if(time_lti_handle) { + time_client_read_list_s *lti_read = NULL; + lti_read = g_malloc0(sizeof(time_client_read_list_s)); + if (lti_read) { + lti_read->char_handle = time_lti_handle; + lti_read->read_cb = __lti_read_cb; + read_all_list = g_slist_append(read_all_list, lti_read); + } + } + if(time_rti_handle) { + time_client_read_list_s *rti_read = NULL; + rti_read = g_malloc0(sizeof(time_client_read_list_s)); + if (rti_read) { + rti_read->char_handle = time_rti_handle; + rti_read->read_cb = __rti_read_cb; + read_all_list = g_slist_append(read_all_list, rti_read); + } + } + if(time_twdst_handle) { + time_client_read_list_s *twdst_read = NULL; + twdst_read = g_malloc0(sizeof(time_client_read_list_s)); + if (twdst_read) { + twdst_read->char_handle = time_twdst_handle; + twdst_read->read_cb = __ndcs_read_cb; + read_all_list = g_slist_append(read_all_list, twdst_read); + } + } + + if(read_all_list) { + time_client_read_list_s *read_list = (time_client_read_list_s *)read_all_list->data; + bt_gatt_client_read_value(read_list->char_handle, __time_client_read_all_cb, read_list->read_cb); + read_all_list = g_slist_remove(read_all_list, read_list); + } + else { + test_cursor = BT_GATT_TEST_TIME_CLIENT_MONITOR_SERVICES; + } +} + +void __cti_read_cb(bt_gatt_h characteristic, char *value, int length) +{ + int year = 0; + + if(length != 10) { + USR_PRT("invalid value received from remote device"); + return; + } + DBG_PRT("value[1] = %d, value[0] = %d", value[1], value[0]); + year = (value[1] << 8) + value[0]; + USR_PRT("\n\t\tCURRENT TIME INFORMATION (YYYY/MM/DD HH:MM:SS"); + USR_PRT("\t%d/%d/%d %d:%d:%d", year, value[2], value[3], value[4], value[5], value[6]); + switch(value[7]) { + case DAY_UNKNOWN: + USR_PRT("\tDay of the week : Unknown"); + break; + case MONDAY: + USR_PRT("\tDay of the week : MONDAY"); + break; + case TUESDAY: + USR_PRT("\tDay of the week : TUESDAY"); + break; + case WEDNESDAY: + USR_PRT("\tDay of the week : WEDNESDAY"); + break; + case THURSDAY: + USR_PRT("\tDay of the week : THURSDAY"); + break; + case FRIDAY: + USR_PRT("\tDay of the week : FRIDAY"); + break; + case SATURDAY: + USR_PRT("\tDay of the week : SATURDAY"); + break; + case SUNDAY: + USR_PRT("\tDay of the week : SUNDAY"); + break; + } + USR_PRT("\tfractions256 = %d", value[8]); + USR_PRT("\tAdjust reason= %d", value[9]); +} + +void __lti_read_cb(bt_gatt_h characteristic, char *value, int length) +{ + if(length != 2) { + USR_PRT("invalid value received from remote device"); + return; + } + USR_PRT("\n\t\tLocal Time Information"); + USR_PRT("\tTime Zone %d", value[0]); + USR_PRT("\tDST = %d", value[1]); +} + +void __rti_read_cb(bt_gatt_h characteristic, char *value, int length) +{ + if(length != 4) { + USR_PRT("invalid value received from remote device"); + return; + } + USR_PRT("\n\t\tReference Time Information"); + USR_PRT("\tTime source %d", value[0]); + USR_PRT("\tAccuracy = %d", value[1]); + USR_PRT("\tDays since last update = %d", value[2]); + USR_PRT("\tHours since last update = %d", value[3]); +} + +void __ndcs_read_cb(bt_gatt_h characteristic, char *value, int length) +{ + int year = 0; + if(length != 8) { + USR_PRT("invalid value received from remote device"); + return; + } + year = (value[1] << 8) + value[0]; + USR_PRT("\n\t\tTime with DST Information"); + USR_PRT("\t%d/%d/%d %d:%d:%d", year, value[2], value[3], value[4], value[5], value[6]); + USR_PRT("\tDST offset %d", value[7]); +} diff --git a/test/gatt_profile_test_suite/bt_unit_test_gatt_time_profile_server.c b/test/gatt_profile_test_suite/bt_unit_test_gatt_time_profile_server.c new file mode 100755 index 0000000..38eb32a --- /dev/null +++ b/test/gatt_profile_test_suite/bt_unit_test_gatt_time_profile_server.c @@ -0,0 +1,694 @@ +/* + +Time-Profile version (TIP) 1.0 +Current Time Service (CTS)1.1 +Next DST Change Service (NDCS) 1.0 +Reference Time Update Service (RTUS) 1.0 + +TIP, CTS, NDCS, RTUS are standard abbreviations. + +*/ + + +#include "bt_unit_test_gatt_time_profile.h" +#include <time.h> + +extern bool gatt_debug; + +bt_gatt_server_h tip_server = NULL; + +static time_test_gatt_state_e test_cursor = BT_GATT_TEST_TIME_INITIALIZATION; + +static int __time_profile_server_launch(void); +void __time_server_connection_state_changed_cb(int result, bool connected, const char *remote_address, void *user_data); +static int __initialize_tip_server(); +static int __initialize_cts(); +static int __initialize_ndcs(); +static int __initialize_rtus(); + +int time_server_initialize(void) +{ + int ret = BT_ERROR_NONE; + test_cursor = BT_GATT_TEST_TIME_INITIALIZATION; + + ret = bt_initialize(); + if (ret == BT_ERROR_NONE || ret == BT_ERROR_ALREADY_DONE) + DBG_PRT("Initialized"); + else + goto fail; + + ret = bt_adapter_enable(); + if (ret == BT_ERROR_NONE || ret == BT_ERROR_ALREADY_DONE) + DBG_PRT("Adapter enabled"); + else + goto fail; + + ret = bt_gatt_set_connection_state_changed_cb(__time_server_connection_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + goto fail; + + test_cursor = BT_GATT_TEST_TIME_INITIALIZED; + return ret; +fail: + DBG_PRT("Initiailization error returns %d", ret); + return ret; +} + +void time_server_accept_input(char *buf) +{ + //ignore the other options for server + if (test_cursor == BT_GATT_TEST_TIME_INITIALIZED) { + if (__time_profile_server_launch() != BT_ERROR_NONE) + test_cursor = BT_GATT_TEST_TIME_INITIALIZED; + } +} + +void time_server_signal_handler(int signno) +{ + bt_gatt_disconnect(remote_addr); + bt_gatt_unset_connection_state_changed_cb(); +} + + +gboolean time_server_key_event_cb(GIOChannel *chan, + GIOCondition cond, + gpointer data) +{ + char buf[BUFFER_LEN] = { 0 }; + unsigned int len = 0; + + if (g_io_channel_read_chars(chan, buf, sizeof(buf), + &len, NULL) == G_IO_STATUS_ERROR) { + DBG_PRT("IO Channel read error"); + return FALSE; + } + + if (test_cursor == BT_GATT_TEST_UNRECOVERABLE) { + USR_PRT("Unrecoverable error, please reboot"); + } else if (test_cursor == BT_GATT_TEST_TIME_INITIALIZATION) { + if(time_server_initialize() != BT_ERROR_NONE) { + USR_PRT("Initialization failed please reboot"); + } else { + DBG_PRT("Initialization is successfull"); + if (__time_profile_server_launch() != BT_ERROR_NONE) { + test_cursor = BT_GATT_TEST_UNRECOVERABLE; + USR_PRT("Time profile server launch failed"); + } + } + + } else if (test_cursor == BT_GATT_TEST_TIME_INITIALIZED) { + if (__time_profile_server_launch() != BT_ERROR_NONE) { + test_cursor = BT_GATT_TEST_UNRECOVERABLE; + USR_PRT("Time profile server launch failed"); + } + } else if (test_cursor == BT_GATT_TEST_TIME_SERVER_INITIALIZED) { + USR_PRT("Time profile server initialized. Ready to accept the connections"); + } else { + USR_PRT("Default case: Server ready to accept the connection"); + } + + return TRUE; +} + +void __time_server_connection_state_changed_cb(int result, bool connected, const char *remote_address, void *user_data) +{ + //shopuld we consider the case of "BT_GATT_TEST_UNRECOVERABLE" ?? + if (connected) { + DBG_PRT("Remote device connected"); + g_strlcpy(remote_addr, remote_address, BT_ADDR_LENGTH); + } +} + +static int __time_profile_server_launch(void) +{ + int ret = BT_ERROR_NONE; + test_cursor = BT_GATT_TEST_TIME_SERVER_INITIALIZING; + DBG_PRT("__time_profile_server_launch"); + //Initialize the server + ret = __initialize_tip_server(); + if(ret != BT_ERROR_NONE) { + USR_PRT("Server initialization failed"); + USR_PRT("Please reboot the Device"); + test_cursor = BT_GATT_TEST_UNRECOVERABLE; + goto done; + } + DBG_PRT("__initialize_tip_server = %d", ret); + //Current time service is mandatory service + ret = __initialize_cts(); + if(ret != BT_ERROR_NONE) { + USR_PRT("Current time service initialization failed"); + USR_PRT("This is a mandatory service, So aborting initialization sequence"); + USR_PRT("Please reboot the Device"); + test_cursor = BT_GATT_TEST_UNRECOVERABLE; + goto done; //if mandatory service can't be initilaized then don't proceed + } + DBG_PRT("__initialize_cts = %d", ret); + goto done; //As of now multiple services registration is failing. So skipping, + //Next DST Change Service is a optional service + ret = __initialize_ndcs(); + if(ret != BT_ERROR_NONE) { + USR_PRT("Current Time Service initialization failed"); + USR_PRT("It is an optional service, so continue to host Time Profile"); + } + DBG_PRT("__initialize_ndcs = %d", ret); + //Reference Time Update service is optional service + ret = __initialize_rtus(); + if(ret != BT_ERROR_NONE) { + USR_PRT("Reference Time Update Service initialization failed"); + USR_PRT("It is an optional service, so continue to host Time Profile"); + } + DBG_PRT("__initialize_rtus = %d", ret); + ret = BT_ERROR_NONE; + test_cursor = BT_GATT_TEST_TIME_SERVER_INITIALIZED; +done: + return ret; +} + +static int __initialize_tip_server() +{ + int ret = BT_ERROR_NONE; + + ret = bt_gatt_server_initialize(); + if(ret != BT_ERROR_NONE) { + DBG_PRT("Server Initialization failed"); + return ret; + } + + ret = bt_gatt_server_create(&tip_server); + if(ret != BT_ERROR_NONE) { + DBG_PRT("Server Initialization failed"); + return ret; + } + return ret; +} + +static int __initialize_cts() +{ + int ret = BT_ERROR_NONE; + bt_gatt_h cts_service = NULL; + char *cts_service_uuid = "1805"; // Current Time Service + +//begining of current time characteristic declaration + bt_gatt_h current_time_characteristic = NULL; + char *current_time_char_uuid = "2a2b"; // Current Time characteristic + int current_time_char_permissions = BT_GATT_PERMISSION_READ; + int current_time_char_properties = BT_GATT_PROPERTY_NOTIFY | BT_GATT_PROPERTY_READ; // write is optional, it is ignored as of now. + unsigned char current_time_char_value[10] = {0}; // 0 is not the proper default value. should check the Date Time + Day of Week spec + +/* + char value breakup + todo : check whether the below characteristic value follow, LSO to MSO order from spec + + Exact Time 256 : Day Date Time + Fractions 256 + Day Date Time : Date Time + Day of Week + Date Time : 7 bytes (current_time_char_value[0] to current_time_char_value[6]) + Day of Week : 1 byte (current_time_char_value[7]) + total : 8 bytes + Fractions 256 : 1 byte (current_time_char_value[8]) + Total bytes for Exact Time 256 = 9 bytes + + Adjust Reason : 1 byte (current_time_char_value[9]) + + Total Bytes of this characteristic = 10 bytes +*/ + + bt_gatt_h cccdesc = NULL; + char *cccdesc_uuid = "2902"; + int cccdesc_permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + char cccdesc_value[2] = {0, 0}; // Notification disabled by default +//end of current time characteristic declaration + + +//begining of Local time information characteristic declaration + bt_gatt_h lti_characteristic = NULL; + char *lti_char_uuid = "2a0f"; // Local Time Information + int lti_char_permissions = BT_GATT_PERMISSION_READ; + int lti_char_properties = BT_GATT_PROPERTY_READ; // write is optional, it is ignored as of now. + char lti_char_value[2] = {0}; // 0 is not the proper default value. should check the Date Time + Day of Week spec + +/* + char value breakup + todo : check whether the below characteristic value follow, LSO to MSO order from spec + + Time Zone : (lti_char_value[0]) sint8 (signed 8 bit integer) Minimu value -48, Maximum value 56 + + DST offset : (lti_char_value[1]) uint8 (Unsigned 8 bit integer) Minimum value 0, Maximum value 8 + +*/ + +//end of Local time information characteristic declaration + +//begining of Reference time information characteristic declaration + bt_gatt_h rti_characteristic = NULL; + char *rti_char_uuid = "2a14"; // Reference Time Information + int rti_char_permissions = BT_GATT_PERMISSION_READ; + int rti_char_properties = BT_GATT_PROPERTY_READ; + char rti_char_value[4] = {0}; // recheck the default value. + +/* + char value breakup + todo : check whether the below characteristic value follow, LSO to MSO order from spec + + Source : Time source, 8bit, Minimum value 0, Maximum value 7. rti_char_value[0] + + Accuracy : Time Accuracy, uint8, Minimum Value 0 Maximum value 253. rti_char_value[1] + + Days Since Update: uint8, Minimum Value 0, Maximum value 254. rti_char_value[2] + + Hours since update: uint8, Minimum value 0, Maximum value 23. rti_char_value[3] + +*/ + +//end of Reference time information characteristic declaration + + ret = bt_gatt_service_create(cts_service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &cts_service); + if (ret != BT_ERROR_NONE) + goto fail; + +//begining of current_time_characteristic +/* default value Initialization */ +//Exact Time 256 + //Day Date Time + //Date Time + //Year 2015 + current_time_char_value[0] = 15; + current_time_char_value[1] = 20; + //Month september + current_time_char_value[2] = 9; + //Day 03 + current_time_char_value[3] = 3; + //Hours 10 + current_time_char_value[4] = 10; + //Minutes 10 + current_time_char_value[5] = 10; + //seconds 10 + current_time_char_value[6] = 10; + //Day of week + current_time_char_value[7] = FRIDAY; + //Fractions256 + current_time_char_value[8] = 0; +//Adjust Reason + current_time_char_value[9] = 0; //It is initialized with "no reason". gatt_tip_current_time_adj_reason_mask_e should be used while notifying + ret = bt_gatt_characteristic_create(current_time_char_uuid, current_time_char_permissions, current_time_char_properties, + (char*)current_time_char_value, sizeof(current_time_char_value), ¤t_time_characteristic); + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_gatt_service_add_characteristic(cts_service, current_time_characteristic); + + if (ret != BT_ERROR_NONE) { + bt_gatt_destroy(current_time_characteristic); + goto fail; + } + bt_gatt_server_set_read_value_requested_cb(current_time_characteristic, current_time_read_value_requested_cb, NULL); + + ret = bt_gatt_descriptor_create(cccdesc_uuid, cccdesc_permissions, cccdesc_value, sizeof(cccdesc_value), &cccdesc); + + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_gatt_characteristic_add_descriptor(current_time_characteristic, cccdesc); + + if (ret != BT_ERROR_NONE) { + bt_gatt_destroy(cccdesc); + goto fail; + } +//end of current_time_characteristic + +//begining of Local time information characteristic +/* default value Initialization */ + //Time Zone : sint8, enum declaration is not done for the ease of development + lti_char_value[0] = 16; //UTC+4:00 + //Daylight Saving Time + lti_char_value[1] = DST_STANDARD_TIME; + ret = bt_gatt_characteristic_create(lti_char_uuid, lti_char_permissions, lti_char_properties, + lti_char_value, sizeof(lti_char_value), <i_characteristic); + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_gatt_service_add_characteristic(cts_service, lti_characteristic); + + if (ret != BT_ERROR_NONE) { + bt_gatt_destroy(lti_characteristic); + goto fail; + } + bt_gatt_server_set_read_value_requested_cb(lti_characteristic, lti_read_value_requested_cb, NULL); + +//end of Local time information characteristic + + +//begining of Reference time information characteristic +/* default value Initialization */ + //source : Time source + rti_char_value[0] = MANUAL; + //Accuracy: can be 0 to 253, 254 = Accuracy out of range, 255 = Accuracy Unknown + rti_char_value[1] = 0xff; //Accuracy Unknown + //Days Since Update + rti_char_value[2] = 0; //0 days since updated + //Hours since Updated + rti_char_value[3] = 0; //0 hours since updated + ret = bt_gatt_characteristic_create(rti_char_uuid, rti_char_permissions, rti_char_properties, + rti_char_value, sizeof(rti_char_value), &rti_characteristic); + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_gatt_service_add_characteristic(cts_service, rti_characteristic); + + if (ret != BT_ERROR_NONE) { + bt_gatt_destroy(rti_characteristic); + goto fail; + } + bt_gatt_server_set_read_value_requested_cb(rti_characteristic, rti_read_value_requested_cb, NULL); +//end of Reference time information characteristic + + ret = bt_gatt_server_register_service(tip_server, cts_service); + + if (ret == BT_ERROR_NONE) + return ret; + +fail: + bt_gatt_destroy(cts_service); + return ret; +} + +static int __initialize_ndcs() +{ + int ret = BT_ERROR_NONE; + bt_gatt_h ndcs_service = NULL; + char *ndcs_service_uuid = "1807"; // Next DST Change Service + +//begining of Time with DST characteristic declaration + bt_gatt_h twdst_characteristic = NULL; + char *twdst_char_uuid = "2a11"; // Time with DST + int twdst_char_permissions = BT_GATT_PERMISSION_READ; + int twdst_char_properties = BT_GATT_PROPERTY_READ; + char twdst_char_value[8] = {0}; +/* + char value breakup + todo : check whether the below characteristic value follow, LSO to MSO order from spec + Date Time: twdst_char_value[0] to twdst_char_value[6] + twdst_char_value[0] and twdst_char_value[1]= Year. Minimum value 1582, Maximum value 9999 + twdst_char_value[2] = Month. Minimum value 0, Maximum value 12 + twdst_char_value[3] = Day. Minimum value 1, Maximum value 31 + twdst_char_value[4] = Hours. Minimum value 0, Maximum value 23 + twdst_char_value[5] = Minutes. Minimum value 0, Maximum value 59 + twdst_char_value[6] = Seconds. Minimum value 0, Maximum value 59 + + DST Offset: twdst_char_value[7] + twdst_char_value[7] = DST offset. Minimum value 0, Maximum value 8 +*/ +//end of Time with DST characteristic declaration + +/* default value Initialization, Hard-coded. Later change this to retrieve from system information */ + // Year 2015 + twdst_char_value[0] = 15; + twdst_char_value[1] = 20; + // Month September + twdst_char_value[2] = 9; //enumaration Declaration is not required, because it is generic and common + // Day 03 + twdst_char_value[3] = 3; + // Hours 10 + twdst_char_value[4] = 10; + // Minutes 10 + twdst_char_value[5] = 10; + // Seconds + twdst_char_value[6] = 10; + // DST Offset + twdst_char_value[7] = DST_STANDARD_TIME; + ret = bt_gatt_service_create(ndcs_service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &ndcs_service); + if (ret != BT_ERROR_NONE) + goto fail; + +//begining of Time With DST characteristic + ret = bt_gatt_characteristic_create(twdst_char_uuid, twdst_char_permissions, twdst_char_properties, + twdst_char_value, sizeof(twdst_char_value), &twdst_characteristic); + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_gatt_service_add_characteristic(ndcs_service, twdst_characteristic); + + if (ret != BT_ERROR_NONE) { + bt_gatt_destroy(twdst_characteristic); + goto fail; + } + bt_gatt_server_set_read_value_requested_cb(twdst_characteristic, twdst_read_value_requested_cb, NULL); +//end of Time With DST characteristic + + ret = bt_gatt_server_register_service(tip_server, ndcs_service); + + if (ret == BT_ERROR_NONE) + return ret; + +fail: + bt_gatt_destroy(ndcs_service); + return ret; + +} + + +static int __initialize_rtus() +{ + int ret = BT_ERROR_NONE; + bt_gatt_h rtus_service = NULL; + char *rtus_service_uuid = "1806"; // Reference Time Update Service + +//begining of Time Update Control Point characteristic declaration + bt_gatt_h tucp_characteristic = NULL; + char *tucp_char_uuid = "2a16"; // Time Update Control Point. + int tucp_char_permissions = BT_GATT_PERMISSION_WRITE; + int tucp_char_properties = BT_GATT_PROPERTY_WRITE_WITHOUT_RESPONSE; + char tucp_char_value[1] = {0}; +/* + char value breakup + + Time Update Control Point : (tucp_char_value[0]) uint8 (unsigned 8 bit integer) Minimu value 1, Maximum value 2 + +*/ + +//end of Time Update Control Point characteristic declaration + +//begining of Time Update State characteristic declaration + bt_gatt_h tus_characteristic = NULL; + char *tus_char_uuid = "2a17"; // Time Update Control Point. + int tus_char_permissions = BT_GATT_PERMISSION_READ; + int tus_char_properties = BT_GATT_PROPERTY_READ; + char tus_char_value[2] = {0}; +/* + char value breakup + + Current state : (tus_char_value[0]) uint8 (unsigned 8 bit integer) Minimu value 0, Maximum value 1 + + Result : (tus_char_value[1]) uint8 (unsigned 8 bit integer) Minimu value 0, Maximum value 4 +*/ +//end of Time Update State characteristic declaration + + ret = bt_gatt_service_create(rtus_service_uuid, BT_GATT_SERVICE_TYPE_PRIMARY, &rtus_service); + if (ret != BT_ERROR_NONE) + goto fail; + +//begining of Time With DST characteristic +/* default value Initialization, */ + tucp_char_value[0] = TUCP_RESERVED; + ret = bt_gatt_characteristic_create(tucp_char_uuid, tucp_char_permissions, tucp_char_properties, + tucp_char_value, sizeof(tucp_char_value), &tucp_characteristic); + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_gatt_service_add_characteristic(rtus_service, tucp_characteristic); + + if (ret != BT_ERROR_NONE) { + bt_gatt_destroy(tucp_characteristic); + goto fail; + } + bt_gatt_server_set_value_changed_cb(tucp_characteristic, tucp_value_changed_cb, NULL); +//end of Time With DST characteristic + +//begining of Time Update State characteristic +/* default value Initialization, */ + tus_char_value[0] = TUS_CURRENT_STATE_IDLE; + tus_char_value[1] = TUS_RESULT_SUCCESSFULL; + ret = bt_gatt_characteristic_create(tus_char_uuid, tus_char_permissions, tus_char_properties, + tus_char_value, sizeof(tus_char_value), &tus_characteristic); + if (ret != BT_ERROR_NONE) + goto fail; + + ret = bt_gatt_service_add_characteristic(rtus_service, tus_characteristic); + + if (ret != BT_ERROR_NONE) { + bt_gatt_destroy(tus_characteristic); + goto fail; + } + bt_gatt_server_set_read_value_requested_cb(tus_characteristic, tus_read_value_requested_cb, NULL); +//end of Time Update State characteristic + + ret = bt_gatt_server_register_service(tip_server, rtus_service); + + if (ret == BT_ERROR_NONE) + return ret; + +fail: + bt_gatt_destroy(rtus_service); + return ret; + +} + + +void current_time_read_value_requested_cb(char *remote_address, int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, int offset, void *user_data) +{ + DBG_PRT("+"); +//user_data is set to NULL while registering the callback. +//Since there should be only one instance of service, there will be only one instance of characteristic and corresponding value. +//So, check and correct the characteristic value. (value will be same for all the connected clients) + + struct timespec tp; + struct tm tm; + unsigned char current_time_char_value[10] = {0}; // 0 is not the proper default value. should check the Date Time + Day of Week spec + int year =0; + + if (clock_gettime(CLOCK_REALTIME, &tp) == -1) { + DBG_PRT("clock_gettime error"); + goto done; + } + + if (localtime_r(&tp.tv_sec, &tm) == NULL) { + DBG_PRT("localtime_r error"); + goto done; + } + + DBG_PRT("tm.tm_year = %d ", tm.tm_year); + DBG_PRT("tm.tm_mon = %d ", tm.tm_mon); + DBG_PRT("tm.tm_mday = %d ", tm.tm_mday); + DBG_PRT("tm.tm_hour = %d ", tm.tm_hour); + DBG_PRT("tm.tm_min = %d ", tm.tm_min); + DBG_PRT("tm.tm_sec = %d ", tm.tm_sec); + DBG_PRT("tm.tm_wday = %d ", tm.tm_wday); + + year = 1900 + tm.tm_year; + //Year 2015 + current_time_char_value[0] = ((year >> 0) & 0xff); + current_time_char_value[1] = ((year >> 8) & 0xff); + //Month september + current_time_char_value[2] = tm.tm_mon; + //Day 03 + current_time_char_value[3] = tm.tm_mday; + //Hours 10 + current_time_char_value[4] = tm.tm_hour; + //Minutes 10 + current_time_char_value[5] = tm.tm_min; + //seconds 10 + current_time_char_value[6] = tm.tm_sec; + //Day of week + current_time_char_value[7] = tm.tm_wday; + //Fractions256 + current_time_char_value[8] = 0; +//Adjust Reason + current_time_char_value[9] = 0; //set to "no reason". gatt_tip_current_time_adj_reason_mask_e should be used while notifying +done: + bt_gatt_server_send_response(request_id, offset, (char*)current_time_char_value, sizeof(current_time_char_value) - offset); +} + +void lti_read_value_requested_cb(char *remote_address, int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, int offset, void *user_data) +{ + DBG_PRT("+"); + char value[2] = {0, }; +//user_data is set to NULL while registering the callback. +//Since there should be only one instance of service, there will be only one instance of characteristic and corresponding value. +//So, check and correct the characteristic value. (value will be same for all the connected clients) + + tzset(); + + /* Convert POSIX "timezone" (seconds West of GMT) to Time Profile + * format (offset from UTC in number of 15 minutes increments). */ + value[0] = (signed char) (-1 * timezone / (60 * 15)); + + /* FIXME: POSIX "daylight" variable only indicates whether there + * is DST for the local time or not. The offset is unknown. */ + value[1] = daylight ? 0xff : 0x00; + + DBG_PRT("Time Zone = %u", value[0]); + DBG_PRT("DayLight = %d", value[1]); + + bt_gatt_server_send_response(request_id, offset, value, sizeof(value) - offset); +} + +void rti_read_value_requested_cb(char *remote_address, int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, int offset, void *user_data) +{ + DBG_PRT("+"); +//user_data is set to NULL while registering the callback. +//Since there should be only one instance of service, there will be only one instance of characteristic and corresponding value. +//So, check and correct the characteristic value. (value will be same for all the connected clients) +} + +void twdst_read_value_requested_cb(char *remote_address, int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, int offset, void *user_data) +{ + DBG_PRT("+"); +//user_data is set to NULL while registering the callback. +//Since there should be only one instance of service, there will be only one instance of characteristic and corresponding value. +//So, check and correct the characteristic value. (value will be same for all the connected clients) + struct timespec tp; + struct tm tm; + char twdst_char_value[8] = {0}; + int year =0; + + if (clock_gettime(CLOCK_REALTIME, &tp) == -1) { + DBG_PRT("clock_gettime error"); + goto done; + } + + if (localtime_r(&tp.tv_sec, &tm) == NULL) { + DBG_PRT("localtime_r error"); + goto done; + } + + DBG_PRT("tm.tm_year = %d ", tm.tm_year); + DBG_PRT("tm.tm_mon = %d ", tm.tm_mon); + DBG_PRT("tm.tm_mday = %d ", tm.tm_mday); + DBG_PRT("tm.tm_hour = %d ", tm.tm_hour); + DBG_PRT("tm.tm_min = %d ", tm.tm_min); + DBG_PRT("tm.tm_sec = %d ", tm.tm_sec); + + year = 1900 + tm.tm_year; + //Year 2015 + twdst_char_value[0] = ((year >> 0) & 0xff); + twdst_char_value[1] = ((year >> 8) & 0xff); + //Month september + twdst_char_value[2] = tm.tm_mon; + //Day 03 + twdst_char_value[3] = tm.tm_mday; + //Hours 10 + twdst_char_value[4] = tm.tm_hour; + //Minutes 10 + twdst_char_value[5] = tm.tm_min; + //seconds 10 + twdst_char_value[6] = tm.tm_sec; + + tzset(); + + /* FIXME: POSIX "daylight" variable only indicates whether there + * is DST for the local time or not. The offset is unknown. */ + twdst_char_value[7] = daylight ? 0xff : 0x00; +done: + bt_gatt_server_send_response(request_id, offset, (char*)twdst_char_value, sizeof(twdst_char_value) - offset); + +} + +void tus_read_value_requested_cb(char *remote_address, int request_id, bt_gatt_server_h server, + bt_gatt_h gatt_handle, int offset, void *user_data) +{ + DBG_PRT("+"); +//user_data is set to NULL while registering the callback. +//Since there should be only one instance of service, there will be only one instance of characteristic and corresponding value. +//So, check and correct the characteristic value. (value will be same for all the connected clients) +} + +void tucp_value_changed_cb(char *remote_address, bt_gatt_server_h server, bt_gatt_h gatt_handle, int offset, + char *value, int len, void *user_data) +{ + DBG_PRT("+"); +//user_data is set to NULL while registering the callback. +//take action on the written value. +} diff --git a/tv_lib/arm/libcapi-network-bluetooth.so.0.1.45+tv b/tv_lib/arm/libcapi-network-bluetooth.so.0.1.45+tv Binary files differnew file mode 100755 index 0000000..29e5c11 --- /dev/null +++ b/tv_lib/arm/libcapi-network-bluetooth.so.0.1.45+tv diff --git a/tv_lib/i586/libcapi-network-bluetooth.so.0.1.53 b/tv_lib/i586/libcapi-network-bluetooth.so.0.1.53 Binary files differnew file mode 100755 index 0000000..8f23f47 --- /dev/null +++ b/tv_lib/i586/libcapi-network-bluetooth.so.0.1.53 diff --git a/tv_src/bluetooth-adapter.c b/tv_src/bluetooth-adapter.c new file mode 100644 index 0000000..a5c1b8a --- /dev/null +++ b/tv_src/bluetooth-adapter.c @@ -0,0 +1,2037 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <glib.h> +#include <string.h> +#include <stdlib.h> +#include <ctype.h> +#include <dlog.h> +#include <stdio.h> +#include <stdbool.h> +#include <bluetooth-api.h> +#include <fcntl.h> +#include <sqlite3.h> +#include <db-util.h> + +#include "bluetooth.h" +#include "bluetooth_product.h" +#include "bluetooth_private.h" + +#ifdef TIZEN_LE_DISABLE +#define BT_CHECK_LE_SUPPORT() \ + { \ + BT_CHECK_BT_SUPPORT(); \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_LE_SUPPORT() +#endif + +#define BT_MOBILE_HEADLESS_DB "/opt/usr/dbspace/.bluetooth_headless_mobilelist.db" +#define BT_DB_HEADLESS_TABLE "inbound" +#define BT_MOBILE_HEADLESS_DB_QUERY_LEN 512 +#define TEXT(s, n) (const char *)sqlite3_column_text(s, n) + + +/*Mobile Headless Start*/ +static void __delete_glistdata(gpointer data, gpointer user_data) +{ + bt_headlessdb_device_info *noti_data = data; + + if (noti_data == NULL) + return; + else + { + free(noti_data->bdaddress); + free(noti_data->dev_type); + } + free(noti_data); +} + +void bt_mobileheadless_close_db(void **sdb1) +{ + sqlite3 **sdb =(sqlite3 **) sdb1; + if(*sdb) + { + db_util_close(*sdb); + } + *sdb = NULL; +} + +static bool _bt_mobileheadless_check_ifaddress_present_in_db(sqlite3 *sdb,const char *device_address) +{ + + BT_CHECK_INPUT_PARAMETER(sdb); + BT_CHECK_INPUT_PARAMETER(device_address); + + int ret = 0; + sqlite3_stmt *stmt = NULL; + + char query[BT_MOBILE_HEADLESS_DB_QUERY_LEN] = {0, }; + snprintf(query, sizeof(query), + "SELECT * FROM %s WHERE addr='%s';", + BT_DB_HEADLESS_TABLE,device_address); + + ret = sqlite3_prepare(sdb, query, -1, &stmt, NULL); + if (ret != SQLITE_OK || stmt == NULL) { + sqlite3_finalize(stmt); + return false; + } + + ret = sqlite3_step(stmt); + if (ret == SQLITE_ROW) { + sqlite3_finalize(stmt); + return true; + } + + sqlite3_finalize(stmt); + return false; +} + +static int _bt_mobileheadless_add_db(sqlite3 *sdb, const char *remote_address,const char *dev_type) +{ + BT_DBG("+\n"); + + BT_CHECK_INPUT_PARAMETER(sdb); + BT_CHECK_INPUT_PARAMETER(remote_address); + BT_CHECK_INPUT_PARAMETER(dev_type); + if (_bt_mobileheadless_check_ifaddress_present_in_db(sdb,remote_address)) + { + BT_DBG("Remote Address : [%s] is already added to DB\n ", remote_address); + return BLUETOOTH_ERROR_NONE; + + } + + if(bt_adapter_register_headless_device(remote_address) != BT_ERROR_NONE) + BT_ERR("Failed to register device to headless list"); + + char *query = NULL; + sqlite3_stmt *stmt = NULL; + + query = sqlite3_mprintf("INSERT INTO %s (id,addr,dev_type) VALUES(?, '%q', '%q');",BT_DB_HEADLESS_TABLE, remote_address,dev_type); + if (!query) + { + return BLUETOOTH_ERROR_INTERNAL; + } + + BT_DBG("query : %s", query); + int ret = sqlite3_prepare_v2(sdb, query, strlen(query), &stmt, NULL); + if (ret != SQLITE_OK) + goto error; + + ret = sqlite3_step(stmt); + if (ret != SQLITE_DONE) + goto error; + + sqlite3_finalize(stmt); + sqlite3_free(query); + + BT_DBG("-\n"); + return BLUETOOTH_ERROR_NONE; + +error: + BT_ERR("[ERROR] szQuery : %s", query); + BT_ERR("[ERROR] SQL error msg : %s", sqlite3_errmsg(sdb)); + if (stmt) { + sqlite3_finalize(stmt); + } + sqlite3_free(query); + + return BLUETOOTH_ERROR_INTERNAL; +} + +static GSList* _bt_mobileheadless_getall_db(sqlite3 *sdb) +{ + if (NULL == sdb) + return NULL; + + GSList *slist = NULL; + sqlite3_stmt *stmt = NULL; + int idx = 0; + + char query[BT_MOBILE_HEADLESS_DB_QUERY_LEN] = {0, }; + snprintf(query, sizeof(query), + "SELECT * FROM %s;", + BT_DB_HEADLESS_TABLE); + + int ret = sqlite3_prepare(sdb, query, -1, &stmt, NULL); + if (ret != SQLITE_OK || stmt == NULL) { + BT_ERR("SQL error\n"); + sqlite3_finalize(stmt); + return NULL; + } + + ret = sqlite3_step(stmt); + + while (ret == SQLITE_ROW) { + bt_headlessdb_device_info* btheadless = malloc(sizeof(bt_headlessdb_device_info)); + idx = 0; + if (btheadless) + { + btheadless->bdaddress = (char*)g_strdup(TEXT(stmt, idx+1)); + btheadless->dev_type = (char*)g_strdup(TEXT(stmt, idx+2)); + slist = g_slist_append(slist, btheadless); + ret = sqlite3_step(stmt); + } + else + { + BT_ERR("Failed to Get memory for bt_headlessdb_device_info\n"); + } + } + + sqlite3_finalize(stmt); + return slist; +} + +static int _bt_mobileheadless_delete_db(sqlite3 *sdb,const char *remote_address) +{ + BT_CHECK_INPUT_PARAMETER(remote_address); + BT_CHECK_INPUT_PARAMETER(sdb); + + int ret = BLUETOOTH_ERROR_NONE; + sqlite3_stmt *stmt = NULL; + + if(bt_adapter_unregister_headless_device(remote_address) != BT_ERROR_NONE) + BT_ERR("Failed to unregister device to headless list"); + + char query[BT_MOBILE_HEADLESS_DB_QUERY_LEN] = {0, }; + snprintf(query, sizeof(query), + "DELETE FROM %s WHERE addr='%s';", + BT_DB_HEADLESS_TABLE, remote_address); + + + BT_DBG("query : %s", query); + + ret = sqlite3_prepare_v2(sdb, query, strlen(query), &stmt, NULL); + if (ret != SQLITE_OK) { + BT_ERR("sqlite3_prepare_v2(%s) Failed(%s)", query, sqlite3_errmsg(sdb)); + return BLUETOOTH_ERROR_INTERNAL; + } + + ret = sqlite3_step(stmt); + if (ret != SQLITE_DONE) { + BT_ERR("sqlite3_step() Failed(%d)", ret); + sqlite3_finalize(stmt); + return BLUETOOTH_ERROR_INTERNAL; + } + + sqlite3_finalize(stmt); + + return BLUETOOTH_ERROR_NONE; +} + +static int _bt_mobileheadless_deleteall_db(sqlite3 *sdb) +{ + BT_CHECK_INPUT_PARAMETER(sdb); + int ret = BLUETOOTH_ERROR_NONE; + GSList *dev_list = NULL; + dev_list = _bt_mobileheadless_getall_db(sdb); + if (ret < BT_ERROR_NONE) + { + BT_ERR("failed to get bluetooth_get_all_headless_mobile_in_DB "); + } + else + { + if (dev_list == NULL) + { + BT_ERR(" BT_MOBILE_HEADLESS_DB database is Empty\n "); + } + else + { + BT_DBG("Showing all Address present in BT_MOBILE_HEADLESS_DB db\n"); + GSList* tmp = dev_list; + while (tmp != NULL) + { + if(bt_adapter_unregister_headless_device((gchar*) tmp->data) != BT_ERROR_NONE) + BT_ERR("Failed to unregister device to headless list"); + tmp = g_slist_next(tmp); + } + + if (dev_list !=NULL) + { + g_slist_foreach(dev_list,(GFunc) __delete_glistdata, NULL); + g_slist_free(dev_list); + dev_list = NULL; + } + tmp = NULL; + } + } + + + ret = BLUETOOTH_ERROR_NONE; + + sqlite3_stmt *stmt = NULL; + + char query[BT_MOBILE_HEADLESS_DB_QUERY_LEN] = {0, }; + snprintf(query, sizeof(query), + "DELETE FROM %s;", + BT_DB_HEADLESS_TABLE); + + + BT_DBG("query : %s", query); + + ret = sqlite3_prepare_v2(sdb, query, strlen(query), &stmt, NULL); + if (ret != SQLITE_OK) { + BT_ERR("sqlite3_prepare_v2(%s) Failed(%s)", query, sqlite3_errmsg(sdb)); + return BLUETOOTH_ERROR_INTERNAL; + } + + ret = sqlite3_step(stmt); + if (ret != SQLITE_DONE) { + BT_ERR("sqlite3_step() Failed(%d)", ret); + sqlite3_finalize(stmt); + return BLUETOOTH_ERROR_INTERNAL; + } + + sqlite3_finalize(stmt); + + return BLUETOOTH_ERROR_NONE; +} + +int bt_headless_open_db(void **sdb1) +{ + sqlite3 **sdb =(sqlite3 **) sdb1; + if(*sdb) + { + return BLUETOOTH_ERROR_NONE; + } + + int ret = db_util_open(BT_MOBILE_HEADLESS_DB, sdb, DB_UTIL_REGISTER_HOOK_METHOD); + BT_DBG("\n db_util_open result for BT_MOBILE_HEADLESS_DB is [%d]\n",ret); + + if (ret) { + BT_ERR("Can't open database: %s", sqlite3_errmsg(*sdb)); + db_util_close(*sdb); + return BLUETOOTH_ERROR_INTERNAL; + } + + if (*sdb == NULL) + { + return BLUETOOTH_ERROR_INTERNAL; + } + return BLUETOOTH_ERROR_NONE; +} + +int bt_bluetooth_add_headless_device_in_DB(void *sdb1,const char *remote_address,const char*dev_type) +{ + sqlite3 *sdb =(sqlite3 *) sdb1; + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + BT_CHECK_INPUT_PARAMETER(dev_type); + BT_CHECK_INPUT_PARAMETER(sdb); + + return (_bt_mobileheadless_add_db(sdb,remote_address,dev_type)); +} + +int bt_bluetooth_add_headless_mobile_in_DB(void *sdb1,const char *remote_address) +{ + sqlite3 *sdb =(sqlite3 *) sdb1; + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + //BT_CHECK_INPUT_PARAMETER(dev_type); + BT_CHECK_INPUT_PARAMETER(sdb); + + return (bt_bluetooth_add_headless_device_in_DB(sdb,remote_address,"Mobile")); +} + +int bt_bluetooth_delete_headless_mobile_in_DB(void *sdb1,const char *remote_address) +{ + sqlite3 *sdb =(sqlite3 *) sdb1; + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + BT_CHECK_INPUT_PARAMETER(sdb); + return (_bt_mobileheadless_delete_db(sdb,remote_address)); +} + +int bt_bluetooth_get_all_headless_device_in_DB(void *sdb1,GSList **dev_list) +{ + sqlite3 *sdb =(sqlite3 *) sdb1; + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(sdb); + + *dev_list = _bt_mobileheadless_getall_db(sdb); + + if(*dev_list == NULL) + return BLUETOOTH_ERROR_INTERNAL; + + return BLUETOOTH_ERROR_NONE; +} + +int bt_bluetooth_get_all_headless_mobile_in_DB(void *sdb1,GSList **dev_list) +{ + sqlite3 *sdb =(sqlite3 *) sdb1; + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(sdb); + + *dev_list = NULL;//_bt_mobileheadless_getall_db(sdb); + + //if(*dev_list == NULL) + // return BLUETOOTH_ERROR_INTERNAL; + + return BLUETOOTH_ERROR_NONE; +} + +int bt_bluetooth_delete_all_headless_mobile_in_DB(void *sdb1) +{ + sqlite3 *sdb =(sqlite3 *) sdb1; + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(sdb); + + return (_bt_mobileheadless_deleteall_db(sdb)); +} +/*Headless Mobile End*/ + + +int bt_adapter_enable(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(bluetooth_enable_adapter()); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_adapter_disable(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(bluetooth_disable_adapter()); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_adapter_reset(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(bluetooth_reset_adapter()); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_adapter_get_state(bt_adapter_state_e *adapter_state) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(adapter_state); + + *adapter_state = bluetooth_check_adapter(); + return BT_ERROR_NONE; +} + +int bt_adapter_get_address(char **address) +{ + bluetooth_device_address_t loc_address = { {0} }; + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(address); + + error_code = _bt_get_error_code(bluetooth_get_local_address(&loc_address)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + return error_code; + } + + error_code = _bt_convert_address_to_string(address, &loc_address); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + return error_code; + } + + return BT_ERROR_NONE; +} + +int bt_adapter_get_name(char **name) +{ + int ret = BT_ERROR_NONE; + bluetooth_device_name_t loc_name = { {0} }; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(name); + + ret = _bt_get_error_code(bluetooth_get_local_name(&loc_name)); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + return ret; + } + + *name = strdup(loc_name.name); + if (*name == NULL) { + BT_ERR("OUT_OF_MEMORY(0x%08x)", BT_ERROR_OUT_OF_MEMORY); + return BT_ERROR_OUT_OF_MEMORY; + } + + return BT_ERROR_NONE; +} + +int bt_adapter_set_name(const char *name) +{ + bluetooth_device_name_t loc_name = { {0} }; + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(name); + + strncpy(loc_name.name, name, BLUETOOTH_DEVICE_NAME_LENGTH_MAX); + loc_name.name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX] = '\0'; + + ret = _bt_get_error_code(bluetooth_set_local_name(&loc_name)); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_adapter_get_visibility(bt_adapter_visibility_mode_e *mode, int *duration) +{ + bluetooth_discoverable_mode_t discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE; + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(mode); + + ret = _bt_get_error_code(bluetooth_get_discoverable_mode(&discoverable_mode)); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + return ret; + } + + *mode = _bt_get_bt_visibility_mode_e(discoverable_mode); + + if (duration) + *duration = 0; + + if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE) { + if (duration == NULL) + return BT_ERROR_NONE; + ret = bluetooth_get_timeout_value(duration); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + } + + return BT_ERROR_NONE; +} + +int bt_adapter_set_visibility(bt_adapter_visibility_mode_e visibility_mode, int timeout_sec) +{ + bluetooth_discoverable_mode_t discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE; + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + switch (visibility_mode) { + case BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE: + discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE; + break; + case BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE: + discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE; + timeout_sec = 0; + break; + case BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE: + discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE; + timeout_sec = 0; + break; + case BT_ADAPTER_VISIBILITY_MODE_NON_CONNECTABLE: + discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_NON_CONNECTABLE; + timeout_sec = 0; + break; + default: + BT_ERR("INVALID_PARAMETER(0x%08x)", BT_ERROR_INVALID_PARAMETER); + return BT_ERROR_INVALID_PARAMETER; + } + + error_code = _bt_get_error_code(bluetooth_set_discoverable_mode(discoverable_mode, timeout_sec)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + + return error_code; +} + +int bt_adapter_foreach_bonded_device(bt_adapter_bonded_device_cb foreach_cb, void *user_data) +{ + GPtrArray *dev_list = NULL; + bt_device_info_s *dev_info = NULL; + bluetooth_device_info_t *ptr = NULL; + int ret = BT_ERROR_NONE; + unsigned int i = 0; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(foreach_cb); + + dev_list = g_ptr_array_new(); + if (dev_list == NULL) { + BT_ERR("OUT_OF_MEMORY(0x%08x)", BT_ERROR_OUT_OF_MEMORY); + return BT_ERROR_OUT_OF_MEMORY; + } + + ret = _bt_get_error_code(bluetooth_get_bonded_device_list(&dev_list)); + if (ret != BT_ERROR_NONE || dev_list == NULL) { + BT_ERR("%s(0x%08x) : Failed to get bonded device list", _bt_convert_error_to_string(ret), ret); + return ret; + } + + for (i = 0; i < dev_list->len; i++) { + ptr = g_ptr_array_index(dev_list, i); + if (ptr != NULL) { + ret = _bt_get_bt_device_info_s(&dev_info, (bluetooth_device_info_t *)ptr); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x) : Failed to get device info", _bt_convert_error_to_string(ret), ret); + break; + } + + if (!foreach_cb(dev_info, user_data)) { + _bt_free_bt_device_info_s(dev_info); + break; + } + _bt_free_bt_device_info_s(dev_info); + } else { + BT_ERR("OPERATION_FAILED(0x%08x)", BT_ERROR_OPERATION_FAILED); + ret = BT_ERROR_OPERATION_FAILED; + break; + } + } + + if (dev_list != NULL) { + g_ptr_array_free(dev_list, TRUE); + } + + return ret; +} + +int bt_adapter_get_bonded_device_info(const char *remote_address, bt_device_info_s **device_info) +{ + int ret; + bluetooth_device_address_t addr_hex = { {0,} }; + bluetooth_device_info_t *info; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + + info = (bluetooth_device_info_t *)malloc(sizeof(bluetooth_device_info_t)); + if (info == NULL) + return BT_ERROR_OUT_OF_MEMORY; + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + ret = _bt_get_error_code(bluetooth_get_bonded_device(&addr_hex, info)); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x) : Failed to run function", + _bt_convert_error_to_string(ret), ret); + } else { + ret = _bt_get_bt_device_info_s(device_info, info); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x) : Failed to get device info", + _bt_convert_error_to_string(ret), + ret); + } + } + + free(info); + + return ret; +} + +int bt_adapter_free_device_info(bt_device_info_s *device_info) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(device_info); + + _bt_free_bt_device_info_s(device_info); + + return BT_ERROR_NONE; +} + + +int bt_adapter_get_specific_bonded_device_info(const char *remote_address, bt_hid_device_info_s **device_info) +{ + + int ret; + bluetooth_device_address_t addr_hex = { {0,} }; + bluetooth_hid_device_info_t *hid_info; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + + hid_info = (bluetooth_hid_device_info_t *)malloc(sizeof(bluetooth_hid_device_info_t)); + if (hid_info == NULL) + return BT_ERROR_OUT_OF_MEMORY; + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + ret = _bt_get_error_code(bluetooth_get_specific_bonded_device(&addr_hex, hid_info)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x) : Failed to run function", + _bt_convert_error_to_string(ret), ret); + } else { + ret = _bt_get_specific_bt_device_info_s(device_info, hid_info); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x) : Failed to get device hid_info", + _bt_convert_error_to_string(ret), + ret); + } + } + + free(hid_info); + + return ret; +} + +int bt_adapter_free_hid_device_info(bt_hid_device_info_s *device_info) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(device_info); + _bt_free_specific_bt_device_info_s(device_info); + + return BT_ERROR_NONE; +} + +int bt_adapter_is_service_used(const char *service_uuid, bool *used) +{ + int ret = BT_ERROR_NONE; + gboolean is_used = FALSE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(service_uuid); + BT_CHECK_INPUT_PARAMETER(used); + + if (strcmp(service_uuid, OPP_UUID) == 0) { + *used = bluetooth_obex_server_is_activated(); + } else { + ret = _bt_get_error_code(bluetooth_is_service_used(service_uuid, + &is_used)); + *used = (is_used ? true : false); + } + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x) : Failed to run function", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_adapter_set_state_changed_cb(bt_adapter_state_changed_cb callback, void *user_data) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_STATE_CHANGED, callback, user_data); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_adapter_set_name_changed_cb(bt_adapter_name_changed_cb callback, void *user_data) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_NAME_CHANGED, callback, user_data); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_adapter_set_visibility_mode_changed_cb(bt_adapter_visibility_mode_changed_cb callback, void *user_data) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_VISIBILITY_MODE_CHANGED, callback, user_data); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_adapter_set_device_discovery_state_changed_cb(bt_adapter_device_discovery_state_changed_cb callback, void *user_data) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_DEVICE_DISCOVERY_STATE_CHANGED, callback, user_data); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_adapter_start_smartrc_tput_mode(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(_bt_start_smartrc_tput_mode()); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_adapter_stop_smartrc_tput_mode(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(_bt_stop_smartrc_tput_mode()); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_adapter_le_set_device_discovery_state_changed_cb(bt_adapter_le_device_discovery_state_changed_cb callback, void *user_data) +{ + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + + _bt_le_adapter_init(); + _bt_set_cb(BT_EVENT_LE_DEVICE_DISCOVERY_STATE_CHANGED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_adapter_le_unset_device_discovery_state_changed_cb(void) +{ + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_LE_DEVICE_DISCOVERY_STATE_CHANGED); + _bt_le_adapter_deinit(); + return BT_ERROR_NONE; +} + +int bt_adapter_unset_state_changed_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_STATE_CHANGED); + return BT_ERROR_NONE; +} + +int bt_adapter_unset_name_changed_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_NAME_CHANGED); + return BT_ERROR_NONE; +} + +int bt_adapter_unset_visibility_mode_changed_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_VISIBILITY_MODE_CHANGED); + return BT_ERROR_NONE; +} + +int bt_adapter_set_visibility_duration_changed_cb(bt_adapter_visibility_duration_changed_cb callback, void *user_data) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + /* Will impelement it */ + + return BT_ERROR_NONE; +} + +int bt_adapter_unset_visibility_duration_changed_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + /* Will impelement it */ + + return BT_ERROR_NONE; +} + +int bt_adapter_unset_device_discovery_state_changed_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_DEVICE_DISCOVERY_STATE_CHANGED); + return BT_ERROR_NONE; +} + +int bt_adapter_set_max_device_connected_cb(bt_adapter_max_conection_reached_cb callback, void *user_data) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_set_cb(BT_EVENT_MAX_CONNECTION_REACHED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_adapter_set_authentication_req_cb(bt_adapter_authentication_req_cb callback, void *user_data) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_set_cb(BT_EVENT_AUTHENTICATION_REQUEST, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_adapter_unset_authentication_req_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_AUTHENTICATION_REQUEST); + return BT_ERROR_NONE; +} + +int bt_adapter_unset_max_device_connected_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_MAX_CONNECTION_REACHED); + return BT_ERROR_NONE; +} + +int bt_adapter_set_duration(int duration) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(bluetooth_set_discovery_duration((unsigned short)duration)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_adapter_start_device_discovery(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(bluetooth_start_discovery(0, 0, BLUETOOTH_DEVICE_MAJOR_MASK_MISC)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_adapter_start_device_discovery_with_duration(int duration) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(bluetooth_start_discovery(0, (unsigned short)duration, BLUETOOTH_DEVICE_MAJOR_MASK_MISC)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + + +int bt_adapter_stop_device_discovery(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(bluetooth_cancel_discovery()); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_adapter_start_device_discovery_with_class_of_device(int major, int minor) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(bluetooth_start_discovery_with_class_of_device(major, minor)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_adapter_start_device_discovery_with_address(const char *remote_address) +{ + int error_code = BT_ERROR_NONE; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + error_code = _bt_get_error_code(bluetooth_start_discovery_with_address(&addr_hex)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_adapter_start_device_discovery_for_3dtv(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_start_discovery_for_3dtv()); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_adapter_is_discovering(bool *is_discovering) +{ + int ret = 0; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(is_discovering); + + ret = bluetooth_is_discovering(); + if (ret >= BLUETOOTH_ERROR_BASE) { + *is_discovering = (ret == 1) ? true : false; + return BT_ERROR_NONE; + } else { + ret = _bt_get_error_code(ret); + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + return ret; + } +} + +/*LE Only API's */ +int bt_adapter_le_start_device_discovery(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(bluetooth_start_le_discovery()); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + BT_ERR("bt_adapter_le_start_device_discovery<< err= %d", error_code); + return error_code; +} + +int bt_adapter_le_stop_device_discovery(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(bluetooth_stop_le_discovery()); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + BT_ERR("bt_adapter_le_stop_device_discovery<< err= %d", error_code); + return error_code; +} + +int bt_adapter_le_is_discovering(bool *is_discovering) +{ + int ret = 0; + + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(is_discovering); + + ret = bluetooth_is_le_discovering(); + if (ret >= BLUETOOTH_ERROR_BASE) { + *is_discovering = (ret == 1) ? true : false; + BT_ERR("bt_adapter_le_is_discovering is_discovering = %d", *is_discovering); + return BT_ERROR_NONE; + } else { + ret = _bt_get_error_code(ret); + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + return ret; + } +} + +int bt_adapter_set_device_id(unsigned short vid, unsigned short pid) +{ + unsigned short vendor_id = { 0 }; + unsigned short product_id = { 0 }; + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + vendor_id = vid; + product_id = pid; + + ret = _bt_get_error_code(bluetooth_set_device_id(vendor_id, product_id)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + return ret; +} + +int bt_adapter_block_bt_channels_for_using_wifi(unsigned char first_disabled_channel, + unsigned char last_disabled_channel) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + + ret = _bt_get_error_code(bluetooth_block_bt_channels_for_using_wifi(first_disabled_channel, + last_disabled_channel)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + return ret; +} + +int bt_adapter_set_tx_power(bt_adapter_tx_pwr_class tx_power_class) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_set_tx_power(tx_power_class)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_adapter_set_headless_mode(bool enable) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_set_headless_mode(enable)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_adapter_register_headless_device(const char *remote_address) +{ + int error_code = BT_ERROR_NONE; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + error_code = _bt_get_error_code(bluetooth_register_headless_device(&addr_hex)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int _bt_get_bt_headless_device_info_s(bt_adapter_headless_dev_info_s **dest_dev, + bluetooth_headless_device_info_t *source_dev) +{ + char hexclass_string[9] = {0,}; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INPUT_PARAMETER(source_dev); + + *dest_dev = (bt_adapter_headless_dev_info_s *)malloc(sizeof(bt_adapter_headless_dev_info_s)); + if (*dest_dev == NULL) { + return BT_ERROR_OUT_OF_MEMORY; + } + + _bt_convert_address_to_string(&((*dest_dev)->remote_address), &(source_dev->device_address)); + + snprintf(hexclass_string, 9, "%2.2X:%2.2X:%2.2X", + source_dev->hexclass[0], source_dev->hexclass[1], source_dev->hexclass[2]); + + (*dest_dev)->hexclass = strdup(hexclass_string); + (*dest_dev)->null_pin_code = source_dev->null_pin_code; + + return BT_ERROR_NONE; +} + +void _bt_free_headless_device_info_s(bt_adapter_headless_dev_info_s *device_info) +{ + BT_CHECK_BT_SUPPORT(); + + if (device_info == NULL) + return; + + if (device_info->remote_address != NULL) { + free(device_info->remote_address); + device_info->remote_address = NULL; + } + + if (device_info->hexclass != NULL) { + free(device_info->hexclass); + device_info->hexclass = NULL; + } + + free(device_info); + device_info = NULL; +} + +int bt_adapter_free_headless_device_info(bt_adapter_headless_dev_info_s *device_info) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(device_info); + _bt_free_headless_device_info_s(device_info); + + return BT_ERROR_NONE; +} + +int bt_adapter_foreach_headless_device_info(bt_adapter_headless_device_info_cb foreach_cb, void *user_data) +{ + GPtrArray *dev_list = NULL; + bt_adapter_headless_dev_info_s *dev_info = NULL; + bluetooth_headless_device_info_t *ptr = NULL; + int ret = BT_ERROR_NONE; + unsigned int i = 0; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(foreach_cb); + + dev_list = g_ptr_array_new(); + if (dev_list == NULL) { + BT_ERR("OUT_OF_MEMORY(0x%08x)", BT_ERROR_OUT_OF_MEMORY); + return BT_ERROR_OUT_OF_MEMORY; + } + ret = _bt_get_error_code(bluetooth_get_headless_device_list(&dev_list)); + if (ret != BT_ERROR_NONE || dev_list == NULL) { + BT_ERR("%s(0x%08x) : Failed to get bonded device list", + _bt_convert_error_to_string(ret), ret); + return ret; + } + + for (i = 0; i < dev_list->len; i++) { + ptr = (bluetooth_headless_device_info_t*)g_ptr_array_index(dev_list, i); + if (ptr != NULL) { + ret = _bt_get_bt_headless_device_info_s(&dev_info, + (bluetooth_headless_device_info_t*)ptr); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x) : Failed to get device info", + _bt_convert_error_to_string(ret), ret); + break; + } + + if (!foreach_cb(dev_info, user_data)) { + _bt_free_headless_device_info_s(dev_info); + break; + } + _bt_free_headless_device_info_s(dev_info); + } else { + BT_ERR("OPERATION_FAILED(0x%08x)", BT_ERROR_OPERATION_FAILED); + ret = BT_ERROR_OPERATION_FAILED; + break; + } + } + + if (dev_list != NULL) { + g_ptr_array_free(dev_list, TRUE); + } + + return ret; +} + +int bt_adapter_unregister_headless_device(const char *remote_address) +{ + int error_code = BT_ERROR_NONE; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + error_code = _bt_get_error_code(bluetooth_unregister_headless_device(&addr_hex)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_adapter_set_headless_scan_control(bool llr_scan) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_set_headless_scan_control(llr_scan)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_adapter_sleep_bluetooth(bool standby) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + /* If standby is false, then set Normal headless Mode */ + if (!standby) { + /* TV INstant On */ + } else { + } + /* Implement it in later */ + + error_code = _bt_get_error_code(bluetooth_set_power_off_mode(BLUETOOTH_STANBY_OFF)); + + return error_code; +} + +int bt_adapter_power_off(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_set_power_off_mode(BLUETOOTH_POWER_OFF)); + + return error_code; + +} + +int bt_adapter_set_advertising_state_changed_cb(bt_adapter_advertising_state_changed_cb callback, void *user_data) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_ADVERTISING_STATE_CHANGED, callback, user_data); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_adapter_unset_advertising_state_changed_cb(void) +{ + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_ADVERTISING_STATE_CHANGED); + return BT_ERROR_NONE; +} + +int bt_adapter_start_advertising(bt_adapter_advertising_params_s *adv_params) +{ + int org_error_code = BLUETOOTH_ERROR_NONE; + int error_code = BT_ERROR_NONE; + + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + if (adv_params == NULL) { + org_error_code = bluetooth_set_advertising(TRUE); + } else { + org_error_code = bluetooth_set_custom_advertising(TRUE, + (bluetooth_advertising_params_t *)adv_params); + } + + error_code = _bt_get_error_code(org_error_code); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + + return error_code; +} + +int bt_adapter_stop_advertising(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_set_advertising(FALSE)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + + return error_code; +} + +int bt_adapter_is_advertising(bool *is_advertising) +{ + int ret; + gboolean advertising = FALSE; + + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(is_advertising); + + ret = bluetooth_is_advertising(&advertising); + if (ret >= BLUETOOTH_ERROR_BASE) { + *is_advertising = advertising ? true : false; + return BT_ERROR_NONE; + } else { + ret = _bt_get_error_code(ret); + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + return ret; + } +} + +int bt_adapter_add_white_list(const char *address) +{ + int error_code = BT_ERROR_NONE; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(address); + _bt_convert_address_to_hex(&addr_hex, address); + + error_code = _bt_get_error_code(bluetooth_add_white_list(&addr_hex)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + + return error_code; +} + +int bt_adapter_remove_white_list(const char *address) +{ + int error_code = BT_ERROR_NONE; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(address); + _bt_convert_address_to_hex(&addr_hex, address); + + error_code = _bt_get_error_code(bluetooth_remove_white_list(&addr_hex)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + + return error_code; +} + +int bt_adapter_clear_white_list(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_clear_white_list()); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + + return error_code; +} + +static int __bt_get_ad_data_by_type(char *in_data, int in_len, + char in_type, char **data, int *data_len) +{ + if (in_data == NULL || data == NULL || data_len == NULL) + return BT_ERROR_OPERATION_FAILED; + + if (in_len < 0) + return BT_ERROR_OPERATION_FAILED; + + int i; + int len = 0; + int type = 0; + + for (i = 0; i < in_len; i++) { + len = in_data[i]; + if (len <= 0 || i + 1 >= in_len) { + BT_ERR("Invalid advertising data"); + return BT_ERROR_OPERATION_FAILED; + } + + type = in_data[i + 1]; + if (type == in_type) { + i = i + 2; + len--; + break; + } + + i += len; + len = 0; + } + + if (i + len > in_len) { + BT_ERR("Invalid advertising data"); + return BT_ERROR_OPERATION_FAILED; + } else if (len == 0) { + BT_INFO("AD Type 0x%02x data is not set", in_type); + *data = NULL; + *data_len = 0; + return BT_ERROR_NONE; + } + + *data = g_memdup(&in_data[i], len); + if (*data == NULL) + return BT_ERROR_OUT_OF_MEMORY; + *data_len = len; + + return BT_ERROR_NONE; +} + + +int bt_adapter_get_advertising_manufacturer_data(char **data, int *len) +{ + bluetooth_advertising_data_t adv = { {0} }; + int adv_len = 0; + int ret; + + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(data); + BT_CHECK_INPUT_PARAMETER(len); + + ret = _bt_get_error_code(bluetooth_get_advertising_data(&adv, &adv_len)); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + return ret; + } + + ret = __bt_get_ad_data_by_type((char *)adv.data, adv_len, 0xff, + data, len); + if (ret != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + + return ret; +} + +int bt_adapter_set_advertising_manufacturer_data(char *data, int len) +{ + int ret; + int adv_data_size; + bluetooth_advertising_data_t adv = { {0} }; + + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(data); + + adv_data_size = sizeof(adv.data); + + if (len + 2 > adv_data_size || len < 0) + return BT_ERROR_INVALID_PARAMETER; + + adv.data[0] = len + 1; + adv.data[1] = 0xFF; + + memcpy(&adv.data[2], data, len); + + ret = _bt_get_error_code(bluetooth_set_advertising_data(&adv, len + 2)); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_adapter_set_advertising_manufacturer_data_changed_cb( + bt_adapter_advertising_manufacturer_data_changed_cb callback, + void *user_data) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_ADVERTISING_MANUFACTURER_DATA_CHANGED, + callback, user_data); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_adapter_unset_advertising_manufacturer_data_changed_cb(void) +{ + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_ADVERTISING_MANUFACTURER_DATA_CHANGED); + return BT_ERROR_NONE; +} + +int bt_adapter_get_scan_resp_manufacturer_data(char **data, int *len) +{ + bluetooth_scan_resp_data_t resp = { {0} }; + int resp_len = 0; + int ret; + + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(data); + BT_CHECK_INPUT_PARAMETER(len); + + ret = _bt_get_error_code(bluetooth_get_scan_response_data(&resp, &resp_len)); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + return ret; + } + + ret = __bt_get_ad_data_by_type((char *)resp.data, resp_len, 0xff, + data, len); + if (ret != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + + return ret; +} + +int bt_adapter_set_scan_resp_manufacturer_data(char *data, int len) +{ + int ret; + bluetooth_scan_resp_data_t resp = { {0} }; + int resp_data_size; + + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(data); + + resp_data_size = sizeof(resp.data); + + if (len + 2 > resp_data_size || len < 0) + return BT_ERROR_INVALID_PARAMETER; + + resp.data[0] = len + 1; + resp.data[1] = 0xFF; + + memcpy(&resp.data[2], data, len); + + ret = _bt_get_error_code(bluetooth_set_scan_response_data(&resp, len + 2)); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_adapter_set_scan_resp_manufacturer_data_changed_cb( + bt_adapter_scan_resp_manufacturer_data_changed_cb callback, + void *user_data) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_SCAN_RESPONSE_MANUFACTURER_DATA_CHANGED, + callback, user_data); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_adapter_unset_scan_resp_manufacturer_data_changed_cb(void) +{ + BT_CHECK_LE_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_ADVERTISING_MANUFACTURER_DATA_CHANGED); + return BT_ERROR_NONE; +} + +int bt_adapter_set_scan_parameter(float interval, float window) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + ret = bluetooth_set_scan_parameters(interval, window); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + return ret; +} + +int bt_adapter_set_headless_advertising_data(char *data, int len) +{ + int ret; + bluetooth_advertising_data_t adv = { {0} }; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(data); + + memcpy(&adv.data[0], data, len); + + ret = _bt_get_error_code(bluetooth_set_headless_advertising_data(&adv, len)); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_adapter_is_samsung_audio_dock_connected(bool *connected) +{ + int ret = BT_ERROR_NONE; + gboolean is_connected = FALSE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INPUT_PARAMETER(connected); + + ret = _bt_get_error_code(bluetooth_is_samsung_audio_dock_connected(&is_connected)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x) : Failed to run function", _bt_convert_error_to_string(ret), ret); + } else { + *connected = (is_connected ? true : false); + BT_DBG("bt_adapter_is_samsung_audio_dock_connected: connected = %d ret = %d", *connected, ret); + } + + return ret; +} + +int bt_adapter_get_chip_version(int *version) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INPUT_PARAMETER(version); + + ret = _bt_get_error_code(bluetooth_get_chip_version(version)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x) : Failed to run function", _bt_convert_error_to_string(ret), ret); + } else { + BT_DBG("version : %d", *version); + } + + return ret; +} + +int bt_adapter_update_firmware(int chip_type) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + + ret = bluetooth_update_firmware(chip_type); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + return ret; +} + +int bt_adapter_set_app_ready(bool ready) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + + ret = bluetooth_set_app_ready(ready); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + return ret; +} + +int bt_adapter_is_required_update_firmware(bool *required) +{ + int ret = BT_ERROR_NONE; + gboolean is_required = FALSE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INPUT_PARAMETER(required); + + ret = _bt_get_error_code(bluetooth_is_required_update_firmware(&is_required)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x) : Failed to run function", _bt_convert_error_to_string(ret), ret); + } else { + *required = (is_required ? true : false); + BT_DBG("bt_adapter_is_required_update_firmware: required = %d ret = %d", *required, ret); + } + + return ret; +} + +int bt_adapter_cancel_firmware_update(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(bluetooth_cancel_firmware_update()); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_adapter_set_bt_chip_fw_update_status_cb(bt_adapter_notify_bt_chip_fw_update_status_cb callback, + void *user_data) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_BT_CHIP_FW_UPDATE_STATUS, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_adapter_unset_bt_chip_fw_update_status_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_BT_CHIP_FW_UPDATE_STATUS); + return BT_ERROR_NONE; +} + +int bt_adapter_get_local_oob_data(unsigned char **hash, unsigned char **randomizer, + int *hash_len, int *randomizer_len) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_set_remote_oob_data(const char *remote_address, + unsigned char *hash, unsigned char *randomizer, + int hash_len, int randomizer_len) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_remove_remote_oob_data(const char *remote_address) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_start_scan(bt_adapter_le_scan_result_cb cb, void *user_data) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_stop_scan(void) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_get_scan_result_service_uuids(const bt_adapter_le_device_scan_result_info_s *info, + bt_adapter_le_packet_type_e pkt_type, char ***uuids, int *count) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_get_scan_result_device_name(const bt_adapter_le_device_scan_result_info_s *info, + bt_adapter_le_packet_type_e pkt_type, char **name) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_get_scan_result_tx_power_level(const bt_adapter_le_device_scan_result_info_s *info, + bt_adapter_le_packet_type_e pkt_type, int *power_level) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_get_scan_result_service_solicitation_uuids(const bt_adapter_le_device_scan_result_info_s *info, + bt_adapter_le_packet_type_e pkt_type, char ***uuids, int *count) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_get_scan_result_service_data_list(const bt_adapter_le_device_scan_result_info_s *info, + bt_adapter_le_packet_type_e pkt_type, bt_adapter_le_service_data_s **data_list, int *count) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + + +int bt_adapter_le_free_service_data_list(bt_adapter_le_service_data_s *data_list, int count) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_get_scan_result_appearance(const bt_adapter_le_device_scan_result_info_s *info, + bt_adapter_le_packet_type_e pkt_type, int *appearance) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_get_scan_result_manufacturer_data(const bt_adapter_le_device_scan_result_info_s *info, + bt_adapter_le_packet_type_e pkt_type, int *manufacturer_id, char **manufacturer_data, int *manufacturer_data_len) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_create_advertiser(bt_advertiser_h *advertiser) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_destroy_advertiser(bt_advertiser_h advertiser) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_add_advertising_data(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, bt_adapter_le_packet_data_type_e data_type, + void *data, unsigned int data_size) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_add_advertising_service_uuid(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, const char *uuid) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_add_advertising_service_solicitation_uuid(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, const char *uuid) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_add_advertising_service_data(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, const char *uuid, + const char *service_data, int service_data_len) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_set_advertising_appearance(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, int appearance) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_add_advertising_manufacturer_data(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, int manufacturer_id, + const char *manufacturer_data, int manufacturer_data_len) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_set_advertising_device_name(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, bool include_name) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_set_advertising_tx_power_level(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, bool include_tx_power) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_remove_advertising_data(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type, bt_adapter_le_packet_data_type_e data_type) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_clear_advertising_data(bt_advertiser_h advertiser, + bt_adapter_le_packet_type_e pkt_type) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_start_advertising(bt_advertiser_h advertiser, + bt_adapter_le_advertising_params_s *adv_params, + bt_adapter_le_advertising_state_changed_cb cb, void *user_data) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + + +int bt_adapter_le_stop_advertising(bt_advertiser_h advertiser) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_start_advertising_new(bt_advertiser_h advertiser, + bt_adapter_le_advertising_state_changed_cb cb, void *user_data) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + + +int bt_adapter_le_set_advertising_mode(bt_advertiser_h advertiser, + bt_adapter_le_advertising_mode_e mode) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_adapter_le_set_advertising_connectable(bt_advertiser_h advertiser, bool connectable) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + diff --git a/tv_src/bluetooth-audio.c b/tv_src/bluetooth-audio.c new file mode 100644 index 0000000..c9d9ada --- /dev/null +++ b/tv_src/bluetooth-audio.c @@ -0,0 +1,845 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <stdbool.h> +#include <bluetooth-api.h> +#include <string.h> +#include "bluetooth.h" +#include "bluetooth_product.h" +#include "bluetooth_private.h" +#include "bluetooth-audio-api.h" +#include "bluetooth-telephony-api.h" + +typedef struct _call_list_s { + GList *list; +} call_list_s; + +static bool is_audio_initialized = false; + +#if defined (TIZEN_HFP_DISABLE) && defined (TIZEN_A2DP_DISABLE) +#define BT_CHECK_AUDIO_SUPPORT() \ + { \ + BT_CHECK_BT_SUPPORT(); \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_AUDIO_SUPPORT() +#endif + +#ifdef TIZEN_HFP_DISABLE +#define BT_CHECK_HFP_SUPPORT() \ + { \ + BT_CHECK_BT_SUPPORT(); \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_HFP_SUPPORT() +#endif + +#ifdef TIZEN_A2DP_DISABLE +#define BT_CHECK_A2DP_SUPPORT() \ + { \ + BT_CHECK_BT_SUPPORT(); \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_A2DP_SUPPORT() +#endif + +#define BT_CHECK_AUDIO_INIT_STATUS() \ + if (__bt_check_audio_init_status() == BT_ERROR_NOT_INITIALIZED) \ + { \ + LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \ + return BT_ERROR_NOT_INITIALIZED; \ + } + +int __bt_check_audio_init_status(void) +{ + if (is_audio_initialized != true) { + BT_ERR("NOT_INITIALIZED(0x%08x)", BT_ERROR_NOT_INITIALIZED); + return BT_ERROR_NOT_INITIALIZED; + } + + return BT_ERROR_NONE; +} + +/*The below API is just to convert the error from Telephony API's to CAPI error codes, +* this is temporary change and changes to proper error code will be done in +* subsequent check ins.*/ +int _bt_convert_telephony_error_code(int error) +{ + switch(error) { + case BLUETOOTH_TELEPHONY_ERROR_NONE: + return BT_ERROR_NONE; + case BLUETOOTH_TELEPHONY_ERROR_INVALID_PARAM: + return BT_ERROR_INVALID_PARAMETER; + case BLUETOOTH_TELEPHONY_ERROR_NOT_INITIALIZED: + return BT_ERROR_NOT_INITIALIZED; + case BLUETOOTH_TELEPHONY_ERROR_NOT_ENABLED: + return BT_ERROR_NOT_ENABLED; + case BLUETOOTH_TELEPHONY_ERROR_AUDIO_NOT_CONNECTED: + case BLUETOOTH_TELEPHONY_ERROR_NOT_CONNECTED: + return BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED; + case BLUETOOTH_TELEPHONY_ERROR_BUSY: + return BT_ERROR_RESOURCE_BUSY; + case BLUETOOTH_TELEPHONY_ERROR_NO_MEMORY: + return BT_ERROR_OUT_OF_MEMORY; + case BLUETOOTH_TELEPHONY_ERROR_ALREADY_INITIALIZED: + case BLUETOOTH_TELEPHONY_ERROR_ALREADY_EXSIST: + case BLUETOOTH_TELEPHONY_ERROR_ALREADY_CONNECTED: + return BT_ERROR_ALREADY_DONE; + case BLUETOOTH_TELEPHONY_ERROR_INTERNAL: + case BLUETOOTH_TELEPHONY_ERROR_NOT_AVAILABLE: + case BLUETOOTH_TELEPHONY_ERROR_I_O_ERROR: + case BLUETOOTH_TELEPHONY_ERROR_OPERATION_NOT_AVAILABLE: + return BT_ERROR_OPERATION_FAILED; + default: + return BT_ERROR_NONE; + } +} + +int bt_audio_initialize(void) +{ + int error; + + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error = bluetooth_audio_init(_bt_audio_event_proxy, NULL); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } + +#ifndef TELEPHONY_DISABLED /* B2_3G */ + error = bluetooth_telephony_init((void *)_bt_telephony_event_proxy, NULL); + error = _bt_convert_telephony_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("[%s] (0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } +#endif + + is_audio_initialized = true; + return BT_ERROR_NONE; +} + +int bt_audio_deinitialize(void) +{ + int error; + + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + error = bluetooth_audio_deinit(); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } + +#ifndef TELEPHONY_DISABLED /* B2_3G */ + error = bluetooth_telephony_deinit(); + error = _bt_convert_telephony_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } +#endif + + is_audio_initialized = false; + return BT_ERROR_NONE; +} + +int bt_audio_connect(const char *remote_address, bt_audio_profile_type_e type) +{ + int error; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + + if (type == BT_AUDIO_PROFILE_TYPE_HSP_HFP) { + BT_CHECK_HFP_SUPPORT(); +#ifdef TELEPHONY_DISABLED + BT_ERR("NOT SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); + return BT_ERROR_NOT_SUPPORTED; +#endif + } else if (type == BT_AUDIO_PROFILE_TYPE_A2DP) { + BT_CHECK_A2DP_SUPPORT(); + } else if (type == BT_AUDIO_PROFILE_TYPE_ALL) { +#if defined (TIZEN_HFP_DISABLE) || defined (TELEPHONY_DISABLED) + BT_ERR("HSP NOT SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); + type = BT_AUDIO_PROFILE_TYPE_A2DP; +#else + BT_ERR("A2DP NOT SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); + type = BT_AUDIO_PROFILE_TYPE_HSP_HFP; +#endif + } + + BT_CHECK_INPUT_PARAMETER(remote_address); + _bt_convert_address_to_hex(&addr_hex, remote_address); + switch(type) { +#ifndef TELEPHONY_DISABLED + case BT_AUDIO_PROFILE_TYPE_HSP_HFP: + error = bluetooth_ag_connect(&addr_hex); + break; +#endif + case BT_AUDIO_PROFILE_TYPE_A2DP: + error = bluetooth_av_connect(&addr_hex); + break; + case BT_AUDIO_PROFILE_TYPE_ALL: + default: + error = bluetooth_audio_connect(&addr_hex); + break; + } + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_audio_disconnect(const char *remote_address, bt_audio_profile_type_e type) +{ + int error; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + + if (type == BT_AUDIO_PROFILE_TYPE_HSP_HFP) { + BT_CHECK_HFP_SUPPORT(); +#ifdef TELEPHONY_DISABLED + BT_ERR("NOT SUPPORTED(0x%08x)", BT_ERROR_NOT_SUPPORTED); + return BT_ERROR_NOT_SUPPORTED; +#endif + } else if (type == BT_AUDIO_PROFILE_TYPE_A2DP) { + BT_CHECK_A2DP_SUPPORT(); + } + + BT_CHECK_INPUT_PARAMETER(remote_address); + _bt_convert_address_to_hex(&addr_hex, remote_address); + switch(type) { +#ifndef TELEPHONY_DISABLED + case BT_AUDIO_PROFILE_TYPE_HSP_HFP: + error = bluetooth_ag_disconnect(&addr_hex); + break; +#endif + case BT_AUDIO_PROFILE_TYPE_A2DP: + error = bluetooth_av_disconnect(&addr_hex); + break; + case BT_AUDIO_PROFILE_TYPE_ALL: + default: + error = bluetooth_audio_disconnect(&addr_hex); + break; + } + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_audio_set_connection_state_changed_cb(bt_audio_connection_state_changed_cb callback, void *user_data) +{ + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AUDIO_CONNECTION_STATUS, callback, user_data); + return BT_ERROR_NONE; + +} +int bt_audio_unset_connection_state_changed_cb(void) +{ + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + if (_bt_check_cb(BT_EVENT_AUDIO_CONNECTION_STATUS) == true) + _bt_unset_cb(BT_EVENT_AUDIO_CONNECTION_STATUS); + return BT_ERROR_NONE; +} + +int bt_a2dp_sink_connect(const char *remote_address) +{ + int error; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + _bt_convert_address_to_hex(&addr_hex, remote_address); + error = bluetooth_a2dp_sink_connect(&addr_hex); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_a2dp_sink_disconnect(const char *remote_address) +{ + int error; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + _bt_convert_address_to_hex(&addr_hex, remote_address); + error = bluetooth_a2dp_sink_disconnect(&addr_hex); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_a2dp_sink_set_connection_state_changed_cb(bt_a2dp_sink_connection_state_changed_cb callback, void *user_data) +{ + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_A2DP_SINK_CONNECTION_STATUS, callback, user_data); + return BT_ERROR_NONE; + +} +int bt_a2dp_sink_unset_connection_state_changed_cb(void) +{ + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + if (_bt_check_cb(BT_EVENT_A2DP_SINK_CONNECTION_STATUS) == true) + _bt_unset_cb(BT_EVENT_A2DP_SINK_CONNECTION_STATUS); + return BT_ERROR_NONE; +} + + +int bt_a2dp_sink_set_audio_state_changed_cb(bt_a2dp_sink_audio_state_changed_cb callback, void *user_data) +{ + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_A2DP_SINK_AUDIO_STATUS, callback, user_data); + return BT_ERROR_NONE; + +} +int bt_a2dp_sink_unset_audio_state_changed_cb(void) +{ + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + if (_bt_check_cb(BT_EVENT_A2DP_SINK_AUDIO_STATUS) == true) + _bt_unset_cb(BT_EVENT_A2DP_SINK_AUDIO_STATUS); + return BT_ERROR_NONE; +} + +int bt_a2dp_sink_get_audio_info(const char *remote_address, bt_a2dp_sink_audio_info_s **audio_info) +{ + int error; + + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + + bluetooth_a2dp_sink_audio_info_t *bluetooth_audio_info = NULL; + bluetooth_device_address_t addr_hex = { {0,} }; + + bluetooth_audio_info = (bluetooth_a2dp_sink_audio_info_t*) g_try_malloc0(sizeof(bluetooth_a2dp_sink_audio_info_t)); + + if (bluetooth_audio_info == NULL) + return BT_ERROR_OUT_OF_MEMORY; + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + + error = bluetooth_a2dp_sink_get_audio_info(&addr_hex, bluetooth_audio_info); + + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + else { + error = _bt_get_bt_a2dp_sink_audio_info_s(audio_info, bluetooth_audio_info); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + } + + g_free(bluetooth_audio_info); + + return BT_ERROR_NONE; + +} + +int bt_a2dp_sink_free_audio_info(bt_a2dp_sink_audio_info_s *audio_info) +{ + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(audio_info); + + _bt_free_bt_a2dp_sink_audio_info_s(audio_info); + + return BT_ERROR_NONE; + +} + +int bt_ag_notify_speaker_gain(int gain) +{ + int error; + + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + error = bluetooth_telephony_set_speaker_gain((unsigned short)gain); + error = _bt_convert_telephony_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_ag_get_speaker_gain(int *gain) +{ + int error; + + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(gain); + error = bluetooth_telephony_get_headset_volume((unsigned int *)gain); + error = _bt_convert_telephony_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_ag_is_nrec_enabled(bool *enabled) +{ + int error; + gboolean is_enabled = FALSE; + + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(enabled); + + error = bluetooth_telephony_is_nrec_enabled(&is_enabled); + *enabled = (is_enabled ? true : false); + + error = _bt_convert_telephony_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + + return error; +} + +int bt_ag_set_microphone_gain_changed_cb(bt_ag_microphone_gain_changed_cb callback, void *user_data) +{ + BT_CHECK_HFP_SUPPORT(); + + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AG_MICROPHONE_GAIN_CHANGE, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_ag_unset_microphone_gain_changed_cb(void) +{ + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + if (_bt_check_cb(BT_EVENT_AG_MICROPHONE_GAIN_CHANGE) == true) + _bt_unset_cb(BT_EVENT_AG_MICROPHONE_GAIN_CHANGE); + return BT_ERROR_NONE; +} + +int bt_ag_set_speaker_gain_changed_cb(bt_ag_speaker_gain_changed_cb callback, + void *user_data) +{ + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AG_SPEAKER_GAIN_CHANGE, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_ag_unset_speaker_gain_changed_cb(void) +{ + BT_CHECK_HFP_SUPPORT(); + + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + if (_bt_check_cb(BT_EVENT_AG_SPEAKER_GAIN_CHANGE) == true) + _bt_unset_cb(BT_EVENT_AG_SPEAKER_GAIN_CHANGE); + return BT_ERROR_NONE; +} + +int bt_ag_open_sco(void) +{ + int error; + + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + error = bluetooth_telephony_audio_open(); + error = _bt_convert_telephony_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_ag_close_sco(void) +{ + int error; + + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + error = bluetooth_telephony_audio_close(); + error = _bt_convert_telephony_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_ag_is_sco_opened(bool *opened) +{ + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(opened); + *opened = bluetooth_telephony_is_sco_connected(); + return BT_ERROR_NONE; +} + +int bt_ag_set_sco_state_changed_cb(bt_ag_sco_state_changed_cb callback, + void *user_data) +{ + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AG_SCO_CONNECTION_STATUS, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_ag_unset_sco_state_changed_cb(void) +{ + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + if (_bt_check_cb(BT_EVENT_AG_SCO_CONNECTION_STATUS) == true) + _bt_unset_cb(BT_EVENT_AG_SCO_CONNECTION_STATUS); + return BT_ERROR_NONE; +} + +int bt_ag_notify_call_event(bt_ag_call_event_e event, unsigned int call_id, const char *phone_number) +{ + int error; + + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_INFO("call_id [%d] / event [%d]", call_id, event); + + switch(event) { + case BT_AG_CALL_EVENT_IDLE: + error = bluetooth_telephony_call_end(call_id); + break; + case BT_AG_CALL_EVENT_ANSWERED: + error = bluetooth_telephony_call_answered(call_id, FALSE); + break; + case BT_AG_CALL_EVENT_HELD: + error = bluetooth_telephony_call_held(call_id); + break; + case BT_AG_CALL_EVENT_RETRIEVED: + error = bluetooth_telephony_call_retrieved(call_id); + break; + case BT_AG_CALL_EVENT_DIALING: + BT_CHECK_INPUT_PARAMETER(phone_number); + error = bluetooth_telephony_indicate_outgoing_call( + phone_number, call_id, FALSE); + break; + case BT_AG_CALL_EVENT_ALERTING: + error = bluetooth_telephony_call_remote_ringing(call_id); + break; + case BT_AG_CALL_EVENT_INCOMING: + BT_CHECK_INPUT_PARAMETER(phone_number); + error = bluetooth_telephony_indicate_incoming_call(phone_number, + call_id); + break; + default: + error = BT_ERROR_INVALID_PARAMETER; + } + error = _bt_convert_telephony_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_ag_notify_call_list(bt_call_list_h list) +{ + int error; + unsigned int call_count; + call_list_s *handle; + + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(list); + handle = (call_list_s *)list; + call_count = g_list_length(handle->list); + error = bluetooth_telephony_set_call_status((void *)handle->list, call_count); + error = _bt_convert_telephony_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_ag_notify_voice_recognition_state(bool state) +{ + int error; + + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + if (state) + error = bluetooth_telephony_start_voice_recognition(); + else + error = bluetooth_telephony_stop_voice_recognition(); + error = _bt_convert_telephony_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_ag_set_call_handling_event_cb(bt_ag_call_handling_event_cb callback, + void *user_data) +{ + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AG_CALL_HANDLING_EVENT, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_ag_unset_call_handling_event_cb(void) +{ + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + if (_bt_check_cb(BT_EVENT_AG_CALL_HANDLING_EVENT) == true) + _bt_unset_cb(BT_EVENT_AG_CALL_HANDLING_EVENT); + return BT_ERROR_NONE; +} + +int bt_ag_set_multi_call_handling_event_cb( + bt_ag_multi_call_handling_event_cb callback, + void *user_data) +{ + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AG_MULTI_CALL_HANDLING_EVENT, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_ag_unset_multi_call_handling_event_cb(void) +{ + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + if (_bt_check_cb(BT_EVENT_AG_MULTI_CALL_HANDLING_EVENT) == true) + _bt_unset_cb(BT_EVENT_AG_MULTI_CALL_HANDLING_EVENT); + return BT_ERROR_NONE; +} + +int bt_ag_set_dtmf_transmitted_cb(bt_ag_dtmf_transmitted_cb callback, + void *user_data) +{ + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AG_DTMF_TRANSMITTED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_ag_unset_dtmf_transmitted_cb(void) +{ + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + if (_bt_check_cb(BT_EVENT_AG_DTMF_TRANSMITTED) == true) + _bt_unset_cb(BT_EVENT_AG_DTMF_TRANSMITTED); + return BT_ERROR_NONE; +} + +int bt_call_list_create(bt_call_list_h *list) +{ + call_list_s *handle; + + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(list); + if (*list != NULL) { + BT_ERR("BT_ERROR_ALREADY_DONE(0x%08x)", BT_ERROR_ALREADY_DONE); + return BT_ERROR_ALREADY_DONE; + } + handle = g_malloc0(sizeof(call_list_s)); + if (handle == NULL) { + BT_ERR("BT_ERROR_OUT_OF_MEMORY(0x%08x)", BT_ERROR_OUT_OF_MEMORY); + return BT_ERROR_OUT_OF_MEMORY; + } + + *list = handle; + return BT_ERROR_NONE; +} + +int bt_call_list_destroy(bt_call_list_h list) +{ + int result; + call_list_s *handle; + + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(list); + handle = (call_list_s *)list; + result = bt_call_list_reset(list); + g_free(handle); + return result; +} + +int bt_call_list_reset(bt_call_list_h list) +{ + call_list_s *handle; + bt_telephony_call_status_info_t *call_status; + + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(list); + handle = (call_list_s *)list; + do { + call_status = (bt_telephony_call_status_info_t *)g_list_nth_data(handle->list, 0); + if (call_status == NULL) + break; + handle->list = g_list_remove(handle->list, call_status); + + g_free(call_status); + } while (1); + return BT_ERROR_NONE; +} + +int bt_call_list_add(bt_call_list_h list, unsigned int call_id, bt_ag_call_state_e state, const char *phone_number) +{ + call_list_s *handle; + bt_telephony_call_status_info_t *call_status; + + BT_CHECK_HFP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(list); + BT_CHECK_INPUT_PARAMETER(phone_number); + + handle = (call_list_s *)list; + call_status = g_malloc0(sizeof(bt_telephony_call_status_info_t)); + + /* Fix : NULL_RETURNS */ + if (call_status == NULL) + return BT_ERROR_OUT_OF_MEMORY; + call_status->call_id = call_id; + call_status->call_status = state; + + handle->list = g_list_append(handle->list, (gpointer)call_status); + return BT_ERROR_NONE; +} + + +int bt_audio_select_stream(bt_audio_stream_type_s stream) +{ + int error; + + BT_CHECK_A2DP_SUPPORT(); + + error = bluetooth_audio_select_stream(stream); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + + return error; +} + +int bt_audio_select_role(bt_audio_role_type_s role) +{ + int error; + + BT_CHECK_A2DP_SUPPORT(); + + error = bluetooth_audio_select_role(role); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + + return error; +} + + +int bt_set_audio_data_receive_cb(bt_audio_data_receive_cb callback, void *user_data) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + + ret = bluetooth_audio_data_path_init(_bt_audio_event_proxy); + ret = _bt_get_error_code(ret); + if (ret != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + else + _bt_set_cb(BT_EVENT_AUDIO_DATA_RECVD , callback, user_data); + + return ret; +} + +int bt_unset_audio_data_receive_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_AUDIO_DATA_RECVD); + bluetooth_audio_data_path_deinit(); + return BT_ERROR_NONE; +} diff --git a/tv_src/bluetooth-avrcp.c b/tv_src/bluetooth-avrcp.c new file mode 100644 index 0000000..557b23b --- /dev/null +++ b/tv_src/bluetooth-avrcp.c @@ -0,0 +1,390 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <stdbool.h> +#include <bluetooth-api.h> +#include "bluetooth.h" +#include "bluetooth_product.h" +#include "bluetooth_private.h" +#include "bluetooth-audio-api.h" +#include "bluetooth-media-control.h" + +static bool is_avrcp_target_initialized = false; +static bool is_avrcp_control_initialized = false; + +#ifdef TIZEN_AVRCP_DISABLE +#define BT_CHECK_AVRCP_SUPPORT() \ + { \ + BT_CHECK_BT_SUPPORT(); \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_AVRCP_SUPPORT() +#endif + +#define BT_CHECK_AVRCP_TARGET_INIT_STATUS() \ + if (__bt_check_avrcp_target_init_status() == BT_ERROR_NOT_INITIALIZED) \ + { \ + LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \ + return BT_ERROR_NOT_INITIALIZED; \ + } + +int __bt_check_avrcp_target_init_status(void) +{ + if (is_avrcp_target_initialized != true) { + BT_ERR("NOT_INITIALIZED(0x%08x)", BT_ERROR_NOT_INITIALIZED); + return BT_ERROR_NOT_INITIALIZED; + } + + return BT_ERROR_NONE; +} + +#define BT_CHECK_AVRCP_CONTROL_INIT_STATUS() \ + if (__bt_check_avrcp_control_init_status() == BT_ERROR_NOT_INITIALIZED) \ + { \ + LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \ + return BT_ERROR_NOT_INITIALIZED; \ + } + +int __bt_check_avrcp_control_init_status(void) +{ + if (is_avrcp_control_initialized != true) { + BT_ERR("NOT_INITIALIZED(0x%08x)", BT_ERROR_NOT_INITIALIZED); + return BT_ERROR_NOT_INITIALIZED; + } + + return BT_ERROR_NONE; +} + +/*The below API is just to conver the error from Audio API's to CAPI error codes, +* this is temporary change and changes to proper error code will be done in +* subsequent check ins.*/ +int _bt_convert_avrcp_error_code(int error) +{ + switch(error) { + case BT_MEDIA_ERROR_NONE: + return BT_ERROR_NONE; + case BT_MEDIA_ERROR_INTERNAL: + return BT_ERROR_INVALID_PARAMETER; + case BT_MEDIA_ERROR_ALREADY_INITIALIZED: + return BT_ERROR_OPERATION_FAILED; + default: + return BT_ERROR_NONE; + } +} + +int bt_avrcp_target_initialize(bt_avrcp_target_connection_state_changed_cb callback, void *user_data) +{ + int error; + + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AVRCP_CONNECTION_STATUS, callback, user_data); + error = bluetooth_media_player_init(_bt_avrcp_event_proxy, NULL); + error = _bt_convert_avrcp_error_code(error); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } + + is_avrcp_target_initialized = true; + return BT_ERROR_NONE; +} + +int bt_avrcp_target_deinitialize(void) +{ + int error; + + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AVRCP_TARGET_INIT_STATUS(); + if (_bt_check_cb(BT_EVENT_AVRCP_CONNECTION_STATUS) == true) + _bt_unset_cb(BT_EVENT_AVRCP_CONNECTION_STATUS); + + error = bluetooth_media_player_deinit(); + error = _bt_convert_avrcp_error_code(error); + + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } + + is_avrcp_target_initialized = false; + return BT_ERROR_NONE; +} + +int bt_avrcp_target_notify_equalizer_state(bt_avrcp_equalizer_state_e state) +{ + int error; + + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AVRCP_TARGET_INIT_STATUS(); + error = bluetooth_media_player_change_property(EQUALIZER, state); + error = _bt_convert_avrcp_error_code(error); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} +int bt_avrcp_target_notify_repeat_mode(bt_avrcp_repeat_mode_e mode) +{ + int error; + + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AVRCP_TARGET_INIT_STATUS(); + error = bluetooth_media_player_change_property(REPEAT, mode); + error = _bt_convert_avrcp_error_code(error); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_avrcp_target_notify_shuffle_mode(bt_avrcp_shuffle_mode_e mode) +{ + int error; + + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AVRCP_TARGET_INIT_STATUS(); + error = bluetooth_media_player_change_property(SHUFFLE, mode); + error = _bt_convert_avrcp_error_code(error); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} +int bt_avrcp_target_notify_scan_mode(bt_avrcp_scan_mode_e mode) +{ + int error; + + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AVRCP_TARGET_INIT_STATUS(); + error = bluetooth_media_player_change_property(SCAN, mode); + error = _bt_convert_avrcp_error_code(error); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_avrcp_target_notify_player_state(bt_avrcp_player_state_e state) +{ + int error; + + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AVRCP_TARGET_INIT_STATUS(); + error = bluetooth_media_player_change_property(STATUS, state); + error = _bt_convert_avrcp_error_code(error); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_avrcp_target_notify_position(unsigned int position) +{ + int error; + + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AVRCP_TARGET_INIT_STATUS(); + error = bluetooth_media_player_change_property(POSITION, position); + error = _bt_convert_avrcp_error_code(error); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_avrcp_target_notify_track(const char *title, const char *artist, const char *album, + const char *genre, unsigned int track_num, unsigned int total_tracks, unsigned int duration) +{ + int error; + + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AVRCP_TARGET_INIT_STATUS(); + media_metadata_attributes_t metadata; + metadata.title = title; + metadata.artist = artist; + metadata.duration = duration; + metadata.genre = genre; + metadata.number = track_num; + metadata.album = album; + metadata.total_tracks = total_tracks; + error = bluetooth_media_player_change_track(&metadata); + error = _bt_convert_avrcp_error_code(error); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_avrcp_target_send_cmd(bt_device_send_avrcp_cmd_e avrcp_cmd) +{ + int error; + + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + switch(avrcp_cmd) + { + case BT_AVRCP_DEVICE_TURN_OFF: + error = bluetooth_media_player_send_cmd(BT_DEVICE_OFF); + break; + case BT_AVRCP_DEVICE_SET_VOLUME_UP: + error = bluetooth_media_player_send_cmd(BT_VOLUME_UP); + break; + case BT_AVRCP_DEVICE_SET_VOLUME_DOWN: + error = bluetooth_media_player_send_cmd(BT_VOLUME_DOWN); + break; + case BT_AVRCP_DEVICE_SET_MUTE: + error = bluetooth_media_player_send_cmd(BT_MUTE); + break; + default: + return BT_ERROR_INVALID_PARAMETER; + } + error = _bt_convert_avrcp_error_code(error); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_avrcp_set_name(char *provider_name, char *service_name) +{ + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INPUT_PARAMETER(provider_name); + BT_CHECK_INPUT_PARAMETER(service_name); + + int error_code = BT_ERROR_NONE; + error_code = _bt_get_error_code(bluetooth_media_set_name(provider_name, service_name)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_avrcp_set_equalizer_state_changed_cb(bt_avrcp_equalizer_state_changed_cb callback, void *user_data) +{ + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AVRCP_EQUALIZER_STATE_CHANGED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_avrcp_unset_equalizer_state_changed_cb(void) +{ + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_AVRCP_EQUALIZER_STATE_CHANGED); + return BT_ERROR_NONE; +} + +int bt_avrcp_set_repeat_mode_changed_cb(bt_avrcp_repeat_mode_changed_cb callback, void *user_data) +{ + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AVRCP_REPEAT_MODE_CHANGED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_avrcp_unset_repeat_mode_changed_cb(void) +{ + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_AVRCP_REPEAT_MODE_CHANGED); + return BT_ERROR_NONE; +} + +int bt_avrcp_set_shuffle_mode_changed_cb(bt_avrcp_shuffle_mode_changed_cb callback, void *user_data) +{ + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AVRCP_SHUFFLE_MODE_CHANGED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_avrcp_unset_shuffle_mode_changed_cb(void) +{ + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_AVRCP_SHUFFLE_MODE_CHANGED); + return BT_ERROR_NONE; +} + +int bt_avrcp_set_scan_mode_changed_cb(bt_avrcp_scan_mode_changed_cb callback, void *user_data) +{ + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AVRCP_SCAN_MODE_CHANGED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_avrcp_unset_scan_mode_changed_cb(void) +{ + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_AVRCP_SCAN_MODE_CHANGED); + return BT_ERROR_NONE; +} + +int bt_set_avrcp_volume_changed_cb(bt_avrcp_volume_changed_cb callback, void *user_data) +{ + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AVRCP_VOLUME_CHANGED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_set_avrcp_mute_state_changed_cb(bt_avrcp_mute_state_changed_cb callback, void *user_data) +{ + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AVRCP_MUTE_STATUS_CHANGED, callback, user_data); + return BT_ERROR_NONE; +} +int bt_avrcp_unset_mute_status_changed_cb(void) +{ + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_AVRCP_MUTE_STATUS_CHANGED); + return BT_ERROR_NONE; +} + diff --git a/tv_src/bluetooth-common.c b/tv_src/bluetooth-common.c new file mode 100644 index 0000000..e1a2cbd --- /dev/null +++ b/tv_src/bluetooth-common.c @@ -0,0 +1,2030 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <glib.h> +#include <string.h> +#include <stdlib.h> +#include <ctype.h> +#include <dlog.h> +#include <stdio.h> +#include <stdbool.h> +#include <sys/time.h> +#include <bluetooth-api.h> + +#include "bluetooth.h" +#include "bluetooth_product.h" +#include "bluetooth_private.h" +#include "bluetooth-media-control.h" +#include "bluetooth-telephony-api.h" +#include "BTLogger_interface.h" + +static bool is_initialized = false; +static bool is_le_initialized = false; +static bool is_smartc_tput = false; +static struct bt_smartrc_throughput_data_s tput_data; +static struct timeval tput_start_time; +static bt_event_sig_event_slot_s bt_event_slot_container[] = { + {BT_EVENT_STATE_CHANGED, NULL, NULL}, + {BT_EVENT_NAME_CHANGED, NULL, NULL}, + {BT_EVENT_VISIBILITY_MODE_CHANGED, NULL, NULL}, + {BT_EVENT_DEVICE_DISCOVERY_STATE_CHANGED, NULL, NULL}, + {BT_EVENT_BOND_CREATED, NULL, NULL}, + {BT_EVENT_BOND_DESTROYED, NULL, NULL}, + {BT_EVENT_AUTHORIZATION_CHANGED, NULL, NULL}, + {BT_EVENT_SERVICE_SEARCHED, NULL, NULL}, + {BT_EVENT_DATA_RECEIVED, NULL, NULL}, + {BT_EVENT_CONNECTION_STATE_CHANGED, NULL, NULL}, + {BT_EVENT_RFCOMM_CONNECTION_REQUESTED, NULL, NULL}, + {BT_EVENT_OPP_CONNECTION_REQUESTED, NULL, NULL}, + {BT_EVENT_OPP_PUSH_REQUESTED, NULL, NULL}, + {BT_EVENT_OPP_SERVER_TRANSFER_PROGRESS, NULL, NULL}, + {BT_EVENT_OPP_SERVER_TRANSFER_FINISHED, NULL, NULL}, + {BT_EVENT_OPP_CLIENT_PUSH_RESPONSED, NULL, NULL}, + {BT_EVENT_OPP_CLIENT_PUSH_PROGRESS, NULL, NULL}, + {BT_EVENT_OPP_CLIENT_PUSH_FINISHED, NULL, NULL}, + {BT_EVENT_PAN_CONNECTION_STATE_CHANGED, NULL, NULL}, + {BT_EVENT_NAP_CONNECTION_STATE_CHANGED, NULL, NULL}, + {BT_EVENT_HDP_CONNECTED, NULL, NULL}, + {BT_EVENT_HDP_DISCONNECTED, NULL, NULL}, + {BT_EVENT_HDP_DATA_RECEIVED, NULL, NULL}, + {BT_EVENT_AUDIO_CONNECTION_STATUS, NULL, NULL}, + {BT_EVENT_AG_SCO_CONNECTION_STATUS, NULL, NULL}, + {BT_EVENT_AG_CALL_HANDLING_EVENT, NULL, NULL}, + {BT_EVENT_AG_MULTI_CALL_HANDLING_EVENT, NULL, NULL}, + {BT_EVENT_AG_DTMF_TRANSMITTED, NULL, NULL}, + {BT_EVENT_AG_MICROPHONE_GAIN_CHANGE, NULL, NULL}, + {BT_EVENT_AG_SPEAKER_GAIN_CHANGE, NULL, NULL}, + {BT_EVENT_AVRCP_CONNECTION_STATUS, NULL, NULL}, + {BT_EVENT_AVRCP_EQUALIZER_STATE_CHANGED, NULL, NULL}, + {BT_EVENT_AVRCP_REPEAT_MODE_CHANGED, NULL, NULL}, + {BT_EVENT_AVRCP_SHUFFLE_MODE_CHANGED, NULL, NULL}, + {BT_EVENT_AVRCP_SCAN_MODE_CHANGED, NULL, NULL}, + {BT_EVENT_AVRCP_VOLUME_CHANGED, NULL, NULL}, + {BT_EVENT_AVRCP_MUTE_STATUS_CHANGED, NULL, NULL}, + {BT_EVENT_A2DP_SINK_CONNECTION_STATUS, NULL, NULL}, + {BT_EVENT_A2DP_SINK_AUDIO_STATUS, NULL, NULL}, + {BT_EVENT_AUDIO_DATA_RECVD, NULL, NULL}, + {BT_EVENT_HID_CONNECTION_STATUS, NULL, NULL}, + {BT_EVENT_DEVICE_CONNECTION_STATUS, NULL, NULL}, + {BT_EVENT_GATT_CHARACTERISTIC_DISCOVERED, NULL, NULL}, + {BT_EVENT_GATT_VALUE_CHANGED, NULL, NULL}, + {BT_EVENT_GATT_WRITE_CHARACTERISTIC, NULL, NULL}, + {BT_EVENT_GATT_CLIENT_CHARACTERISTIC_DISCOVERED_LEGACY, NULL, NULL}, + {BT_EVENT_GATT_CLIENT_CHARACTERISTIC_DESCRIPTOR_DISCOVERED_LEGACY, NULL, NULL}, + {BT_EVENT_GATT_CLIENT_VALUE_CHANGED_LEGACY, NULL, NULL}, + {BT_EVENT_GATT_CLIENT_READ_CHARACTERISTIC_LEGACY, NULL, NULL}, + {BT_EVENT_GATT_CLIENT_WRITE_CHARACTERISTIC_LEGACY, NULL, NULL}, + {BT_EVENT_HID_AUDIO_DATA_RECVD, NULL, NULL}, + {BT_EVENT_HID_VOICE_KEY_PRESSED, NULL, NULL}, + {BT_EVENT_HID_BATTERY_STATUS_RECEIVED, NULL, NULL}, + {BT_EVENT_HID_MBR_RETURN_RECVD, NULL, NULL}, + {BT_EVENT_HID_SENSOR_DATA_RECEIVED, NULL, NULL}, + {BT_EVENT_HID_SMARTRC_CONNECTION_STATUS, NULL, NULL}, + {BT_EVENT_AUTHORIZE_REQUEST, NULL, NULL}, + {BT_EVENT_MAX_CONNECTION_REACHED, NULL, NULL}, + {BT_EVENT_AUTHENTICATION_REQUEST, NULL, NULL}, + {BT_EVENT_SYNC3D_ASSOCIATION_NOTIFIED, NULL, NULL}, + {BT_EVENT_SYNC3D_VSPEC_EVENT_RECEIVED, NULL, NULL}, + {BT_EVENT_ADVERTISING_STATE_CHANGED, NULL, NULL}, + {BT_EVENT_ADVERTISING_MANUFACTURER_DATA_CHANGED, NULL, NULL}, + {BT_EVENT_SCAN_RESPONSE_MANUFACTURER_DATA_CHANGED, NULL, NULL}, + {BT_EVENT_LE_DEVICE_DISCOVERY_STATE_CHANGED, NULL, NULL}, + {BT_EVENT_HID_SMARTRC_FW_UPDATE_STATUS, NULL, NULL}, + {BT_EVENT_DUT_MODE, NULL, NULL}, + {BT_EVENT_BT_CHIP_FW_UPDATE_STATUS, NULL, NULL} +}; + +/* + * Internal Functions + */ +static void __bt_event_proxy(int event, bluetooth_event_param_t * param, void *user_data); +static void __bt_le_event_proxy(int event, bluetooth_event_param_t *param, void *user_data); +static int __bt_get_cb_index(int event); +static void __bt_convert_lower_to_upper(char *origin); +static int __bt_get_bt_device_sdp_info_s(bt_device_sdp_info_s **dest, bt_sdp_info_t *source); +static void __bt_free_bt_device_sdp_info_s(bt_device_sdp_info_s *sdp_info); +static int __bt_get_bt_adapter_device_discovery_info_s(bt_adapter_device_discovery_info_s **discovery_info, bluetooth_device_info_t *source_info); +static void __bt_free_bt_adapter_device_discovery_info_s(bt_adapter_device_discovery_info_s *discovery_info); + +static void __bt_free_bt_device_connection_info_s(bt_device_connection_info_s *conn_info); + +static int __bt_get_bt_adapter_le_device_discovery_info_s( + bt_adapter_device_discovery_info_s **le_discovery_info, + bluetooth_le_device_info_t *source_info); +static void __bt_free_bt_adapter_le_device_discovery_info_s(bt_adapter_device_discovery_info_s *discovery_info); + +/* + * Public Functions + */ + +int bt_initialize(void) +{ + BT_CHECK_BT_SUPPORT(); + if (is_initialized != true) { + if (bluetooth_register_callback(&__bt_event_proxy, NULL) != BLUETOOTH_ERROR_NONE) { + BT_ERR("OPERATION_FAILED(0x%08x)", BT_ERROR_OPERATION_FAILED); + return BT_ERROR_OPERATION_FAILED; + } + is_initialized = true; + } + + return BT_ERROR_NONE; +} + +int bt_deinitialize(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + if (bluetooth_unregister_callback() != BLUETOOTH_ERROR_NONE) { + BT_ERR("OPERATION_FAILED(0x%08x)", BT_ERROR_OPERATION_FAILED); + return BT_ERROR_OPERATION_FAILED; + } + is_initialized = false; + + return BT_ERROR_NONE; +} + + +/* + * Common Functions + */ +int _bt_check_init_status(void) +{ + if (is_initialized != true) + { + BT_ERR("NOT_INITIALIZED(0x%08x)", BT_ERROR_NOT_INITIALIZED); + return BT_ERROR_NOT_INITIALIZED; + } + + return BT_ERROR_NONE; +} + +void _bt_set_cb(int events, void *callback, void *user_data) +{ + bt_event_slot_container[events].callback = callback; + bt_event_slot_container[events].user_data = user_data; +} + +void _bt_unset_cb(int events) +{ + if (bt_event_slot_container[events].callback != NULL) { + bt_event_slot_container[events].callback = NULL; + bt_event_slot_container[events].user_data = NULL; + } +} + +bool _bt_check_cb(int events) +{ + return (bt_event_slot_container[events].callback != NULL) ? true : false; +} + +int _bt_le_adapter_init(void) +{ + if (is_le_initialized) + return BT_ERROR_NONE; + + if (bluetooth_le_register_callback(&__bt_le_event_proxy, NULL) != BLUETOOTH_ERROR_NONE) { + BT_ERR("OPERATION_FAILED(0x%08x)", BT_ERROR_OPERATION_FAILED); + return BT_ERROR_OPERATION_FAILED; + } + is_le_initialized = true; + + return BT_ERROR_NONE; +} + +int _bt_le_adapter_deinit(void) +{ + if (!is_le_initialized) { + BT_ERR("NOT_INITIALIZED(0x%08x)", BT_ERROR_NOT_INITIALIZED); + return BT_ERROR_NOT_INITIALIZED; + } + + if (bluetooth_le_unregister_callback() != BLUETOOTH_ERROR_NONE) { + BT_ERR("OPERATION_FAILED(0x%08x)", BT_ERROR_OPERATION_FAILED); + return BT_ERROR_OPERATION_FAILED; + } + is_le_initialized = false; + + return BT_ERROR_NONE; +} + +int _bt_get_error_code(int origin_error) +{ + switch (origin_error) { + case BLUETOOTH_ERROR_NONE: + return BT_ERROR_NONE; + case BLUETOOTH_ERROR_NOT_CONNECTED: + return BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED; + case BLUETOOTH_ERROR_INVALID_DATA: + case BLUETOOTH_ERROR_INVALID_PARAM: + case BLUETOOTH_ERROR_NOT_SUPPORT: + return BT_ERROR_INVALID_PARAMETER; + case BLUETOOTH_ERROR_MEMORY_ALLOCATION: + case BLUETOOTH_ERROR_OUT_OF_MEMORY: + return BT_ERROR_OUT_OF_MEMORY; + case BLUETOOTH_ERROR_TIMEOUT: + return BT_ERROR_TIMED_OUT; + case BLUETOOTH_ERROR_DEVICE_NOT_ENABLED: + return BT_ERROR_NOT_ENABLED; + case BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED: + case BLUETOOTH_ERROR_ALREADY_INITIALIZED: + case BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST: + return BT_ERROR_ALREADY_DONE; + case BLUETOOTH_ERROR_NOT_PAIRED: + return BT_ERROR_REMOTE_DEVICE_NOT_BONDED; + case BLUETOOTH_ERROR_NOT_IN_OPERATION: + return BT_ERROR_NOT_IN_PROGRESS; + case BLUETOOTH_ERROR_IN_PROGRESS: + return BT_ERROR_NOW_IN_PROGRESS; + case BLUETOOTH_ERROR_DEVICE_BUSY: + return BT_ERROR_RESOURCE_BUSY; + case BLUETOOTH_ERROR_CANCEL: + case BLUETOOTH_ERROR_CANCEL_BY_USER: + return BT_ERROR_CANCELLED; + case BLUETOOTH_ERROR_AUTHENTICATION_FAILED: + return BT_ERROR_AUTH_FAILED; + case BLUETOOTH_ERROR_HOST_DOWN: + return BT_ERROR_REMOTE_DEVICE_NOT_FOUND; + case BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR: + return BT_ERROR_SERVICE_SEARCH_FAILED; + case BLUETOOTH_ERROR_MAX_CONNECTION: + return BT_ERROR_MAX_CONNECTION_LIMIT_REACHED; + case BLUETOOTH_ERROR_SERVICE_NOT_FOUND: + case BLUETOOTH_ERROR_PARING_FAILED: + case BLUETOOTH_ERROR_ALREADY_CONNECT: + case BLUETOOTH_ERROR_NO_RESOURCES: + case BLUETOOTH_ERROR_REGISTRATION_FAILED: + case BLUETOOTH_ERROR_CONNECTION_BUSY: + case BLUETOOTH_ERROR_MAX_CLIENT: + case BLUETOOTH_ERROR_INVALID_CALLBACK: + case BLUETOOTH_ERROR_NOT_FOUND: + case BLUETOOTH_ERROR_INTERNAL: + case BLUETOOTH_ERROR_CONNECTION_ERROR: + case BLUETOOTH_ERROR_ACCESS_DENIED: + default: + return BT_ERROR_OPERATION_FAILED; + } + +} + +int _bt_get_bt_device_info_s(bt_device_info_s **dest_dev, bluetooth_device_info_t *source_dev) +{ + int i = 0; + + BT_CHECK_INPUT_PARAMETER(source_dev); + + *dest_dev = (bt_device_info_s *)malloc(sizeof(bt_device_info_s)); + if (*dest_dev == NULL) { + return BT_ERROR_OUT_OF_MEMORY; + } + + if (strlen(source_dev->device_name.name) > 0) { + (*dest_dev)->remote_name = strdup(source_dev->device_name.name); + } else { + (*dest_dev)->remote_name = NULL; + } + + _bt_convert_address_to_string(&((*dest_dev)->remote_address), &(source_dev->device_address)); + + (*dest_dev)->bt_class.major_device_class = source_dev->device_class.major_class; + (*dest_dev)->bt_class.minor_device_class = source_dev->device_class.minor_class; + (*dest_dev)->bt_class.major_service_class_mask = source_dev->device_class.service_class; + if (source_dev->service_index > 0 && + (BLUETOOTH_MAX_SERVICES_FOR_DEVICE >= source_dev->service_index)) { + (*dest_dev)->service_uuid = (char **)malloc(sizeof(char *) * source_dev->service_index); + if ((*dest_dev)->service_uuid != NULL) { + for (i = 0; i < source_dev->service_index; i++) { + (*dest_dev)->service_uuid[i] = g_strndup(source_dev->uuids[i], BLUETOOTH_UUID_STRING_MAX); + if ((*dest_dev)->service_uuid[i] != NULL) { + __bt_convert_lower_to_upper((*dest_dev)->service_uuid[i]); + } + } + } + (*dest_dev)->service_count = source_dev->service_index; + } else { + BT_ERR("source_dev->service_index = %d", source_dev->service_index); + (*dest_dev)->service_uuid = NULL; + (*dest_dev)->service_count = 0; + } + (*dest_dev)->is_bonded = (bool)source_dev->paired; + (*dest_dev)->is_connected = (bool)source_dev->connected; + (*dest_dev)->is_authorized = (bool)source_dev->trust; + (*dest_dev)->vid = (unsigned int)source_dev->vid; + (*dest_dev)->pid = (unsigned int)source_dev->pid; + (*dest_dev)->service_mask = (unsigned int)source_dev->service_mask; + + return BT_ERROR_NONE; +} + +void _bt_free_bt_device_info_s(bt_device_info_s *device_info) +{ + int i = 0; + + if (device_info == NULL) + return; + + if (device_info->remote_name != NULL) + free(device_info->remote_name); + + if (device_info->remote_address != NULL) + free(device_info->remote_address); + + if (device_info->service_uuid != NULL) { + for (i = 0; i < device_info->service_count; i++) { + if (device_info->service_uuid[i] != NULL) + free(device_info->service_uuid[i]); + } + free(device_info->service_uuid); + } + + free(device_info); + device_info = NULL; +} + +int _bt_get_specific_bt_device_info_s(bt_hid_device_info_s **dest_dev, bluetooth_hid_device_info_t *source_dev) +{ + + BT_CHECK_INPUT_PARAMETER(source_dev); + *dest_dev = (bt_hid_device_info_s *)malloc(sizeof(bt_hid_device_info_s)); + if (*dest_dev == NULL) { + return BT_ERROR_OUT_OF_MEMORY; + } + + (*dest_dev)->device_type = (unsigned char)source_dev->device_type; + (*dest_dev)->capability = (unsigned short)source_dev->capability; + (*dest_dev)->battery_status = (unsigned char)source_dev->battery_status; + (*dest_dev)->resolution_width = (short)source_dev->hid_data[0]; + (*dest_dev)->resolution_height = (short)source_dev->hid_data[1]; + (*dest_dev)->size_x = (short)source_dev->hid_data[2]; + (*dest_dev)->size_y = (short)source_dev->hid_data[3]; + + return BT_ERROR_NONE; +} + +void _bt_free_specific_bt_device_info_s(bt_hid_device_info_s *device_info) +{ + if (device_info == NULL) + return; + + free(device_info); + device_info = NULL; +} + +int _bt_convert_address_to_string(char **addr_str, bluetooth_device_address_t *addr_hex) +{ + char address[18] = { 0, }; + + BT_CHECK_INPUT_PARAMETER(addr_hex); + + snprintf(address, 18, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", addr_hex->addr[0], addr_hex->addr[1], addr_hex->addr[2], addr_hex->addr[3], addr_hex->addr[4], addr_hex->addr[5]); + *addr_str = strdup(address); + + if (*addr_str != NULL) { + return BT_ERROR_NONE; + } else { + return BT_ERROR_OUT_OF_MEMORY; + } +} + +void _bt_convert_address_to_hex(bluetooth_device_address_t *addr_hex, const char *addr_str) +{ + int i = 0; + unsigned int addr[BLUETOOTH_ADDRESS_LENGTH] = { 0, }; + + if (addr_str == NULL) + return; + + i = sscanf(addr_str, "%X:%X:%X:%X:%X:%X", &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5]); + if (i != BLUETOOTH_ADDRESS_LENGTH) { + BT_ERR("Invalid format string - %s", addr_str); + } + + for (i = 0; i < BLUETOOTH_ADDRESS_LENGTH; i++) { + addr_hex->addr[i] = (unsigned char)addr[i]; + } +} + +const char *_bt_convert_error_to_string(int error) +{ + switch (error) { + case BT_ERROR_CANCELLED: + return "CANCELLED"; + case BT_ERROR_INVALID_PARAMETER: + return "INVALID_PARAMETER"; + case BT_ERROR_OUT_OF_MEMORY: + return "OUT_OF_MEMORY"; + case BT_ERROR_RESOURCE_BUSY: + return "RESOURCE_BUSY"; + case BT_ERROR_TIMED_OUT: + return "TIMED_OUT"; + case BT_ERROR_NOW_IN_PROGRESS: + return "NOW_IN_PROGRESS"; + case BT_ERROR_NOT_INITIALIZED: + return "NOT_INITIALIZED"; + case BT_ERROR_NOT_ENABLED: + return "DEVICE_NOT_ENABLED"; + case BT_ERROR_ALREADY_DONE: + return "ALREADY_DONE"; + case BT_ERROR_OPERATION_FAILED: + return "OPERATION_FAILED"; + case BT_ERROR_NOT_IN_PROGRESS: + return "NOT_IN_PROGRESS"; + case BT_ERROR_REMOTE_DEVICE_NOT_BONDED: + return "REMOTE_DEVICE_NOT_BONDED"; + case BT_ERROR_AUTH_REJECTED: + return "AUTH_REJECTED"; + case BT_ERROR_AUTH_FAILED: + return "AUTH_FAILED"; + case BT_ERROR_REMOTE_DEVICE_NOT_FOUND: + return "REMOTE_DEVICE_NOT_FOUND"; + case BT_ERROR_SERVICE_SEARCH_FAILED: + return "SERVICE_SEARCH_FAILED"; + case BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED: + return "DEVICE_NOT_CONNECTED"; + case BT_ERROR_MAX_CONNECTION_LIMIT_REACHED: + return "MAX_CONNECTION_LIMIT_REACHED"; + default: + return "UNKNOWN"; + } +} + +bt_adapter_visibility_mode_e _bt_get_bt_visibility_mode_e(bluetooth_discoverable_mode_t mode) +{ + switch (mode) { + case BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE: + return BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE; + case BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE: + return BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE; + default: + return BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE; + } +} + +/* + * Internal Functions + */ + +static int __bt_get_bt_device_sdp_info_s(bt_device_sdp_info_s **dest, bt_sdp_info_t *source) +{ + int i = 0; + + *dest = (bt_device_sdp_info_s *)malloc(sizeof(bt_device_sdp_info_s)); + if (*dest == NULL) { + return BT_ERROR_OUT_OF_MEMORY; + } + + if (_bt_convert_address_to_string(&((*dest)->remote_address), &(source->device_addr)) != BT_ERROR_NONE) { + __bt_free_bt_device_sdp_info_s(*dest); + return BT_ERROR_OUT_OF_MEMORY; + } + + if (source->service_index > 0) { + (*dest)->service_uuid = (char **)malloc(sizeof(char *) * source->service_index); + if ((*dest)->service_uuid == NULL) { + __bt_free_bt_device_sdp_info_s(*dest); + return BT_ERROR_OUT_OF_MEMORY; + } + + for (i = 0; i < source->service_index; i++) { + (*dest)->service_uuid[i] = strdup(source->uuids[i]); + if ((*dest)->service_uuid[i] == NULL) { + __bt_free_bt_device_sdp_info_s(*dest); + return BT_ERROR_OUT_OF_MEMORY; + } + __bt_convert_lower_to_upper((*dest)->service_uuid[i]); + } + } else { + (*dest)->service_uuid = NULL; + } + (*dest)->service_count = source->service_index; + + return BT_ERROR_NONE; +} + +static void __bt_free_bt_device_sdp_info_s(bt_device_sdp_info_s *sdp_info) +{ + int i = 0; + + if (sdp_info == NULL) + return; + + if (sdp_info->remote_address != NULL) + free(sdp_info->remote_address); + + if (sdp_info->service_uuid != NULL) { + for (i = 0; i < sdp_info->service_count; i++) { + if (sdp_info->service_uuid[i] != NULL) + free(sdp_info->service_uuid[i]); + } + free(sdp_info->service_uuid); + } + + free(sdp_info); + sdp_info = NULL; +} + +void _bt_audio_event_proxy(int event, bt_audio_event_param_t *param, void *user_data) +{ + bluetooth_event_param_t new_param; + new_param.event = param->event; + new_param.param_data = param->param_data; + new_param.result = param->result; + new_param.user_data = NULL; + __bt_event_proxy(event, &new_param, user_data); +} + +void _bt_telephony_event_proxy(int event, telephony_event_param_t *param, void *user_data) +{ + bluetooth_event_param_t new_param; + new_param.event = param->event; + new_param.param_data = param->param_data; + new_param.result = param->result; + new_param.user_data = NULL; + __bt_event_proxy(event, &new_param, user_data); +} + +void _bt_avrcp_event_proxy(int event, media_event_param_t *param, void *user_data) +{ + bluetooth_event_param_t new_param; + new_param.event = param->event; + new_param.param_data = param->param_data; + new_param.result = param->result; + new_param.user_data = param->user_data; + __bt_event_proxy(event, &new_param, user_data); +} + +void _bt_hid_event_proxy(int event, hid_event_param_t *param, void *user_data) +{ + bluetooth_event_param_t new_param; + new_param.event = param->event; + new_param.param_data = param->param_data; + new_param.result = param->result; + new_param.user_data = param->user_data; + __bt_event_proxy(event, &new_param, user_data); +} + +void _bt_sync3d_event_proxy(int event, bt_sync3d_event_param_t *param, void *user_data) +{ + bluetooth_event_param_t new_param; + new_param.event = param->event; + new_param.param_data = param->param_data; + new_param.result = param->result; + new_param.user_data = param->user_data; + __bt_event_proxy(event, &new_param, user_data); +} + +static int __bt_get_bt_device_connection_info_s(bt_device_connection_info_s **dest, bluetooth_device_address_t *source) +{ + *dest = (bt_device_connection_info_s *)g_malloc0(sizeof(bt_device_connection_info_s)); + if (*dest == NULL) { + return BT_ERROR_OUT_OF_MEMORY; + } + + if (_bt_convert_address_to_string(&((*dest)->remote_address), source) != BT_ERROR_NONE) { + __bt_free_bt_device_connection_info_s(*dest); + return BT_ERROR_OUT_OF_MEMORY; + } + + return BT_ERROR_NONE; +} + +static void __bt_free_bt_device_connection_info_s(bt_device_connection_info_s *conn_info) +{ + if (conn_info == NULL) + return; + + if (conn_info->remote_address != NULL) + free(conn_info->remote_address); + + free(conn_info); + conn_info = NULL; +} + +static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *user_data) +{ + int i; + int call_id; + int *avrcp_mode; + unsigned short *volume; + bluetooth_rfcomm_connection_t *connection_ind = NULL; + bluetooth_rfcomm_disconnection_t *disconnection_ind = NULL; + bt_socket_connection_s rfcomm_connection; + bt_device_sdp_info_s *sdp_info = NULL; + bt_adapter_device_discovery_info_s *discovery_info = NULL; + bt_device_info_s *bonded_device = NULL; + bluetooth_rfcomm_connection_request_t *reqeust_ind = NULL; + bt_obex_server_authorize_into_t *auth_info = NULL; + bt_obex_server_transfer_info_t *transfer_info = NULL; + bt_opc_transfer_info_t *client_info = NULL; + bluetooth_device_address_t *bd_addr = NULL; + telephony_event_callid_t *call_data = NULL; + telephony_event_dtmf_t *dtmf_data = NULL; + char *device_addr = NULL; + int error_code = BT_ERROR_NONE; + int event_index = -1; + bluetooth_network_device_info_t *dev_info = NULL; + bt_hdp_connected_t *hdp_conn_info = NULL; + bt_hdp_disconnected_t *hdp_disconn_info = NULL; + bt_hdp_data_ind_t *hdp_data_ind = NULL; + bt_gatt_discovered_char_t *svc_char = NULL; + bt_gatt_char_value_t *char_val = NULL; + bluetooth_authentication_request_info_t *auth_information = NULL; + bluetooth_authorization_request_info_t *authorization_info = NULL; + bt_device_connection_info_s *conn_info = NULL; + bt_a2dp_sink_audio_info_s *audio_info = NULL; + unsigned char progress; + bool *mute_status = FALSE; + + event_index = __bt_get_cb_index(event); + if (event_index == -1 || bt_event_slot_container[event_index].callback == NULL) { + return; + } + + memset(&rfcomm_connection, 0x00, sizeof(bt_socket_connection_s)); + + switch (event) { + case BLUETOOTH_EVENT_ENABLED: + BT_INFO("bt_adapter_state_changed_cb() will be called with BT_ADAPTER_ENABLED"); + ((bt_adapter_state_changed_cb) bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_ADAPTER_ENABLED, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_DISABLED: + BT_INFO("bt_adapter_state_changed_cb() will be called with BT_ADAPTER_DISABLED"); + ((bt_adapter_state_changed_cb) bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_ADAPTER_DISABLED, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: + BT_INFO("bt_adapter_name_changed_cb() will be called"); + ((bt_adapter_name_changed_cb)bt_event_slot_container[event_index].callback) + ((char *)(param->param_data), bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED: + BT_INFO("bt_adapter_visibility_mode_changed_cb() will be called"); + ((bt_adapter_visibility_mode_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), _bt_get_bt_visibility_mode_e(*(bt_adapter_visibility_mode_e *)(param->param_data)), bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_DISCOVERY_STARTED: + BT_INFO("bt_adapter_device_discovery_state_changed_cb() will be called with BT_ADAPTER_DEVICE_DISCOVERY_STARTED"); + ((bt_adapter_device_discovery_state_changed_cb) bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_STARTED, NULL, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_DISCOVERY_FINISHED: + BT_INFO("bt_adapter_device_discovery_state_changed_cb() will be called with BT_ADAPTER_DEVICE_DISCOVERY_FINISHED"); + ((bt_adapter_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_FINISHED, NULL, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: + BT_INFO("bt_adapter_device_discovery_state_changed_cb() will be called with BT_ADAPTER_DEVICE_DISCOVERY_FOUND: error= %d",_bt_get_error_code(param->result)); + if (__bt_get_bt_adapter_device_discovery_info_s(&discovery_info, (bluetooth_device_info_t *)(param->param_data)) == BT_ERROR_NONE) { + ((bt_adapter_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_FOUND, discovery_info, bt_event_slot_container[event_index].user_data); + __bt_free_bt_adapter_device_discovery_info_s(discovery_info); + } else { + ((bt_adapter_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_FOUND, NULL, bt_event_slot_container[event_index].user_data); + } + break; + case BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND: + BT_INFO("bt_adapter_device_discovery_state_changed_cb() will be called with BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND"); + if (__bt_get_bt_adapter_le_device_discovery_info_s(&discovery_info, (bluetooth_le_device_info_t *)(param->param_data)) == BT_ERROR_NONE) { + ((bt_adapter_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_FOUND, discovery_info, bt_event_slot_container[event_index].user_data); + __bt_free_bt_adapter_device_discovery_info_s(discovery_info); + } else { + ((bt_adapter_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_FOUND, NULL, bt_event_slot_container[event_index].user_data); + } + break; + case BLUETOOTH_EVENT_BONDING_FINISHED: + BT_INFO("bt_device_bond_created_cb() will be called"); + _bt_get_bt_device_info_s(&bonded_device, (bluetooth_device_info_t *)(param->param_data)); + + ((bt_device_bond_created_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), bonded_device, bt_event_slot_container[event_index].user_data); + _bt_free_bt_device_info_s(bonded_device); + bonded_device = NULL; + break; + case BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED: + BT_INFO("bt_device_bond_destroyed_cb() will be called"); + _bt_convert_address_to_string(&device_addr, (bluetooth_device_address_t *)(param->param_data)); + ((bt_device_bond_destroyed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), device_addr, bt_event_slot_container[event_index].user_data); + if (device_addr != NULL) + free(device_addr); + device_addr = NULL; + break; + case BLUETOOTH_EVENT_DEVICE_LIMIT_REACHED: + BT_INFO("bt_device_max_conection_reached_cb() will be called with \ + BT_EVENT_MAX_CONNECTION_REACHED "); + device_addr = (char *)(param->param_data); + ((bt_adapter_max_conection_reached_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), device_addr, bt_event_slot_container[event_index].user_data); + if (device_addr != NULL) + free(device_addr); + break; + case BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY: + BT_INFO("bt_adapter_authentication_req_cb() will be called with \ + BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY"); + auth_information = (bluetooth_authentication_request_info_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, &auth_information->device_address); + BT_DBG("BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY: name = %s address = %s passkey = %s", auth_information->device_name.name, + device_addr, auth_information->str_passkey); + + ((bt_adapter_authentication_req_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_AUTH_KEYBOARD_PASSKEY_DISPLAY, auth_information->device_name.name, + device_addr, auth_information->str_passkey, bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + device_addr = NULL; + break; + case BLUETOOTH_EVENT_PIN_REQUEST: + BT_INFO("bt_adapter_authentication_req_cb() will be called with \ + BLUETOOTH_EVENT_PIN_REQUEST"); + auth_information = (bluetooth_authentication_request_info_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, &auth_information->device_address); + + BT_DBG("BUETOOTH_EVENT_PIN_REQUEST: name = %s address = %s", auth_information->device_name.name, + device_addr); + + ((bt_adapter_authentication_req_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_AUTH_PIN_REQUEST, auth_information->device_name.name, device_addr, + auth_information->str_passkey, bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + device_addr = NULL; + break; + case BLUETOOTH_EVENT_PASSKEY_REQUEST: + BT_INFO("bt_adapter_authentication_req_cb will be called with \ + BLUETOOTH_EVENT_PASSKEY_REQUEST"); + + auth_information = (bluetooth_authentication_request_info_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, &auth_information->device_address); + + BT_DBG("BLUETOOTH_EVENT_PASSKEY_REQUEST: name = %s address = %s", auth_information->device_name.name, + device_addr); + + ((bt_adapter_authentication_req_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_AUTH_PIN_REQUEST, auth_information->device_name.name, device_addr, + auth_information->str_passkey, bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + device_addr = NULL; + + break; + case BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST: + BT_INFO("bt_adapter_authentication_req_cb will be called with \ + BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST"); + + auth_information = (bluetooth_authentication_request_info_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, &auth_information->device_address); + + BT_DBG("BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST: name = %s address = %s passkey = %s ", + auth_information->device_name.name, device_addr, auth_information->str_passkey); + ((bt_adapter_authentication_req_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_AUTH_PASSKEY_CONFIRM_REQUEST, auth_information->device_name.name, device_addr, + auth_information->str_passkey, bt_event_slot_container[event_index].user_data); + if (device_addr != NULL) + free(device_addr); + device_addr = NULL; + + break; + case BLUETOOTH_EVENT_SSP_CONSENT_REQUEST: + BT_INFO("bt_adapter_authentication_req_cb() will be called with \ + BLUETOOTH_EVENT_SSP_CONSENT_REQUEST"); + auth_information = (bluetooth_authentication_request_info_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, &auth_information->device_address); + + BT_DBG("BLUETOOTH_EVENT_SSP_CONSENT_REQUEST: name = %s address = %s", + auth_information->device_name.name, device_addr); + + ((bt_adapter_authentication_req_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_AUTH_SSP_CONSENT_REQUEST, + auth_information->device_name.name, device_addr, + auth_information->str_passkey, bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + device_addr = NULL; + break; + case BLUETOOTH_EVENT_DEVICE_AUTHORIZED: + BT_INFO("bt_device_authorization_changed_cb() will be called with BT_DEVICE_AUTHORIZED"); + _bt_convert_address_to_string(&device_addr, (bluetooth_device_address_t *)(param->param_data)); + ((bt_device_authorization_changed_cb)bt_event_slot_container[event_index].callback) + (BT_DEVICE_AUTHORIZED, device_addr, bt_event_slot_container[event_index].user_data); + if (device_addr != NULL) + free(device_addr); + break; + case BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED: + BT_INFO("bt_device_authorization_changed_cb() will be called with BT_DEVICE_UNAUTHORIZED"); + _bt_convert_address_to_string(&device_addr, (bluetooth_device_address_t *)(param->param_data)); + ((bt_device_authorization_changed_cb)bt_event_slot_container[event_index].callback) + (BT_DEVICE_UNAUTHORIZED, device_addr, bt_event_slot_container[event_index].user_data); + if (device_addr != NULL) + free(device_addr); + break; + case BLUETOOTH_EVENT_DEVICE_CONNECTED: + BT_INFO("bt_device_connection_state_changed_cb() will be called"); + __bt_get_bt_device_connection_info_s(&conn_info, (bluetooth_device_address_t *)(param->param_data)); + + ((bt_device_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (true, conn_info, bt_event_slot_container[event_index].user_data); + __bt_free_bt_device_connection_info_s(conn_info); + break; + case BLUETOOTH_EVENT_DEVICE_DISCONNECTED: + BT_INFO("bt_device_connection_state_changed_cb() will be called"); + __bt_get_bt_device_connection_info_s(&conn_info, (bluetooth_device_address_t *)(param->param_data)); + + ((bt_device_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (false, conn_info, bt_event_slot_container[event_index].user_data); + __bt_free_bt_device_connection_info_s(conn_info); + break; + case BLUETOOTH_EVENT_AUTHORIZE_REQUEST: + authorization_info = (bluetooth_authorization_request_info_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, &authorization_info->device_address); + + BT_DBG("BLUETOOTH_EVENT_AUTHORIZE_REQUEST: name = %s address = %s", + authorization_info->device_name.name, device_addr); + BT_INFO("bt_device_auth_event_cb() will be called with BT_EVENT_AUTHORIZE_REQUEST"); + ((bt_device_auth_event_cb) bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), + device_addr, authorization_info->device_name.name, + bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + device_addr = NULL; + + break; + case BLUETOOTH_EVENT_SERVICE_SEARCHED: + BT_INFO("bt_device_service_searched_cb() will be called"); + __bt_get_bt_device_sdp_info_s(&sdp_info, (bt_sdp_info_t *)(param->param_data)); + error_code = _bt_get_error_code(param->result); + // In service search, BT_ERROR_SERVICE_SEARCH_FAILED is returned instead of BT_ERROR_OPERATION_FAILED. + if (error_code == BT_ERROR_OPERATION_FAILED) + error_code = BT_ERROR_SERVICE_SEARCH_FAILED; + ((bt_device_service_searched_cb)bt_event_slot_container[event_index].callback) + (error_code, sdp_info, bt_event_slot_container[event_index].user_data); + __bt_free_bt_device_sdp_info_s(sdp_info); + break; + case BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED: + BT_INFO("bt_socket_data_received_cb() will be called"); + ((bt_socket_data_received_cb)bt_event_slot_container[event_index].callback) + ((bt_socket_received_data_s *)(param->param_data), bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_RFCOMM_CONNECTED: + BT_INFO("bt_socket_connection_state_changed_cb() will be called with BT_SOCKET_CONNECTED"); + if (param->result == BLUETOOTH_ERROR_INVALID_PARAM) + error_code = BT_ERROR_OPERATION_FAILED; + else + error_code = _bt_get_error_code(param->result); + + connection_ind = (bluetooth_rfcomm_connection_t *)(param->param_data); + + if (connection_ind) { + rfcomm_connection.socket_fd = connection_ind->socket_fd; + rfcomm_connection.local_role = connection_ind->device_role; + + if (strlen(connection_ind->uuid) > 0) { + rfcomm_connection.service_uuid = strdup(connection_ind->uuid); + BT_DBG("uuid: [%s]", rfcomm_connection.service_uuid); + } + + _bt_convert_address_to_string(&(rfcomm_connection.remote_address), + &(connection_ind->device_addr)); + } + + ((bt_socket_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (error_code, BT_SOCKET_CONNECTED, &rfcomm_connection, bt_event_slot_container[event_index].user_data); + + if (rfcomm_connection.remote_address != NULL) { + free(rfcomm_connection.remote_address); + rfcomm_connection.remote_address = NULL; + } + + if (rfcomm_connection.service_uuid != NULL) { + free(rfcomm_connection.service_uuid); + rfcomm_connection.service_uuid = NULL; + } + + break; + case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED: + BT_INFO("bt_socket_connection_state_changed_cb() will be called with BT_SOCKET_DISCONNECTED"); + + disconnection_ind = (bluetooth_rfcomm_disconnection_t *)(param->param_data); + + if (disconnection_ind) { + rfcomm_connection.socket_fd = disconnection_ind->socket_fd; + rfcomm_connection.local_role = disconnection_ind->device_role; + + if (strlen(disconnection_ind->uuid) > 0) { + rfcomm_connection.service_uuid = strdup(disconnection_ind->uuid); + BT_DBG("uuid: [%s]", rfcomm_connection.service_uuid); + } + + _bt_convert_address_to_string(&(rfcomm_connection.remote_address), + &(disconnection_ind->device_addr)); + } + + ((bt_socket_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_SOCKET_DISCONNECTED, &rfcomm_connection, bt_event_slot_container[event_index].user_data); + + if (rfcomm_connection.remote_address != NULL) { + free(rfcomm_connection.remote_address); + rfcomm_connection.remote_address = NULL; + } + + if (rfcomm_connection.service_uuid != NULL) { + free(rfcomm_connection.service_uuid); + rfcomm_connection.service_uuid = NULL; + } + + break; + case BLUETOOTH_EVENT_RFCOMM_AUTHORIZE: + BT_INFO("bt_socket_connection_requested_cb() will be called"); + reqeust_ind = (bluetooth_rfcomm_connection_request_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, &(reqeust_ind->device_addr)); + ((bt_socket_connection_requested_cb)bt_event_slot_container[event_index].callback) + (reqeust_ind->socket_fd, device_addr, bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + break; + case BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE: + BT_INFO("bt_opp_server_connection_requested_cb() will be called"); + bd_addr = (bluetooth_device_address_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, bd_addr); + ((bt_opp_server_connection_requested_cb)bt_event_slot_container[event_index].callback) + (device_addr, bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + break; + case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE: + BT_INFO("bt_opp_server_push_requested_cb() will be called"); + auth_info = (bt_obex_server_authorize_into_t *)(param->param_data); + ((bt_opp_server_push_requested_cb)bt_event_slot_container[event_index].callback) + (auth_info->filename, auth_info->length, bt_event_slot_container[event_index].user_data); + break; + + case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED: + BT_INFO("bt_opp_server_transfer_started_cb() will be called"); + transfer_info = (bt_obex_server_transfer_info_t *)(param->param_data); + ((bt_opp_server_transfer_progress_cb)bt_event_slot_container[event_index].callback) + (transfer_info->filename, transfer_info->file_size, 0, bt_event_slot_container[event_index].user_data); + break; + + case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS: + BT_INFO("bt_opp_server_transfer_in_progress_cb() will be called"); + transfer_info = (bt_obex_server_transfer_info_t *)(param->param_data); + ((bt_opp_server_transfer_progress_cb)bt_event_slot_container[event_index].callback) + (transfer_info->filename, transfer_info->file_size, transfer_info->percentage, bt_event_slot_container[event_index].user_data); + break; + + case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED: + BT_INFO("bt_opp_server_transfer_completed_cb() will be called"); + transfer_info = (bt_obex_server_transfer_info_t *)(param->param_data); + + ((bt_opp_server_transfer_finished_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), transfer_info->filename, transfer_info->file_size, bt_event_slot_container[event_index].user_data); + + break; + + case BLUETOOTH_EVENT_OPC_CONNECTED: + BT_INFO("bt_opp_client_push_responded_cb() will be called"); + bd_addr = (bluetooth_device_address_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, bd_addr); + + ((bt_opp_client_push_responded_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), device_addr, bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + break; + + case BLUETOOTH_EVENT_OPC_DISCONNECTED: + BT_INFO("bt_opp_client_push_finished_cb() will be called"); + bd_addr = (bluetooth_device_address_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, bd_addr); + + ((bt_opp_client_push_finished_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), device_addr, bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + break; + + case BLUETOOTH_EVENT_OPC_TRANSFER_STARTED: + BT_INFO("BLUETOOTH_EVENT_OPC_TRANSFER_STARTED"); + /* This event don't be used in CAPI */ + break; + + case BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS: + BT_INFO("bt_opp_client_transfer_in_progress_cb() will be called"); + client_info = (bt_opc_transfer_info_t *)(param->param_data); + ((bt_opp_client_push_progress_cb)bt_event_slot_container[event_index].callback) + (client_info->filename, client_info->size, client_info->percentage, bt_event_slot_container[event_index].user_data); + break; + + case BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE: + BT_INFO("BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE"); + /* This event don't be used in CAPI */ + break; + + case BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED: + BT_INFO("BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED"); + dev_info = (bluetooth_network_device_info_t *)(param->param_data); + + if (param->result != BLUETOOTH_ERROR_NONE) { + BT_ERR("Fail to connect the network server"); + } + _bt_convert_address_to_string(&device_addr, &dev_info->device_address); + ((bt_nap_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (TRUE, device_addr, dev_info->interface_name, bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + break; + + case BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED: + BT_INFO("BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED"); + dev_info = (bluetooth_network_device_info_t *)(param->param_data); + + if (param->result != BLUETOOTH_ERROR_NONE) { + BT_ERR("Fail to disconnect the network server"); + } + _bt_convert_address_to_string(&device_addr, &dev_info->device_address); + ((bt_nap_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (FALSE, device_addr, dev_info->interface_name, bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + break; + case BLUETOOTH_EVENT_NETWORK_DISCONNECTED: + BT_INFO("BLUETOOTH_EVENT_NETWORK_DISCONNECTED"); + bd_addr = (bluetooth_device_address_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, bd_addr); + + ((bt_panu_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), FALSE, device_addr, BLUETOOTH_NETWORK_NAP_ROLE, + bt_event_slot_container[event_index].user_data); + if (device_addr != NULL) + free(device_addr); + break; + + case BLUETOOTH_EVENT_NETWORK_CONNECTED: + BT_INFO("BLUETOOTH_EVENT_NETWORK_CONNECTED"); + bd_addr = (bluetooth_device_address_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, bd_addr); + + ((bt_panu_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), TRUE, device_addr, BLUETOOTH_NETWORK_NAP_ROLE, + bt_event_slot_container[event_index].user_data); + if (device_addr != NULL) + free(device_addr); + break; + + case BLUETOOTH_EVENT_HDP_CONNECTED: + BT_INFO("HDP Connected "); + hdp_conn_info = (bt_hdp_connected_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, &hdp_conn_info->device_address); + ((bt_hdp_connected_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), device_addr, hdp_conn_info->app_handle, + hdp_conn_info->type, hdp_conn_info->channel_id, + bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + break; + + case BLUETOOTH_EVENT_HDP_DISCONNECTED: + BT_INFO("HDP disconnected callback will be "); + hdp_disconn_info = (bt_hdp_disconnected_t *)(param->param_data); + + _bt_convert_address_to_string(&device_addr, &hdp_disconn_info->device_address); + ((bt_hdp_disconnected_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), device_addr, + hdp_disconn_info->channel_id, bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + break; + case BLUETOOTH_EVENT_HDP_DATA_RECEIVED: + BT_INFO("HDP data recieved callback will be "); + hdp_data_ind = (bt_hdp_data_ind_t *)(param->param_data); + if (param->result != BLUETOOTH_ERROR_NONE) { + BT_ERR("Fail to receive HDP data"); + } + + ((bt_hdp_data_received_cb)bt_event_slot_container[event_index].callback) + (hdp_data_ind->channel_id, hdp_data_ind->buffer, hdp_data_ind->size, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AG_CONNECTED: + BT_INFO("BLUETOOTH_EVENT_AG_CONNECTED "); + device_addr = (char *)(param->param_data); + ((bt_audio_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), TRUE, device_addr, BT_AUDIO_PROFILE_TYPE_HSP_HFP, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AG_DISCONNECTED: + BT_INFO("BLUETOOTH_EVENT_AG_DISCONNECTED "); + device_addr = (char *)(param->param_data); + ((bt_audio_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), FALSE, device_addr, BT_AUDIO_PROFILE_TYPE_HSP_HFP, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_TELEPHONY_AUDIO_CONNECTED: + BT_INFO("BLUETOOTH_EVENT_TELEPHONY_AUDIO_CONNECTED "); + ((bt_ag_sco_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), TRUE, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_TELEPHONY_AUDIO_DISCONNECTED: + BT_INFO("BLUETOOTH_EVENT_TELEPHONY_AUDIO_DISCONNECTED "); + ((bt_ag_sco_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), FALSE, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_TELEPHONY_ANSWER_CALL: + call_data = (telephony_event_callid_t *)param->param_data; + call_id = call_data->callid; + BT_INFO("BLUETOOTH_EVENT_TELEPHONY_ANSWER_CALL "); + ((bt_ag_call_handling_event_cb)bt_event_slot_container[event_index].callback) + (BT_AG_CALL_HANDLING_EVENT_ANSWER, call_id, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_TELEPHONY_RELEASE_CALL: + call_data = (telephony_event_callid_t *)param->param_data; + call_id = call_data->callid; + BT_INFO("BLUETOOTH_EVENT_TELEPHONY_RELEASE_CALL "); + ((bt_ag_call_handling_event_cb)bt_event_slot_container[event_index].callback) + (BT_AG_CALL_HANDLING_EVENT_RELEASE, call_id, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_TELEPHONY_REJECT_CALL: + call_data = (telephony_event_callid_t *)param->param_data; + call_id = call_data->callid; + BT_INFO("BLUETOOTH_EVENT_TELEPHONY_REJECT_CALL "); + ((bt_ag_call_handling_event_cb)bt_event_slot_container[event_index].callback) + (BT_AG_CALL_HANDLING_EVENT_REJECT, call_id, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_TELEPHONY_CHLD_0_RELEASE_ALL_HELD_CALL: + BT_INFO("BLUETOOTH_EVENT_TELEPHONY_CHLD_0_RELEASE_ALL_HELD_CALL "); + ((bt_ag_multi_call_handling_event_cb)bt_event_slot_container[event_index].callback) + (BT_AG_MULTI_CALL_HANDLING_EVENT_RELEASE_HELD_CALLS, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_TELEPHONY_CHLD_1_RELEASE_ALL_ACTIVE_CALL: + BT_INFO("BLUETOOTH_EVENT_TELEPHONY_CHLD_1_RELEASE_ALL_ACTIVE_CALL "); + ((bt_ag_multi_call_handling_event_cb)bt_event_slot_container[event_index].callback) + (BT_AG_MULTI_CALL_HANDLING_EVENT_RELEASE_ACTIVE_CALLS, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_TELEPHONY_CHLD_2_ACTIVE_HELD_CALL: + BT_INFO("BLUETOOTH_EVENT_TELEPHONY_CHLD_2_ACTIVE_HELD_CALL "); + ((bt_ag_multi_call_handling_event_cb)bt_event_slot_container[event_index].callback) + (BT_AG_MULTI_CALL_HANDLING_EVENT_ACTIVATE_HELD_CALL, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_TELEPHONY_CHLD_3_MERGE_CALL: + BT_INFO("BLUETOOTH_EVENT_TELEPHONY_CHLD_3_MERGE_CALL "); + ((bt_ag_multi_call_handling_event_cb)bt_event_slot_container[event_index].callback) + (BT_AG_MULTI_CALL_HANDLING_EVENT_MERGE_CALLS, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_TELEPHONY_CHLD_4_EXPLICIT_CALL_TRANSFER: + BT_INFO("BLUETOOTH_EVENT_TELEPHONY_CHLD_4_EXPLICIT_CALL_TRANSFER "); + ((bt_ag_multi_call_handling_event_cb)bt_event_slot_container[event_index].callback) + (BT_AG_MULTI_CALL_HANDLING_EVENT_EXPLICIT_CALL_TRANSFER, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_TELEPHONY_SEND_DTMF: { + dtmf_data = (telephony_event_dtmf_t *)param->param_data; + + BT_INFO("BLUETOOTH_EVENT_TELEPHONY_SEND_DTMF "); + ((bt_ag_dtmf_transmitted_cb)bt_event_slot_container[event_index].callback) + (dtmf_data->dtmf, bt_event_slot_container[event_index].user_data); + break; + } + case BLUETOOTH_EVENT_AG_SPEAKER_GAIN: + BT_INFO("BLUETOOTH_EVENT_AG_SPEAKER_GAIN"); + int *spk_gain = (int *)(param->param_data); + ((bt_ag_speaker_gain_changed_cb)bt_event_slot_container[event_index].callback) + (*spk_gain, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AG_MIC_GAIN: + BT_INFO("BLUETOOTH_EVENT_AG_MIC_GAIN"); + int *mik_gain = (int *)(param->param_data); + ((bt_ag_microphone_gain_changed_cb)bt_event_slot_container[event_index].callback) + (*mik_gain, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AG_AUDIO_CONNECTED: + BT_INFO("BLUETOOTH_EVENT_AG_AUDIO_CONNECTED"); + ((bt_audio_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), TRUE, NULL, BT_AUDIO_PROFILE_TYPE_HSP_HFP, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AG_AUDIO_DISCONNECTED: + BT_INFO("BLUETOOTH_EVENT_AG_AUDIO_DISCONNECTED"); + device_addr = (char *)(param->param_data); + + ((bt_audio_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), FALSE, device_addr, BT_AUDIO_PROFILE_TYPE_HSP_HFP, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AV_CONNECTED: + BT_INFO("BLUETOOTH_EVENT_AV_CONNECTED "); + device_addr = (char *)(param->param_data); + ((bt_audio_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), TRUE, device_addr, BT_AUDIO_PROFILE_TYPE_A2DP, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AV_DISCONNECTED: + BT_INFO("BLUETOOTH_EVENT_Av_DISCONNECTED "); + device_addr = (char *)(param->param_data); + ((bt_audio_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), FALSE, device_addr, BT_AUDIO_PROFILE_TYPE_A2DP, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AVRCP_CONNECTED: + BT_INFO("BLUETOOTH_EVENT_AVRCP_CONNECTED "); + device_addr = (char *)(param->param_data); + ((bt_avrcp_target_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (TRUE, device_addr, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AVRCP_DISCONNECTED: + BT_INFO("BLUETOOTH_EVENT_AVRCP_DISCONNECTED "); + device_addr = (char *)(param->param_data); + ((bt_avrcp_target_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (FALSE, device_addr, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AVRCP_SETTING_SHUFFLE_STATUS: + BT_INFO("BLUETOOTH_EVENT_AVRCP_SETTING_SHUFFLE_STATUS "); + avrcp_mode = (int *)(param->param_data); + ((bt_avrcp_shuffle_mode_changed_cb)bt_event_slot_container[event_index].callback) + ((bt_avrcp_shuffle_mode_e)*avrcp_mode, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AVRCP_SETTING_EQUALIZER_STATUS: + BT_INFO("BLUETOOTH_EVENT_AVRCP_SETTING_EQUALIZER_STATUS "); + avrcp_mode = (int *)(param->param_data); + ((bt_avrcp_equalizer_state_changed_cb)bt_event_slot_container[event_index].callback) + ((bt_avrcp_equalizer_state_e)*avrcp_mode, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AVRCP_SETTING_REPEAT_STATUS: + BT_INFO("BLUETOOTH_EVENT_AVRCP_SETTING_REPEAT_STATUS "); + avrcp_mode = (int *)(param->param_data); + ((bt_avrcp_repeat_mode_changed_cb)bt_event_slot_container[event_index].callback) + ((bt_avrcp_repeat_mode_e)*avrcp_mode, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AVRCP_SETTING_SCAN_STATUS: + BT_INFO("BLUETOOTH_EVENT_AVRCP_SETTING_SCAN_STATUS "); + avrcp_mode = (int *)(param->param_data); + ((bt_avrcp_scan_mode_changed_cb)bt_event_slot_container[event_index].callback) + ((bt_avrcp_scan_mode_e)*avrcp_mode, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AVRCP_VOLUME_CHANGED: + BT_INFO("BLUETOOTH_EVENT_AVRCP_SETTING_SCAN_STATUS "); + volume = (unsigned short *)(param->param_data); + ((bt_avrcp_volume_changed_cb)bt_event_slot_container[event_index].callback) + (*volume, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_AVRCP_MUTE_STATUS_CHANGED: + mute_status = (bool *)(param->param_data); + ((bt_avrcp_mute_state_changed_cb)bt_event_slot_container[event_index].callback) + (*mute_status, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_A2DP_SINK_CONNECTED: + BT_INFO("BLUETOOTH_EVENT_A2DP_SINK_CONNECTED "); + device_addr = (char *)(param->param_data); + ((bt_a2dp_sink_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (TRUE, device_addr, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_A2DP_SINK_DISCONNECTED: + BT_INFO("BLUETOOTH_EVENT_A2DP_SINK_DISCONNECTED "); + device_addr = (char *)(param->param_data); + ((bt_a2dp_sink_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (FALSE, device_addr, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_A2DP_SINK_AUDIO_SUSPEND: + BT_INFO("BLUETOOTH_EVENT_A2DP_SINK_AUDIO_SUSPEND "); + device_addr = (char *)(param->param_data); + ((bt_a2dp_sink_audio_state_changed_cb)bt_event_slot_container[event_index].callback) + (BT_A2DP_SINK_AUDIO_SUSPEND, device_addr, NULL, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_A2DP_SINK_AUDIO_STOPPED: + BT_INFO("BLUETOOTH_EVENT_A2DP_SINK_AUDIO_STOPPED "); + device_addr = (char *)(param->param_data); + ((bt_a2dp_sink_audio_state_changed_cb)bt_event_slot_container[event_index].callback) + (BT_A2DP_SINK_AUDIO_STOPPED, device_addr, NULL, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_A2DP_SINK_AUDIO_STARTED: + BT_INFO("BLUETOOTH_EVENT_A2DP_SINK_AUDIO_STARTED "); + bluetooth_a2dp_sink_audio_info_t *info = (bluetooth_a2dp_sink_audio_info_t *)(param->param_data); + audio_info = (bt_a2dp_sink_audio_info_s *)g_malloc0(sizeof(bt_a2dp_sink_audio_info_s)); + audio_info->info_status = info->info_status; + audio_info->sampling_freq = info->sampling_freq; + audio_info->num_channel = info->num_channel; + audio_info->bits_per_sample = info->bits_per_sample; + ((bt_a2dp_sink_audio_state_changed_cb)bt_event_slot_container[event_index].callback) + (BT_A2DP_SINK_AUDIO_STARTED, info->addr, audio_info, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_AUDIO_DATA_RECVD:{ + ((bt_audio_data_receive_cb)bt_event_slot_container[event_index].callback) + ((bt_audio_data_s *)(param->param_data),bt_event_slot_container[event_index].user_data); + break; + } + case BLUETOOTH_HID_CONNECTED: + BT_INFO("BLUETOOTH_HID_CONNECTED"); + bd_addr = (bluetooth_device_address_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, bd_addr); + BT_ERR("@@@ result= %d" , _bt_get_error_code(param->result)); + ((bt_hid_host_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), TRUE, device_addr, bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + break; + case BLUETOOTH_HID_DISCONNECTED: + BT_INFO("BLUETOOTH_HID_DISCONNECTED"); + bd_addr = (bluetooth_device_address_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, bd_addr); + ((bt_hid_host_connection_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), FALSE, device_addr, bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); + break; + case BLUETOOTH_HID_SMARTRC_FW_UPDATE_PROGRESS: { + progress = *((unsigned char *) (param->param_data)); + BT_INFO("BLUETOOTH_HID_SMARTRC_FW_UPDATE_PROGRESS progress=0x%x", progress); + ((bt_hid_notify_smart_rc_fw_update_status_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), progress, bt_event_slot_container[event_index].user_data); + break; + } + case BLUETOOTH_HID_SMARTRC_FW_UPDATE_COMPLETE: { + BT_INFO("BLUETOOTH_HID_SMARTRC_FW_UPDATE_COMPLETE"); + if(_bt_get_error_code(param->result) == BT_ERROR_NONE) + progress = 0x64; /* To indicate 100% completion */ + else + progress = 0xFF; /* To indicate invalid progress in case of error */ + ((bt_hid_notify_smart_rc_fw_update_status_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), progress, bt_event_slot_container[event_index].user_data); + break; + } + case BLUETOOTH_EVENT_CHIP_FW_UPDATE_PROGRESS: { + progress = *((unsigned char *) (param->param_data)); + if (_bt_get_error_code(param->result) == BT_ERROR_NONE) { + BT_INFO("BLUETOOTH_EVENT_CHIP_FW_UPDATE_PROGRESS: No Error"); + } else { + BT_ERR("BLUETOOTH_EVENT_CHIP_FW_UPDATE_PROGRESS: Error!!!"); + progress = 0xFF; /* To indicate invalid progress in case of error */ + } + BT_INFO("BLUETOOTH_EVENT_CHIP_FW_UPDATE_PROGRESS: progress=0x%x", progress); + ((bt_adapter_notify_bt_chip_fw_update_status_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), progress, bt_event_slot_container[event_index].user_data); + break; + } + case BLUETOOTH_HID_AUDIO_DATA_RECVD: + if (is_smartc_tput) + { + tput_data.total_bytes += ((bt_hid_voice_data_s *)(param->param_data))->length; + } + else + { + ((bt_hid_audio_data_receive_cb)bt_event_slot_container[event_index].callback) + ((bt_hid_voice_data_s *)(param->param_data), + bt_event_slot_container[event_index].user_data); + } + break; + case BLUETOOTH_HID_VOICE_KEY_PRESSED: { + int btn_state = *((int *) (param->param_data)); + BT_INFO("bt_hid_notify_sound_key_pressed_cb() will be called " + "with BT_EVENT_HID_VOICE_KEY_PRESSED"); + ((bt_hid_notify_sound_key_pressed_cb)bt_event_slot_container[event_index].callback) + (btn_state, bt_event_slot_container[event_index].user_data); + break; + } + + case BLUETOOTH_HID_BATTERY_STATUS_RECEIVED: + BT_INFO("(bt_hid_notify_battery_status_received_cb will be called \ + with BT_EVENT_HID_BATTERY_STATUS_RECEIVED"); + ((bt_hid_notify_battery_status_received_cb)bt_event_slot_container[event_index].callback) + ((bt_hid_battery_status_info_s *)(param->param_data), + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_HID_MBR_RETURN_PKT_RECEIVED: + BT_INFO("(bt_hid_mbr_return_receive_cb will be called \ + with BT_EVENT_HID_MBR_RETURN_RECVD"); + ((bt_hid_mbr_return_receive_cb)bt_event_slot_container[event_index].callback) + ((bt_hid_mbr_return_s *)(param->param_data), + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_HID_SENSOR_DATA_RECEIVED: + ((bt_hid_sensor_data_receive_cb)bt_event_slot_container[event_index].callback) + ((bt_smart_rc_sensor_data_s *)(param->param_data), + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_HID_SMARTRC_CONNECTED: { + BT_INFO("(bt_hid_notify_smart_rc_connection_cb will be called \ + with BT_HID_SMARTRC_CONNECTION_STATUS as connected\n"); + _bt_get_bt_device_info_s(&bonded_device, (bluetooth_device_info_t *)(param->param_data)); + ((bt_hid_notify_smart_rc_connection_cb)bt_event_slot_container[event_index].callback) + (TRUE, bonded_device, bt_event_slot_container[event_index].user_data); + _bt_free_bt_device_info_s(bonded_device); + bonded_device = NULL; + + break; + } + case BLUETOOTH_HID_SMARTRC_DISCONNECTED: { + BT_INFO("(bt_hid_notify_smart_rc_connection_cb will be called \ + with BT_HID_SMARTRC_CONNECTION_STATUS as disconnected\n"); + _bt_get_bt_device_info_s(&bonded_device, (bluetooth_device_info_t *)(param->param_data)); + ((bt_hid_notify_smart_rc_connection_cb)bt_event_slot_container[event_index].callback) + (FALSE, bonded_device, bt_event_slot_container[event_index].user_data); + _bt_free_bt_device_info_s(bonded_device); + bonded_device = NULL; + + break; + } + + case BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED: + BT_INFO("BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED"); + svc_char = (bt_gatt_discovered_char_t *)(param->param_data); + + if (svc_char == NULL) + return; + + for (i = 1; i <= svc_char->handle_info.count; i++) { + ((bt_gatt_characteristics_discovered_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), i, svc_char->handle_info.count, svc_char->handle_info.handle[i-1], + bt_event_slot_container[event_index].user_data); + } + + _bt_unset_cb(BT_EVENT_GATT_CHARACTERISTIC_DISCOVERED); + + break; + case BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED: + BT_INFO("BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED"); + char_val = (bt_gatt_char_value_t *)(param->param_data); + + if (char_val == NULL) + return; + + ((bt_gatt_characteristic_changed_cb)bt_event_slot_container[event_index].callback) + (char_val->char_handle, char_val->char_value, char_val->val_len, + bt_event_slot_container[event_index].user_data); + + break; + case BLUETOOTH_EVENT_SYNC3D_ASSOCIATION_NOTIFY: + BT_INFO("BLUETOOTH_EVENT_SYNC3D_ASSOCIATION_NOTIFY"); + ((bt_sync3d_association_notified_cb)bt_event_slot_container[event_index].callback) + ((bt_sync3d_association_notify_s *)(param->param_data), + bt_event_slot_container[event_index].user_data); + + break; + case BLUETOOTH_EVENT_SYNC3D_VSPEC_CODE_CHANGE: + BT_INFO("BLUETOOTH_EVENT_SYNC3D_VSPEC_CODE_CHANGE"); + ((bt_sync3d_event_cb)bt_event_slot_container[event_index].callback) + (NULL, SYNC3D_CODE_CHANGE_EVENT, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_SYNC3D_VSPEC_FRAME_PERIOD: + BT_INFO("BLUETOOTH_EVENT_SYNC3D_VSPEC_FRAME_PERIOD"); + ((bt_sync3d_event_cb)bt_event_slot_container[event_index].callback) + ((bt_sync3d_frame_period_s *)(param->param_data), + SYNC3D_FRAME_PERIOD_CHANGE_EVENT, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_ADVERTISING_STARTED: + BT_INFO("BLUETOOTH_EVENT_ADVERTISING_STARTED"); + ((bt_adapter_advertising_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_ADAPTER_ADVERTISING_STARTED, + (bt_adapter_advertising_params_s *)param->param_data, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_ADVERTISING_STOPPED: + BT_INFO("BLUETOOTH_EVENT_ADVERTISING_STOPPED"); + ((bt_adapter_advertising_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_ADAPTER_ADVERTISING_STOPPED, NULL, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_ADVERTISING_MANUFACTURER_DATA_CHANGED: + BT_INFO("BLUETOOTH_EVENT_ADVERTISING_MANUFACTURER_DATA_CHANGED"); + ((bt_adapter_advertising_manufacturer_data_changed_cb)bt_event_slot_container[event_index].callback) + (param->param_data, param->result, + bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_SCAN_RESPONSE_MANUFACTURER_DATA_CHANGED: + BT_INFO("BLUETOOTH_EVENT_SCAN_RESPONSE_MANUFACTURER_DATA_CHANGED"); + ((bt_adapter_scan_resp_manufacturer_data_changed_cb)bt_event_slot_container[event_index].callback) + (param->param_data, param->result, + bt_event_slot_container[event_index].user_data); + break; + + default: + break; + } +} + +/* For LE Only Scan */ +static void __bt_le_event_proxy(int event, bluetooth_event_param_t *param, void *user_data) +{ + bt_socket_connection_s rfcomm_connection; + bt_adapter_device_discovery_info_s *discovery_info = NULL; + int event_index = -1; + + event_index = __bt_get_cb_index(event); + if (event_index == -1 || bt_event_slot_container[event_index].callback == NULL) { + return; + } + memset(&rfcomm_connection, 0x00, sizeof(bt_socket_connection_s)); + + switch (event) { + case BLUETOOTH_EVENT_LE_DISCOVERY_STARTED: + BT_INFO("BLUETOOTH_EVENT_LE_DISCOVERY_STARTED"); + ((bt_adapter_le_device_discovery_state_changed_cb) bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_ADAPTER_LE_DEVICE_DISCOVERY_STARTED, NULL, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_LE_DISCOVERY_FINISHED: + BT_INFO("BLUETOOTH_EVENT_LE_DISCOVERY_FINISHED"); + ((bt_adapter_le_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_ADAPTER_LE_DEVICE_DISCOVERY_FINISHED, NULL, bt_event_slot_container[event_index].user_data); + break; + case BLUETOOTH_EVENT_REMOTE_LE_ONLY_DEVICE_FOUND: + BT_INFO("BLUETOOTH_EVENT_REMOTE_LE_ONLY_DEVICE_FOUND"); + if (__bt_get_bt_adapter_le_device_discovery_info_s(&discovery_info, (bluetooth_le_device_info_t *)(param->param_data)) == BT_ERROR_NONE) { + ((bt_adapter_le_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_ADAPTER_LE_DEVICE_DISCOVERY_FOUND, discovery_info, bt_event_slot_container[event_index].user_data); + __bt_free_bt_adapter_le_device_discovery_info_s(discovery_info); + } else { + ((bt_adapter_le_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), BT_ADAPTER_LE_DEVICE_DISCOVERY_FOUND, NULL, bt_event_slot_container[event_index].user_data); + } + break; + default: + break; + } +} + +static int __bt_get_bt_adapter_device_discovery_info_s(bt_adapter_device_discovery_info_s **discovery_info, bluetooth_device_info_t *source_info) { + int i; + + BT_CHECK_INPUT_PARAMETER(source_info); + + *discovery_info = (bt_adapter_device_discovery_info_s *)g_malloc0(sizeof(bt_adapter_device_discovery_info_s)); + if (*discovery_info == NULL) { + return BT_ERROR_OUT_OF_MEMORY; + } + + if (strlen(source_info->device_name.name) > 0) { + (*discovery_info)->remote_name = strdup(source_info->device_name.name); + } else { + (*discovery_info)->remote_name = NULL; + } + + _bt_convert_address_to_string(&((*discovery_info)->remote_address), &(source_info->device_address)); + + (*discovery_info)->bt_class.major_device_class = source_info->device_class.major_class; + (*discovery_info)->bt_class.minor_device_class = source_info->device_class.minor_class; + (*discovery_info)->bt_class.major_service_class_mask = source_info->device_class.service_class; + (*discovery_info)->vendor_id = source_info->vid; + (*discovery_info)->product_id = source_info->pid; + + BT_INFO("Remote Device Found: vid = [0x%x] pid= [0x%x]", (*discovery_info)->vendor_id, (*discovery_info)->product_id); + if (source_info->service_index > 0) { + (*discovery_info)->service_uuid = (char **)malloc(sizeof(char *) * source_info->service_index); + if ((*discovery_info)->service_uuid != NULL) { + for (i = 0; i < source_info->service_index; i++) { + (*discovery_info)->service_uuid[i] = strdup(source_info->uuids[i]); + if ((*discovery_info)->service_uuid[i] != NULL) { + __bt_convert_lower_to_upper((*discovery_info)->service_uuid[i]); + } + + BT_DBG("UUID: %s", (*discovery_info)->service_uuid[i]); + } + } + } else { + (*discovery_info)->service_uuid = NULL; + } + (*discovery_info)->service_count = source_info->service_index; + + (*discovery_info)->rssi = (int)source_info->rssi; + + (*discovery_info)->is_bonded = (bool)source_info->paired; + + return BT_ERROR_NONE; +} + +static void __bt_free_bt_adapter_device_discovery_info_s(bt_adapter_device_discovery_info_s *discovery_info) +{ + int i; + + if (discovery_info == NULL) + return; + + if (discovery_info->remote_name != NULL) + free(discovery_info->remote_name); + + if (discovery_info->remote_address != NULL) + free(discovery_info->remote_address); + + if (discovery_info->service_uuid != NULL) { + for (i = 0; i < discovery_info->service_count; i++) { + if (discovery_info->service_uuid[i] != NULL) + free(discovery_info->service_uuid[i]); + } + free(discovery_info->service_uuid); + } + + if (discovery_info->adv_data != NULL) + free(discovery_info->adv_data); + if (discovery_info->scan_data != NULL) + free(discovery_info->scan_data); + + free(discovery_info); + discovery_info = NULL; +} + +static int __bt_get_bt_adapter_le_device_discovery_info_s( + bt_adapter_device_discovery_info_s **le_discovery_info, + bluetooth_le_device_info_t *source_info) +{ + + BT_CHECK_INPUT_PARAMETER(source_info); + + *le_discovery_info = (bt_adapter_device_discovery_info_s *)g_malloc0(sizeof(bt_adapter_device_discovery_info_s)); + if (*le_discovery_info == NULL) { + return BT_ERROR_OUT_OF_MEMORY; + } + + if (strlen(source_info->device_name.name) > 0) { + (*le_discovery_info)->remote_name = strdup(source_info->device_name.name); + } else { + (*le_discovery_info)->remote_name = NULL; + } + + _bt_convert_address_to_string(&((*le_discovery_info)->remote_address), &(source_info->device_address)); + + (*le_discovery_info)->appearance = 0; + (*le_discovery_info)->service_uuid = NULL; + (*le_discovery_info)->service_count = 0; + + (*le_discovery_info)->rssi = (int)source_info->rssi; + (*le_discovery_info)->is_bonded = (bool)source_info->paired; + (*le_discovery_info)->adv_data_len = source_info->adv_ind_data.data_len; + if ((*le_discovery_info)->adv_data_len > 0) { + (*le_discovery_info)->adv_data = malloc(source_info->adv_ind_data.data_len); + memcpy((*le_discovery_info)->adv_data, source_info->adv_ind_data.data.data, source_info->adv_ind_data.data_len); + } else { + (*le_discovery_info)->adv_data = NULL; + } + + (*le_discovery_info)->scan_data_len = source_info->scan_resp_data.data_len; + if ((*le_discovery_info)->scan_data_len > 0) { + (*le_discovery_info)->scan_data = malloc(source_info->scan_resp_data.data_len); + memcpy((*le_discovery_info)->scan_data, source_info->scan_resp_data.data.data, source_info->scan_resp_data.data_len); + } else { + (*le_discovery_info)->scan_data = NULL; + } + return BT_ERROR_NONE; +} + +static void __bt_free_bt_adapter_le_device_discovery_info_s(bt_adapter_device_discovery_info_s *discovery_info) +{ + int i; + + if (discovery_info == NULL) + return; + + if (discovery_info->remote_address != NULL) + free(discovery_info->remote_address); + + if (discovery_info->remote_name != NULL) + free(discovery_info->remote_name); + + if (discovery_info->service_uuid != NULL) { + for (i = 0; i < discovery_info->service_count; i++) { + if (discovery_info->service_uuid[i] != NULL) + free(discovery_info->service_uuid[i]); + } + free(discovery_info->service_uuid); + } + + if (discovery_info->adv_data != NULL) + free(discovery_info->adv_data); + if (discovery_info->scan_data != NULL) + free(discovery_info->scan_data); + + free(discovery_info); + discovery_info = NULL; +} + +static int __bt_get_cb_index(int event) +{ + switch (event) { + case BLUETOOTH_EVENT_ENABLED: + case BLUETOOTH_EVENT_DISABLED: + return BT_EVENT_STATE_CHANGED; + case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED: + return BT_EVENT_NAME_CHANGED; + case BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED: + return BT_EVENT_VISIBILITY_MODE_CHANGED; + case BLUETOOTH_EVENT_DISCOVERY_STARTED: + case BLUETOOTH_EVENT_DISCOVERY_FINISHED: + case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED: + case BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND: + BT_ERR("BT_EVENT_DEVICE_DISCOVERY_STATE_CHANGED"); + return BT_EVENT_DEVICE_DISCOVERY_STATE_CHANGED; + case BLUETOOTH_EVENT_LE_DISCOVERY_STARTED: + case BLUETOOTH_EVENT_LE_DISCOVERY_FINISHED: + /* In order to call LE specific discovery callback, we need a separate callback index, + BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND already returns BT_EVENT_DEVICE_DISCOVERY_STATE_CHANGED + which is the index for genric or interleaved discovery callback, so for LE ONLY scan, we dont want + to use genric discovery callback, so a separate event BLUETOOTH_EVENT_REMOTE_LE_ONLY_DEVICE_FOUND + is created */ + case BLUETOOTH_EVENT_REMOTE_LE_ONLY_DEVICE_FOUND: + BT_ERR("BT_EVENT_LE_DEVICE_DISCOVERY_STATE_CHANGED"); + return BT_EVENT_LE_DEVICE_DISCOVERY_STATE_CHANGED; + case BLUETOOTH_EVENT_BONDING_FINISHED: + return BT_EVENT_BOND_CREATED; + case BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED: + return BT_EVENT_BOND_DESTROYED; + case BLUETOOTH_EVENT_DEVICE_LIMIT_REACHED: + return BT_EVENT_MAX_CONNECTION_REACHED; + case BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY: + case BLUETOOTH_EVENT_PASSKEY_REQUEST: + case BLUETOOTH_EVENT_PIN_REQUEST: + case BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST: + case BLUETOOTH_EVENT_SSP_CONSENT_REQUEST: + return BT_EVENT_AUTHENTICATION_REQUEST; + case BLUETOOTH_EVENT_DEVICE_AUTHORIZED: + case BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED: + return BT_EVENT_AUTHORIZATION_CHANGED; + case BLUETOOTH_EVENT_DEVICE_CONNECTED: + case BLUETOOTH_EVENT_DEVICE_DISCONNECTED: + return BT_EVENT_DEVICE_CONNECTION_STATUS; + case BLUETOOTH_EVENT_AUTHORIZE_REQUEST: + return BT_EVENT_AUTHORIZE_REQUEST; + case BLUETOOTH_EVENT_SERVICE_SEARCHED: + return BT_EVENT_SERVICE_SEARCHED; + case BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED: + return BT_EVENT_DATA_RECEIVED; + case BLUETOOTH_EVENT_RFCOMM_CONNECTED: + case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED: + return BT_EVENT_CONNECTION_STATE_CHANGED; + case BLUETOOTH_EVENT_RFCOMM_AUTHORIZE: + return BT_EVENT_RFCOMM_CONNECTION_REQUESTED; + case BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE: + return BT_EVENT_OPP_CONNECTION_REQUESTED; + case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE: + return BT_EVENT_OPP_PUSH_REQUESTED; + case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED: + return BT_EVENT_OPP_SERVER_TRANSFER_PROGRESS; + case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS: + return BT_EVENT_OPP_SERVER_TRANSFER_PROGRESS; + case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED: + return BT_EVENT_OPP_SERVER_TRANSFER_FINISHED; + case BLUETOOTH_EVENT_OPC_CONNECTED: + return BT_EVENT_OPP_CLIENT_PUSH_RESPONSED; + case BLUETOOTH_EVENT_OPC_TRANSFER_STARTED: + return BT_EVENT_OPP_CLIENT_PUSH_PROGRESS; + case BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS: + case BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE: + return BT_EVENT_OPP_CLIENT_PUSH_PROGRESS; + case BLUETOOTH_EVENT_OPC_DISCONNECTED: + return BT_EVENT_OPP_CLIENT_PUSH_FINISHED; + case BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED: + case BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED: + return BT_EVENT_NAP_CONNECTION_STATE_CHANGED; + case BLUETOOTH_EVENT_NETWORK_CONNECTED: + case BLUETOOTH_EVENT_NETWORK_DISCONNECTED: + return BT_EVENT_PAN_CONNECTION_STATE_CHANGED; + case BLUETOOTH_EVENT_HDP_DATA_RECEIVED: + return BT_EVENT_HDP_DATA_RECEIVED; + case BLUETOOTH_EVENT_HDP_CONNECTED: + return BT_EVENT_HDP_CONNECTED; + case BLUETOOTH_EVENT_HDP_DISCONNECTED: + return BT_EVENT_HDP_DISCONNECTED; + case BLUETOOTH_EVENT_AG_CONNECTED: + return BT_EVENT_AUDIO_CONNECTION_STATUS; + case BLUETOOTH_EVENT_AG_DISCONNECTED: + return BT_EVENT_AUDIO_CONNECTION_STATUS; + case BLUETOOTH_EVENT_AG_SPEAKER_GAIN: + return BT_EVENT_AG_SPEAKER_GAIN_CHANGE; + case BLUETOOTH_EVENT_AG_MIC_GAIN: + return BT_EVENT_AG_MICROPHONE_GAIN_CHANGE; + case BLUETOOTH_EVENT_AG_AUDIO_CONNECTED: + return BT_EVENT_AUDIO_CONNECTION_STATUS; + case BLUETOOTH_EVENT_AG_AUDIO_DISCONNECTED: + return BT_EVENT_AUDIO_CONNECTION_STATUS; + case BLUETOOTH_EVENT_TELEPHONY_AUDIO_CONNECTED: + return BT_EVENT_AG_SCO_CONNECTION_STATUS; + case BLUETOOTH_EVENT_TELEPHONY_AUDIO_DISCONNECTED: + return BT_EVENT_AG_SCO_CONNECTION_STATUS; + case BLUETOOTH_EVENT_TELEPHONY_ANSWER_CALL: + case BLUETOOTH_EVENT_TELEPHONY_RELEASE_CALL: + case BLUETOOTH_EVENT_TELEPHONY_REJECT_CALL: + return BT_EVENT_AG_CALL_HANDLING_EVENT; + case BLUETOOTH_EVENT_TELEPHONY_CHLD_0_RELEASE_ALL_HELD_CALL: + case BLUETOOTH_EVENT_TELEPHONY_CHLD_1_RELEASE_ALL_ACTIVE_CALL: + case BLUETOOTH_EVENT_TELEPHONY_CHLD_2_ACTIVE_HELD_CALL: + case BLUETOOTH_EVENT_TELEPHONY_CHLD_3_MERGE_CALL: + case BLUETOOTH_EVENT_TELEPHONY_CHLD_4_EXPLICIT_CALL_TRANSFER: + return BT_EVENT_AG_MULTI_CALL_HANDLING_EVENT; + case BLUETOOTH_EVENT_TELEPHONY_SEND_DTMF: + return BT_EVENT_AG_DTMF_TRANSMITTED; + case BLUETOOTH_EVENT_AV_CONNECTED: + return BT_EVENT_AUDIO_CONNECTION_STATUS; + case BLUETOOTH_EVENT_AV_DISCONNECTED: + return BT_EVENT_AUDIO_CONNECTION_STATUS; + case BLUETOOTH_EVENT_AVRCP_CONNECTED: + case BLUETOOTH_EVENT_AVRCP_DISCONNECTED: + return BT_EVENT_AVRCP_CONNECTION_STATUS; + case BLUETOOTH_EVENT_AVRCP_SETTING_SHUFFLE_STATUS: + return BT_EVENT_AVRCP_SHUFFLE_MODE_CHANGED; + case BLUETOOTH_EVENT_AVRCP_SETTING_EQUALIZER_STATUS: + return BT_EVENT_AVRCP_EQUALIZER_STATE_CHANGED; + case BLUETOOTH_EVENT_AVRCP_SETTING_REPEAT_STATUS: + return BT_EVENT_AVRCP_REPEAT_MODE_CHANGED; + case BLUETOOTH_EVENT_AVRCP_SETTING_SCAN_STATUS: + return BT_EVENT_AVRCP_SCAN_MODE_CHANGED; + case BLUETOOTH_EVENT_AVRCP_VOLUME_CHANGED: + return BT_EVENT_AVRCP_VOLUME_CHANGED; + case BLUETOOTH_EVENT_AVRCP_MUTE_STATUS_CHANGED: + return BT_EVENT_AVRCP_MUTE_STATUS_CHANGED; + case BLUETOOTH_EVENT_A2DP_SINK_CONNECTED: + return BT_EVENT_A2DP_SINK_CONNECTION_STATUS; + case BLUETOOTH_EVENT_A2DP_SINK_DISCONNECTED: + return BT_EVENT_A2DP_SINK_CONNECTION_STATUS; + case BLUETOOTH_EVENT_A2DP_SINK_AUDIO_SUSPEND: + case BLUETOOTH_EVENT_A2DP_SINK_AUDIO_STOPPED: + case BLUETOOTH_EVENT_A2DP_SINK_AUDIO_STARTED: + return BT_EVENT_A2DP_SINK_AUDIO_STATUS; + case BLUETOOTH_AUDIO_DATA_RECVD: + return BT_EVENT_AUDIO_DATA_RECVD; + case BLUETOOTH_HID_CONNECTED: + return BT_EVENT_HID_CONNECTION_STATUS; + case BLUETOOTH_HID_DISCONNECTED: + return BT_EVENT_HID_CONNECTION_STATUS; + case BLUETOOTH_HID_SMARTRC_FW_UPDATE_PROGRESS: + case BLUETOOTH_HID_SMARTRC_FW_UPDATE_COMPLETE: + BT_ERR("BLUETOOTH_HID_SMARTRC_FW_UPDATE_STATUS"); + return BT_EVENT_HID_SMARTRC_FW_UPDATE_STATUS; + case BLUETOOTH_EVENT_CHIP_FW_UPDATE_PROGRESS: + BT_ERR("BLUETOOTH_EVENT_CHIP_FW_UPDATE_STATUS"); + return BT_EVENT_BT_CHIP_FW_UPDATE_STATUS; + case BLUETOOTH_HID_AUDIO_DATA_RECVD: + if (is_smartc_tput) + return BT_EVENT_DUT_MODE; + else + return BT_EVENT_HID_AUDIO_DATA_RECVD; + case BLUETOOTH_HID_VOICE_KEY_PRESSED: + return BT_EVENT_HID_VOICE_KEY_PRESSED; + case BLUETOOTH_HID_BATTERY_STATUS_RECEIVED: + return BT_EVENT_HID_BATTERY_STATUS_RECEIVED; + case BLUETOOTH_HID_MBR_RETURN_PKT_RECEIVED: + return BT_EVENT_HID_MBR_RETURN_RECVD; + case BLUETOOTH_HID_SENSOR_DATA_RECEIVED: + return BT_EVENT_HID_SENSOR_DATA_RECEIVED; + case BLUETOOTH_HID_SMARTRC_CONNECTED: + case BLUETOOTH_HID_SMARTRC_DISCONNECTED: + return BT_EVENT_HID_SMARTRC_CONNECTION_STATUS; + case BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED: + return BT_EVENT_GATT_CHARACTERISTIC_DISCOVERED; + case BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED: + return BT_EVENT_GATT_VALUE_CHANGED; + case BLUETOOTH_EVENT_GATT_WRITE_CHAR: + return BT_EVENT_GATT_WRITE_CHARACTERISTIC; + case BLUETOOTH_EVENT_SYNC3D_ASSOCIATION_NOTIFY: + return BT_EVENT_SYNC3D_ASSOCIATION_NOTIFIED; + case BLUETOOTH_EVENT_SYNC3D_VSPEC_CODE_CHANGE: + case BLUETOOTH_EVENT_SYNC3D_VSPEC_FRAME_PERIOD: + return BT_EVENT_SYNC3D_VSPEC_EVENT_RECEIVED; + case BLUETOOTH_EVENT_ADVERTISING_STARTED: + case BLUETOOTH_EVENT_ADVERTISING_STOPPED: + return BT_EVENT_ADVERTISING_STATE_CHANGED; + case BLUETOOTH_EVENT_ADVERTISING_MANUFACTURER_DATA_CHANGED: + return BT_EVENT_ADVERTISING_MANUFACTURER_DATA_CHANGED; + case BLUETOOTH_EVENT_SCAN_RESPONSE_MANUFACTURER_DATA_CHANGED: + return BT_EVENT_SCAN_RESPONSE_MANUFACTURER_DATA_CHANGED; + default: + return -1; + } +} + +static void __bt_convert_lower_to_upper(char *origin) +{ + int length = strlen(origin); + int i = 0; + + for (i = 0; i < length; i++) { + if (islower(origin[i])) { + origin[i] = toupper(origin[i]); + } + } +} + +static gboolean _bt_smartrc_tput_mode_timer_expired(gpointer user_data) +{ + int ret = BT_ERROR_NONE; + unsigned char input_data[3]; + struct timeval tput_end_time; + long seconds, useconds, total_time; + input_data[0] = 0x03; input_data[1]=0x00; input_data[2]=0x00; + + BT_DBG("Throughput mode timer expired"); + if (!is_smartc_tput) + return (false); + + ret = bt_hid_send_rc_command(NULL, input_data, 1); + if (ret < BT_ERROR_NONE) + BT_DBG("failed with [0x%04x]", ret); + else + BT_DBG("Send RC command successfull for stop"); + + gettimeofday(&tput_end_time, NULL); + seconds = tput_end_time.tv_sec - tput_start_time.tv_sec; + useconds = tput_end_time.tv_usec - tput_start_time.tv_usec; + total_time = (seconds * 1000) + (useconds/1000); + tput_data.throughput = ((long)(tput_data.total_bytes*8)/total_time)*1000; + tput_data.total_msecs = total_time; + + ((bt_adapter_smartrc_tput_mode_cb)bt_event_slot_container[BT_EVENT_DUT_MODE].callback) + (&tput_data, bt_event_slot_container[BT_EVENT_DUT_MODE].user_data); + + is_smartc_tput = false; + + return (false); +} + +int _bt_start_smartrc_tput_mode(void) +{ + int ret = BT_ERROR_NONE; + unsigned char input_data[3]; + + memset(&tput_data, 0x00, sizeof(tput_data)); + input_data[0] = 0x04; input_data[1]=0x00; input_data[2]=0x00; + BT_DBG("Starting DUT mode for SmartRC"); + ret = bt_hid_send_rc_command(NULL, input_data, 1); + gettimeofday(&tput_start_time, NULL); + if (ret < BT_ERROR_NONE) + { + BT_DBG("failed with [0x%04x]", ret); + return (ret); + } + + g_timeout_add_seconds(15, _bt_smartrc_tput_mode_timer_expired, NULL); + is_smartc_tput = true; + BT_DBG("Started DUT mode for SmartRC"); + return (BT_ERROR_NONE); +} + +int _bt_stop_smartrc_tput_mode(void) +{ + g_timeout_add_seconds(0.2, _bt_smartrc_tput_mode_timer_expired, NULL); + + return (BT_ERROR_NONE); +} + +int _bt_get_bt_a2dp_sink_audio_info_s(bt_a2dp_sink_audio_info_s **dest_audio_info, bluetooth_a2dp_sink_audio_info_t *source_audio_info) +{ + BT_CHECK_INPUT_PARAMETER(source_audio_info); + + *dest_audio_info = (bt_a2dp_sink_audio_info_s*) g_try_malloc0(sizeof(bt_a2dp_sink_audio_info_s)); + + if (*dest_audio_info == NULL) { + return BT_ERROR_OUT_OF_MEMORY; + } + + (*dest_audio_info)->sampling_freq = source_audio_info->sampling_freq; + + (*dest_audio_info)->num_channel = source_audio_info->num_channel; + + (*dest_audio_info)->bits_per_sample = source_audio_info->bits_per_sample; + + return BT_ERROR_NONE; + +} + +void _bt_free_bt_a2dp_sink_audio_info_s(bt_a2dp_sink_audio_info_s *audio_info) +{ + if (audio_info != NULL) + g_free(audio_info); + return; +} diff --git a/tv_src/bluetooth-device.c b/tv_src/bluetooth-device.c new file mode 100644 index 0000000..283418d --- /dev/null +++ b/tv_src/bluetooth-device.c @@ -0,0 +1,408 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <vconf.h> +#include <glib.h> +#include <dlog.h> +#include <stdio.h> +#include <bluetooth-api.h> + +#include "bluetooth.h" +#include "bluetooth_product.h" +#include "bluetooth_private.h" + +int bt_device_create_bond(const char *device_address) +{ + bluetooth_device_address_t addr_hex = { {0,} }; + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(device_address); + + _bt_convert_address_to_hex(&addr_hex, device_address); + error_code = _bt_get_error_code(bluetooth_bond_device(&addr_hex)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + + return error_code; +} + +int bt_device_cancel_bonding(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(bluetooth_cancel_bonding()); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + + return error_code; +} + +int bt_device_destroy_bond(const char *device_address) +{ + bluetooth_device_address_t addr_hex = { {0,} }; + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(device_address); + + _bt_convert_address_to_hex(&addr_hex, device_address); + error_code = _bt_get_error_code(bluetooth_unbond_device(&addr_hex)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + + return error_code; +} + +int bt_device_set_alias(const char *device_address, const char *alias) +{ + bluetooth_device_address_t addr_hex = { {0,} }; + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(device_address); + BT_CHECK_INPUT_PARAMETER(alias); + + _bt_convert_address_to_hex(&addr_hex, device_address); + error_code = _bt_get_error_code(bluetooth_set_alias(&addr_hex, alias)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_device_accept_authorization(const char *device_address, int service_id) +{ + bluetooth_device_address_t addr_hex = { {0,} }; + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(device_address); + + _bt_convert_address_to_hex(&addr_hex, device_address); + + error_code = _bt_get_error_code(bluetooth_device_accept_authorization(&addr_hex, service_id)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_device_reject_authorization(const char *device_address, int service_id) +{ + bluetooth_device_address_t addr_hex = { {0,} }; + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(device_address); + + _bt_convert_address_to_hex(&addr_hex, device_address); + + error_code = _bt_get_error_code(bluetooth_device_reject_authorization(&addr_hex, service_id)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_device_set_authorization(const char *device_address, bt_device_authorization_e authorization) +{ + bluetooth_device_address_t addr_hex = { {0,} }; + gboolean trusted = FALSE; + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(device_address); + + _bt_convert_address_to_hex(&addr_hex, device_address); + if (authorization == BT_DEVICE_AUTHORIZED) + trusted = TRUE; + + error_code = _bt_get_error_code(bluetooth_authorize_device(&addr_hex, trusted)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_device_start_service_search(const char *device_address) +{ + bluetooth_device_address_t addr_hex = { {0,} }; + int ret = 0; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(device_address); + + _bt_convert_address_to_hex(&addr_hex, device_address); + ret = _bt_get_error_code(bluetooth_search_service(&addr_hex)); + + /* In service search, BT_ERROR_SERVICE_SEARCH_FAILED is returned instead of BT_ERROR_OPERATION_FAILED. */ + if (ret == BT_ERROR_OPERATION_FAILED) + ret = BT_ERROR_SERVICE_SEARCH_FAILED; + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + return ret; +} + +int bt_device_cancel_service_search(void) +{ + int ret = 0; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + ret = _bt_get_error_code(bluetooth_cancel_service_search()); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_device_foreach_connected_profiles(const char *remote_address, bt_device_connected_profile callback, void *user_data) +{ + bluetooth_device_address_t addr_hex = { {0,} }; + gboolean is_connected = FALSE; + int ret; + int i = 0; + int profiles[] = {BT_PROFILE_RFCOMM, BT_PROFILE_A2DP, + BT_PROFILE_HSP, BT_PROFILE_HID, 0}; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + BT_CHECK_INPUT_PARAMETER(callback); + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + while (profiles[i] != 0) { + ret = _bt_get_error_code(bluetooth_is_device_connected(&addr_hex, + profiles[i], + &is_connected)); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + return ret; + } + + if (is_connected == TRUE) { + if (!callback(profiles[i], user_data)) + break; + } + + i++; + } + + return BT_ERROR_NONE; +} + +int bt_device_set_bond_created_cb(bt_device_bond_created_cb callback, void *user_data) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_BOND_CREATED, callback, user_data); + + return BT_ERROR_NONE; +} + +int bt_device_set_bond_destroyed_cb(bt_device_bond_destroyed_cb callback, void *user_data) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_BOND_DESTROYED, callback, user_data); + + return BT_ERROR_NONE; +} + +int bt_device_set_authorization_changed_cb(bt_device_authorization_changed_cb callback, void *user_data) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AUTHORIZATION_CHANGED, callback, user_data); + + return BT_ERROR_NONE; +} + +int bt_device_set_service_searched_cb(bt_device_service_searched_cb callback, void *user_data) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_SERVICE_SEARCHED, callback, user_data); + + return BT_ERROR_NONE; +} + +int bt_device_set_connection_state_changed_cb(bt_device_connection_state_changed_cb callback, void *user_data) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_DEVICE_CONNECTION_STATUS, callback, user_data); + + return BT_ERROR_NONE; +} + +int bt_device_set_auth_event_state_changed_cb(bt_device_auth_event_state_changed_cb callback, void *user_data) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + + BT_ERR("bt_device_set_auth_event_state_changed_cb API is depricated"); + BT_ERR("Please use bt_device_set_auth_event_cb API"); + + return BT_ERROR_OPERATION_FAILED; +} + +int bt_device_set_auth_event_cb(bt_device_auth_event_cb callback, void *user_data) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AUTHORIZE_REQUEST, callback, user_data); + + return BT_ERROR_NONE; +} + +int bt_device_unset_bond_created_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_BOND_CREATED); + return BT_ERROR_NONE; +} + +int bt_device_unset_bond_destroyed_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_BOND_DESTROYED); + return BT_ERROR_NONE; +} + +int bt_device_unset_authorization_changed_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_AUTHORIZATION_CHANGED); + return BT_ERROR_NONE; +} + +int bt_device_unset_service_searched_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_SERVICE_SEARCHED); + return BT_ERROR_NONE; +} + +int bt_device_unset_connection_state_changed_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_DEVICE_CONNECTION_STATUS); + return BT_ERROR_NONE; +} + +int bt_device_is_a2dp_connected(bool *connected) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INPUT_PARAMETER(connected); + int bt_device_state = VCONFKEY_BT_DEVICE_NONE; + + *connected = false; + + if (vconf_get_int(VCONFKEY_BT_DEVICE, &bt_device_state) != 0) { + LOGI("vconf_get_str failed"); + return BT_ERROR_OPERATION_FAILED; + } + + if (bt_device_state & VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED) + *connected = true; + + BT_ERR("a2dp connected: %d", *connected); + + return BT_ERROR_NONE; +} + +int bt_passkey_reply(char *passkey, bool authentication_reply) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(passkey); + int error_code = BT_ERROR_NONE; + error_code = _bt_get_error_code(bluetooth_passkey_reply(passkey, authentication_reply)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_passkey_confirmation_reply(bool confirmation_reply) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + int error_code = BT_ERROR_NONE; + error_code = _bt_get_error_code(bluetooth_passkey_confirmation_reply(confirmation_reply)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_ssp_consent_reply(bool reply) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + int error_code = BT_ERROR_NONE; + error_code = _bt_get_error_code(bluetooth_ssp_consent_reply(reply)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + +int bt_device_get_service_mask_from_uuid_list(char **uuids, + int no_of_service, + bt_service_class_t *service_mask_list) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_device_is_profile_connected(const char *remote_address, bt_profile_e bt_profile, + bool *connected_status) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + diff --git a/tv_src/bluetooth-dut.c b/tv_src/bluetooth-dut.c new file mode 100644 index 0000000..38c5a5d --- /dev/null +++ b/tv_src/bluetooth-dut.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <stdio.h> +#include <stdbool.h> +#include <bluetooth-api.h> + +#include "bluetooth.h" +#include "bluetooth_product.h" +#include "bluetooth_private.h" + +int bt_dut_set_configure_mode(bool mode) +{ + int error_code = BT_ERROR_NONE; + + error_code = _bt_get_error_code(bluetooth_dut_set_configure_mode(mode)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_dut_sent_mode(unsigned short opcode, unsigned char *data, unsigned short length) +{ + int error_code = BT_ERROR_NONE; + + if (NULL == data || 0 == length) + return BT_ERROR_INVALID_PARAMETER; + + error_code = _bt_get_error_code(bluetooth_dut_send_mode(opcode, data, length)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_dut_wakeup_test(void) +{ + int error_code = BT_ERROR_NONE; + + error_code = _bt_get_error_code(bluetooth_dut_wakeup_test()); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + return error_code; +} + + diff --git a/tv_src/bluetooth-gatt.c b/tv_src/bluetooth-gatt.c new file mode 100644 index 0000000..749b658 --- /dev/null +++ b/tv_src/bluetooth-gatt.c @@ -0,0 +1,526 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdbool.h> +#include <dlog.h> +#include <bluetooth-api.h> + +#include "bluetooth.h" +#include "bluetooth_product.h" +#include "bluetooth_private.h" + +static bool is_gatt_server_initialized = false; + +#ifdef TIZEN_GATT_DISABLE +#define BT_CHECK_GATT_SUPPORT() \ + { \ + BT_CHECK_BT_SUPPORT(); \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_GATT_SUPPORT() +#endif + +#define BT_CHECK_GATT_SERVER_INIT_STATUS() \ + if (__bt_check_gatt_server_init_status() == BT_ERROR_NOT_INITIALIZED) \ + { \ + LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \ + return BT_ERROR_NOT_INITIALIZED; \ + } + +int __bt_check_gatt_server_init_status(void) +{ + if (is_gatt_server_initialized != true) { + BT_ERR("NOT_INITIALIZED(0x%08x)", BT_ERROR_NOT_INITIALIZED); + return BT_ERROR_NOT_INITIALIZED; + } + + return BT_ERROR_NONE; +} + + +int bt_gatt_foreach_primary_services(const char *remote_address, + bt_gatt_primary_service_cb callback, + void *user_data) +{ + int i; + int ret; + bool foreach_call = true; + bluetooth_device_address_t addr_hex = { {0,} }; + bt_gatt_handle_info_t *prim_svc; + + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + BT_CHECK_INPUT_PARAMETER(callback); + + prim_svc = g_new0(bt_gatt_handle_info_t, 1); + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + ret = _bt_get_error_code(bluetooth_gatt_get_primary_services(&addr_hex, + prim_svc)); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x) : Failed to run function", + _bt_convert_error_to_string(ret), ret); + g_free(prim_svc); + return ret; + } + + for (i = 0; i < prim_svc->count; i++) { + if (prim_svc->handle[i] == NULL) + continue; + + BT_DBG("handle: %s", prim_svc->handle[i]); + + if (foreach_call == true && + !callback((bt_gatt_attribute_h)prim_svc->handle[i], user_data)) { + foreach_call = false; + } + + /* Application should clone the handle using API in callback */ + /* bt_gatt_clone_attribute_handle */ + g_free(prim_svc->handle[i]); + } + + g_free(prim_svc->handle); + g_free(prim_svc); + + return ret; +} + +int bt_gatt_discover_characteristics(bt_gatt_attribute_h service, + bt_gatt_characteristics_discovered_cb callback, + void *user_data) +{ + int ret; + + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(service); + BT_CHECK_INPUT_PARAMETER(callback); + + ret = _bt_get_error_code(bluetooth_gatt_discover_service_characteristics((const char *)service)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } else { + _bt_set_cb(BT_EVENT_GATT_CHARACTERISTIC_DISCOVERED, callback, user_data); + } + + return ret; +} + +int bt_gatt_get_service_uuid(bt_gatt_attribute_h service, char **uuid) +{ + int i; + int ret; + bt_gatt_service_property_t property; + + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(service); + + memset(&property, 0x00, sizeof(bt_gatt_service_property_t)); + + ret = _bt_get_error_code(bluetooth_gatt_get_service_property((const char *)service, &property)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } else { + *uuid = g_strdup(property.uuid); + + if (property.handle_info.count != 0 && property.handle_info.handle) { + for (i = 0; i < property.handle_info.count; i++) { + g_free(property.handle_info.handle[i]); + } + g_free(property.handle_info.handle); + } + } + + return ret; +} + +int bt_gatt_foreach_included_services(bt_gatt_attribute_h service, + bt_gatt_included_service_cb callback, + void *user_data) +{ + int i; + int ret; + bool foreach_call = true; + bt_gatt_service_property_t property; + + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(service); + BT_CHECK_INPUT_PARAMETER(callback); + + memset(&property, 0x00, sizeof(bt_gatt_service_property_t)); + + ret = _bt_get_error_code(bluetooth_gatt_get_service_property((const char *)service, &property)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } else { + if (property.handle_info.count == 0 || + property.handle_info.handle == NULL) { + return ret; + } + + for (i = 0; i < property.handle_info.count; i++) { + if (property.handle_info.handle[i] == NULL) + continue; + + if (foreach_call == true && + !callback((bt_gatt_attribute_h)property.handle_info.handle[i], + user_data)) { + foreach_call = false; + } + + g_free(property.handle_info.handle[i]); + } + g_free(property.handle_info.handle); + } + return ret; +} + +int bt_gatt_set_characteristic_changed_cb(bt_gatt_characteristic_changed_cb callback, + void *user_data) +{ + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + + _bt_set_cb(BT_EVENT_GATT_CLIENT_VALUE_CHANGED_LEGACY, callback, user_data); + + return BT_ERROR_NONE; +} + +int bt_gatt_unset_characteristic_changed_cb() +{ + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + _bt_unset_cb(BT_EVENT_GATT_CLIENT_VALUE_CHANGED_LEGACY); + + return BT_ERROR_NONE; +} + +int bt_gatt_get_characteristic_declaration(bt_gatt_attribute_h characteristic, + char **uuid, unsigned char **value, + int *value_length) +{ + int ret; + bt_gatt_char_property_t property; + + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(characteristic); + + memset(&property, 0x00, sizeof(bt_gatt_char_property_t)); + + ret = _bt_get_error_code(bluetooth_gatt_get_characteristics_property((const char *)characteristic, &property)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } else { + if (property.uuid) { + *uuid = g_strdup(property.uuid); + g_free(property.uuid); + } + + if (property.val && property.val_len != 0) { + *value = g_memdup(property.val, property.val_len); + *value_length = property.val_len; + g_free(property.val); + } + + g_free(property.name); + + } + + return ret; +} + +int bt_gatt_set_characteristic_value(bt_gatt_attribute_h characteristic, + const unsigned char *value, + int value_length) +{ + int ret; + + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(characteristic); + BT_CHECK_INPUT_PARAMETER(value); + + if (value_length <= 0) + return BT_ERROR_INVALID_PARAMETER; + + ret = _bt_get_error_code(bluetooth_gatt_set_characteristics_value((const char *)characteristic, + (const guint8 *)value, value_length, 1)); + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_gatt_clone_attribute_handle(bt_gatt_attribute_h *handle, + bt_gatt_attribute_h origin) +{ + int error = BT_ERROR_NONE; + + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(origin); + + *handle = g_strdup((char *)origin); + + return error; +} + +int bt_gatt_destroy_attribute_handle(bt_gatt_attribute_h handle) +{ + int error = BT_ERROR_NONE; + + BT_CHECK_GATT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(handle); + + g_free(handle); + + return error; +} + +int bt_gatt_watch_characteristic_changes(bt_gatt_attribute_h service) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_unwatch_characteristic_changes(bt_gatt_attribute_h service) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_set_characteristic_value_request(bt_gatt_attribute_h characteristic, + const unsigned char *value, int value_length, + bt_gatt_characteristic_write_cb callback) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_read_characteristic_value(bt_gatt_attribute_h characteristic, + bt_gatt_characteristic_read_cb callback) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_discover_characteristic_descriptor(bt_gatt_attribute_h characteristic_handle, + bt_gatt_characteristic_descriptor_discovered_cb callback, + void *user_data) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_get_value(bt_gatt_h gatt_handle, char **value, int *value_length) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_get_int_value(bt_gatt_h gatt_handle, bt_data_type_int_e type, int offset, int *value) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_get_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type, int offset, float *value) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_set_value(bt_gatt_h gatt_handle, const char *value, int value_length) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_set_int_value(bt_gatt_h gatt_handle, bt_data_type_int_e type, int value, int offset) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_set_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type, + int mantissa, int exponent, int offset) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + + +int bt_gatt_get_uuid(bt_gatt_h gatt_handle, char **uuid) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_get_type(bt_gatt_h gatt_handle, bt_gatt_type_e *gatt_type) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_service_get_client(bt_gatt_h service, bt_gatt_client_h *client) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_service_get_characteristic(bt_gatt_h service, const char *uuid, + bt_gatt_h *characteristic) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_service_foreach_characteristics(bt_gatt_h service, + bt_gatt_foreach_cb callback, void *user_data) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_service_get_included_service(bt_gatt_h service, const char *uuid, + bt_gatt_h *included_service) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_service_foreach_included_services(bt_gatt_h service, + bt_gatt_foreach_cb callback, void *user_data) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_characteristic_get_service(bt_gatt_h characteristic, bt_gatt_h *service) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_characteristic_get_properties(bt_gatt_h characteristic, int *properties) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_characteristic_set_properties(bt_gatt_h characteristic, int properties) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_characteristic_get_write_type(bt_gatt_h characteristic, + bt_gatt_write_type_e *write_type) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_characteristic_set_write_type(bt_gatt_h characteristic, + bt_gatt_write_type_e write_type) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_characteristic_get_descriptor(bt_gatt_h characteristic, const char *uuid, + bt_gatt_h *descriptor) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_characteristic_foreach_descriptors(bt_gatt_h characteristic, + bt_gatt_foreach_cb callback, void *user_data) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_descriptor_get_characteristic(bt_gatt_h descriptor, bt_gatt_h *characteristic) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_client_create(const char *remote_address, bt_gatt_client_h *client) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_client_destroy(bt_gatt_client_h client) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_client_get_remote_address(bt_gatt_client_h client, + char **remote_address) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_client_read_value(bt_gatt_h gatt_handle, + bt_gatt_client_request_completed_cb callback, void *user_data) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_client_write_value(bt_gatt_h gatt_handle, + bt_gatt_client_request_completed_cb callback, void *user_data) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_client_set_characteristic_value_changed_cb(bt_gatt_h characteristic, + bt_gatt_client_characteristic_value_changed_cb callback, + void *user_data) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_client_unset_characteristic_value_changed_cb(bt_gatt_h characteristic) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_client_get_service(bt_gatt_client_h client, const char *uuid, + bt_gatt_h *service) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_client_foreach_services(bt_gatt_client_h client, + bt_gatt_foreach_cb callback, void *user_data) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_connect(const char *address, bool auto_connect) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_disconnect(const char *address) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_set_connection_state_changed_cb(bt_gatt_connection_state_changed_cb callback, void *user_data) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + +int bt_gatt_unset_connection_state_changed_cb(void) +{ + BT_NOT_SUPPORTED_FUNCTION(); +} + diff --git a/tv_src/bluetooth-hdp.c b/tv_src/bluetooth-hdp.c new file mode 100644 index 0000000..4477d63 --- /dev/null +++ b/tv_src/bluetooth-hdp.c @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <glib.h> +#include <dlog.h> +#include <stdio.h> +#include <stdbool.h> +#include <string.h> +#include <bluetooth-api.h> + +#include "bluetooth.h" +#include "bluetooth_private.h" + +#ifdef TIZEN_HDP_DISABLE +#define BT_CHECK_HDP_SUPPORT() \ + { \ + BT_CHECK_BT_SUPPORT(); \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_HDP_SUPPORT() +#endif + +int bt_hdp_register_sink_app(unsigned short data_type, char **app_id) +{ + int error = BT_ERROR_NONE; + + BT_CHECK_HDP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(app_id); + error = bluetooth_hdp_activate(data_type, HDP_ROLE_SINK, HDP_QOS_ANY, app_id); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_hdp_unregister_sink_app(const char *app_id) +{ + int error = BT_ERROR_NONE; + + BT_CHECK_HDP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(app_id); + error = bluetooth_hdp_deactivate(app_id); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_hdp_send_data(unsigned int channel, const char *data, unsigned int size) +{ + int error = BT_ERROR_NONE; + + BT_CHECK_HDP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + if (NULL == data || 0 >= size) { + BT_ERR("%s", _bt_convert_error_to_string(BT_ERROR_INVALID_PARAMETER)); + } + error = bluetooth_hdp_send_data(channel, data, size); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_hdp_connect_to_source(const char *remote_address, const char *app_id) +{ + int error = BT_ERROR_NONE; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_HDP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(app_id); + BT_CHECK_INPUT_PARAMETER(remote_address); + _bt_convert_address_to_hex(&addr_hex, remote_address); + error = bluetooth_hdp_connect(app_id, HDP_QOS_ANY, &addr_hex); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_hdp_disconnect(const char *remote_address, unsigned int channel) +{ + int error = BT_ERROR_NONE; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_HDP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + _bt_convert_address_to_hex(&addr_hex, remote_address); + + error = bluetooth_hdp_disconnect(channel, &addr_hex); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_hdp_set_connection_state_changed_cb(bt_hdp_connected_cb connected_cb, + bt_hdp_disconnected_cb disconnected_cb, void *user_data) +{ + BT_CHECK_HDP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(connected_cb); + BT_CHECK_INPUT_PARAMETER(disconnected_cb); + _bt_set_cb(BT_EVENT_HDP_CONNECTED, connected_cb, user_data); + _bt_set_cb(BT_EVENT_HDP_DISCONNECTED, disconnected_cb, user_data); + return BT_ERROR_NONE; + +} + +int bt_hdp_unset_connection_state_changed_cb(void) +{ + BT_CHECK_HDP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + if ( _bt_check_cb(BT_EVENT_HDP_CONNECTED) == true) + _bt_unset_cb(BT_EVENT_HDP_CONNECTED); + if ( _bt_check_cb(BT_EVENT_HDP_DISCONNECTED) == true) + _bt_unset_cb(BT_EVENT_HDP_DISCONNECTED); + + return BT_ERROR_NONE; +} + +int bt_hdp_set_data_received_cb(bt_hdp_data_received_cb callback, + void *user_data) +{ + BT_CHECK_HDP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_HDP_DATA_RECEIVED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_hdp_unset_data_received_cb(void) +{ + BT_CHECK_HDP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + if ( _bt_check_cb(BT_EVENT_HDP_DATA_RECEIVED) == true) + _bt_unset_cb(BT_EVENT_HDP_DATA_RECEIVED); + return BT_ERROR_NONE; +} diff --git a/tv_src/bluetooth-hid.c b/tv_src/bluetooth-hid.c new file mode 100644 index 0000000..8389def --- /dev/null +++ b/tv_src/bluetooth-hid.c @@ -0,0 +1,613 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include <vconf.h> +#include <glib.h> +#include <dlog.h> +#include <stdio.h> +#include <stdbool.h> +#include <string.h> +#include <bluetooth-api.h> +#include <bluetooth-hid-api.h> + +#include "bluetooth.h" +#include "bluetooth_product.h" +#include "bluetooth_private.h" + +static bool is_hid_host_initialized = false; + +#ifdef TIZEN_HID_HOST_DISABLE +#define BT_CHECK_HID_HOST_SUPPORT() \ + { \ + BT_CHECK_BT_SUPPORT(); \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_HID_HOST_SUPPORT() +#endif + +#ifdef TIZEN_HID_DEVICE_DISABLE +#define BT_CHECK_HID_DEVICE_SUPPORT() \ + { \ + BT_CHECK_BT_SUPPORT(); \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_HID_DEVICE_SUPPORT() +#endif + +#define BT_CHECK_HID_HOST_INIT_STATUS() \ + if (__bt_check_hid_host_init_status() == BT_ERROR_NOT_INITIALIZED) \ + { \ + LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \ + return BT_ERROR_NOT_INITIALIZED; \ + } + +int __bt_check_hid_host_init_status(void) +{ + if (is_hid_host_initialized != true) { + BT_ERR("NOT_INITIALIZED(0x%08x)", BT_ERROR_NOT_INITIALIZED); + return BT_ERROR_NOT_INITIALIZED; + } + + return BT_ERROR_NONE; +} + +int bt_hid_host_initialize(bt_hid_host_connection_state_changed_cb connection_cb, + void *user_data) +{ + int error; + + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(connection_cb); + + error = bluetooth_hid_init(_bt_hid_event_proxy, user_data); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } + + _bt_set_cb(BT_EVENT_HID_CONNECTION_STATUS, connection_cb, user_data); + + is_hid_host_initialized = true; + return BT_ERROR_NONE; +} + +int bt_hid_host_deinitialize() +{ + int error; + + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_HID_HOST_INIT_STATUS(); + + error = bluetooth_hid_deinit(); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + return error; + } + + _bt_unset_cb(BT_EVENT_HID_CONNECTION_STATUS); + + is_hid_host_initialized = false; + return BT_ERROR_NONE; +} + +int bt_hid_host_connect(const char *remote_address) +{ + int error; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_HID_HOST_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + error = bluetooth_hid_connect((hid_device_address_t *)&addr_hex); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_hid_host_disconnect(const char *remote_address) +{ + int error; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_HID_HOST_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + error = bluetooth_hid_disconnect((hid_device_address_t *)&addr_hex); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_hid_set_audio_data_receive_cb(bt_hid_audio_data_receive_cb callback, void *user_data) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + + ret = bluetooth_hid_voice_data_path_init(_bt_hid_event_proxy); + ret = _bt_get_error_code(ret); + if (ret != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + else + _bt_set_cb(BT_EVENT_HID_AUDIO_DATA_RECVD , callback, user_data); + + return ret; +} + +int bt_hid_unset_audio_data_receive_cb(void) +{ + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_HID_AUDIO_DATA_RECVD); + bluetooth_hid_voice_data_path_deinit(); + return BT_ERROR_NONE; +} + +int bt_hid_set_smartrc_tput_mode_cb(bt_adapter_smartrc_tput_mode_cb callback, void *user_data) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + + BT_DBG ("bt_hid_set_smartrc_tput_mode_cb intialized"); + ret = bluetooth_hid_voice_data_path_init(_bt_hid_event_proxy); + ret = _bt_get_error_code(ret); + if (ret != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + else + _bt_set_cb(BT_EVENT_DUT_MODE , callback, user_data); + + return ret; +} + +int bt_hid_unset_smartrc_tput_mode_cb(void) +{ + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_DUT_MODE); + bluetooth_hid_voice_data_path_deinit(); + return BT_ERROR_NONE; +} + +int bt_hid_set_smart_rc_connection_cb(bt_hid_notify_smart_rc_connection_cb callback, void *user_data) +{ + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_HID_SMARTRC_CONNECTION_STATUS, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_hid_unset_smart_rc_connection_cb(void) +{ + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_HID_SMARTRC_CONNECTION_STATUS); + return BT_ERROR_NONE; +} + +int bt_hid_set_sound_key_pressed_cb(bt_hid_notify_sound_key_pressed_cb callback, void *user_data) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + + _bt_set_cb(BT_EVENT_HID_VOICE_KEY_PRESSED, callback, user_data); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_hid_unset_sound_key_pressed_cb(void) +{ + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_HID_VOICE_KEY_PRESSED); + return BT_ERROR_NONE; +} + +int bt_hid_rc_stop_sending_voice(const char *remote_address) +{ + int error; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_HID_HOST_SUPPORT(); + + /* If remote address is NULL, RC command should be + sent to all connected HID devices. So we need to + explicitly send NULL as remote address to BT framework */ + if(remote_address != NULL) { + _bt_convert_address_to_hex(&addr_hex, remote_address); + + error = bluetooth_rc_stop_sending_voice( + (hid_device_address_t *)&addr_hex); + } else { + error = bluetooth_rc_stop_sending_voice(NULL); + } + + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_hid_send_rc_command(const char *remote_address, + const unsigned char *data, unsigned short length) +{ + int error; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_HID_HOST_SUPPORT(); + + if (NULL == data || 0 == length) + return BT_ERROR_INVALID_PARAMETER; + + /* If remote address is NULL, RC command should be + sent to all connected HID devices. So we need to + explicitly send NULL as remote address to BT framework */ + if(remote_address != NULL) { + _bt_convert_address_to_hex(&addr_hex, remote_address); + + error = bluetooth_send_rc_command( + (hid_device_address_t *)&addr_hex, + data, length); + } else { + error = bluetooth_send_rc_command(NULL, data, length); + } + + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_hid_set_battery_status_received_cb(bt_hid_notify_battery_status_received_cb callback, void *user_data) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + + _bt_set_cb(BT_EVENT_HID_BATTERY_STATUS_RECEIVED, callback, user_data); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_hid_unset_battery_status_received_cb(void) +{ + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_HID_BATTERY_STATUS_RECEIVED); + return BT_ERROR_NONE; +} + +int bt_hid_set_mbr_return_receive_cb(bt_hid_mbr_return_receive_cb callback, void *user_data) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + + _bt_set_cb(BT_EVENT_HID_MBR_RETURN_RECVD , callback, user_data); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_hid_unset_mbr_return_receive_cb(void) +{ + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_HID_MBR_RETURN_RECVD); + return BT_ERROR_NONE; +} + +int bt_hid_set_sensor_data_receive_cb(bt_hid_sensor_data_receive_cb callback, void *user_data) +{ + int ret = BT_ERROR_NONE; + + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + + ret = bluetooth_hid_sensor_data_path_init(_bt_hid_event_proxy); + ret = _bt_get_error_code(ret); + if (ret != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + else + _bt_set_cb(BT_EVENT_HID_SENSOR_DATA_RECEIVED, callback, user_data); + + return ret; +} + +int bt_hid_unset_sensor_data_receive_cb(void) +{ + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_HID_SENSOR_DATA_RECEIVED); + bluetooth_hid_sensor_data_path_deinit(); + return BT_ERROR_NONE; +} + +int bt_hid_send_device_command(const char *remote_address, unsigned char device_type, + unsigned char device_cmd) +{ + int error; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_HID_HOST_SUPPORT(); + + /* If remote address is NULL, RC command should be + sent to all connected HID devices. So we need to + explicitly send NULL as remote address to BT framework */ + if(remote_address != NULL) { + _bt_convert_address_to_hex(&addr_hex, remote_address); + + error = bluetooth_rc_send_device_cmd( + (hid_device_address_t *)&addr_hex, + device_type, + device_cmd); + + } else { + error = bluetooth_rc_send_device_cmd(NULL, device_type, device_cmd); + } + + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_hid_send_mbr_command(const char *remote_address, const unsigned char* data, + unsigned short len) +{ + int error; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_HID_HOST_SUPPORT(); + + /* If remote address is NULL, RC command should be + sent to all connected HID devices. So we need to + explicitly send NULL as remote address to BT framework */ + if(remote_address != NULL) { + _bt_convert_address_to_hex(&addr_hex, remote_address); + + error = bluetooth_rc_send_mbr_cmd( + (hid_device_address_t *)&addr_hex, + data, + len); + } else { + error = bluetooth_rc_send_mbr_cmd(NULL, data, len); + } + + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_hid_send_mbr_data(const char *remote_address, const unsigned char* data, + unsigned short len) +{ + + int error; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_HID_HOST_SUPPORT(); + + /* If remote address is NULL, RC command should be + sent to all connected HID devices. So we need to + explicitly send NULL as remote address to BT framework */ + if(remote_address != NULL) { + _bt_convert_address_to_hex(&addr_hex, remote_address); + + error = bluetooth_rc_send_mbr_data( + (hid_device_address_t *)&addr_hex, + data, + len); + } else { + error = bluetooth_rc_send_mbr_data(NULL, data, len); + } + + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + + +int bt_hid_send_haptic_command(const unsigned char data, bool force, int voltage) +{ + int error; + unsigned char input_data[7] = {0, }; + + BT_CHECK_HID_HOST_SUPPORT(); + + input_data[0] = 0x06; /* Haptic data */ + input_data[1] = data; + + error = bluetooth_send_rc_command(NULL, input_data, 2); + + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + + return error; +} + +int bt_hid_send_haptic_data(const char *remote_address, + const unsigned char *data, unsigned short length) +{ + int error; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INPUT_PARAMETER(remote_address); + BT_CHECK_INPUT_PARAMETER(data); + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + error = bluetooth_send_rc_haptic_data( + (hid_device_address_t *)&addr_hex, + data, length); + + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_hid_get_smart_remote_conn_status(bool *is_connected) +{ + int error; + gboolean status = FALSE; + + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INPUT_PARAMETER(is_connected); + + error = bluetooth_get_smart_remote_conn_status(&status); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) { + BT_ERR("bluetooth_get_Smart_remote_conn_status returned %s(0x%08x)", + _bt_convert_error_to_string(error), error); + } + + *is_connected = status ? TRUE : FALSE; + + return error; +} + +int bt_hid_get_smart_rc_battery_status(unsigned char *status) +{ + int battery_status =0; + + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INPUT_PARAMETER(status); + + if(vconf_get_int("file/bluetooth/bt_smart_rc_battery", &battery_status)) { + BT_ERR("get vconf failed\n"); + *status = (char)battery_status; + return BT_ERROR_OPERATION_FAILED; + } + *status = (char)battery_status; + return BT_ERROR_NONE; +} + +int bt_hid_set_calibration_mode(bool enable, int mode) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_HID_HOST_SUPPORT(); + + error_code = _bt_get_error_code(bluetooth_set_calibration_mode(enable, mode)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_hid_set_smart_rc_fw_update_status_cb(bt_hid_notify_smart_rc_fw_update_status_cb callback, void *user_data) +{ + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_HID_SMARTRC_FW_UPDATE_STATUS, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_hid_unset_smart_rc_fw_update_status_cb(void) +{ + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_HID_SMARTRC_FW_UPDATE_STATUS); + return BT_ERROR_NONE; +} + +int bt_hid_update_smart_rc_fw(const char *remote_address, const char *path) +{ + int error; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + BT_CHECK_INPUT_PARAMETER(path); + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + error = bluetooth_update_smart_rc_fw((hid_device_address_t *)&addr_hex, path); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_hid_get_smart_rc_fw_version(const char *remote_address, int *version) +{ + BT_CHECK_HID_HOST_SUPPORT(); + BT_CHECK_INPUT_PARAMETER(version); + + if(vconf_get_int("file/bluetooth/bt_smart_rc_version", version) != 0){ + BT_ERR("BT_VCONF_SMART_RC_VERSION vconf get failed"); + return BT_ERROR_OPERATION_FAILED; + } + BT_ERR("smart rc fw version : %X",*version); + return BT_ERROR_NONE; +} diff --git a/tv_src/bluetooth-opp-client.c b/tv_src/bluetooth-opp-client.c new file mode 100644 index 0000000..388d44d --- /dev/null +++ b/tv_src/bluetooth-opp-client.c @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <glib.h> +#include <dlog.h> +#include <stdio.h> +#include <stdbool.h> +#include <string.h> +#include <bluetooth-api.h> + +#include "bluetooth.h" +#include "bluetooth_private.h" + +GList *sending_files; +static bool is_opp_client_initialized = false; + +#ifdef TIZEN_OPP_CLIENT_DISABLE +#define BT_CHECK_OPP_CLIENT_SUPPORT() \ + { \ + BT_CHECK_BT_SUPPORT(); \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_OPP_CLIENT_SUPPORT() +#endif + +#define BT_CHECK_OPP_CLIENT_INIT_STATUS() \ + if (__bt_check_opp_client_init_status() == BT_ERROR_NOT_INITIALIZED) \ + { \ + LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \ + return BT_ERROR_NOT_INITIALIZED; \ + } + +int __bt_check_opp_client_init_status(void) +{ + if (is_opp_client_initialized != true) { + BT_ERR("NOT_INITIALIZED(0x%08x)", BT_ERROR_NOT_INITIALIZED); + return BT_ERROR_NOT_INITIALIZED; + } + + return BT_ERROR_NONE; +} + +char** __bt_opp_get_file_array(GList *file_list) +{ + char **files = NULL; + char *c_file = NULL; + int file_num = 0; + int i = 0; + + if (file_list == NULL) + return NULL; + + file_num = g_list_length(file_list); + + if (file_num == 0) + return NULL; + + files = (char **)calloc(file_num + 1, sizeof(char *)); + if (!files) + return NULL; + + for (i = 0; i < file_num; i++) { + c_file = (char *)g_list_nth_data(file_list, i); + + if (c_file == NULL) + continue; + + files[i] = c_file; + } + + for (i = 0; i < file_num; i++) + BT_DBG("file: %s", files[i]); + + return files; +} + +int bt_opp_client_initialize(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_OPP_CLIENT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_opc_init()); + + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + return error_code; + } + + is_opp_client_initialized = true; + return BT_ERROR_NONE; +} + +int bt_opp_client_deinitialize(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_OPP_CLIENT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_OPP_CLIENT_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_opc_deinit()); + bt_opp_client_clear_files(); + + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + return error_code; + } + + is_opp_client_initialized = false; + return BT_ERROR_NONE; +} + +int bt_opp_client_add_file(const char *file) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_OPP_CLIENT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_OPP_CLIENT_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(file); + + if (access(file, F_OK) == 0) { + sending_files = g_list_append(sending_files, strdup(file)); + } else { + if (errno == EACCES || errno == EPERM) + error_code = BT_ERROR_PERMISSION_DENIED; + else + error_code = BT_ERROR_INVALID_PARAMETER; + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_opp_client_clear_files(void) +{ + int i = 0; + int file_num = 0; + char *c_file = NULL; + + BT_CHECK_OPP_CLIENT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_OPP_CLIENT_INIT_STATUS(); + + if (sending_files) { + file_num = g_list_length(sending_files); + + for (i = 0; i < file_num; i++) { + c_file = (char *)g_list_nth_data(sending_files, i); + + if (c_file == NULL) + continue; + + free(c_file); + } + + g_list_free(sending_files); + sending_files = NULL; + } + + return BT_ERROR_NONE; +} + +int bt_opp_client_push_files(const char *remote_address, + bt_opp_client_push_responded_cb responded_cb, + bt_opp_client_push_progress_cb progress_cb, + bt_opp_client_push_finished_cb finished_cb, + void *user_data) +{ + int error_code = BT_ERROR_NONE; + bluetooth_device_address_t addr_hex = { {0,} }; + char **files = NULL; + + BT_CHECK_OPP_CLIENT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_OPP_CLIENT_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + files = __bt_opp_get_file_array(sending_files); + + error_code = _bt_get_error_code(bluetooth_opc_push_files(&addr_hex, files)); + + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } else { + _bt_set_cb(BT_EVENT_OPP_CLIENT_PUSH_RESPONSED, responded_cb, user_data); + _bt_set_cb(BT_EVENT_OPP_CLIENT_PUSH_PROGRESS, progress_cb, user_data); + _bt_set_cb(BT_EVENT_OPP_CLIENT_PUSH_FINISHED, finished_cb, user_data); + } + + bt_opp_client_clear_files(); + + if (files) + free(files); + + return error_code; +} + +int bt_opp_client_cancel_push(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_OPP_CLIENT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_OPP_CLIENT_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_opc_cancel_push()); + + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + diff --git a/tv_src/bluetooth-opp-server.c b/tv_src/bluetooth-opp-server.c new file mode 100644 index 0000000..7cd9818 --- /dev/null +++ b/tv_src/bluetooth-opp-server.c @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <stdio.h> +#include <stdbool.h> +#include <bluetooth-api.h> + +#include "bluetooth.h" +#include "bluetooth_private.h" + +static bool is_opp_server_initialized = false; + +#ifdef TIZEN_OPP_SERVER_DISABLE +#define BT_CHECK_OPP_SERVER_SUPPORT() \ + { \ + BT_CHECK_BT_SUPPORT(); \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_OPP_SERVER_SUPPORT() +#endif + + +#define BT_CHECK_OPP_SERVER_INIT_STATUS() \ + if (__bt_check_opp_server_init_status() == BT_ERROR_NOT_INITIALIZED) \ + { \ + LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \ + return BT_ERROR_NOT_INITIALIZED; \ + } + +int __bt_check_opp_server_init_status(void) +{ + if (is_opp_server_initialized != true) { + BT_ERR("NOT_INITIALIZED(0x%08x)", BT_ERROR_NOT_INITIALIZED); + return BT_ERROR_NOT_INITIALIZED; + } + + return BT_ERROR_NONE; +} + +int bt_opp_server_initialize(const char *destination, + bt_opp_server_push_requested_cb push_requested_cb, + void *user_data) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_OPP_SERVER_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(destination); + + error_code = _bt_get_error_code(bluetooth_obex_server_init(destination)); + + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + return error_code; + } + + _bt_set_cb(BT_EVENT_OPP_PUSH_REQUESTED, push_requested_cb, user_data); + + is_opp_server_initialized = true; + return BT_ERROR_NONE; +} + +int bt_opp_server_initialize_by_connection_request(const char *destination, + bt_opp_server_connection_requested_cb connection_requested_cb, + void *user_data) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_OPP_SERVER_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(destination); + + error_code = _bt_get_error_code(bluetooth_obex_server_init_without_agent(destination)); + + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + return error_code; + } + + _bt_set_cb(BT_EVENT_OPP_CONNECTION_REQUESTED, connection_requested_cb, user_data); + + is_opp_server_initialized = true; + return BT_ERROR_NONE; +} + +int bt_opp_server_deinitialize(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_OPP_SERVER_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_OPP_SERVER_INIT_STATUS(); + + if (_bt_check_cb(BT_EVENT_OPP_CONNECTION_REQUESTED) == false) { + error_code = _bt_get_error_code(bluetooth_obex_server_deinit()); + } else { + /* BADA API */ + error_code = _bt_get_error_code(bluetooth_obex_server_deinit_without_agent()); + } + + _bt_unset_cb(BT_EVENT_OPP_CONNECTION_REQUESTED); + _bt_unset_cb(BT_EVENT_OPP_PUSH_REQUESTED); + + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + return error_code; + } + + is_opp_server_initialized = false; + return BT_ERROR_NONE; +} + +int bt_opp_server_accept(bt_opp_server_transfer_progress_cb progress_cb, + bt_opp_server_transfer_finished_cb finished_cb, + const char *name, + void *user_data, + int *transfer_id) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_OPP_SERVER_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_OPP_SERVER_INIT_STATUS(); + + /* Unset the transfer callbacks */ + _bt_unset_cb(BT_EVENT_OPP_SERVER_TRANSFER_PROGRESS); + _bt_unset_cb(BT_EVENT_OPP_SERVER_TRANSFER_FINISHED); + + if (_bt_check_cb(BT_EVENT_OPP_CONNECTION_REQUESTED) == false) { + error_code = _bt_get_error_code(bluetooth_obex_server_accept_authorize(name)); + } else { + /* BADA API */ + error_code = _bt_get_error_code(bluetooth_obex_server_accept_connection()); + } + + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } else { + _bt_set_cb(BT_EVENT_OPP_SERVER_TRANSFER_PROGRESS, progress_cb, user_data); + _bt_set_cb(BT_EVENT_OPP_SERVER_TRANSFER_FINISHED, finished_cb, user_data); + } + + return error_code; +} + +int bt_opp_server_reject(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_OPP_SERVER_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_OPP_SERVER_INIT_STATUS(); + + if (_bt_check_cb(BT_EVENT_OPP_CONNECTION_REQUESTED) == false) { + error_code = _bt_get_error_code(bluetooth_obex_server_reject_authorize()); + } else { + /* BADA API */ + error_code = _bt_get_error_code(bluetooth_obex_server_reject_connection()); + } + + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + /* Unset the transfer callbacks */ + _bt_unset_cb(BT_EVENT_OPP_SERVER_TRANSFER_PROGRESS); + _bt_unset_cb(BT_EVENT_OPP_SERVER_TRANSFER_FINISHED); + + return error_code; +} + +int bt_opp_server_set_destination(const char *destination) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_OPP_SERVER_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_OPP_SERVER_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(destination); + + error_code = _bt_get_error_code(bluetooth_obex_server_set_destination_path(destination)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_opp_server_cancel_transfer(int transfer_id) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_OPP_SERVER_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_OPP_SERVER_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_obex_server_cancel_transfer(transfer_id)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + diff --git a/tv_src/bluetooth-pan.c b/tv_src/bluetooth-pan.c new file mode 100644 index 0000000..a2b5b68 --- /dev/null +++ b/tv_src/bluetooth-pan.c @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <glib.h> +#include <dlog.h> +#include <stdio.h> +#include <stdbool.h> +#include <string.h> +#include <bluetooth-api.h> + +#include "bluetooth.h" +#include "bluetooth_private.h" + +#ifdef TIZEN_PAN_DISABLE +#define BT_CHECK_PAN_SUPPORT() \ + { \ + BT_CHECK_BT_SUPPORT(); \ + LOGE("[%s] NOT_SUPPORTED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_SUPPORTED); \ + return BT_ERROR_NOT_SUPPORTED; \ + } +#else +#define BT_CHECK_PAN_SUPPORT() +#endif + +int bt_nap_activate(void) +{ + int error = BT_ERROR_NONE; + + BT_CHECK_PAN_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error = bluetooth_network_activate_server(); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +int bt_nap_deactivate(void) +{ + int error = BT_ERROR_NONE; + + BT_CHECK_PAN_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error = bluetooth_network_deactivate_server(); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } + return error; +} + +/* bluez don't support the disconnect API about NAP server */ +/* So we implement this, deactivate the server and re-activate the server */ +int bt_nap_disconnect_all(void) +{ + int error = BT_ERROR_NONE; + + BT_CHECK_PAN_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error = bluetooth_network_deactivate_server(); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); + } else { + return bt_nap_activate(); + } + + return error; +} + +int bt_nap_set_connection_state_changed_cb( + bt_nap_connection_state_changed_cb callback, + void *user_data) +{ + BT_CHECK_PAN_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_NAP_CONNECTION_STATE_CHANGED, callback, user_data); + return BT_ERROR_NONE; + +} + +int bt_nap_unset_connection_state_changed_cb(void) +{ + _bt_unset_cb(BT_EVENT_NAP_CONNECTION_STATE_CHANGED); + return BT_ERROR_NONE; +} + +int bt_panu_set_connection_state_changed_cb( + bt_panu_connection_state_changed_cb callback, + void *user_data) +{ + BT_CHECK_PAN_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_PAN_CONNECTION_STATE_CHANGED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_panu_unset_connection_state_changed_cb(void) +{ + _bt_unset_cb(BT_EVENT_PAN_CONNECTION_STATE_CHANGED); + return BT_ERROR_NONE; +} + +int bt_panu_connect(const char *remote_address, bt_panu_service_type_e type) +{ + int error = BT_ERROR_INVALID_PARAMETER; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_PAN_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + _bt_convert_address_to_hex(&addr_hex, remote_address); + if (BT_PANU_SERVICE_TYPE_NAP == type) { + error = bluetooth_network_connect(&addr_hex, + BLUETOOTH_NETWORK_NAP_ROLE, NULL); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), + error); + } + } + return error; +} + +int bt_panu_disconnect(const char *remote_address) +{ + int error = BT_ERROR_INVALID_PARAMETER; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_PAN_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + _bt_convert_address_to_hex(&addr_hex, remote_address); + error = bluetooth_network_disconnect(&addr_hex); + error = _bt_get_error_code(error); + if (error != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), + error); + } + return error; +} + diff --git a/tv_src/bluetooth-socket.c b/tv_src/bluetooth-socket.c new file mode 100644 index 0000000..d5bd896 --- /dev/null +++ b/tv_src/bluetooth-socket.c @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <stdio.h> +#include <bluetooth-api.h> + +#include "bluetooth.h" +#include "bluetooth_private.h" + +int bt_socket_create_rfcomm(const char *uuid, int *socket_fd) +{ + int ret = 0; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(uuid); + BT_CHECK_INPUT_PARAMETER(socket_fd); + + ret = bluetooth_rfcomm_create_socket(uuid); + if (ret < 0) { + ret = _bt_get_error_code(ret); + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + return ret; + } else { + *socket_fd = ret; + return BT_ERROR_NONE; + } +} + +int bt_socket_destroy_rfcomm(int socket_fd) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(bluetooth_rfcomm_remove_socket(socket_fd)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_socket_is_service_used(const char* service_uuid, bool *used) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(service_uuid); + BT_CHECK_INPUT_PARAMETER(used); + + *used = bluetooth_rfcomm_is_server_uuid_available(service_uuid); + + return BT_ERROR_NONE; +} + +int bt_socket_listen_and_accept_rfcomm(int socket_fd, int max_pending_connections) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + error_code = _bt_get_error_code(bluetooth_rfcomm_listen_and_accept(socket_fd, max_pending_connections)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_socket_listen(int socket_fd, int max_pending_connections) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_rfcomm_listen(socket_fd, max_pending_connections)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_socket_accept_sync(int socket_fd, int *connected_socket_fd) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_rfcomm_accept_connection(socket_fd, connected_socket_fd)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_socket_accept(int socket_fd, int *connected_socket_fd) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_rfcomm_accept_connection(socket_fd, connected_socket_fd)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_socket_reject(int socket_fd) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_rfcomm_reject_connection(socket_fd)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_socket_connect_rfcomm(const char *remote_address, const char *remote_port_uuid) +{ + bluetooth_device_address_t addr_hex = { {0,} }; + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); + BT_CHECK_INPUT_PARAMETER(remote_port_uuid); + + _bt_convert_address_to_hex(&addr_hex, remote_address); + + error_code = _bt_get_error_code(bluetooth_rfcomm_connect(&addr_hex, remote_port_uuid)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_socket_disconnect_rfcomm(int socket_fd) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(bluetooth_rfcomm_disconnect(socket_fd)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_socket_send_data(int socket_fd, const char *data, int length) +{ + int ret = 0; + + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + ret = bluetooth_rfcomm_write(socket_fd, data, length); + if (ret == BLUETOOTH_ERROR_NOT_IN_OPERATION) { + BT_ERR("OPERATION_FAILED(0x%08x)", BT_ERROR_OPERATION_FAILED); + return BT_ERROR_OPERATION_FAILED; + } + + ret = _bt_get_error_code(ret); + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + } + + return ret; +} + +int bt_socket_set_data_received_cb(bt_socket_data_received_cb callback, void *user_data) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_DATA_RECEIVED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_socket_unset_data_received_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_DATA_RECEIVED); + return BT_ERROR_NONE; +} + +int bt_socket_set_connection_requested_cb(bt_socket_connection_requested_cb callback, void *user_data) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_RFCOMM_CONNECTION_REQUESTED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_socket_unset_connection_requested_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_RFCOMM_CONNECTION_REQUESTED); + return BT_ERROR_NONE; +} + +int bt_socket_set_connection_state_changed_cb(bt_socket_connection_state_changed_cb callback, void *user_data) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_CONNECTION_STATE_CHANGED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_socket_unset_connection_state_changed_cb(void) +{ + BT_CHECK_BT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_CONNECTION_STATE_CHANGED); + return BT_ERROR_NONE; +} + diff --git a/tv_src/bluetooth-sync3d.c b/tv_src/bluetooth-sync3d.c new file mode 100644 index 0000000..56fece6 --- /dev/null +++ b/tv_src/bluetooth-sync3d.c @@ -0,0 +1,243 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <glib.h> +#include <dlog.h> +#include <stdio.h> +#include <bluetooth-api.h> + +#include "bluetooth.h" +#include "bluetooth_product.h" +#include "bluetooth_private.h" +#include "bluetooth-sync3d-api.h" + +int bt_sync3d_init(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_INIT_STATUS(); + + error_code = bluetooth_sync3d_init(_bt_sync3d_event_proxy); + + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + return error_code; +} + +int bt_sync3d_deinit(void) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_INIT_STATUS(); + + error_code = bluetooth_sync3d_deinit(); + + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + return error_code; +} + +int bt_sync3d_broadcast_on_off(bool on_off) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(set_3d_broadcast_on_off(on_off)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + return error_code; +} + +int bt_sync3d_set_association_notified_cb(bt_sync3d_association_notified_cb callback, + void *user_data) +{ + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_SYNC3D_ASSOCIATION_NOTIFIED, callback, user_data); + + return BT_ERROR_NONE; +} + +int bt_sync3d_unset_association_notified_cb(void) +{ + _bt_unset_cb(BT_EVENT_SYNC3D_ASSOCIATION_NOTIFIED); + return BT_ERROR_NONE; +} + +int bt_sync3d_set_event_received_cb(bt_sync3d_event_cb callback, + void *user_data) +{ + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_SYNC3D_VSPEC_EVENT_RECEIVED, callback, user_data); + + return BT_ERROR_NONE; +} + +int bt_sync3d_unset_event_received_cb(void) +{ + _bt_unset_cb(BT_EVENT_SYNC3D_VSPEC_EVENT_RECEIVED); + return BT_ERROR_NONE; +} + +int bt_sync3d_set_duty_for_broadcast(short duty) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(set_duty_for_broadcast(duty)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_sync3d_set_dealy_for_broadcast(short delay) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(set_dealy_for_broadcast(delay)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_sync3d_set_dtv_mode(bt_sync3d_dtv_mode mode, + const char *master_bd_addr) +{ + int error_code = BT_ERROR_NONE; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_INIT_STATUS(); + + if (mode == BT_SYNC3D_DTV_MODE_SLAVE) + BT_CHECK_INPUT_PARAMETER(master_bd_addr); + + _bt_convert_address_to_hex(&addr_hex, master_bd_addr); + error_code = _bt_get_error_code(set_dtv_mode(mode, &addr_hex)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_sync3d_set_pairing_mode(bool on_off) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(set_pairing_mode(on_off)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_sync3d_set_view_type(bt_sync3d_view_type view_type) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(set_view_type(view_type)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_sync3d_set_dual_audio_mode(bool on_off) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(set_dual_audio_mode(on_off)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_sync3d_get_sync_period(unsigned short *sync_period) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(sync_period); + + error_code = _bt_get_error_code(get_sync_period(sync_period)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_sync3d_set_rssi_for_proximity_pairing(short rssi) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(set_rssi_for_proximity_pairing(rssi)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} + +int bt_sync3d_set_vsync_detect(bool on_off) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_INIT_STATUS(); + + error_code = _bt_get_error_code(set_vsync_detect(on_off)); + if (error_code != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), + error_code); + } + + return error_code; +} |