Bluetooth: ISO: Make it possible to setup unidirectional CIS

The current iso commands in the shell only supports setting up
a bidirectional stream or unidirectional for central role.
Adding rx/tx/rxtx option to iso listen command to allow for
peripheral side configuration of an iso connection.

Signed-off-by: Casper Bonde <casper_bonde@bose.com>
This commit is contained in:
Casper Bonde 2021-05-10 16:51:45 +02:00 committed by Carles Cufí
commit 3af1f4bac5
2 changed files with 30 additions and 8 deletions

View file

@ -140,10 +140,12 @@ struct bt_iso_chan_path {
/** @brief ISO Meta Data structure for received ISO packets. */
struct bt_iso_recv_info {
/** ISO timestamp - valid only if the Bluetooth controller includes it */
/** ISO timestamp - valid only if the Bluetooth controller includes it
* If time stamp is not pressent this value will be 0 on all iso packets
*/
uint32_t ts;
/** ISO Pkt Seq no of the first fragment in the SDU */
/** ISO packet sequence number of the first fragment in the SDU */
uint16_t sn;
};

View file

@ -92,17 +92,36 @@ struct bt_iso_server iso_server = {
static int cmd_listen(const struct shell *shell, size_t argc, char *argv[])
{
int err;
static struct bt_iso_chan_io_qos *tx_qos, *rx_qos;
if (argc > 1) {
iso_server.sec_level = *argv[1] - '0';
if (!strcmp("tx", argv[1])) {
tx_qos = &iso_tx_qos;
rx_qos = NULL;
} else if (!strcmp("rx", argv[1])) {
tx_qos = NULL;
rx_qos = &iso_rx_qos;
} else if (!strcmp("txrx", argv[1])) {
tx_qos = &iso_tx_qos;
rx_qos = &iso_rx_qos;
} else {
shell_error(shell, "Invalid argument - use tx, rx or txrx");
return -ENOEXEC;
}
if (argc > 2) {
iso_server.sec_level = *argv[2] - '0';
}
err = bt_iso_server_register(&iso_server);
if (err) {
shell_error(shell, "Unable to register ISO cap (err %d)",
err);
return err;
}
/* Setup peripheral iso data direction only if register is success */
iso_chan.qos->tx = tx_qos;
iso_chan.qos->rx = rx_qos;
return err;
}
@ -126,13 +145,13 @@ static int cmd_bind(const struct shell *shell, size_t argc, char *argv[])
chans[0] = &iso_chan;
if (argc > 1) {
if (!strcmp("tx", argv[2])) {
if (!strcmp("tx", argv[1])) {
chans[0]->qos->tx = &iso_tx_qos;
chans[0]->qos->rx = NULL;
} else if (!strcmp("rx", argv[2])) {
} else if (!strcmp("rx", argv[1])) {
chans[0]->qos->tx = NULL;
chans[0]->qos->rx = &iso_rx_qos;
} else if (!strcmp("txrx", argv[2])) {
} else if (!strcmp("txrx", argv[1])) {
chans[0]->qos->tx = &iso_tx_qos;
chans[0]->qos->rx = &iso_rx_qos;
}
@ -260,6 +279,7 @@ static int cmd_send(const struct shell *shell, size_t argc, char *argv[])
net_buf_reserve(buf, BT_ISO_CHAN_SEND_RESERVE);
net_buf_add_mem(buf, buf_data, len);
shell_info(shell, "send: %d bytes of data", len);
ret = bt_iso_chan_send(&iso_chan, buf);
if (ret < 0) {
shell_print(shell, "Unable to send: %d", -ret);
@ -476,7 +496,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(iso_cmds,
SHELL_CMD_ARG(bind, NULL, "[dir=tx,rx,txrx] [interval] [packing] [framing] "
"[latency] [sdu] [phy] [rtn]", cmd_bind, 1, 8),
SHELL_CMD_ARG(connect, NULL, "Connect ISO Channel", cmd_connect, 1, 0),
SHELL_CMD_ARG(listen, NULL, "[security level]", cmd_listen, 1, 1),
SHELL_CMD_ARG(listen, NULL, "<dir=tx,rx,txrx> [security level]", cmd_listen, 2, 1),
SHELL_CMD_ARG(send, NULL, "Send to ISO Channel [count]",
cmd_send, 1, 1),
SHELL_CMD_ARG(disconnect, NULL, "Disconnect ISO Channel",