From d0958995a30d6e4cc7e998b23ec00b8eaebbe937 Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Mon, 16 Jun 2025 15:37:34 +0200 Subject: [PATCH] tests: Bluetooth: Tester: Handle BIGInfo after sync request In the BAP Broadcast Sink implementation the sync request, the BIGInfo and the broadcast code can come in any other. Currently the btp_bap_broadcast_sink_bis_sync would reject the request if it came before the BIGInfo, but will now instead store the request and then apply it once the BIGInfo has been received, as there is not BIGInfo BTP event that the caller can use. Signed-off-by: Emil Gydesen --- .../tester/src/audio/btp_bap_broadcast.c | 21 +++++++++++++++++-- .../tester/src/audio/btp_bap_broadcast.h | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/bluetooth/tester/src/audio/btp_bap_broadcast.c b/tests/bluetooth/tester/src/audio/btp_bap_broadcast.c index 79f3bf580a3..3541d1dd14c 100644 --- a/tests/bluetooth/tester/src/audio/btp_bap_broadcast.c +++ b/tests/bluetooth/tester/src/audio/btp_bap_broadcast.c @@ -962,13 +962,18 @@ static void syncable_cb(struct bt_bap_broadcast_sink *sink, const struct bt_iso_ LOG_DBG("Broadcaster PA found, encrypted %d, requested_bis_sync %d", biginfo->encryption, broadcaster->requested_bis_sync); - if (biginfo->encryption) { + broadcaster->biginfo_received = true; + + if (biginfo->encryption && !broadcaster->broadcast_code_received) { /* Wait for Set Broadcast Code and start sync at broadcast_code_cb */ + LOG_DBG("BIGInfo received, but have not yet received broadcast code for encrypted " + "broadcast"); return; } - if (!broadcaster->assistant_request || !broadcaster->requested_bis_sync) { + if (!broadcaster->assistant_request && broadcaster->requested_bis_sync == 0U) { /* No sync with any BIS was requested yet */ + LOG_DBG("BIGInfo received, but have not yet received request to sync to broadcast"); return; } @@ -1205,8 +1210,15 @@ static void broadcast_code_cb(struct bt_conn *conn, broadcaster->sink_recv_state = recv_state; (void)memcpy(broadcaster->sink_broadcast_code, broadcast_code, BT_ISO_BROADCAST_CODE_SIZE); + broadcaster->broadcast_code_received = true; if (!broadcaster->requested_bis_sync) { + LOG_DBG("Broadcast code received, but not requested to sync"); + return; + } + + if (!broadcaster->biginfo_received) { + LOG_DBG("Broadcast code received, but have not yet received BIGInfo"); return; } @@ -1474,6 +1486,11 @@ uint8_t btp_bap_broadcast_sink_bis_sync(const void *cmd, uint16_t cmd_len, void broadcaster->requested_bis_sync = sys_le32_to_cpu(cp->requested_bis_sync); + if (!broadcaster->biginfo_received) { + LOG_DBG("Broadcast sync requested, but have not yet received BIGInfo"); + return BTP_STATUS_SUCCESS; + } + err = bt_bap_broadcast_sink_sync(broadcaster->sink, broadcaster->requested_bis_sync, broadcaster->sink_streams, broadcaster->sink_broadcast_code); diff --git a/tests/bluetooth/tester/src/audio/btp_bap_broadcast.h b/tests/bluetooth/tester/src/audio/btp_bap_broadcast.h index 0f00fa4a142..3f4ef82b256 100644 --- a/tests/bluetooth/tester/src/audio/btp_bap_broadcast.h +++ b/tests/bluetooth/tester/src/audio/btp_bap_broadcast.h @@ -47,6 +47,8 @@ struct btp_bap_broadcast_remote_source { /* BIS Index bitfield read from sync request */ uint32_t requested_bis_sync; bool assistant_request; + bool biginfo_received; + bool broadcast_code_received; uint8_t sink_broadcast_code[BT_ISO_BROADCAST_CODE_SIZE]; const struct bt_bap_scan_delegator_recv_state *sink_recv_state; };