Skip to content

Commit

Permalink
tests: Bluetooth: ISO: Add validation of broadcast info
Browse files Browse the repository at this point in the history
Add validation of the info the application can retrieve by
calling bt_iso_chan_get_info.

Signed-off-by: Emil Gydesen <[email protected]>
  • Loading branch information
Thalley committed Nov 6, 2024
1 parent d4b7bf9 commit 849e439
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/zephyr/bluetooth/hci_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -3348,6 +3348,13 @@ struct bt_hci_evt_le_cis_req {
uint8_t cis_id;
} __packed;

#define BT_HCI_LE_BIG_HANDLE_MIN 0x00
#define BT_HCI_LE_BIG_HANDLE_MAX 0xEF
#define BT_HCI_LE_BIG_SYNC_DELAY_MIN 0x000030U
#define BT_HCI_LE_BIG_SYNC_DELAY_MAX 0x7FFFFFU
#define BT_HCI_LE_TRANSPORT_LATENCY_BIG_MIN 0x000030U
#define BT_HCI_LE_TRANSPORT_LATENCY_BIG_MAX 0x7FFFFFU

#define BT_HCI_EVT_LE_BIG_COMPLETE 0x1b
struct bt_hci_evt_le_big_complete {
uint8_t status;
Expand Down
42 changes: 42 additions & 0 deletions tests/bsim/bluetooth/host/iso/bis/src/bis_broadcaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
#include "common.h"

#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/bluetooth/hci_types.h>
#include <zephyr/bluetooth/iso.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/util.h>

#include "babblekit/flags.h"
#include "babblekit/sync.h"
Expand Down Expand Up @@ -210,6 +213,45 @@ static void create_big(struct bt_le_ext_adv *adv, size_t cnt, struct bt_iso_big
TEST_ASSERT(err == 0, "Failed to create BIG: %d", err);

WAIT_FOR_FLAG(flag_iso_connected);

for (size_t i = 0; i < cnt; i++) {
struct bt_iso_info info;

err = bt_iso_chan_get_info(channels[i], &info);
TEST_ASSERT(err == 0, "Failed to get BIS info: %d", err);

TEST_ASSERT(!info.can_recv);
TEST_ASSERT(info.can_send);
TEST_ASSERT(info.type == BT_ISO_CHAN_TYPE_BROADCASTER);
TEST_ASSERT((info.iso_interval % param.interval) == 0U,
"ISO interval %u shall be a multiple of the SDU interval %u",
info.iso_interval, param.interval);
TEST_ASSERT(IN_RANGE(info.iso_interval, BT_ISO_ISO_INTERVAL_MIN,
BT_ISO_ISO_INTERVAL_MAX),
"Invalid ISO interval 0x%04x", info.iso_interval);
TEST_ASSERT(IN_RANGE(info.max_subevent, BT_ISO_NSE_MIN, BT_ISO_NSE_MAX),
"Invalid subevent number 0x%02x", info.max_subevent);
TEST_ASSERT(IN_RANGE(info.broadcaster.sync_delay, BT_HCI_LE_BIG_SYNC_DELAY_MIN,
BT_HCI_LE_BIG_SYNC_DELAY_MAX),
"Invalid sync delay 0x%06x", info.broadcaster.sync_delay);
TEST_ASSERT(IN_RANGE(info.broadcaster.latency, BT_HCI_LE_TRANSPORT_LATENCY_BIG_MIN,
BT_HCI_LE_TRANSPORT_LATENCY_BIG_MAX),
"Invalid transport latency 0x%06x", info.broadcaster.latency);
TEST_ASSERT((info.broadcaster.pto % info.iso_interval) == 0U,
"PTO in ms %u shall be a multiple of the ISO interval %u",
info.broadcaster.pto, info.iso_interval);
TEST_ASSERT(IN_RANGE((info.broadcaster.pto / info.iso_interval), BT_ISO_PTO_MIN,
BT_ISO_PTO_MAX),
"Invalid PTO 0x%x", (info.broadcaster.pto / info.iso_interval));
TEST_ASSERT(info.broadcaster.phy == BT_GAP_LE_PHY_1M ||
info.broadcaster.phy == BT_GAP_LE_PHY_2M ||
info.broadcaster.phy == BT_GAP_LE_PHY_CODED,
"Invalid PHY 0x%02x", info.broadcaster.phy);
TEST_ASSERT(IN_RANGE(info.broadcaster.bn, BT_ISO_BN_MIN, BT_ISO_BN_MAX),
"Invalid BN 0x%02x", info.broadcaster.bn);
TEST_ASSERT(IN_RANGE(info.broadcaster.irc, BT_ISO_IRC_MIN, BT_ISO_IRC_MAX),
"Invalid IRC 0x%02x", info.broadcaster.irc);
}
}

static void start_tx(void)
Expand Down

0 comments on commit 849e439

Please sign in to comment.