diff options
author | DoHyun Pyun <dh79.pyun@samsung.com> | 2016-10-25 14:11:22 +0900 |
---|---|---|
committer | DoHyun Pyun <dh79.pyun@samsung.com> | 2016-10-25 14:11:22 +0900 |
commit | 1c707c0cffd87dc6ba358dc79111f25205f450a4 (patch) | |
tree | 7fcda9852a09e0c10cbf87b6c18fde0e79e9212a | |
parent | 1211f1cff2b2a96339f6befce770a4b8c2315f6d (diff) | |
download | bluetooth-1c707c0cffd87dc6ba358dc79111f25205f450a4.tar.gz bluetooth-1c707c0cffd87dc6ba358dc79111f25205f450a4.tar.bz2 bluetooth-1c707c0cffd87dc6ba358dc79111f25205f450a4.zip |
Add the internal API to get the pbap connected statussubmit/tizen_3.0/20161102.022329accepted/tizen/3.0/wearable/20161103.002116accepted/tizen/3.0/tv/20161103.002100accepted/tizen/3.0/mobile/20161103.002040accepted/tizen/3.0/ivi/20161103.002130
Change-Id: Ied719209bd17b9b9dd541d30852a62e590c0b6f5
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
-rw-r--r-- | include/mobile/bluetooth_internal.h | 19 | ||||
-rw-r--r-- | include/tv/bluetooth_internal.h | 19 | ||||
-rw-r--r-- | include/wearable/bluetooth_internal.h | 19 | ||||
-rw-r--r-- | src/bluetooth-pbap.c | 25 | ||||
-rw-r--r-- | test/bt_unit_test.c | 13 | ||||
-rw-r--r-- | test/bt_unit_test.h | 1 |
6 files changed, 96 insertions, 0 deletions
diff --git a/include/mobile/bluetooth_internal.h b/include/mobile/bluetooth_internal.h index a6d097e..36c1e44 100644 --- a/include/mobile/bluetooth_internal.h +++ b/include/mobile/bluetooth_internal.h @@ -3149,6 +3149,25 @@ int bt_ipsp_set_connection_state_changed_cb(bt_ipsp_connection_state_changed_cb int bt_ipsp_unset_connection_state_changed_cb(void); /** + * @ingroup CAPI_NETWORK_BLUETOOTH_PBAP_MODULE + * @brief Gets the pbap connected status. + * @since_tizen 3.0 + * @param[in] remote_address The address of the remote device + * @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_pbap_client_is_connected(const char *address, bool *connected_status); + +/** * @} */ diff --git a/include/tv/bluetooth_internal.h b/include/tv/bluetooth_internal.h index a6d097e..36c1e44 100644 --- a/include/tv/bluetooth_internal.h +++ b/include/tv/bluetooth_internal.h @@ -3149,6 +3149,25 @@ int bt_ipsp_set_connection_state_changed_cb(bt_ipsp_connection_state_changed_cb int bt_ipsp_unset_connection_state_changed_cb(void); /** + * @ingroup CAPI_NETWORK_BLUETOOTH_PBAP_MODULE + * @brief Gets the pbap connected status. + * @since_tizen 3.0 + * @param[in] remote_address The address of the remote device + * @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_pbap_client_is_connected(const char *address, bool *connected_status); + +/** * @} */ diff --git a/include/wearable/bluetooth_internal.h b/include/wearable/bluetooth_internal.h index 291b0a0..a256820 100644 --- a/include/wearable/bluetooth_internal.h +++ b/include/wearable/bluetooth_internal.h @@ -3297,6 +3297,25 @@ int bt_ipsp_set_connection_state_changed_cb(bt_ipsp_connection_state_changed_cb int bt_ipsp_unset_connection_state_changed_cb(void); /** + * @ingroup CAPI_NETWORK_BLUETOOTH_PBAP_MODULE + * @brief Gets the pbap connected status. + * @since_tizen 3.0 + * @param[in] remote_address The address of the remote device + * @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_pbap_client_is_connected(const char *address, bool *connected_status); + +/** * @} */ diff --git a/src/bluetooth-pbap.c b/src/bluetooth-pbap.c index 6e81256..716f459 100644 --- a/src/bluetooth-pbap.c +++ b/src/bluetooth-pbap.c @@ -109,6 +109,31 @@ int bt_pbap_client_disconnect(const char *address) return error_code; } +int bt_pbap_client_is_connected(const char *address, bool *connected_status) +{ + bluetooth_device_address_t addr_hex = { {0,} }; + int ret; + gboolean is_connected = FALSE; + + BT_CHECK_PBAP_CLIENT_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(address); + + _bt_convert_address_to_hex(&addr_hex, address); + + ret = _bt_get_error_code(bluetooth_is_device_connected(&addr_hex, + BLUETOOTH_PBAP_SERVICE, &is_connected)); + *connected_status = is_connected ? true : false; + + if (ret != BT_ERROR_NONE) { + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); /* LCOV_EXCL_LINE */ + return ret; + } + + return ret; + +} + int bt_pbap_client_get_phone_book_size(const char *address, bt_pbap_address_book_source_e source, bt_pbap_folder_type_e folder_type, bt_pbap_phone_book_size_cb callback, void *user_data) { diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c index 9e9b2c4..6b6c612 100644 --- a/test/bt_unit_test.c +++ b/test/bt_unit_test.c @@ -1011,6 +1011,8 @@ tc_table_t tc_pbap_client[] = { , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_CONNECT}, {"bt_pbap_client_disconnect()" , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DISCONNECT}, + {"bt_pbap_client_is_connected()" + , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_IS_CONNECTED}, {"bt_pbap_client_get_phone_book_size()" , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE}, {"bt_pbap_client_get_phone_book()" @@ -8891,6 +8893,17 @@ int test_input_callback(void *data) TC_PRT("returns %s\n", __bt_get_error_message(ret)); break; } + case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_IS_CONNECTED: { + bool connected_status = false; + + ret = bt_pbap_client_is_connected(remote_addr, &connected_status); + if (ret < BT_ERROR_NONE) + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + TC_PRT("PBAP Profile [%s]", + connected_status ? "Connected" : "Disconnected"); + break; + } case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE: { ret = bt_pbap_client_get_phone_book_size(remote_addr, 0, 0, diff --git a/test/bt_unit_test.h b/test/bt_unit_test.h index 13162f1..edcc964 100644 --- a/test/bt_unit_test.h +++ b/test/bt_unit_test.h @@ -421,6 +421,7 @@ typedef enum { BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_UNSET_CONNECTION_STATE_CHANGED_CB, BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_CONNECT, BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DISCONNECT, + BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_IS_CONNECTED, BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE, BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKPULL, BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST, |