From: h.sandeep Date: Tue, 25 Oct 2016 04:17:03 +0000 (+0530) Subject: PXP: Add base code Proximity Profile X-Git-Tag: submit/tizen/20161110.000647^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F82%2F93582%2F7;p=platform%2Fcore%2Fapi%2Fbluetooth.git PXP: Add base code Proximity Profile Change-Id: Icab8d0a83ea0aeb21b8e9d9555608214a3e8ad45 Signed-off-by: h.sandeep Signed-off-by: Gowtham Anandha Babu Signed-off-by: h.sandeep --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 626b0ba..067214e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,7 @@ src/bluetooth-avrcp.c src/bluetooth-gatt.c src/bluetooth-ipsp.c src/bluetooth-dpm.c +src/bluetooth-proximity.c ) IF (TIZEN_PROFILE_WEARABLE OR TIZEN_PROFILE_IVI) LIST(APPEND SOURCES src/bluetooth-pbap.c) diff --git a/include/bluetooth_private.h b/include/bluetooth_private.h index 2023522..f2c61f0 100644 --- a/include/bluetooth_private.h +++ b/include/bluetooth_private.h @@ -127,6 +127,7 @@ typedef enum { BT_EVENT_GET_RSSI_EVENT, /**< Get RSSI Strength callback */ BT_EVENT_LE_READ_MAXIMUM_DATA_LENGTH, /**< Read maximun LE data length callback */ BT_EVENT_SUPPORTED_TRUSTED_PROFILE_EVENT, /**< Trusted Profile callback */ + BT_EVENT_PROXIMITY_PROPERTY_CHANGED, /**< Proximity property changed */ #if defined(TIZEN_PROFILE_WEARABLE) || defined(TIZEN_PROFILE_IVI) BT_EVENT_PBAP_CONNECTION_STATUS, /**< PBAP connection status callback */ BT_EVENT_PBAP_PHONEBOOK_SIZE, /**< PBAP Phonebook Size status callback */ diff --git a/include/mobile/bluetooth_internal.h b/include/mobile/bluetooth_internal.h index 8e82632..9fb8067 100644 --- a/include/mobile/bluetooth_internal.h +++ b/include/mobile/bluetooth_internal.h @@ -3143,6 +3143,35 @@ int bt_ipsp_unset_connection_state_changed_cb(void); */ int bt_pbap_client_is_connected(const char *address, bool *connected_status); +/** + * @internal + * @brief Register the Proximity Profile. + */ +int bt_proximity_register(bt_proximity_role_t role, bt_proximity_property_changed_cb callback, void *user_data); + +/** + * @internal + * @brief Unregister the Proximity Profile. + */ +int bt_proximity_unregister(bt_proximity_role_t role); + +/** + * @internal + * @brief Set the Proximity Profile property value. + */ +int bt_proximity_set_property(const char *remote_address, bt_proximity_property_t property, int value); + +/** + * @internal + * @brief Read the Proximity Profile property value. + */ +int bt_proximity_get_property(const char *remote_address, bt_proximity_property_t property, int *value); + +/** + * @internal + * @brief Lists the Proximity Profile property/service supported. + */ +int bt_proximity_get_supported_services(const char *remote_address, int *supported_services); /** * @} */ diff --git a/include/mobile/bluetooth_type_internal.h b/include/mobile/bluetooth_type_internal.h index 65f57a1..545a705 100644 --- a/include/mobile/bluetooth_type_internal.h +++ b/include/mobile/bluetooth_type_internal.h @@ -406,6 +406,27 @@ typedef enum { BT_AUTH_PASSKEY_CONFIRM_REQUEST, /**< PASSKEY confirmation event to match PASSKEY in remote device */ } bt_authentication_type_info_e; +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_PROXIMITY_MODULE + * @brief Proximity Profile Role + * @since_tizen 3.0 + */ +typedef enum { + BT_PROXIMITY_REPORTER, /**< Proximity Profile Reporter role. */ + BT_PROXIMITY_MONITOR, /**< Proximity Profile Monitor role. */ +} bt_proximity_role_t; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_PROXIMITY_MODULE + * @brief Proximity Profile Role + * @since_tizen 3.0 + */ +typedef enum { + BT_PROXIMITY_LINKLOSS_ALERT = 0x01, /**< Proximity profile Link Loss alert property */ + BT_PROXIMITY_IMMEDIATE_ALERT = 0x02, /**< Proximity Profile Immediate alert property */ + BT_PROXIMITY_TX_POWER = 0x04, /**< Proximity Profile Immediate alert property */ +} bt_proximity_property_t; + /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Called when Trusted Profiles is changed. @@ -466,6 +487,12 @@ typedef void (*bt_ipsp_init_state_changed_cb) typedef void (*bt_ipsp_connection_state_changed_cb) (int result, bool connected, const char *remote_address, const char *iface_name, void *user_data); +/** + * @internal + * @brief Proximity profile property changed callback + */ +typedef void (*bt_proximity_property_changed_cb) + (int result, const char *remote_address, int role, int service_type, int prop_value, void *user_data); /** * @internal diff --git a/include/tv/bluetooth_internal.h b/include/tv/bluetooth_internal.h index 636b8d2..33ca0e6 100644 --- a/include/tv/bluetooth_internal.h +++ b/include/tv/bluetooth_internal.h @@ -3122,6 +3122,35 @@ int bt_ipsp_unset_connection_state_changed_cb(void); */ int bt_pbap_client_is_connected(const char *address, bool *connected_status); +/** + * @internal + * @brief Register the Proximity Profile. + */ +int bt_proximity_register(bt_proximity_role_t role, bt_proximity_property_changed_cb callback, void *user_data); + +/** + * @internal + * @brief Unregister the Proximity Profile. + */ +int bt_proximity_unregister(bt_proximity_role_t role); + +/** + * @internal + * @brief Set the Proximity Profile property value. + */ +int bt_proximity_set_property(const char *remote_address, bt_proximity_property_t property, int value); + +/** + * @internal + * @brief Read the Proximity Profile property value. + */ +int bt_proximity_get_property(const char *remote_address, bt_proximity_property_t property, int *value); + +/** + * @internal + * @brief Lists the Proximity Profile property/service supported. + */ +int bt_proximity_get_supported_services(const char *remote_address, int *supported_services); /** * @} */ diff --git a/include/tv/bluetooth_type_internal.h b/include/tv/bluetooth_type_internal.h index 33ae41e..4b6181a 100644 --- a/include/tv/bluetooth_type_internal.h +++ b/include/tv/bluetooth_type_internal.h @@ -406,6 +406,27 @@ typedef enum { BT_AUTH_PASSKEY_CONFIRM_REQUEST, /**< PASSKEY confirmation event to match PASSKEY in remote device */ } bt_authentication_type_info_e; +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_PROXIMITY_MODULE + * @brief Proximity Profile Role + * @since_tizen 3.0 + */ +typedef enum { + BT_PROXIMITY_REPORTER, /**< Proximity Profile Reporter role. */ + BT_PROXIMITY_MONITOR, /**< Proximity Profile Monitor role. */ +} bt_proximity_role_t; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_PROXIMITY_MODULE + * @brief Proximity Profile Role + * @since_tizen 3.0 + */ +typedef enum { + BT_PROXIMITY_LINKLOSS_ALERT = 0x01, /**< Proximity profile Link Loss alert property */ + BT_PROXIMITY_IMMEDIATE_ALERT = 0x02, /**< Proximity Profile Immediate alert property */ + BT_PROXIMITY_TX_POWER = 0x04, /**< Proximity Profile Immediate alert property */ +} bt_proximity_property_t; + /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Called when Trusted Profiles is changed. @@ -497,6 +518,12 @@ typedef void (*bt_adapter_authentication_req_cb)(int result, bt_authentication_t char *device_name, char *remote_addr, char *pass_key, void *user_data); +/** + * @brief Proximity profile property changed callback + */ +typedef void (*bt_proximity_property_changed_cb) + (int result, const char *remote_address, int role, int service_type, int prop_value, void *user_data); + /** * @} */ diff --git a/include/wearable/bluetooth_internal.h b/include/wearable/bluetooth_internal.h index 9599320..e6bde51 100644 --- a/include/wearable/bluetooth_internal.h +++ b/include/wearable/bluetooth_internal.h @@ -3291,6 +3291,35 @@ int bt_pbap_client_is_connected(const char *address, bool *connected_status); int bt_hid_device_send_custom_event(const char *remote_address, unsigned char report_id, const char *data, unsigned int data_len); +/** + * @internal + * @brief Register the Proximity Profile. + */ +int bt_proximity_register(bt_proximity_role_t role, bt_proximity_property_changed_cb callback, void *user_data); + +/** + * @internal + * @brief Unregister the Proximity Profile. + */ +int bt_proximity_unregister(bt_proximity_role_t role); + +/** + * @internal + * @brief Set the Proximity Profile property value. + */ +int bt_proximity_set_property(const char *remote_address, bt_proximity_property_t property, int value); + +/** + * @internal + * @brief Read the Proximity Profile property value. + */ +int bt_proximity_get_property(const char *remote_address, bt_proximity_property_t property, int *value); + +/** + * @internal + * @brief Lists the Proximity Profile property/service supported. + */ +int bt_proximity_get_supported_services(const char *remote_address, int *supported_services); /** * @} */ diff --git a/include/wearable/bluetooth_type_internal.h b/include/wearable/bluetooth_type_internal.h index 04abcc0..cd4cbce 100644 --- a/include/wearable/bluetooth_type_internal.h +++ b/include/wearable/bluetooth_type_internal.h @@ -423,6 +423,27 @@ typedef enum { BT_AUTH_PASSKEY_CONFIRM_REQUEST, /**< PASSKEY confirmation event to match PASSKEY in remote device */ } bt_authentication_type_info_e; +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_PROXIMITY_MODULE + * @brief Proximity Profile Role + * @since_tizen 3.0 + */ +typedef enum { + BT_PROXIMITY_REPORTER, /**< Proximity Profile Reporter role. */ + BT_PROXIMITY_MONITOR, /**< Proximity Profile Monitor role. */ +} bt_proximity_role_t; + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_PROXIMITY_MODULE + * @brief Proximity Profile Role + * @since_tizen 3.0 + */ +typedef enum { + BT_PROXIMITY_LINKLOSS_ALERT = 0x01, /**< Proximity profile Link Loss alert property */ + BT_PROXIMITY_IMMEDIATE_ALERT = 0x02, /**< Proximity Profile Immediate alert property */ + BT_PROXIMITY_TX_POWER = 0x04, /**< Proximity Profile Immediate alert property */ +} bt_proximity_property_t; + /** * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE * @brief Called when Trusted Profiles is changed. @@ -509,6 +530,12 @@ typedef void (*bt_adapter_authentication_req_cb)(int result, bt_authentication_t char *device_name, char *remote_addr, char *pass_key, void *user_data); +/** + * @brief Proximity profile property changed callback + */ +typedef void (*bt_proximity_property_changed_cb) + (int result, const char *remote_address, int role, int service_type, int prop_value, void *user_data); + /** * @} */ diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c index e27f6f8..23d33b8 100644 --- a/src/bluetooth-common.c +++ b/src/bluetooth-common.c @@ -1030,6 +1030,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us bluetooth_authentication_request_info_t *auth_information = NULL; bt_le_data_length_params_t *data_length_info = NULL; bt_ipsp_connection_info_t *bt_ipsp_iface_info = NULL; + bt_pxp_property_changed_params_t *bt_pxp_property_info = NULL; if (!__bt_need_to_handle(event)) return; @@ -2532,6 +2533,20 @@ 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_PXP_PROPERTY_CHANGED: { + BT_DBG("BLUETOOTH_EVENT_PXP_PROPERTY_CHANGED"); /* LCOV_EXCL_LINE */ + bt_pxp_property_info = (bt_pxp_property_changed_params_t *)(param->param_data); + _bt_convert_address_to_string(&device_addr, &bt_pxp_property_info->device_address); + + ((bt_proximity_property_changed_cb)bt_event_slot_container[event_index].callback) /* LCOV_EXCL_LINE */ + (_bt_get_error_code(param->result), device_addr, + bt_pxp_property_info->role, bt_pxp_property_info->service_type, + bt_pxp_property_info->alert_lvl, bt_event_slot_container[event_index].user_data); + + if (device_addr != NULL) + free(device_addr); /* LCOV_EXCL_STOP */ + break; + } default: break; } @@ -3063,6 +3078,8 @@ static int __bt_get_cb_index(int event) #endif case BLUETOOTH_EVENT_IPSP_INIT_STATE_CHANGED: return BT_EVENT_IPSP_INIT_STATE_CHANGED; + case BLUETOOTH_EVENT_PXP_PROPERTY_CHANGED: + return BT_EVENT_PROXIMITY_PROPERTY_CHANGED; default: return -1; } diff --git a/src/bluetooth-proximity.c b/src/bluetooth-proximity.c new file mode 100644 index 0000000..713e2d9 --- /dev/null +++ b/src/bluetooth-proximity.c @@ -0,0 +1,141 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +#include "bluetooth.h" +#include "bluetooth_internal.h" +#include "bluetooth_private.h" + +static int role_registered = -1; + +int bt_proximity_register(bt_proximity_role_t role, bt_proximity_property_changed_cb callback, void *user_data) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); /* LCOV_EXCL_LINE */ + + if (role == BT_PROXIMITY_REPORTER) { + /* register Reporter Role Here */ + error_code = _bt_get_error_code(bluetooth_register_proximity_reporter()); + if (error_code != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + role_registered = role; + + /* register the callback, common for both reporter and monitor roles */ + _bt_set_cb(BT_EVENT_PROXIMITY_PROPERTY_CHANGED, callback, user_data); + + return error_code; +} + +int bt_proximity_unregister(bt_proximity_role_t role) +{ + int error_code = BT_ERROR_NONE; + + BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON); + BT_CHECK_INIT_STATUS(); + + if (role == BT_PROXIMITY_REPORTER) { + /* Unregister Reporter Role Here */ + error_code = _bt_get_error_code(bluetooth_unregister_proximity_reporter()); + if (error_code != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + } + + /* unregister the callback, common for both reporter and monitor roles */ + _bt_unset_cb(BT_EVENT_PROXIMITY_PROPERTY_CHANGED); + role_registered = -1; + + return error_code; +} + +int bt_proximity_set_property(const char *remote_address, bt_proximity_property_t property, int value) +{ + int error_code = BT_ERROR_NONE; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); /* LCOV_EXCL_LINE */ + + if (role_registered != BT_PROXIMITY_MONITOR) + return BT_ERROR_NOT_SUPPORTED; + + _bt_convert_address_to_hex(&addr_hex, remote_address); /* LCOV_EXCL_LINE */ + + error_code = _bt_get_error_code(bluetooth_set_proximity_property(&addr_hex, property, value)); + 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_proximity_get_property(const char *remote_address, bt_proximity_property_t property, int *value) +{ + int error_code = BT_ERROR_NONE; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); /* LCOV_EXCL_LINE */ + + if (role_registered != BT_PROXIMITY_MONITOR) + return BT_ERROR_NOT_SUPPORTED; + + _bt_convert_address_to_hex(&addr_hex, remote_address); /* LCOV_EXCL_LINE */ + + error_code = _bt_get_error_code(bluetooth_get_proximity_property(&addr_hex, property, value)); + + 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_proximity_get_supported_services(const char *remote_address, int *supported_services) +{ + int error_code = BT_ERROR_NONE; + bluetooth_device_address_t addr_hex = { {0,} }; + + BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(remote_address); /* LCOV_EXCL_LINE */ + + if (role_registered != BT_PROXIMITY_MONITOR) + return BT_ERROR_NOT_SUPPORTED; + + _bt_convert_address_to_hex(&addr_hex, remote_address); /* LCOV_EXCL_LINE */ + + error_code = _bt_get_error_code(bluetooth_get_proximity_supported_services(&addr_hex, supported_services)); + + if (error_code != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); + + + return error_code; +} + +/* LCOV_EXCL_STOP */ diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c index 06d4587..5c4644e 100644 --- a/test/bt_unit_test.c +++ b/test/bt_unit_test.c @@ -171,6 +171,8 @@ tc_table_t tc_main[] = { , BT_UNIT_TEST_TABLE_HDP}, {"DPM" , BT_UNIT_TEST_TABLE_DPM}, + {"PXP" + , BT_UNIT_TEST_TABLE_PXP}, #if defined(TIZEN_PROFILE_WEARABLE) || defined(TIZEN_PROFILE_IVI) {"HF Role" , BT_UNIT_TEST_TABLE_HF}, @@ -689,6 +691,28 @@ tc_table_t tc_hps[] = { {NULL , 0x0000}, }; +tc_table_t tc_pxp[] = { + /* HPS functions */ + {"BACK" + , BT_UNIT_TEST_FUNCTION_BACK}, + {"Proximity (Register)" + , BT_UNIT_TEST_FUNCTION_PXP_REGISTER}, + {"Proximity (Unregister)" + , BT_UNIT_TEST_FUNCTION_PXP_UNREGISTER}, + {"Proximity (Connect as Monitor)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT}, + {"Proximity (Disconnect Monitor)" + , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT}, + {"Proximity (Write Alert Level)" + , BT_UNIT_TEST_FUNCTION_PXP_WRITE_ALERT_LEVEL}, + {"Proximity (Read Alert Level)" + , BT_UNIT_TEST_FUNCTION_PXP_READ_ALERT_LEVEL}, + {"Proximity (Get Supported Services)" + , BT_UNIT_TEST_FUNCTION_PXP_GET_SUPPORTED_SERVICES}, + {"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 */ @@ -1107,6 +1131,9 @@ void tc_usage_print(void) case BT_UNIT_TEST_TABLE_DPM: tc_table = tc_DPM; break; + case BT_UNIT_TEST_TABLE_PXP: + tc_table = tc_pxp; + break; #if defined(TIZEN_PROFILE_WEARABLE) || defined(TIZEN_PROFILE_IVI) case BT_UNIT_TEST_TABLE_HF: tc_table = tc_hf; @@ -2426,6 +2453,45 @@ void __bt_HP_client_cp_req_status_changed_cb(bt_gatt_h chr, return; } +void __bt_pxp_montior_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) { + int property = 0; + + TC_PRT("PXP Monitor connected(address = %s)", remote_address); + + ret = bt_proximity_get_supported_services(remote_addr, &property); + TC_PRT("bt_proximity_get_supported_service returns %s\n", + __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) { + TC_PRT("PXP Monitor supported Service\n"); + if (property & BT_PROXIMITY_LINKLOSS_ALERT) + TC_PRT("BT_PROXIMITY_LINKLOSS_ALERT\n"); + if (property & BT_PROXIMITY_IMMEDIATE_ALERT) + TC_PRT("BT_PROXIMITY_IMMEDIATE_ALERT\n"); + if (property & BT_PROXIMITY_TX_POWER) + TC_PRT("BT_PROXIMITY_TX_POWER\n"); + } + } else { + TC_PRT("PXP Monitor DISconnected"); + ret = bt_gatt_unset_connection_state_changed_cb(); + } +} + +void __bt_proximity_property_changed_cb(int result, const char *remote_address, + int role, int service_type, + int prop_value, void *user_data) +{ + TC_PRT("result [%s]", __bt_get_error_message(result)); + TC_PRT("remote_address : %s", remote_address); + TC_PRT("Role : %d", role); + TC_PRT("service_type : %d", service_type); + TC_PRT("prop_value : %d", prop_value); +} + void __bt_gatt_server_notification_sent_cb(int result, const char *remote_address, bt_gatt_server_h server, bt_gatt_h characteristic, bool completed, void *user_data) @@ -4129,6 +4195,129 @@ int test_set_params(int test_id, char *param) break; } + case BT_UNIT_TEST_TABLE_PXP: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_PXP_REGISTER: + case BT_UNIT_TEST_FUNCTION_PXP_UNREGISTER: { + 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); + strncpy(g_test_param.params[param_index - 1], param, strlen(param)); + } + + if (param_index == g_test_param.param_count) { + need_to_set_params = false; +#ifdef ARCH64 + test_input_callback((void *)(uintptr_t)test_id); +#else + test_input_callback((void *)test_id); +#endif + param_index = 0; + return 0; + } + switch (param_index) { + case 0: + TC_PRT("Input Value Type (avail. : \n0.BT_PROXIMITY_REPORTER, \n1.BT_PROXIMITY_MONITOR"); + break; + } + + TC_PRT("Input param(%d) type:%s", + param_index + 1, param_type); + param_index++; + + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_WRITE_ALERT_LEVEL: { + if (param_index == 0) { + g_test_param.param_count = 2; + 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) { + int len = strlen(param); + g_test_param.params[param_index - 1] = g_malloc0(len + 1); + /* Remove new line character */ + param[len - 1] = '\0'; + strncpy(g_test_param.params[param_index - 1], param, strlen(param)); + } + + if (param_index == g_test_param.param_count) { + need_to_set_params = false; +#ifdef ARCH64 + test_input_callback((void *)(uintptr_t)test_id); +#else + test_input_callback((void *)test_id); +#endif + param_index = 0; + return 0; + } + + switch (param_index) { + case 0: + TC_PRT("Input Value Type (avail. : \n1.BT_PROXIMITY_LINKLOSS_ALERT, \n2.BT_PROXIMITY_IMMEDIATE_ALERT"); + break; + case 1: + TC_PRT("Input Value Type (avail. : \n0.NONE, \n1.MILD, \n2.HIGH"); + break; + } + + param_index++; + + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_READ_ALERT_LEVEL: { + 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) { + int len = strlen(param); + g_test_param.params[param_index - 1] = g_malloc0(len + 1); + /* Remove new line character */ + param[len - 1] = '\0'; + strncpy(g_test_param.params[param_index - 1], param, strlen(param)); + } + + if (param_index == g_test_param.param_count) { + need_to_set_params = false; +#ifdef ARCH64 + test_input_callback((void *)(uintptr_t)test_id); +#else + test_input_callback((void *)test_id); +#endif + param_index = 0; + return 0; + } + + switch (param_index) { + case 0: + TC_PRT("Input Value Type (avail. : \n1.BT_PROXIMITY_LINKLOSS_ALERT, \n2.BT_PROXIMITY_IMMEDIATE_ALERT"); + 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: @@ -8809,6 +8998,98 @@ int test_input_callback(void *data) } break; } + + case BT_UNIT_TEST_TABLE_PXP: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_PXP_REGISTER: { + int role; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + role = atoi(g_test_param.params[0]); + ret = bt_proximity_register(role, __bt_proximity_property_changed_cb, NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_UNREGISTER: { + int role; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + role = atoi(g_test_param.params[0]); + ret = bt_proximity_unregister(role); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT: { + bool auto_connect = false; + + 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_pxp_montior_connection_state_changed_cb, + NULL); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT: { + ret = bt_gatt_disconnect(remote_addr); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_WRITE_ALERT_LEVEL: { + int property, alert_value; + if (g_test_param.param_count < 2) { + TC_PRT("Input parameters first"); + break; + } + property = atoi(g_test_param.params[0]); + alert_value = atoi(g_test_param.params[1]); + ret = bt_proximity_set_property(remote_addr, property, alert_value); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_READ_ALERT_LEVEL: { + int alert_level = 0; + int property; + if (g_test_param.param_count < 1) { + TC_PRT("Input parameters first"); + break; + } + property = atoi(g_test_param.params[0]); + ret = bt_proximity_get_property(remote_addr, property, &alert_level); + TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level); + break; + } + case BT_UNIT_TEST_FUNCTION_PXP_GET_SUPPORTED_SERVICES: { + int property = 0; + + ret = bt_proximity_get_supported_services(remote_addr, &property); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + if (ret == BT_ERROR_NONE) { + if (property & BT_PROXIMITY_LINKLOSS_ALERT) + TC_PRT("BT_PROXIMITY_LINKLOSS_ALERT"); + if (property & BT_PROXIMITY_IMMEDIATE_ALERT) + TC_PRT("BT_PROXIMITY_IMMEDIATE_ALERT"); + if (property & BT_PROXIMITY_TX_POWER) + TC_PRT("BT_PROXIMITY_TX_POWER"); + } + 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; + } + #if defined(TIZEN_PROFILE_WEARABLE) || defined(TIZEN_PROFILE_IVI) case BT_UNIT_TEST_TABLE_HF: { switch (test_id) { diff --git a/test/bt_unit_test.h b/test/bt_unit_test.h index 64c9bdd..87c08c9 100644 --- a/test/bt_unit_test.h +++ b/test/bt_unit_test.h @@ -46,6 +46,7 @@ typedef enum { BT_UNIT_TEST_TABLE_IPSP, BT_UNIT_TEST_TABLE_HDP, BT_UNIT_TEST_TABLE_DPM, + BT_UNIT_TEST_TABLE_PXP, #if defined(TIZEN_PROFILE_WEARABLE) || defined(TIZEN_PROFILE_IVI) BT_UNIT_TEST_TABLE_HF, BT_UNIT_TEST_TABLE_PBAP_CLIENT, @@ -437,6 +438,13 @@ typedef enum { BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_ONOFF, BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_VISIBILITY, BT_UNIT_TEST_FUNCTION_CHECK_FEATURE, + BT_UNIT_TEST_FUNCTION_PXP_REGISTER = 1, + BT_UNIT_TEST_FUNCTION_PXP_UNREGISTER, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT, + BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT, + BT_UNIT_TEST_FUNCTION_PXP_WRITE_ALERT_LEVEL, + BT_UNIT_TEST_FUNCTION_PXP_READ_ALERT_LEVEL, + BT_UNIT_TEST_FUNCTION_PXP_GET_SUPPORTED_SERVICES, BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS = 0XFF, } bt_unit_test_function_e;