Return-Path: From: Florian Grandel To: linux-bluetooth@vger.kernel.org Subject: [BlueZ v7 2/4] tools/mgmt-tester: comment add adv test setup Date: Tue, 26 May 2015 03:22:07 +0200 Message-Id: <1432603329-12846-3-git-send-email-fgrandel@gmail.com> In-Reply-To: <1432603329-12846-1-git-send-email-fgrandel@gmail.com> References: <1432603329-12846-1-git-send-email-fgrandel@gmail.com> In-Reply-To: <1432600555-8008-1-git-send-email-fgrandel@gmail.com> References: <1432600555-8008-1-git-send-email-fgrandel@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: The add advertising test setup data was just a number of arrays with undocumented hex data. This sometimes made it difficult to understand the test intent. Comments have been added to the add advertising mgmt and hci parameter data arrays to make them more readable and better document the test intent. --- tools/mgmt-tester.c | 215 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 150 insertions(+), 65 deletions(-) diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index 2c5fc1b..62bea80 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -3886,54 +3886,92 @@ static const struct generic_data read_adv_features_success_2 = { .expect_status = MGMT_STATUS_SUCCESS, }; +/* simple add advertising command */ static const uint8_t add_advertising_param_1[] = { - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, - 0x03, 0x02, 0x0d, 0x18, - 0x04, 0xff, 0x01, 0x02, 0x03, -}; - + 0x01, /* adv instance */ + 0x00, 0x00, 0x00, 0x00, /* flags: none */ + 0x00, 0x00, /* duration */ + 0x00, 0x00, /* timeout: none */ + 0x09, /* adv data len */ + 0x00, /* scan rsp len */ + /* adv data: */ + 0x03, /* AD len */ + 0x02, /* AD type: some 16 bit service class UUIDs */ + 0x0d, 0x18, /* heart rate monitor */ + 0x04, /* AD len */ + 0xff, /* AD type: manufacturer specific data */ + 0x01, 0x02, 0x03, /* custom advertising data */ +}; + +/* add advertising with scan response data */ static const uint8_t add_advertising_param_2[] = { - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x0a, - 0x03, 0x02, 0x0d, 0x18, - 0x04, 0xff, 0x01, 0x02, 0x03, - 0x03, 0x19, 0x40, 0x03, - 0x05, 0x03, 0x0d, 0x18, 0x0f, 0x18, -}; - + /* instance, flags, duration, timeout, adv data len: same as before */ + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, + 0x0a, /* scan rsp len */ + /* adv data: same as before */ + 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03, + /* scan rsp data: */ + 0x03, /* AD len */ + 0x19, /* AD type: external appearance */ + 0x40, 0x03, /* some custom appearance */ + 0x05, /* AD len */ + 0x03, /* AD type: all 16 bit service class UUIDs */ + 0x0d, 0x18, /* heart rate monitor */ + 0x0f, 0x18, /* battery service */ +}; + +/* add advertising with timeout */ static const uint8_t add_advertising_param_3[] = { - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x09, 0x00, - 0x03, 0x02, 0x0d, 0x18, - 0x04, 0xff, 0x01, 0x02, 0x03, + /* instance, flags, duration: same as before */ + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x00, /* timeout: 5 seconds */ + /* adv data: same as before */ + 0x09, 0x00, 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03, }; +/* add advertising with connectable flag */ static const uint8_t add_advertising_param_4[] = { - 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, - 0x03, 0x02, 0x0d, 0x18, - 0x04, 0xff, 0x01, 0x02, 0x03, + 0x01, /* adv instance */ + 0x01, 0x00, 0x00, 0x00, /* flags: connectable*/ + /* duration, timeout, adv/scan data: same as before */ + 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, + 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03, }; +/* add advertising with general discoverable flag */ static const uint8_t add_advertising_param_5[] = { - 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, - 0x03, 0x02, 0x0d, 0x18, - 0x04, 0xff, 0x01, 0x02, 0x03, + 0x01, /* adv instance */ + 0x02, 0x00, 0x00, 0x00, /* flags: general discoverable*/ + /* duration, timeout, adv/scan data: same as before */ + 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, + 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03, }; +/* add advertising with limited discoverable flag */ static const uint8_t add_advertising_param_6[] = { - 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, - 0x03, 0x02, 0x0d, 0x18, - 0x04, 0xff, 0x01, 0x02, 0x03, + 0x01, /* adv instance */ + 0x04, 0x00, 0x00, 0x00, /* flags: limited discoverable */ + /* duration, timeout, adv/scan data: same as before */ + 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, + 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03, }; +/* add advertising with managed flags */ static const uint8_t add_advertising_param_7[] = { - 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, - 0x03, 0x02, 0x0d, 0x18, - 0x04, 0xff, 0x01, 0x02, 0x03, + 0x01, /* adv instance */ + 0x08, 0x00, 0x00, 0x00, /* flags: managed flags */ + /* duration, timeout, adv/scan data: same as before */ + 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, + 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03, }; +/* add advertising with tx power flag */ static const uint8_t add_advertising_param_8[] = { - 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, - 0x03, 0x02, 0x0d, 0x18, - 0x04, 0xff, 0x01, 0x02, 0x03, + 0x01, /* adv instance */ + 0x10, 0x00, 0x00, 0x00, /* flags: tx power */ + /* duration, timeout, adv/scan data: same as before */ + 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, + 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03, }; static const uint8_t advertising_instance_param[] = { @@ -3941,59 +3979,106 @@ static const uint8_t advertising_instance_param[] = { }; static const uint8_t set_adv_data_1[] = { - 0x09, 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03, + /* adv data len */ + 0x09, + /* advertise heart rate monitor and manufacturer specific data */ + 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03, + /* padding */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static const uint8_t set_adv_data_2[] = { - 0x06, 0x05, 0x08, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, + 0x06, /* adv data len */ + 0x05, /* AD len */ + 0x08, /* AD type: shortened local name */ + 0x74, 0x65, 0x73, 0x74, /* "test" */ + /* padding */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, }; static const uint8_t set_adv_data_3[] = { - 0x03, 0x02, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, /* adv data len */ + 0x02, /* AD len */ + 0x0a, /* AD type: tx power */ + 0x00, /* tx power */ + /* padding */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static const uint8_t set_adv_data_4[] = { - 0x0c, 0x02, 0x01, 0x02, 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, - 0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0c, /* adv data len */ + 0x02, /* AD len */ + 0x01, /* AD type: flags */ + 0x02, /* general discoverable */ + 0x03, /* AD len */ + 0x02, /* AD type: some 16bit service class UUIDs */ + 0x0d, 0x18, /* heart rate monitor */ + 0x04, /* AD len */ + 0xff, /* AD type: manufacturer specific data */ + 0x01, 0x02, 0x03, /* custom advertising data */ + /* padding */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static const uint8_t set_adv_data_5[] = { - 0x0c, 0x02, 0x01, 0x01, 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, - 0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0c, /* adv data len */ + 0x02, /* AD len */ + 0x01, /* AD type: flags */ + 0x01, /* limited discoverable */ + /* rest: same as before */ + 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03, + /* padding */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static const uint8_t set_adv_data_6[] = { - 0x0c, 0x02, 0x01, 0x02, 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, - 0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0c, /* adv data len */ + 0x02, /* AD len */ + 0x01, /* AD type: flags */ + 0x02, /* general discoverable */ + /* rest: same as before */ + 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03, + /* padding */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static const uint8_t set_adv_data_7[] = { - 0x0c, 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03, - 0x02, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0c, /* adv data len */ + 0x03, /* AD len */ + 0x02, /* AD type: some 16bit service class UUIDs */ + 0x0d, 0x18, /* heart rate monitor */ + 0x04, /* AD len */ + 0xff, /* AD type: manufacturer specific data */ + 0x01, 0x02, 0x03, /* custom advertising data */ + 0x02, /* AD len */ + 0x0a, /* AD type: tx power */ + 0x00, /* tx power */ + /* padding */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static const uint8_t set_scan_rsp_1[] = { - 0x0a, 0x03, 0x19, 0x40, 0x03, 0x05, 0x03, 0x0d, 0x18, 0x0f, - 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0a, /* scan rsp data len */ + 0x03, /* AD len */ + 0x19, /* AD type: external appearance */ + 0x40, 0x03, /* some custom appearance */ + 0x05, /* AD len */ + 0x03, /* AD type: all 16 bit service class UUIDs */ + 0x0d, 0x18, 0x0f, 0x18, /* heart rate monitor, battery service */ + /* padding */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, }; static const uint8_t add_advertising_invalid_param_1[] = { @@ -4914,9 +4999,9 @@ static void setup_add_advertising_not_powered(const void *test_data) cp->instance = 1; cp->adv_data_len = 6; - cp->data[0] = 0x05; - cp->data[1] = 0x08; - cp->data[2] = 't'; + cp->data[0] = 0x05; /* AD len */ + cp->data[1] = 0x08; /* AD type: shortened local name */ + cp->data[2] = 't'; /* adv data ... */ cp->data[3] = 'e'; cp->data[4] = 's'; cp->data[5] = 't'; @@ -4945,9 +5030,9 @@ static void setup_add_advertising(const void *test_data) cp->instance = 1; cp->adv_data_len = 6; - cp->data[0] = 0x05; - cp->data[1] = 0x08; - cp->data[2] = 't'; + cp->data[0] = 0x05; /* AD len */ + cp->data[1] = 0x08; /* AD type: shortened local name */ + cp->data[2] = 't'; /* adv data ... */ cp->data[3] = 'e'; cp->data[4] = 's'; cp->data[5] = 't'; @@ -4980,9 +5065,9 @@ static void setup_add_advertising_connectable(const void *test_data) cp->instance = 1; cp->adv_data_len = 6; - cp->data[0] = 0x05; - cp->data[1] = 0x08; - cp->data[2] = 't'; + cp->data[0] = 0x05; /* AD len */ + cp->data[1] = 0x08; /* AD type: shortened local name */ + cp->data[2] = 't'; /* adv data ... */ cp->data[3] = 'e'; cp->data[4] = 's'; cp->data[5] = 't'; @@ -5020,9 +5105,9 @@ static void setup_add_advertising_timeout(const void *test_data) cp->instance = 1; cp->timeout = 5; cp->adv_data_len = 6; - cp->data[0] = 0x05; - cp->data[1] = 0x08; - cp->data[2] = 't'; + cp->data[0] = 0x05; /* AD len */ + cp->data[1] = 0x08; /* AD type: shortened local name */ + cp->data[2] = 't'; /* adv data ... */ cp->data[3] = 'e'; cp->data[4] = 's'; cp->data[5] = 't'; @@ -5055,9 +5140,9 @@ static void setup_set_and_add_advertising(const void *test_data) cp->instance = 1; cp->adv_data_len = 6; - cp->data[0] = 0x05; - cp->data[1] = 0x08; - cp->data[2] = 't'; + cp->data[0] = 0x05; /* AD len */ + cp->data[1] = 0x08; /* AD type: shortened local name */ + cp->data[2] = 't'; /* adv data ... */ cp->data[3] = 'e'; cp->data[4] = 's'; cp->data[5] = 't'; -- 1.9.1