Modify HRP APIs for testcase 44/188744/4
authorDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 10 Sep 2018 03:57:28 +0000 (12:57 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 10 Sep 2018 04:44:20 +0000 (13:44 +0900)
Change-Id: Ib99455bf2caf8cd183c386c19be3e03fc8d75331
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
include/bluetooth_internal.h
include/bluetooth_private.h
src/bluetooth-hrp.c
test/bt_unit_test.c

index b8a6b6c..eb9953a 100644 (file)
@@ -4420,7 +4420,7 @@ int bt_hrp_sensor_update_heartrate_value(int heartrate);
  * @brief HRP Sensor API to destory heart rate sensor .
  */
 
-int bt_hrp_sensor_destroy();
+int bt_hrp_sensor_destroy(void);
 
 /**
  * @internal
@@ -4434,31 +4434,31 @@ int bt_hrp_collector_create(const char *remote_address,
  * @internal
  * @brief HRP collector API to destory collector.
  */
-void bt_hrp_collector_destory(bt_hrp_collector_h collector);
+int bt_hrp_collector_destory(bt_hrp_collector_h collector);
 
 /**
  * @internal
  * @brief HRP collector API to start scan .
  */
-int bt_hrp_collector_start_scan();
+int bt_hrp_collector_start_scan(bt_adapter_le_scan_result_cb cb);
 
 /**
  * @internal
  * @brief HRP collector API to stop scan.
  */
-int bt_hrp_collector_stop_scan();
+int bt_hrp_collector_stop_scan(void);
 
 /**
  * @internal
  * @brief HRP collector API to connect to remote sensor .
  */
-int bt_hrp_collector_connect(const char *address, bool auto_connect);
+int bt_hrp_collector_connect(bt_hrp_collector_h collector);
 
 /**
  * @internal
  * @brief HRP collector API to disconnect to remote sensor .
  */
-int bt_hrp_collector_disconnect(const char *address);
+int bt_hrp_collector_disconnect(bt_hrp_collector_h collector);
 
 /**
  * @internal
@@ -4473,7 +4473,7 @@ int bt_hrp_collector_set_notification(bt_hrp_collector_h collector,
  * @brief HRP collector API to read Body Sensor location , fills body sensor location in bsl_location
  */
 
-bt_body_sensor_location_e bt_hrp_get_body_sensor_location(bt_hrp_collector_h collector,
+int bt_hrp_collector_get_body_sensor_location(bt_hrp_collector_h collector,
                        bt_hrp_collector_bsl_read_completed_cb bsl_read_cb);
 
 
index 57c225d..10ea7a6 100644 (file)
@@ -587,9 +587,6 @@ typedef void (*bt_adapter_passkey_notification_cb)(const char *remote_address, c
 #define BT_FEATURE_OOB "tizen.org/feature/network.bluetooth.oob"
 #define BT_FEATURE_GATT_SERVER "tizen.org/feature/network.bluetooth.le.gatt.server"
 #define BT_FEATURE_GATT_CLIENT "tizen.org/feature/network.bluetooth.le.gatt.client"
-#define BT_FEATURE_HRS "tizen.org/feature/network.bluetooth.le.hrp.sensor"
-#define BT_FEATURE_HRC "tizen.org/feature/network.bluetooth.le.hrp.collector"
-
 
 #define BT_CHECK_SUPPORTED_FEATURE(feature_name) \
 do     { \
index 7ac98ed..812e5dc 100755 (executable)
 { \
        BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON); \
        BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE); \
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_HRS); \
 }
 
 #define BT_CHECK_HRC_SUPPORT() \
 { \
        BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON); \
        BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE); \
-       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_HRC); \
 }
 
 /*======================================================================================================
@@ -516,7 +514,6 @@ void __bt_hrp_le_connection_state_changed_cb(int result,
 
 int bt_hrp_sensor_set_heartrate_value(int heartrate)
 {
-
        BT_CHECK_HRS_SUPPORT();
        BT_CHECK_INIT_STATUS();
 
@@ -738,7 +735,7 @@ int bt_hrp_sensor_start(bt_hrp_sensor_advertising_state_changed_cb cb)
 
 }
 
-int bt_hrp_sensor_stop()
+int bt_hrp_sensor_stop(void)
 {
        BT_CHECK_HRS_SUPPORT();
        BT_CHECK_INIT_STATUS();
@@ -785,7 +782,7 @@ int bt_hrp_sensor_update_heartrate_value(int heartrate)
 
 }
 
-int bt_hrp_sensor_destroy()
+int bt_hrp_sensor_destroy(void)
 {
        BT_CHECK_HRS_SUPPORT();
        BT_CHECK_INIT_STATUS();
@@ -793,6 +790,10 @@ int bt_hrp_sensor_destroy()
        BT_INFO("[HR]bt_gatt_server_destroy GATT Destroy\n");
 
        int error_code = BT_ERROR_NOT_INITIALIZED;
+
+       if (hrp_server_info_s.hrp_sensor == NULL)
+               return BT_ERROR_NOT_INITIALIZED;
+
        bt_gatt_destroy(hrp_server_info_s.hrs_descriptor);
        bt_gatt_destroy(hrp_server_info_s.hrs_characteristic);
        bt_gatt_destroy(hrp_server_info_s.dis_characteristic);
@@ -816,6 +817,8 @@ int bt_hrp_sensor_destroy()
                return error_code;
        }
 
+       hrp_server_info_s.hrp_sensor = NULL;
+
        BT_INFO("[HR]bt_gatt_server_destroy Server Deinit\n");
 
        error_code = bt_gatt_server_deinitialize();
@@ -984,8 +987,11 @@ int bt_hrp_collector_create(const char *remote_address, bt_hrp_collector_h *coll
        return error_code;
 }
 
-void bt_hrp_collector_destory(bt_hrp_collector_h collector)
+int bt_hrp_collector_destory(bt_hrp_collector_h collector)
 {
+       BT_CHECK_HRC_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(collector);
 
        bt_hrp_collector_s *collector_s = (bt_hrp_collector_s *)collector;
 
@@ -1000,6 +1006,7 @@ void bt_hrp_collector_destory(bt_hrp_collector_h collector)
                g_free(collector_s);
        }
 
+       return BT_ERROR_NONE;
 }
 
 static void __bt_hrp_le_scan_result_cb(int result,
@@ -1096,10 +1103,13 @@ int bt_hrp_collector_start_scan(bt_adapter_le_scan_result_cb cb)
 
 }
 
-int bt_hrp_collector_stop_scan()
+int bt_hrp_collector_stop_scan(void)
 {
        int error_code = BT_ERROR_NONE;
 
+       BT_CHECK_HRC_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+
        error_code = bt_adapter_le_stop_scan();
        BT_ERR("returns %s\n", _bt_convert_error_to_string(error_code));
 
@@ -1109,15 +1119,18 @@ int bt_hrp_collector_stop_scan()
 
 }
 
-int bt_hrp_collector_connect(const char *address, bool auto_connect)
+int bt_hrp_collector_connect(bt_hrp_collector_h collector)
 {
 
        int error_code = BT_ERROR_NONE;
 
        BT_CHECK_HRC_SUPPORT();
        BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(collector);
+
+       bt_hrp_collector_s *collector_s = (bt_hrp_collector_s *)collector;
 
-       error_code = bt_gatt_connect(address, auto_connect);
+       error_code = bt_gatt_connect(collector_s->remote_address, false);
 
        if (error_code != BT_ERROR_NONE)
                BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
@@ -1125,12 +1138,16 @@ int bt_hrp_collector_connect(const char *address, bool auto_connect)
        return error_code;
 }
 
-int bt_hrp_collector_disconnect(const char *address)
+int bt_hrp_collector_disconnect(bt_hrp_collector_h collector)
 {
        int error_code = BT_ERROR_NONE;
        BT_CHECK_HRC_SUPPORT();
        BT_CHECK_INIT_STATUS();
-       error_code = bt_gatt_disconnect(address);
+       BT_CHECK_INPUT_PARAMETER(collector);
+
+       bt_hrp_collector_s *collector_s = (bt_hrp_collector_s *)collector;
+
+       error_code = bt_gatt_disconnect(collector_s->remote_address);
 
        if (error_code != BT_ERROR_NONE)
                BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
@@ -1142,6 +1159,10 @@ int bt_hrp_collector_set_notification(bt_hrp_collector_h collector,
                bt_hrp_collector_heart_rate_value_changed_cb callback,
                bool isNotify)
 {
+       BT_CHECK_HRC_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(collector);
+
        int error_code = BT_ERROR_NONE;
        bt_hrp_collector_s *collector_s = (bt_hrp_collector_s *)collector;
        bt_gatt_h svc = NULL;
@@ -1149,10 +1170,6 @@ int bt_hrp_collector_set_notification(bt_hrp_collector_h collector,
        bt_gatt_h desc = NULL;
        char *buf = (char *)&isNotify;
 
-       BT_CHECK_HRC_SUPPORT();
-       BT_CHECK_INIT_STATUS();
-       BT_CHECK_INPUT_PARAMETER(collector_s);
-
        if (_bt_hrp_collector_find(collector_s->remote_address) == NULL)
                return BT_ERROR_NOT_INITIALIZED;
 
@@ -1198,18 +1215,18 @@ int bt_hrp_collector_set_notification(bt_hrp_collector_h collector,
        return error_code;
 }
 
-bt_body_sensor_location_e bt_hrp_get_body_sensor_location(bt_hrp_collector_h collector,
+int bt_hrp_collector_get_body_sensor_location(bt_hrp_collector_h collector,
                        bt_hrp_collector_bsl_read_completed_cb bsl_read_cb)
 {
        int error_code = BT_ERROR_NONE;
        bt_gatt_h svc = NULL;
        bt_gatt_h chr = NULL;
 
-       bt_hrp_collector_s *collector_s = (bt_hrp_collector_s *)collector;
-
        BT_CHECK_HRC_SUPPORT();
        BT_CHECK_INIT_STATUS();
-       BT_CHECK_INPUT_PARAMETER(collector_s);
+       BT_CHECK_INPUT_PARAMETER(collector);
+
+       bt_hrp_collector_s *collector_s = (bt_hrp_collector_s *)collector;
 
        if (_bt_hrp_collector_find(collector_s->remote_address) == NULL)
                return BT_ERROR_NOT_INITIALIZED;
index 0127415..8a67a81 100644 (file)
@@ -9722,27 +9722,28 @@ int test_input_callback(void *data)
                }
                case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECT: {
                                TC_PRT("HR COLLECTOR CONNECT\n");
-                               ret = bt_hrp_collector_connect(remote_addr, true);
+                               ret = bt_hrp_collector_connect(collector);
                                TC_PRT("returns %s\n", __bt_get_error_message(ret));
                                break;
                }
                case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DISCONNECT: {
                                TC_PRT("HR COLLECTOR DISCONNECT\n");
-                               ret = bt_hrp_collector_disconnect(remote_addr);
+                               ret = bt_hrp_collector_disconnect(collector);
                                TC_PRT("returns %s\n", __bt_get_error_message(ret));
                                break;
                }
                case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_GET_BSL_LOC: {
                                TC_PRT("HR COLLECTOR GET BSL LOCATION\n");
                                if (collector) {
-                                       ret = bt_hrp_get_body_sensor_location(collector, _bt_hrp_collector_bsl_read_completed_cb);
+                                       ret = bt_hrp_collector_get_body_sensor_location(collector, _bt_hrp_collector_bsl_read_completed_cb);
                                        TC_PRT("returns %s\n", __bt_get_error_message(ret));
                                }
                                break;
                }
                case BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DESTROY: {
                                TC_PRT("HR COLLECTOR DESTROY\n");
-                               bt_hrp_collector_destory(collector);
+                               ret = bt_hrp_collector_destory(collector);
+                               TC_PRT("returns %s\n", __bt_get_error_message(ret));
                                break;
                }
                default: