PXP: Add base code Proximity Profile 82/93582/7 accepted/tizen/common/20161110.190128 accepted/tizen/ivi/20161111.001144 accepted/tizen/mobile/20161111.001046 accepted/tizen/tv/20161111.001103 accepted/tizen/wearable/20161111.001125 submit/tizen/20161110.000647
authorh.sandeep <h.sandeep@samsung.com>
Tue, 25 Oct 2016 04:17:03 +0000 (09:47 +0530)
committerh.sandeep <h.sandeep@samsung.com>
Wed, 9 Nov 2016 04:47:42 +0000 (10:17 +0530)
Change-Id: Icab8d0a83ea0aeb21b8e9d9555608214a3e8ad45
Signed-off-by: h.sandeep <h.sandeep@samsung.com>
Signed-off-by: Gowtham Anandha Babu <gowtham.ab@samsung.com>
Signed-off-by: h.sandeep <h.sandeep@samsung.com>
12 files changed:
CMakeLists.txt
include/bluetooth_private.h
include/mobile/bluetooth_internal.h
include/mobile/bluetooth_type_internal.h
include/tv/bluetooth_internal.h
include/tv/bluetooth_type_internal.h
include/wearable/bluetooth_internal.h
include/wearable/bluetooth_type_internal.h
src/bluetooth-common.c
src/bluetooth-proximity.c [new file with mode: 0644]
test/bt_unit_test.c
test/bt_unit_test.h

index 626b0bac215398d5c77472f032ef38d4322cba5c..067214efea762eed587997a1082a3358db00e370 100644 (file)
@@ -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)
index 2023522d7aa1163b95e01d92bfcbb432a08c1096..f2c61f080a9ee1c769c3c88d81a69e8952c9d6e1 100644 (file)
@@ -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 */
index 8e8263290160a2ad046e68455810d4fd036a51de..9fb8067288194c772dad4fe04551937e9e9c7db7 100644 (file)
@@ -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);
 /**
  * @}
  */
index 65f57a124325c70d8ac863bf4c176efbe5889874..545a7054c8b59e9e8a7c173601b6d3a0e5f7a738 100644 (file)
@@ -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
index 636b8d20287add3ed41ea52c20dd98d4a3853686..33ca0e6d0b79813f9bff2f077e14935cf072054e 100644 (file)
@@ -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);
 /**
  * @}
  */
index 33ae41e87be6a4e874ba1f21bc9cf3db7a3397d0..4b6181aea62a6e8d7682ebf51f3ecac32d439c14 100644 (file)
@@ -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);
+
 /**
  * @}
  */
index 95993202d1c5540da9ab3930d7ea448bfa09bd6f..e6bde51200fdf4e47ac346d486da211acf3313f1 100644 (file)
@@ -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);
 /**
  * @}
  */
index 04abcc0ef096648eedd6f9f5b3ec22f72c84c98f..cd4cbce4a3bdef5ba0a956d25acef51b56377ee9 100644 (file)
@@ -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);
+
 /**
  * @}
  */
index e27f6f868b80676ff5d11f724db71a4a2da64e0c..23d33b8c1b7df43d644370854db32099d7025372 100644 (file)
@@ -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 (file)
index 0000000..713e2d9
--- /dev/null
@@ -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 <glib.h>
+#include <dlog.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <string.h>
+#include <bluetooth-api.h>
+
+#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 */
index 06d45876c649bd6d8752a3bbaa72a4b1e014bcc4..5c4644e519ac243ff46b649990c06842ea99f198 100644 (file)
@@ -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) {
index 64c9bdd031f63e4928d469fc0d654fab4841fed9..87c08c9b84ea70086c0338bae803457a6db6a2be 100644 (file)
@@ -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;