tools/mgmt-tester: Add param check callback for LE Set Adv Params
authorTedd Ho-Jeong An <tedd.an@intel.com>
Sat, 10 Apr 2021 06:46:05 +0000 (23:46 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:35 +0000 (19:08 +0530)
The interval_min and interval_max in LE Set Advertising Parameters
command are changed/updated often whenever the values are tuned in the
kernel, and it causes some tests failure.

This patch adds a parameter check callback for LE Set Advertising
Parameters command to ignore the interval_min and interval_max
parameters.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/mgmt-tester.c

index ef37f0e..b05ae4f 100755 (executable)
@@ -910,6 +910,20 @@ static uint8_t set_connectable_off_scan_adv_param[] = {
                0x00,                                   /* filter_policy */
 };
 
+static int set_connectable_off_scan_adv_check_func(const void *param,
+                                                               uint16_t length)
+{
+       const uint8_t *received = param;
+       uint8_t *expected = set_connectable_off_scan_adv_param;
+
+       /* Compare the received param with expected param, but ignore the
+        * min_internal and max_interval since these values are turned often
+        * in the kernel and we don't want to update the expected value every
+        * time.
+        */
+       return memcmp(&received[4], &expected[4], length - 4);
+}
+
 static const struct generic_data set_connectable_off_le_test_2 = {
        .setup_settings = settings_powered_le_connectable_advertising,
        .send_opcode = MGMT_OP_SET_CONNECTABLE,
@@ -922,6 +936,7 @@ static const struct generic_data set_connectable_off_le_test_2 = {
        .expect_hci_command = BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
        .expect_hci_param = set_connectable_off_scan_adv_param,
        .expect_hci_len = sizeof(set_connectable_off_scan_adv_param),
+       .expect_hci_param_check_func = set_connectable_off_scan_adv_check_func
 };
 
 static uint16_t settings_powered_le_discoverable[] = {
@@ -949,6 +964,7 @@ static const struct generic_data set_connectable_off_le_test_3 = {
        .expect_hci_command = BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
        .expect_hci_param = set_connectable_off_scan_adv_param,
        .expect_hci_len = sizeof(set_connectable_off_scan_adv_param),
+       .expect_hci_param_check_func = set_connectable_off_scan_adv_check_func
 };
 
 static const struct generic_data set_connectable_off_le_test_4 = {
@@ -964,6 +980,7 @@ static const struct generic_data set_connectable_off_le_test_4 = {
        .expect_hci_command = BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
        .expect_hci_param = set_connectable_off_scan_adv_param,
        .expect_hci_len = sizeof(set_connectable_off_scan_adv_param),
+       .expect_hci_param_check_func = set_connectable_off_scan_adv_check_func
 };
 
 static const char set_fast_conn_on_param[] = { 0x01 };
@@ -4750,6 +4767,7 @@ static const struct generic_data add_advertising_success_13 = {
        .expect_hci_command = BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
        .expect_hci_param = set_connectable_off_scan_adv_param,
        .expect_hci_len = sizeof(set_connectable_off_scan_adv_param),
+       .expect_hci_param_check_func = set_connectable_off_scan_adv_check_func
 };
 
 static uint8_t set_connectable_off_adv_param[] = {
@@ -4763,6 +4781,20 @@ static uint8_t set_connectable_off_adv_param[] = {
                0x00,                                   /* filter_policy */
 };
 
+static int set_connectable_off_adv_check_func(const void *param,
+                                                               uint16_t length)
+{
+       const uint8_t *received = param;
+       uint8_t *expected = set_connectable_off_adv_param;
+
+       /* Compare the received param with expected param, but ignore the
+        * min_internal and max_interval since these values are turned often
+        * in the kernel and we don't want to update the expected value every
+        * time.
+        */
+       return memcmp(&received[4], &expected[4], length - 4);
+}
+
 static const struct generic_data add_advertising_success_14 = {
        .setup_settings = settings_powered_le,
        .send_opcode = MGMT_OP_ADD_ADVERTISING,
@@ -4774,6 +4806,7 @@ static const struct generic_data add_advertising_success_14 = {
        .expect_hci_command = BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
        .expect_hci_param = set_connectable_off_adv_param,
        .expect_hci_len = sizeof(set_connectable_off_adv_param),
+       .expect_hci_param_check_func = set_connectable_off_adv_check_func
 };
 
 static const struct generic_data add_advertising_success_15 = {
@@ -4814,6 +4847,7 @@ static const struct generic_data add_advertising_success_17 = {
        .expect_hci_command = BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
        .expect_hci_param = set_connectable_off_adv_param,
        .expect_hci_len = sizeof(set_connectable_off_adv_param),
+       .expect_hci_param_check_func = set_connectable_off_adv_check_func
 };
 
 static const char set_powered_off_le_settings_param[] = {