[BLE-HR] Verification Fixes 01/189901/1 accepted/tizen/unified/20180927.073750 submit/tizen/20180926.233914
authorAbhishek Chandra <abhishek.ch@samsung.com>
Fri, 21 Sep 2018 11:18:51 +0000 (16:48 +0530)
committerAbhishek Chandra <abhishek.ch@samsung.com>
Fri, 21 Sep 2018 11:19:27 +0000 (16:49 +0530)
- Easy understandble string name changes
and cleanup in bt_unit_test.
- State change event fix.
- HR Notification sending/recieving fix.
- BSL read response fix .

Change-Id: I061a24861f408c69efaca39da1f1c0954877b319
Signed-off-by: Abhishek Chandra <abhishek.ch@samsung.com>
src/bluetooth-common.c
src/bluetooth-hrp.c
test/bt_unit_test.c
test/bt_unit_test.h

index a9dfb15..afdcadd 100644 (file)
@@ -2201,9 +2201,6 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
                        cb(_bt_get_error_code(param->result), TRUE, device_addr,
                                bt_event_slot_container[event_index].user_data);
 
-               /*HRP Server*/
-               __bt_hrp_le_connection_state_changed_cb(param->result, device_addr, TRUE);
-
                g_free(device_addr);
                device_addr = NULL;
                break;
@@ -2219,9 +2216,6 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
                        cb(_bt_get_error_code(param->result), FALSE, device_addr,
                                bt_event_slot_container[event_index].user_data);
 
-               /*HRP Server*/
-               __bt_hrp_le_connection_state_changed_cb(param->result, device_addr, FALSE);
-
                g_free(device_addr);
                device_addr = NULL;
                break;
@@ -2248,6 +2242,9 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
                        }
                }
 
+               /*HRP Server*/
+               __bt_hrp_le_connection_state_changed_cb(param->result, device_addr, TRUE);
+
                if (event_index >= 0)
                        cb = bt_event_slot_container[event_index].callback;
                if (cb)
@@ -2273,6 +2270,11 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
                        /* Mark services not discovered */
                        client_s->services_discovered = false;
                }
+
+
+               /*HRP Server*/
+               __bt_hrp_le_connection_state_changed_cb(param->result, device_addr, FALSE);
+
                if (event_index >= 0)
                        cb = bt_event_slot_container[event_index].callback;
                if (cb)
index d2b6ba9..59e9448 100644 (file)
@@ -103,16 +103,6 @@ typedef struct {
        bt_hrp_collector_bsl_read_completed_cb bsl_read_cb;
 } bt_hrp_collector_s;
 
-static const char * const bsl_str_enum[] = {
-       "other",
-       "chest",
-       "wrist",
-       "finger",
-       "hand",
-       "earlobe",
-       "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);
@@ -128,7 +118,7 @@ static void __bt_hrp_sensor_read_value_requested_cb(
        bt_gatt_server_h server, bt_gatt_h gatt_handle,
        int offset, void *user_data)
 {
-       char *bsl_str_loc = g_strdup(bsl_str_enum[hrp_server_info_s.body_sensor_location]);
+       char bsl_str_loc = hrp_server_info_s.body_sensor_location;
 
        BT_INFO("[HR] __bt_gatt_server_read_value_requested_cb");
        BT_INFO("[HR] remote_address %s", remote_address);
@@ -140,10 +130,7 @@ static void __bt_hrp_sensor_read_value_requested_cb(
        /* Send Cached response*/
        bt_gatt_server_send_response(request_id,
                BT_GATT_REQUEST_TYPE_READ, offset,
-               BT_ATT_ERROR_NONE, bsl_str_loc, strlen(bsl_str_loc));
-
-
-       g_free(bsl_str_loc);
+               BT_ATT_ERROR_NONE, &bsl_str_loc, 1);
 
 }
 
@@ -465,7 +452,6 @@ static int _bt_hrp_sensor_update_heartrate_value(int heartrate)
        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;
@@ -815,9 +801,9 @@ static void _bt_hrp_collector_characteristic_value_changed_cb(bt_hrp_collector_h
        }
 
        /*To do :Extract value in to uint and send*/
-       unsigned short hr_value = *value;
+       unsigned short hr_value = value[1];
 
-       if (collector_s && collector_s->char_update_cb)
+       if (collector_s && collector_s->hr_chr_notify_h && collector_s->char_update_cb)
                collector_s->char_update_cb(characteristic, hr_value, user_data);
 
 }
index 42d38ea..7041e89 100644 (file)
@@ -1185,15 +1185,11 @@ tc_table_t tc_hr_sensor[] = {
                , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_CONTACT_VALUE},
        {"[sensor]Set Device Name"
                , BT_UNIT_TEST_FUNCTION_HR_SENSOR_SET_DEVICE_NAME},
-       {"[sensor]Set Notification 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"
+       {"[sensor] Create Sensor"
                , BT_UNIT_TEST_FUNCTION_HR_SENSOR_CREATE},
-       {"HR Sensor Notify"
+       {"[sensor] Notify Collector"
                , BT_UNIT_TEST_FUNCTION_HR_SENSOR_NOTIFY},
-       {"HR Sensor Destroy"
+       {"[sensor] Destroy Sensor"
                , BT_UNIT_TEST_FUNCTION_HR_SENSOR_DESTORY},
        {NULL                                   , 0x0000},
 };
@@ -1201,23 +1197,23 @@ tc_table_t tc_hr_sensor[] = {
 tc_table_t tc_hr_collector[] = {
        {"BACK"
                , BT_UNIT_TEST_FUNCTION_BACK},
-       {"[collector]HR collector set notification"
+       {"[collector]Set Connection State callback"
+               , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECTION_STATE_CALLBACK},
+       {"[collector]Set/Unset Notification"
                , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_SET_NOTIFICATION},
-       {"[collector]HR collector start scan"
+       {"[collector]Start Scan"
                , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_START_SCAN},
-       {"[collector]HR collector stop scan"
+       {"[collector]Stop Scan"
                , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_STOP_SCAN},
-       {"[collector]HR collector connect"
+       {"[collector]Connect Sensor"
                , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECT},
-       {"[collector]HR collector disconnect"
+       {"[collector]Disconnect Sensor"
                , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DISCONNECT},
-       {"[collector]HR collector create"
+       {"[collector]Create Collector"
                , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CREATE},
-       {"[collector]HR collector destroy"
+       {"[collector]Destroy Collector"
                , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DESTROY},
-       {"[collector]HR collector connection state callback"
-               , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECTION_STATE_CALLBACK},
-       {"[collector]HR collector read bsl value "
+       {"[collector]Read Body Sensor Location"
                , BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_GET_BSL_LOC},
        {NULL                                   , 0x0000},
 };
@@ -9698,6 +9694,7 @@ int test_input_callback(void *data)
                                TC_PRT("HR COLLECTOR DESTROY\n");
                                ret = bt_hrp_collector_destory(collector);
                                TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                               collector  = NULL;
                                break;
                }
                default:
index 5c958a6..753b7bd 100644 (file)
@@ -525,20 +525,18 @@ typedef enum {
        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_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_NOTIFY,
        BT_UNIT_TEST_FUNCTION_HR_SENSOR_DESTORY,
        /*HR-Collector*/
-       BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_SET_NOTIFICATION = 1,
+       BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECTION_STATE_CALLBACK = 1,
+       BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_SET_NOTIFICATION,
        BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_START_SCAN,
        BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_STOP_SCAN,
        BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECT,
        BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DISCONNECT,
        BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CREATE,
        BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_DESTROY,
-       BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_CONNECTION_STATE_CALLBACK,
        BT_UNIT_TEST_FUNCTION_HR_COLLECTOR_GET_BSL_LOC,
 
        BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS = 0XFF,