This adds a new Broadcast Receiver test, to validate that a Broadcast
Sink is able to sync to the PA transmitted by a Source (when no BIG
is active) and is able to successfully detect the BASE:
ISO Broadcaster Receiver Defer Get BASE - Success
This test depends on the kernel updates introduced by patch
Bluetooth: ISO: Handle PA sync when no BIGInfo reports are generated
Iulia Tanasescu (3):
lib: Add macros for HCI_MAX_PER_AD_LENGTH and EIR_SERVICE_DATA_LENGTH
bthost: Add support for Set PA data
iso-tester: Add test for Broadcast Receiver Get BASE
emulator/bthost.c | 48 ++++++++++++++++++++++++++++++-
emulator/bthost.h | 4 ++-
lib/bluetooth.h | 5 +++-
tools/iso-tester.c | 70 ++++++++++++++++++++++++++++++++++++++++++++--
4 files changed, 121 insertions(+), 6 deletions(-)
base-commit: 4520eca3e5d81be77dba629cd62f8d59632240c1
--
2.39.2
This adds bthost_set_pa_data.
---
emulator/bthost.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-
emulator/bthost.h | 4 +++-
2 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/emulator/bthost.c b/emulator/bthost.c
index 8c40fce90..d710f4982 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -5,7 +5,7 @@
*
* Copyright (C) 2011-2012 Intel Corporation
* Copyright (C) 2004-2010 Marcel Holtmann <[email protected]>
- * Copyright 2023 NXP
+ * Copyright 2023-2024 NXP
*
*
*/
@@ -3127,6 +3127,52 @@ void bthost_set_pa_params(struct bthost *bthost)
send_command(bthost, BT_HCI_CMD_LE_SET_PA_PARAMS, &cp, sizeof(cp));
}
+static void set_pa_data(struct bthost *bthost, const uint8_t *data,
+ uint8_t len, uint8_t offset)
+{
+ struct bt_hci_cmd_le_set_pa_data *cp;
+ uint8_t buf[sizeof(*cp) + HCI_MAX_PER_AD_LENGTH];
+
+ cp = (void *)buf;
+
+ memset(cp, 0, sizeof(*cp));
+ memset(cp->data, 0, HCI_MAX_PER_AD_LENGTH);
+
+ cp->handle = 1;
+
+ if (len - offset > HCI_MAX_PER_AD_LENGTH) {
+ cp->data_len = HCI_MAX_PER_AD_LENGTH;
+
+ if (!offset)
+ cp->operation = 0x01;
+ else
+ cp->operation = 0x00;
+ } else {
+ cp->data_len = len - offset;
+
+ if (!offset)
+ cp->operation = 0x03;
+ else
+ cp->operation = 0x02;
+ }
+
+ memcpy(cp->data, data + offset, cp->data_len);
+
+ send_command(bthost, BT_HCI_CMD_LE_SET_PA_DATA, buf,
+ sizeof(*cp) + cp->data_len);
+
+ if (cp->operation == 0x01 || cp->operation == 0x00) {
+ offset += cp->data_len;
+ set_pa_data(bthost, data, len, offset);
+ }
+}
+
+void bthost_set_pa_data(struct bthost *bthost, const uint8_t *data,
+ uint8_t len)
+{
+ set_pa_data(bthost, data, len, 0);
+}
+
void bthost_set_pa_enable(struct bthost *bthost, uint8_t enable)
{
struct bt_hci_cmd_le_set_pa_enable cp;
diff --git a/emulator/bthost.h b/emulator/bthost.h
index 46781365b..f03262d46 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -5,7 +5,7 @@
*
* Copyright (C) 2011-2012 Intel Corporation
* Copyright (C) 2004-2010 Marcel Holtmann <[email protected]>
- * Copyright 2023 NXP
+ * Copyright 2023-2024 NXP
*
*
*/
@@ -102,6 +102,8 @@ void bthost_set_ext_adv_data(struct bthost *bthost, const uint8_t *data,
void bthost_set_ext_adv_params(struct bthost *bthost);
void bthost_set_ext_adv_enable(struct bthost *bthost, uint8_t enable);
void bthost_set_pa_params(struct bthost *bthost);
+void bthost_set_pa_data(struct bthost *bthost, const uint8_t *data,
+ uint8_t len);
void bthost_set_pa_enable(struct bthost *bthost, uint8_t enable);
void bthost_create_big(struct bthost *bthost, uint8_t num_bis, uint8_t enc,
const uint8_t *bcode);
--
2.39.2
This adds the HCI_MAX_PER_AD_LENGTH and EIR_SERVICE_DATA_LENGTH macros.
---
lib/bluetooth.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/bluetooth.h b/lib/bluetooth.h
index 75dc960c8..f67d79f66 100644
--- a/lib/bluetooth.h
+++ b/lib/bluetooth.h
@@ -6,7 +6,7 @@
* Copyright (C) 2000-2001 Qualcomm Incorporated
* Copyright (C) 2002-2003 Maxim Krasnyansky <[email protected]>
* Copyright (C) 2002-2010 Marcel Holtmann <[email protected]>
- * Copyright 2023 NXP
+ * Copyright 2023-2024 NXP
*
*
*/
@@ -191,6 +191,9 @@ struct bt_iso_bcast_qos {
uint16_t timeout;
};
+#define HCI_MAX_PER_AD_LENGTH 252
+#define EIR_SERVICE_DATA_LENGTH 4
+
/* (HCI_MAX_PER_AD_LENGTH - EIR_SERVICE_DATA_LENGTH) */
#define BASE_MAX_LENGTH 248
struct bt_iso_base {
--
2.39.2
This adds a new Broadcast Receiver test, to validate that a Broadcast
Sink is able to sync to the PA transmitted by a Source (when no BIG
is active) and is able to successfully detect the BASE:
ISO Broadcaster Receiver Defer Get BASE - Success
---
tools/iso-tester.c | 70 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 67 insertions(+), 3 deletions(-)
diff --git a/tools/iso-tester.c b/tools/iso-tester.c
index 60afef301..67d698291 100644
--- a/tools/iso-tester.c
+++ b/tools/iso-tester.c
@@ -23,6 +23,7 @@
#include "lib/bluetooth.h"
#include "lib/iso.h"
#include "lib/mgmt.h"
+#include "lib/uuid.h"
#include "monitor/bt.h"
#include "emulator/vhci.h"
@@ -34,6 +35,8 @@
#include "src/shared/util.h"
#include "src/shared/queue.h"
+#define EIR_SERVICE_DATA_16 0x16
+
#define QOS_IO(_interval, _latency, _sdu, _phy, _rtn) \
{ \
.interval = _interval, \
@@ -487,6 +490,7 @@ struct iso_client_data {
size_t base_len;
bool listen_bind;
bool pa_bind;
+ bool big;
};
typedef bool (*iso_defer_accept_t)(struct test_data *data, GIOChannel *io);
@@ -1301,6 +1305,7 @@ static const struct iso_client_data bcast_16_2_1_recv = {
.recv = &send_16_2_1,
.bcast = true,
.server = true,
+ .big = true,
};
static const struct iso_client_data bcast_enc_16_2_1_recv = {
@@ -1309,6 +1314,7 @@ static const struct iso_client_data bcast_enc_16_2_1_recv = {
.recv = &send_16_2_1,
.bcast = true,
.server = true,
+ .big = true,
};
static const struct iso_client_data bcast_16_2_1_recv_defer = {
@@ -1319,6 +1325,7 @@ static const struct iso_client_data bcast_16_2_1_recv_defer = {
.bcast = true,
.server = true,
.listen_bind = true,
+ .big = true,
};
static const struct iso_client_data bcast_16_2_1_recv_defer_no_bis = {
@@ -1327,6 +1334,7 @@ static const struct iso_client_data bcast_16_2_1_recv_defer_no_bis = {
.defer = true,
.bcast = true,
.server = true,
+ .big = true,
};
static const struct iso_client_data bcast_16_2_1_recv_defer_pa_bind = {
@@ -1336,6 +1344,17 @@ static const struct iso_client_data bcast_16_2_1_recv_defer_pa_bind = {
.bcast = true,
.server = true,
.pa_bind = true,
+ .big = true,
+};
+
+static const struct iso_client_data bcast_16_2_1_recv_defer_get_base = {
+ .qos = QOS_IN_16_2_1,
+ .expect_err = 0,
+ .defer = true,
+ .bcast = true,
+ .server = true,
+ .base = base_lc3_ac_12,
+ .base_len = sizeof(base_lc3_ac_12),
};
static const struct iso_client_data bcast_ac_12 = {
@@ -1498,9 +1517,28 @@ static void setup_powered_callback(uint8_t status, uint16_t length,
if (isodata->bcast) {
bthost_set_pa_params(host);
bthost_set_pa_enable(host, 0x01);
- bthost_create_big(host, 1,
- isodata->qos.bcast.encryption,
- isodata->qos.bcast.bcode);
+
+ if (isodata->base) {
+ uint8_t eir[HCI_MAX_PER_AD_LENGTH] = {0};
+ uint16_t eir_len = 0;
+
+ eir[eir_len++] = EIR_SERVICE_DATA_LENGTH - 1 +
+ isodata->base_len;
+ eir[eir_len++] = EIR_SERVICE_DATA_16;
+ put_le16(BAA_SERVICE, &eir[eir_len]);
+ eir_len += 2;
+ memcpy(&eir[eir_len], isodata->base,
+ isodata->base_len);
+ eir_len += isodata->base_len;
+
+ bthost_set_pa_data(host, eir, eir_len);
+ }
+
+ if (isodata->big)
+ bthost_create_big(host, 1,
+ isodata->qos.bcast.encryption,
+ isodata->qos.bcast.bcode);
+
} else if (!isodata->send && isodata->recv) {
const uint8_t *bdaddr;
@@ -2183,6 +2221,7 @@ static gboolean iso_connect(GIOChannel *io, GIOCondition cond,
socklen_t len;
struct bt_iso_qos qos;
bool ret = true;
+ uint8_t base[BASE_MAX_LENGTH] = {0};
sk = g_io_channel_unix_get_fd(io);
@@ -2211,6 +2250,27 @@ static gboolean iso_connect(GIOChannel *io, GIOCondition cond,
return FALSE;
}
+ if (isodata->bcast && isodata->server && isodata->base) {
+ len = BASE_MAX_LENGTH;
+
+ if (getsockopt(sk, SOL_BLUETOOTH, BT_ISO_BASE,
+ base, &len) < 0) {
+ tester_warn("Can't get socket option : %s (%d)",
+ strerror(errno), errno);
+ data->step = 0;
+ tester_test_failed();
+ return FALSE;
+ }
+
+ if (len != isodata->base_len ||
+ memcmp(base, isodata->base, len)) {
+ tester_warn("Unexpected BASE");
+ data->step = 0;
+ tester_test_failed();
+ return FALSE;
+ }
+ }
+
len = sizeof(sk_err);
if (getsockopt(sk, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0)
@@ -3383,6 +3443,10 @@ int main(int argc, char *argv[])
&bcast_16_2_1_recv_defer_pa_bind,
setup_powered,
test_bcast_recv_defer);
+ test_iso("ISO Broadcaster Receiver Defer Get BASE - Success",
+ &bcast_16_2_1_recv_defer_get_base,
+ setup_powered,
+ test_bcast_recv);
test_iso("ISO Broadcaster AC 12 - Success", &bcast_ac_12, setup_powered,
test_bcast);
--
2.39.2
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=840594
---Test result---
Test Summary:
CheckPatch PASS 1.06 seconds
GitLint FAIL 0.93 seconds
BuildEll FAIL 20.18 seconds
BluezMake PASS 1616.74 seconds
MakeCheck PASS 12.97 seconds
MakeDistcheck PASS 175.42 seconds
CheckValgrind PASS 243.56 seconds
CheckSmatch WARNING 347.79 seconds
bluezmakeextell FAIL 6.77 seconds
IncrementalBuild PASS 4627.14 seconds
ScanBuild PASS 984.86 seconds
Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ,1/3] lib: Add macros for HCI_MAX_PER_AD_LENGTH and EIR_SERVICE_DATA_LENGTH
WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
1: T1 Title exceeds max length (81>80): "[BlueZ,1/3] lib: Add macros for HCI_MAX_PER_AD_LENGTH and EIR_SERVICE_DATA_LENGTH"
##############################
Test: BuildEll - FAIL
Desc: Build and Install ELL
Output:
writing RSA key
writing RSA key
writing RSA key
writing RSA key
writing RSA key
make[1]: *** [Makefile:3253: unit/ec-cert-server.pem] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1293: all] Error 2
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
emulator/bthost.c:584:28: warning: Variable length array is used.emulator/bthost.c:741:28: warning: Variable length array is used.
##############################
Test: bluezmakeextell - FAIL
Desc: Build Bluez with External ELL
Output:
configure.ac:21: installing './compile'
configure.ac:36: installing './config.guess'
configure.ac:36: installing './config.sub'
configure.ac:5: installing './install-sh'
configure.ac:5: installing './missing'
Makefile.am: installing './depcomp'
parallel-tests: installing './test-driver'
Package cups was not found in the pkg-config search path.
Perhaps you should add the directory containing `cups.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cups' found
configure: error: Package requirements (ell >= 0.39) were not met:
No package 'ell' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables ELL_CFLAGS
and ELL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
---
Regards,
Linux Bluetooth
Hi Iulia,
On Tue, Apr 2, 2024 at 7:43 AM Iulia Tanasescu <[email protected]> wrote:
>
> This adds a new Broadcast Receiver test, to validate that a Broadcast
> Sink is able to sync to the PA transmitted by a Source (when no BIG
> is active) and is able to successfully detect the BASE:
>
> ISO Broadcaster Receiver Defer Get BASE - Success
> ---
> tools/iso-tester.c | 70 ++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 67 insertions(+), 3 deletions(-)
>
> diff --git a/tools/iso-tester.c b/tools/iso-tester.c
> index 60afef301..67d698291 100644
> --- a/tools/iso-tester.c
> +++ b/tools/iso-tester.c
> @@ -23,6 +23,7 @@
> #include "lib/bluetooth.h"
> #include "lib/iso.h"
> #include "lib/mgmt.h"
> +#include "lib/uuid.h"
>
> #include "monitor/bt.h"
> #include "emulator/vhci.h"
> @@ -34,6 +35,8 @@
> #include "src/shared/util.h"
> #include "src/shared/queue.h"
>
> +#define EIR_SERVICE_DATA_16 0x16
> +
> #define QOS_IO(_interval, _latency, _sdu, _phy, _rtn) \
> { \
> .interval = _interval, \
> @@ -487,6 +490,7 @@ struct iso_client_data {
> size_t base_len;
> bool listen_bind;
> bool pa_bind;
> + bool big;
> };
>
> typedef bool (*iso_defer_accept_t)(struct test_data *data, GIOChannel *io);
> @@ -1301,6 +1305,7 @@ static const struct iso_client_data bcast_16_2_1_recv = {
> .recv = &send_16_2_1,
> .bcast = true,
> .server = true,
> + .big = true,
> };
>
> static const struct iso_client_data bcast_enc_16_2_1_recv = {
> @@ -1309,6 +1314,7 @@ static const struct iso_client_data bcast_enc_16_2_1_recv = {
> .recv = &send_16_2_1,
> .bcast = true,
> .server = true,
> + .big = true,
> };
>
> static const struct iso_client_data bcast_16_2_1_recv_defer = {
> @@ -1319,6 +1325,7 @@ static const struct iso_client_data bcast_16_2_1_recv_defer = {
> .bcast = true,
> .server = true,
> .listen_bind = true,
> + .big = true,
> };
>
> static const struct iso_client_data bcast_16_2_1_recv_defer_no_bis = {
> @@ -1327,6 +1334,7 @@ static const struct iso_client_data bcast_16_2_1_recv_defer_no_bis = {
> .defer = true,
> .bcast = true,
> .server = true,
> + .big = true,
> };
>
> static const struct iso_client_data bcast_16_2_1_recv_defer_pa_bind = {
> @@ -1336,6 +1344,17 @@ static const struct iso_client_data bcast_16_2_1_recv_defer_pa_bind = {
> .bcast = true,
> .server = true,
> .pa_bind = true,
> + .big = true,
> +};
> +
> +static const struct iso_client_data bcast_16_2_1_recv_defer_get_base = {
> + .qos = QOS_IN_16_2_1,
> + .expect_err = 0,
> + .defer = true,
> + .bcast = true,
> + .server = true,
> + .base = base_lc3_ac_12,
> + .base_len = sizeof(base_lc3_ac_12),
> };
>
> static const struct iso_client_data bcast_ac_12 = {
> @@ -1498,9 +1517,28 @@ static void setup_powered_callback(uint8_t status, uint16_t length,
> if (isodata->bcast) {
> bthost_set_pa_params(host);
> bthost_set_pa_enable(host, 0x01);
> - bthost_create_big(host, 1,
> - isodata->qos.bcast.encryption,
> - isodata->qos.bcast.bcode);
> +
> + if (isodata->base) {
> + uint8_t eir[HCI_MAX_PER_AD_LENGTH] = {0};
> + uint16_t eir_len = 0;
> +
> + eir[eir_len++] = EIR_SERVICE_DATA_LENGTH - 1 +
> + isodata->base_len;
> + eir[eir_len++] = EIR_SERVICE_DATA_16;
> + put_le16(BAA_SERVICE, &eir[eir_len]);
> + eir_len += 2;
> + memcpy(&eir[eir_len], isodata->base,
> + isodata->base_len);
> + eir_len += isodata->base_len;
I'd use util_iov helpers to generate this instead of manually
generating it like above.
> +
> + bthost_set_pa_data(host, eir, eir_len);
> + }
> +
> + if (isodata->big)
> + bthost_create_big(host, 1,
> + isodata->qos.bcast.encryption,
> + isodata->qos.bcast.bcode);
> +
> } else if (!isodata->send && isodata->recv) {
> const uint8_t *bdaddr;
>
> @@ -2183,6 +2221,7 @@ static gboolean iso_connect(GIOChannel *io, GIOCondition cond,
> socklen_t len;
> struct bt_iso_qos qos;
> bool ret = true;
> + uint8_t base[BASE_MAX_LENGTH] = {0};
>
> sk = g_io_channel_unix_get_fd(io);
>
> @@ -2211,6 +2250,27 @@ static gboolean iso_connect(GIOChannel *io, GIOCondition cond,
> return FALSE;
> }
>
> + if (isodata->bcast && isodata->server && isodata->base) {
> + len = BASE_MAX_LENGTH;
> +
> + if (getsockopt(sk, SOL_BLUETOOTH, BT_ISO_BASE,
> + base, &len) < 0) {
> + tester_warn("Can't get socket option : %s (%d)",
> + strerror(errno), errno);
> + data->step = 0;
> + tester_test_failed();
> + return FALSE;
> + }
> +
> + if (len != isodata->base_len ||
> + memcmp(base, isodata->base, len)) {
> + tester_warn("Unexpected BASE");
> + data->step = 0;
> + tester_test_failed();
> + return FALSE;
> + }
> + }
> +
> len = sizeof(sk_err);
>
> if (getsockopt(sk, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0)
> @@ -3383,6 +3443,10 @@ int main(int argc, char *argv[])
> &bcast_16_2_1_recv_defer_pa_bind,
> setup_powered,
> test_bcast_recv_defer);
> + test_iso("ISO Broadcaster Receiver Defer Get BASE - Success",
> + &bcast_16_2_1_recv_defer_get_base,
> + setup_powered,
> + test_bcast_recv);
>
> test_iso("ISO Broadcaster AC 12 - Success", &bcast_ac_12, setup_powered,
> test_bcast);
> --
> 2.39.2
>
--
Luiz Augusto von Dentz