[Sensor] API merged ,removed and code refactoring. 34/189234/2 accepted/tizen/unified/20180918.062800 submit/tizen/20180916.233618 submit/tizen/20180917.042059
authorAbhishek Chandra <abhishek.ch@samsung.com>
Fri, 14 Sep 2018 11:21:43 +0000 (16:51 +0530)
committerAbhishek Chandra <abhishek.ch@samsung.com>
Sat, 15 Sep 2018 11:58:18 +0000 (17:28 +0530)
Changes are:
1) Functionality bt_hrp_sensor_update_heartrate_value
and bt_hrp_sensor_set_heartrate_value  are merged to
bt_hrp_sensor_set_heartrate_value .
2) removed bt_hrp_sensor_advertising_state_changed_cb
as this is not needed for application.
3) functionality of bt_hrp_sensor_start is merged
in bt_hrp_sensor_create .
4) functionality of bt_hrp_sensor_stop is merged
in bt_hrp_sensor_distroy.
5) Connected collector list in the sensor is removed ,
as sensor side connected is already managed by Gatt
server , so it was redundant and hence removed .
6) bt_hrp_sensor_unset_sensor_notification_state_change_cb
is removed, as is not needed by application .

Change-Id: I93ba307a9a9f06aa4a80a77571b502df61ffdd95
Signed-off-by: Abhishek Chandra <abhishek.ch@samsung.com>
include/bluetooth_internal.h
include/bluetooth_type_internal.h
src/bluetooth-hrp.c [changed mode: 0755->0644]
test/bt_unit_test.c
test/bt_unit_test.h

index eb9953a..d7a8180 100644 (file)
@@ -4344,7 +4344,7 @@ int bt_otp_client_delete_object(bt_otp_client_h otp_client,
 
 /**
  * @internal
- * @brief HRP Sensor API to set initial heart rate value , before creating sensor.
+ * @brief HRP Sensor API to set initial heart rate value , will also notify to all connected clients if notification is enabled .
  */
 int bt_hrp_sensor_set_heartrate_value(int heartrate);
 
@@ -4382,13 +4382,6 @@ int bt_hrp_sensor_set_device_manufacturer_name(char *manuf_name);
 
 /**
  * @internal
- * @brief HRP Sensor API to set Notification callback, before creating sensor.
- */
-int bt_hrp_sensor_set_sensor_notification_state_change_cb(
-                               bt_gatt_server_characteristic_notification_state_changed_cb     callback, void *user_data);
-
-/**
- * @internal
  * @brief HRP Sensor API for creating sensor and services.
  */
 
@@ -4396,27 +4389,6 @@ int bt_hrp_sensor_create(void);
 
 /**
  * @internal
- * @brief HRP Sensor API to start advertising .
- */
-
-int bt_hrp_sensor_start(bt_hrp_sensor_advertising_state_changed_cb cb);
-
-/**
- * @internal
- * @brief HRP Sensor API to stop advertising .
- */
-
-int bt_hrp_sensor_stop(void);
-
-/**
- * @internal
- * @brief HRP Sensor API to Notify Heartrate value.
- */
-
-int bt_hrp_sensor_update_heartrate_value(int heartrate);
-
-/**
- * @internal
  * @brief HRP Sensor API to destory heart rate sensor .
  */
 
@@ -4440,7 +4412,7 @@ int bt_hrp_collector_destory(bt_hrp_collector_h collector);
  * @internal
  * @brief HRP collector API to start scan .
  */
-int bt_hrp_collector_start_scan(bt_adapter_le_scan_result_cb cb);
+int bt_hrp_collector_start_scan(bt_hrp_collector_scan_result_cb cb);
 
 /**
  * @internal
index 790034f..7e78416 100644 (file)
@@ -1165,6 +1165,20 @@ typedef enum {
 } bt_serv_char_type_t;
 
 /**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE
+ * @brief  Called when the LE advertisement callback for HRP sensor has been found.
+ * @since_tizen 4.0
+ *
+ * @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
+ *
+ *
+ */
+typedef void (*bt_hrp_collector_scan_result_cb)(int result,
+               bt_adapter_le_device_scan_result_info_s *info, void *user_data);
+
+/**
  * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_CLIENT_MODULE
  * @brief  Called when the client request read operation on body sensor location has been completed.
  * @since_tizen 4
old mode 100755 (executable)
new mode 100644 (file)
index 812e5dc..1f416d0
 #define HEART_RATE_CONTROL_POINT_UUID  "2a39"
 #define DEVICE_INFORMATION_UUID                        "180a"
 
-#define HEART_RATE_CHARAC_CFG_UUID                                             "2902"
+#define HEART_RATE_CHARAC_CFG_UUID                                                     "2902"
 #define DEVICE_INFO_CHARAC_MANUFACTURER_NAME_STRING            "2A29"
 #define TODO 0
-//Connected Collector List
-typedef struct {
-       char *remote_address;
-       bool isconnected;
-} bt_hrp_collector_notify_info_s;
-
 //Server Info Local Structure
 typedef struct bt_hrp_server_info_s {
        //fill with Setter API's
@@ -84,10 +78,7 @@ typedef struct bt_hrp_server_info_s {
        bt_gatt_h hrs_descriptor;                                                                       // hrs cccd
        bt_gatt_h bsl_characteristic;                                                           // body sensor location
        bt_advertiser_h advertiser;
-       bt_hrp_sensor_advertising_state_changed_cb adv_app_cb;          //application callback for updating state changes
-       bt_gatt_server_characteristic_notification_state_changed_cb notif_app_cb; //application callback for updating notification
        bt_body_sensor_location_e body_sensor_location;                                                 //body sensor location
-       GSList *hrs_collector_connected_list;                                           //connected collector list , to be updated when read or write cccd request comes from client
 } bt_hrp_server_info_s;
 
 static guint adv_timer_id;
@@ -122,7 +113,6 @@ static const char * const bsl_str_enum[] = {
        "foot",
 };
 
-
 GSList *hrp_collector_list;
 static bt_adapter_le_scan_result_cb scan_cb;   //le scan application callback
 static bt_hrp_collector_s *_bt_hrp_collector_find(const char *remote_address);
@@ -178,8 +168,6 @@ static void __bt_hrp_reduced_interval_adv_state_changed_cb(int result,
                adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ?
                "started" : "stopped", adv_state);
 
-       if (hrp_server_info_s.adv_app_cb && adv_state == BT_ADAPTER_LE_ADVERTISING_STOPPED)
-               hrp_server_info_s.adv_app_cb(result, adv_state, user_data);
 }
 
 static gboolean __hrp_timeout(gpointer user_data)
@@ -204,9 +192,6 @@ static void __bt_hrp_gatt_server_set_char_notification_state_change_cb(bool noti
        BT_INFO("[HR]server %s", (char *)server);
        BT_INFO("[HR]gatt_handle %s", (char *)gatt_handle);
 
-       if (hrp_server_info_s.notif_app_cb)
-               hrp_server_info_s.notif_app_cb(notify, server,  gatt_handle, user_data);
-
 }
 
 static void __bt_hrp_fast_interval_adv_state_changed_cb(int result,
@@ -243,9 +228,6 @@ static void __bt_hrp_fast_interval_adv_state_changed_cb(int result,
                        return;
                }
        }
-       /*todo : Send Start and stop enums*/
-       if (hrp_server_info_s.adv_app_cb)
-               hrp_server_info_s.adv_app_cb(result, adv_state, user_data);
 
 }
 
@@ -401,7 +383,7 @@ static int __bt_hrp_create_secondary_service(void)
        return error_code;
 }
 
-static int __bt_hrp_sensor_create_service(void)
+static int _bt_hrp_sensor_create_service(void)
 {
 
        int error_code = BT_ERROR_NOT_INITIALIZED;
@@ -427,13 +409,6 @@ static int __bt_hrp_sensor_create_service(void)
        return error_code;
 }
 
-static void _bt_hrp_sensor_client_info_free(gpointer object)
-{
-       bt_hrp_collector_notify_info_s *client_s = (bt_hrp_collector_notify_info_s *)object;
-       g_free(client_s->remote_address);
-       client_s->isconnected = false;
-}
-
 static void _bt_hrp_sensor_initilize(void)
 {
        hrp_server_info_s.hrp_sensor = NULL;
@@ -443,8 +418,6 @@ static void _bt_hrp_sensor_initilize(void)
        hrp_server_info_s.dis_characteristic = NULL;
        hrp_server_info_s.hrs_descriptor = NULL;
        hrp_server_info_s.advertiser = NULL;
-       hrp_server_info_s.adv_app_cb = NULL;
-       hrp_server_info_s.hrs_collector_connected_list = NULL;
        hrp_server_info_s.is_in_contact = true;
 
        if (hrp_server_info_s.is_hr_value_init == false)
@@ -470,34 +443,10 @@ void __bt_hrp_le_connection_state_changed_cb(int result,
        BT_INFO("[HR] bt_hrp_le_connection_state_changed_cb Result : %d", result);
        BT_INFO("[HR]IsConnected : %d", connected);
        BT_INFO("[HR]Remote Address : %s", remote_address);
-       bool isappend = true;
 
        /*If Sensor */
        if (hrp_server_info_s.hrp_sensor != NULL) {
                BT_INFO("[HR] bt_hrp_le_connection_state_changed_cb Sensor!!");
-
-               GSList *iter = hrp_server_info_s.hrs_collector_connected_list;
-
-               for (; iter; iter = g_slist_next(iter)) {
-                       if ((iter) && (iter->data != NULL) &&
-                               (((bt_hrp_collector_notify_info_s *)iter->data)->remote_address != NULL)) {
-                               if (!g_ascii_strcasecmp(((bt_hrp_collector_notify_info_s *)iter->data)->remote_address,
-                                                                                       remote_address)) {
-                                       ((bt_hrp_collector_notify_info_s *)iter->data)->isconnected = connected;
-                                       isappend = false;
-                                       break;
-                               }
-                       }
-               }
-
-               if (isappend) {
-                       bt_hrp_collector_notify_info_s *client_s = g_malloc(sizeof(bt_hrp_collector_notify_info_s));
-                       client_s->isconnected = connected;
-                       client_s->remote_address = g_strdup(remote_address);
-                       hrp_server_info_s.hrs_collector_connected_list =
-                                       g_slist_append(hrp_server_info_s.hrs_collector_connected_list, (gpointer)client_s);
-               }
-
        } else {
                        /*If Collector*/
                        bt_hrp_collector_s *collector_s = _bt_hrp_collector_find(remote_address);
@@ -510,8 +459,135 @@ void __bt_hrp_le_connection_state_changed_cb(int result,
 
 }
 
-/*Application Interfaces*/
+static int _bt_hrp_sensor_update_heartrate_value(int heartrate)
+{
+       BT_CHECK_HRS_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+
+       int error_code = BT_ERROR_NOT_INITIALIZED;
+
+       if (NULL == hrp_server_info_s.hrp_sensor) {
+               BT_ERR("[HR Sensor START] Call Create First !!\n");
+               return error_code;
+       }
+
+       error_code = bt_gatt_set_int_value(hrp_server_info_s.hrs_characteristic,
+                       BT_DATA_TYPE_UINT16, heartrate, 1);
+       if (error_code != BT_ERROR_NONE) {
+               BT_ERR("[HR]bt_gatt_set_int_value failed with [0x%04x]", error_code);
+               return error_code;
+       }
+
+       error_code = bt_gatt_server_notify_characteristic_changed_value(hrp_server_info_s.hrs_characteristic,
+                                       __bt_hrp_notification_send_cb,  NULL,  NULL);
+       if (error_code != BT_ERROR_NONE) {
+               BT_ERR("bt_gatt_server_notify_characteristic_changed_value : %s\n", _bt_convert_error_to_string(error_code));
+               return error_code;
+       }
+
+       return error_code;
+
+}
+
+static int _bt_hrp_sensor_start(void)
+{
+       int error_code = BT_ERROR_NOT_INITIALIZED;
+
+       BT_CHECK_HRS_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+
+       if (NULL == hrp_server_info_s.hrp_sensor) {
+               BT_ERR("[HR Sensor START] Call Create First !!\n");
+               return error_code;
+       }
+
+       BT_INFO("[HR] START GATT SERVER \n");
+       error_code = bt_gatt_server_start();
+       if (error_code != BT_ERROR_NONE)        {
+               BT_ERR("[HR]bt_gatt_server_start : %s \n", _bt_convert_error_to_string(error_code));
+               return error_code;
+       }
+
+       if (hrp_server_info_s.advertiser == NULL) {
+
+               error_code = bt_adapter_le_create_advertiser(&hrp_server_info_s.advertiser);
+               if (error_code != BT_ERROR_NONE)        {
+                       BT_ERR("[HR Sensor START] bt_adapter_le_create_advertiser : %s \n", _bt_convert_error_to_string(error_code));
+                       return error_code;
+               }
+       } else {
 
+               error_code = bt_adapter_le_clear_advertising_data(hrp_server_info_s.advertiser,
+                       BT_ADAPTER_LE_PACKET_ADVERTISING);
+               if (error_code != BT_ERROR_NONE) {
+                       BT_ERR("[HR Sensor START] clear advertising data [0x%04x]", error_code);
+                       return error_code;
+               }
+               error_code = bt_adapter_le_clear_advertising_data(hrp_server_info_s.advertiser,
+                       BT_ADAPTER_LE_PACKET_SCAN_RESPONSE);
+               if (error_code != BT_ERROR_NONE) {
+                       BT_ERR("[HR Sensor START] clear scan response data [0x%04x]", error_code);
+                       return error_code;
+               }
+       }
+
+       error_code = bt_adapter_le_add_advertising_service_solicitation_uuid(hrp_server_info_s.advertiser,
+                       BT_ADAPTER_LE_PACKET_ADVERTISING, HEART_RATE_UUID);
+       if (error_code != BT_ERROR_NONE) {
+               BT_ERR("[HR Sensor START] add service_solicitation_uuid [0x%04x]", error_code);
+               return error_code;
+       }
+
+       error_code = bt_adapter_le_set_advertising_device_name(hrp_server_info_s.advertiser,
+               BT_ADAPTER_LE_PACKET_ADVERTISING, true);
+
+       if (error_code != BT_ERROR_NONE)
+               BT_ERR("[HR Sensor START] set device name [0x%04x]", error_code);
+
+
+               /*interval = 150*/
+       error_code = bt_adapter_le_set_advertising_mode(hrp_server_info_s.advertiser, BT_ADAPTER_LE_ADVERTISING_MODE_LOW_LATENCY);
+       if (error_code != BT_ERROR_NONE) {
+               BT_ERR("[HR Sensor START] add scan response data [0x%04x]", error_code);
+               return error_code;
+       }
+
+       error_code = bt_adapter_le_set_advertising_device_name(hrp_server_info_s.advertiser,
+               BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true);
+
+       if (error_code != BT_ERROR_NONE)
+               BT_ERR("[HR Sensor START] set device name [0x%04x]", error_code);
+
+       error_code = bt_adapter_le_start_advertising_new(hrp_server_info_s.advertiser,
+                                                                               __bt_hrp_fast_interval_adv_state_changed_cb, NULL);
+       if (error_code != BT_ERROR_NONE) {
+               BT_ERR("[HR Sensor START] failed with [0x%04x]", error_code);
+               return error_code;
+       }
+
+       BT_INFO("[HR Sensor START] bt_hrp_sensor_start exit\n");
+       return error_code;
+
+}
+
+static int _bt_hrp_sensor_stop(void)
+{
+       BT_CHECK_HRS_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+
+       int error_code = BT_ERROR_NOT_INITIALIZED;
+
+       error_code = bt_adapter_le_stop_advertising(hrp_server_info_s.advertiser);
+       if (error_code != BT_ERROR_NONE) {
+               BT_ERR("[HR]bt_hrp_sensor_stop failed with [0x%04x]", error_code);
+               return error_code;
+       }
+
+       return error_code;
+
+}
+
+/*Application Interfaces*/
 int bt_hrp_sensor_set_heartrate_value(int heartrate)
 {
        BT_CHECK_HRS_SUPPORT();
@@ -523,6 +599,9 @@ int bt_hrp_sensor_set_heartrate_value(int heartrate)
        hrp_server_info_s.hr_value = heartrate;
        hrp_server_info_s.is_hr_value_init = true;
 
+       if (_bt_hrp_sensor_update_heartrate_value(heartrate) != BT_ERROR_NONE)
+               BT_ERR("[HR] bt_hrp_sensor_set_heartrate_value Did not Notify !!");
+
        return BT_ERROR_NONE;
 }
 
@@ -597,18 +676,6 @@ int bt_hrp_sensor_set_device_manufacturer_name(char *manuf_name)
        return BT_ERROR_NONE;
 }
 
-int bt_hrp_sensor_set_sensor_notification_state_change_cb(
-                               bt_gatt_server_characteristic_notification_state_changed_cb     callback, void *user_data)
-{
-       BT_CHECK_HRS_SUPPORT();
-       BT_CHECK_INIT_STATUS();
-       BT_CHECK_INPUT_PARAMETER(callback);
-
-       hrp_server_info_s.notif_app_cb = callback;
-
-       return BT_ERROR_NONE;
-}
-
 int bt_hrp_sensor_create(void)
 {
        int error_code = BT_ERROR_NONE;
@@ -643,143 +710,19 @@ int bt_hrp_sensor_create(void)
                return error_code;
        }
 
-       error_code = __bt_hrp_sensor_create_service();
+       error_code = _bt_hrp_sensor_create_service();
        if (error_code != BT_ERROR_NONE)        {
-               BT_ERR("[HRP- Sensor Create] __bt_hrp_sensor_create_service : %s \n", _bt_convert_error_to_string(error_code));
-               return error_code;
-       }
-       return error_code;
-}
-
-int bt_hrp_sensor_start(bt_hrp_sensor_advertising_state_changed_cb cb)
-{
-       int error_code = BT_ERROR_NOT_INITIALIZED;
-
-       BT_CHECK_HRS_SUPPORT();
-       BT_CHECK_INIT_STATUS();
-       BT_CHECK_INPUT_PARAMETER(cb);
-
-       if (NULL == hrp_server_info_s.hrp_sensor) {
-               BT_ERR("[HR Sensor START] Call Create First !!\n");
+               BT_ERR("[HRP- Sensor Create] _bt_hrp_sensor_create_service : %s \n", _bt_convert_error_to_string(error_code));
                return error_code;
        }
 
-       BT_INFO("[HR] START GATT SERVER \n");
-       error_code = bt_gatt_server_start();
+       error_code = _bt_hrp_sensor_start();
        if (error_code != BT_ERROR_NONE)        {
-               BT_ERR("[HR]bt_gatt_server_start : %s \n", _bt_convert_error_to_string(error_code));
-               return error_code;
-       }
-
-       if (hrp_server_info_s.advertiser == NULL) {
-
-               error_code = bt_adapter_le_create_advertiser(&hrp_server_info_s.advertiser);
-               if (error_code != BT_ERROR_NONE)        {
-                       BT_ERR("[HR Sensor START] bt_adapter_le_create_advertiser : %s \n", _bt_convert_error_to_string(error_code));
-                       return error_code;
-               }
-       } else {
-
-               error_code = bt_adapter_le_clear_advertising_data(hrp_server_info_s.advertiser,
-                       BT_ADAPTER_LE_PACKET_ADVERTISING);
-               if (error_code != BT_ERROR_NONE) {
-                       BT_ERR("[HR Sensor START] clear advertising data [0x%04x]", error_code);
-                       return error_code;
-               }
-               error_code = bt_adapter_le_clear_advertising_data(hrp_server_info_s.advertiser,
-                       BT_ADAPTER_LE_PACKET_SCAN_RESPONSE);
-               if (error_code != BT_ERROR_NONE) {
-                       BT_ERR("[HR Sensor START] clear scan response data [0x%04x]", error_code);
-                       return error_code;
-               }
-       }
-
-       error_code = bt_adapter_le_add_advertising_service_solicitation_uuid(hrp_server_info_s.advertiser,
-                       BT_ADAPTER_LE_PACKET_ADVERTISING, HEART_RATE_UUID);
-       if (error_code != BT_ERROR_NONE) {
-               BT_ERR("[HR Sensor START] add service_solicitation_uuid [0x%04x]", error_code);
-               return error_code;
-       }
-
-       error_code = bt_adapter_le_set_advertising_device_name(hrp_server_info_s.advertiser,
-               BT_ADAPTER_LE_PACKET_ADVERTISING, true);
-
-       if (error_code != BT_ERROR_NONE)
-               BT_ERR("[HR Sensor START] set device name [0x%04x]", error_code);
-
-
-               /*interval = 150*/
-       error_code = bt_adapter_le_set_advertising_mode(hrp_server_info_s.advertiser, BT_ADAPTER_LE_ADVERTISING_MODE_LOW_LATENCY);
-       if (error_code != BT_ERROR_NONE) {
-               BT_ERR("[HR Sensor START] add scan response data [0x%04x]", error_code);
-               return error_code;
-       }
-
-       hrp_server_info_s.adv_app_cb = cb;
-
-       error_code = bt_adapter_le_set_advertising_device_name(hrp_server_info_s.advertiser,
-               BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true);
-
-       if (error_code != BT_ERROR_NONE)
-               BT_ERR("[HR Sensor START] set device name [0x%04x]", error_code);
-
-       error_code = bt_adapter_le_start_advertising_new(hrp_server_info_s.advertiser,
-                                                                               __bt_hrp_fast_interval_adv_state_changed_cb, NULL);
-       if (error_code != BT_ERROR_NONE) {
-               BT_ERR("[HR Sensor START] failed with [0x%04x]", error_code);
-               return error_code;
-       }
-
-       BT_INFO("[HR Sensor START] bt_hrp_sensor_start exit\n");
-       return error_code;
-
-}
-
-int bt_hrp_sensor_stop(void)
-{
-       BT_CHECK_HRS_SUPPORT();
-       BT_CHECK_INIT_STATUS();
-
-       int error_code = BT_ERROR_NOT_INITIALIZED;
-
-       error_code = bt_adapter_le_stop_advertising(hrp_server_info_s.advertiser);
-       if (error_code != BT_ERROR_NONE) {
-               BT_ERR("[HR]bt_hrp_sensor_stop failed with [0x%04x]", error_code);
+               BT_ERR("[HRP- Sensor Create] _bt_hrp_sensor_start : %s \n", _bt_convert_error_to_string(error_code));
                return error_code;
        }
 
        return error_code;
-
-}
-
-int bt_hrp_sensor_update_heartrate_value(int heartrate)
-{
-       BT_CHECK_HRS_SUPPORT();
-       BT_CHECK_INIT_STATUS();
-
-       int error_code = BT_ERROR_NOT_INITIALIZED;
-
-       if (NULL == hrp_server_info_s.hrp_sensor) {
-               BT_ERR("[HR Sensor START] Call Create First !!\n");
-               return error_code;
-       }
-
-       error_code = bt_gatt_set_int_value(hrp_server_info_s.hrs_characteristic,
-                       BT_DATA_TYPE_UINT16, heartrate, 1);
-       if (error_code != BT_ERROR_NONE) {
-               BT_ERR("[HR]bt_gatt_set_int_value failed with [0x%04x]", error_code);
-               return error_code;
-       }
-
-       error_code = bt_gatt_server_notify_characteristic_changed_value(hrp_server_info_s.hrs_characteristic,
-                                       __bt_hrp_notification_send_cb,  NULL,  NULL);
-       if (error_code != BT_ERROR_NONE) {
-               BT_ERR("bt_gatt_server_notify_characteristic_changed_value : %s\n", _bt_convert_error_to_string(error_code));
-               return error_code;
-       }
-
-       return error_code;
-
 }
 
 int bt_hrp_sensor_destroy(void)
@@ -794,6 +737,12 @@ int bt_hrp_sensor_destroy(void)
        if (hrp_server_info_s.hrp_sensor == NULL)
                return BT_ERROR_NOT_INITIALIZED;
 
+       error_code = _bt_hrp_sensor_stop();
+       if (error_code != BT_ERROR_NONE) {
+               BT_ERR("[HR]bt_hrp_sensor_stop failed with [0x%04x]", error_code);
+               return error_code;
+       }
+
        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);
@@ -801,16 +750,12 @@ int bt_hrp_sensor_destroy(void)
        bt_gatt_destroy(hrp_server_info_s.dis_service);
        bt_gatt_destroy(hrp_server_info_s.hrp_service);
 
-       BT_INFO("[HR]bt_gatt_server_destroy Advertiser Destroy\n");
-
        error_code = bt_adapter_le_destroy_advertiser(hrp_server_info_s.advertiser);
        if (error_code != BT_ERROR_NONE) {
-               BT_ERR("[HR]bt_hrp_sensor_stop failed with [0x%04x]", error_code);
+               BT_ERR("[HR]bt_adapter_le_destroy_advertiser failed with [0x%04x]", error_code);
                return error_code;
        }
 
-       BT_INFO("[HR]bt_gatt_server_destroy Server Destroy\n");
-
        error_code = bt_gatt_server_destroy(hrp_server_info_s.hrp_sensor);
        if (error_code != BT_ERROR_NONE) {
                BT_ERR("[HR]bt_gatt_server_destroy failed with [0x%04x]", error_code);
@@ -819,11 +764,9 @@ int bt_hrp_sensor_destroy(void)
 
        hrp_server_info_s.hrp_sensor = NULL;
 
-       BT_INFO("[HR]bt_gatt_server_destroy Server Deinit\n");
-
        error_code = bt_gatt_server_deinitialize();
        if (error_code != BT_ERROR_NONE) {
-               BT_ERR("[HR]bt_gatt_server_destroy failed with [0x%04x]", error_code);
+               BT_ERR("[HR]bt_gatt_server_deinitialize failed with [0x%04x]", error_code);
                return error_code;
        }
 
@@ -847,19 +790,10 @@ int bt_hrp_sensor_destroy(void)
        if (hrp_server_info_s.manufname)
                g_free(hrp_server_info_s.manufname);
 
-       hrp_server_info_s.adv_app_cb = NULL;
-       hrp_server_info_s.notif_app_cb = NULL;
        hrp_server_info_s.body_sensor_location = BT_BSL_NOTSUPPORTED;
 
-       g_slist_free_full(hrp_server_info_s.hrs_collector_connected_list, _bt_hrp_sensor_client_info_free);
-
-       hrp_server_info_s.hrs_collector_connected_list = NULL;
-
        BT_INFO("[HR]bt_gatt_server_destroy Exit\n");
-
-
        return error_code;
-
 }
 
 /*======================================================================================================
@@ -1068,7 +1002,7 @@ int bt_hrp_collector_unset_connection_state_changed_cb(bt_hrp_collector_h collec
        return BT_ERROR_NONE;
 }
 
-int bt_hrp_collector_start_scan(bt_adapter_le_scan_result_cb cb)
+int bt_hrp_collector_start_scan(bt_hrp_collector_scan_result_cb cb)
 {
 
        bt_scan_filter_h scan_filter = NULL;
index 8a67a81..6f126a1 100644 (file)
@@ -1179,8 +1179,6 @@ tc_table_t tc_hr_sensor[] = {
        /* HR Sensor functions */
        {"BACK"
                , BT_UNIT_TEST_FUNCTION_BACK},
-       {"[sensor]Set HeartRate Value"
-               , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_HR_VALUE},
        {"[sensor]Set Location Value"
                , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_LOC_VALUE},
        {"[sensor]Set Contact Value"
@@ -1188,19 +1186,11 @@ tc_table_t tc_hr_sensor[] = {
        {"[sensor]Set Device Name"
                , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_DEVICE_NAME},
        {"[sensor]Set Notification Callback"
-               , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_NOTIF_CB},
-       {"[sensor]Set Read Callback"
                , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_READ_CB},
        {"[sensor]Set Send Notification Callback"
                , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_SEND_NOTIF_CB},
        {"HR Sensor Create Instance"
                , BT_UNIT_TEST_FUNCTION_HR_SENSOR_CREATE},
-       {"HR Sensor Start Advertising"
-               , BT_UNIT_TEST_FUNCTION_HR_SENSOR_START},
-       {"HR Sensor Stop Advertising"
-               , BT_UNIT_TEST_FUNCTION_HR_SENSOR_STOP},
-       {"HR Sensor SET Notify"
-               , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_NOTIFY},
        {"HR Sensor Notify"
                , BT_UNIT_TEST_FUNCTION_HR_SENSOR_NOTIFY},
        {"HR Sensor Destroy"
@@ -3276,16 +3266,6 @@ static void __bt_otp_client_object_delete_cb(int result, const char *remote_addr
                BT_ERR("Object[%llu] delete failed!", obj_id);
 }
 
-static void __bt_adapter_hrp_sensor_adv_state_cb(int result,
-               bt_hrp_sensor_advertising_state_e adv_state, void *user_data)
-{
-       TC_PRT("[HR]Result : %d", result);
-       TC_PRT("[HR]Advertiser : %p", advertiser);
-       TC_PRT("[HR]Advertising %s [%d]",
-               adv_state == BT_HRP_SENSOR_ADVERTISING_STARTED ?
-               "started" : "stopped", adv_state);
-}
-
 void __bt_gatt_client_read_request_completed_cb(int result,
                bt_gatt_h request_handle, void *user_data)
 {
@@ -9611,12 +9591,6 @@ int test_input_callback(void *data)
        }
                case BT_UNIT_TEST_TABLE_HRP_SENSOR: {
                switch (test_id) {
-               case BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_HR_VALUE: {
-                       TC_PRT("HR SENSOR SET HR VALUE\n");
-                       int heartrate = 0x38;
-                       bt_hrp_sensor_set_heartrate_value(heartrate);
-                       break;
-               }
                case BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_LOC_VALUE: {
                        TC_PRT("HR SENSOR SET LOC VALUE\n");
                        bt_body_sensor_location_e location = BT_BSL_WRIST;
@@ -9636,33 +9610,15 @@ int test_input_callback(void *data)
                        bt_hrp_sensor_set_device_manufacturer_name(name);
                        break;
                }
-               case BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_NOTIF_CB: {
-                       TC_PRT("HR SENSOR SET NOTIFICATION CALLBACK\n");
-                       bt_hrp_sensor_set_sensor_notification_state_change_cb(
-                                       __bt_gatt_server_notification_state_change_cb, NULL);
-                       break;
-               }
                case BT_UNIT_TEST_FUNCTION_HR_SENSOR_CREATE: {
                        TC_PRT("HR SENSOR CREATE\n");
                        ret  = bt_hrp_sensor_create();
                        TC_PRT("returns %s\n", __bt_get_error_message(ret));
                        break;
                }
-               case BT_UNIT_TEST_FUNCTION_HR_SENSOR_START: {
-                       TC_PRT("HR SENSOR START\n");
-                       ret = bt_hrp_sensor_start(__bt_adapter_hrp_sensor_adv_state_cb);
-                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
-                       break;
-               }
-               case BT_UNIT_TEST_FUNCTION_HR_SENSOR_STOP: {
-                       TC_PRT("HR SENSOR STOP\n");
-                       ret = bt_hrp_sensor_stop();
-                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
-                       break;
-               }
                case BT_UNIT_TEST_FUNCTION_HR_SENSOR_NOTIFY: {
                        TC_PRT("HR SENSOR UPDATE HR value\n");
-                       bt_hrp_sensor_update_heartrate_value(60 + (rand()%60));
+                       bt_hrp_sensor_set_heartrate_value(60 + (rand()%60));
                        break;
                }
                case BT_UNIT_TEST_FUNCTION_HR_SENSOR_DESTORY: {
index 6ae90c2..5c958a6 100644 (file)
@@ -522,17 +522,12 @@ typedef enum {
        BT_UNIT_TEST_FUNCTION_OTP_CLIENT_DELETE_OBJ,
 
        /*HR-Sensor*/
-       BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_HR_VALUE = 1,
-       BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_LOC_VALUE,
+       BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_LOC_VALUE = 1,
        BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_CONTACT_VALUE,
        BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_DEVICE_NAME,
-       BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_NOTIF_CB,
        BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_READ_CB,
        BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_SEND_NOTIF_CB,
        BT_UNIT_TEST_FUNCTION_HR_SENSOR_CREATE,
-       BT_UNIT_TEST_FUNCTION_HR_SENSOR_START,
-       BT_UNIT_TEST_FUNCTION_HR_SENSOR_STOP,
-       BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_NOTIFY,
        BT_UNIT_TEST_FUNCTION_HR_SENSOR_NOTIFY,
        BT_UNIT_TEST_FUNCTION_HR_SENSOR_DESTORY,
        /*HR-Collector*/