Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth: ISO: Minor fixes for ISO shell #64244

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions subsys/bluetooth/shell/iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include "bt.h"

#define TX_BUF_TIMEOUT K_SECONDS(1)

static uint32_t cis_sn_last;
static uint32_t bis_sn_last;
static int64_t cis_sn_last_updated_ticks;
Expand Down Expand Up @@ -131,15 +133,15 @@ struct bt_iso_chan iso_chan = {
};

NET_BUF_POOL_FIXED_DEFINE(tx_pool, 1, BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU),
8, NULL);
CONFIG_BT_CONN_TX_USER_DATA_SIZE, NULL);

#if defined(CONFIG_BT_ISO_CENTRAL)
static struct bt_iso_cig *cig;

static int cmd_cig_create(const struct shell *sh, size_t argc, char *argv[])
{
int err;
struct bt_iso_cig_param param;
struct bt_iso_cig_param param = {0};
struct bt_iso_chan *chans[CIS_ISO_CHAN_COUNT];

if (cig != NULL) {
Expand Down Expand Up @@ -504,11 +506,16 @@ static int cmd_send(const struct shell *sh, size_t argc, char *argv[])
cis_sdu_interval_us);

while (count--) {
buf = net_buf_alloc(&tx_pool, K_FOREVER);
buf = net_buf_alloc(&tx_pool, TX_BUF_TIMEOUT);
if (buf == NULL) {
shell_error(sh, "Failed to get buffer...");
return -ENOEXEC;
}

net_buf_reserve(buf, BT_ISO_CHAN_SEND_RESERVE);

net_buf_add_mem(buf, buf_data, len);
shell_info(sh, "send: %d bytes of data", len);
shell_info(sh, "send: %d bytes of data with PSN %u", len, cis_sn_last);
ret = bt_iso_chan_send(&iso_chan, buf, cis_sn_last,
BT_ISO_TIMESTAMP_NONE);
if (ret < 0) {
Expand Down Expand Up @@ -612,23 +619,25 @@ static int cmd_broadcast(const struct shell *sh, size_t argc, char *argv[])
}

len = MIN(bis_iso_chan.qos->tx->sdu, CONFIG_BT_ISO_TX_MTU);

bis_sn_last = get_next_sn(bis_sn_last, &bis_sn_last_updated_ticks,
bis_sdu_interval_us);

while (count--) {
for (int i = 0; i < BIS_ISO_CHAN_COUNT; i++) {
buf = net_buf_alloc(&bis_tx_pool, K_FOREVER);
net_buf_reserve(buf, BT_ISO_CHAN_SEND_RESERVE);

net_buf_add_mem(buf, buf_data, len);
ret = bt_iso_chan_send(&bis_iso_chan, buf, bis_sn_last,
BT_ISO_TIMESTAMP_NONE);
if (ret < 0) {
shell_print(sh, "[%i]: Unable to broadcast: %d", i, -ret);
net_buf_unref(buf);
return -ENOEXEC;
}
buf = net_buf_alloc(&bis_tx_pool, TX_BUF_TIMEOUT);
if (buf == NULL) {
shell_error(sh, "Failed to get buffer...");
return -ENOEXEC;
}

net_buf_reserve(buf, BT_ISO_CHAN_SEND_RESERVE);

net_buf_add_mem(buf, buf_data, len);
shell_info(sh, "send: %d bytes of data with PSN %u", len, bis_sn_last);
ret = bt_iso_chan_send(&bis_iso_chan, buf, bis_sn_last, BT_ISO_TIMESTAMP_NONE);
if (ret < 0) {
shell_print(sh, "Unable to broadcast: %d", -ret);
net_buf_unref(buf);
return -ENOEXEC;
}
}

Expand All @@ -640,7 +649,7 @@ static int cmd_broadcast(const struct shell *sh, size_t argc, char *argv[])
static int cmd_big_create(const struct shell *sh, size_t argc, char *argv[])
{
int err;
struct bt_iso_big_create_param param;
struct bt_iso_big_create_param param = {0};
struct bt_le_ext_adv *adv = adv_sets[selected_adv];

if (!adv) {
Expand Down
Loading