Bluetooth: ISO: Extract and store information about RX and TX

Instead of relying only on the `tx` and `rx` qos pointers,
we extract further information from the
bt_hci_evt_le_cis_established event to properly determine if we
can actually send or receive data.

This is useful to help determine which data paths to setup,
and whether to reject requests to send.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2022-01-20 17:53:48 +01:00 committed by Carles Cufí
parent 476d199752
commit b88b25adac
2 changed files with 39 additions and 11 deletions

View file

@ -703,6 +703,11 @@ struct bt_iso_info {
/** The maximum number of subevents in each ISO event */
uint8_t max_subevent;
/** True if the channel can transmit ISO data */
bool can_send;
/** True if the channel can receive ISO data */
bool can_recv;
/** Connection Type specific Info.*/
union {
#if defined(CONFIG_BT_ISO_UNICAST)

View file

@ -811,23 +811,23 @@ void hci_le_cis_established(struct net_buf *buf)
}
if (!evt->status) {
struct bt_iso_chan_io_qos *tx;
struct bt_iso_chan_io_qos *rx;
struct bt_conn_iso *iso_conn;
struct bt_iso_chan *chan;
iso_conn = &iso->iso;
chan = iso_conn->chan;
__ASSERT(chan != NULL && chan->qos != NULL, "Invalid ISO chan");
/* Reset sequence number */
iso->iso.seq_num = 0;
iso_conn = &iso->iso;
tx = chan->qos->tx;
rx = chan->qos->rx;
if (iso->role == BT_HCI_ROLE_PERIPHERAL) {
struct bt_iso_chan_io_qos *rx;
struct bt_iso_chan_io_qos *tx;
struct bt_iso_chan *chan;
chan = iso_conn->chan;
__ASSERT(chan != NULL && chan->qos != NULL,
"Invalid ISO chan");
rx = chan->qos->rx;
tx = chan->qos->tx;
@ -844,8 +844,31 @@ void hci_le_cis_established(struct net_buf *buf)
iso_conn->info.type = BT_ISO_CHAN_TYPE_CONNECTED;
} /* values are already set for central */
store_cis_info(evt, &iso_conn->info);
/* Verify if device can send */
iso_conn->info.can_send = false;
if (tx != NULL) {
if (iso->role == BT_HCI_ROLE_PERIPHERAL &&
evt->p_bn > 0) {
iso_conn->info.can_send = true;
} else if (iso->role == BT_HCI_ROLE_CENTRAL &&
evt->c_bn > 0) {
iso_conn->info.can_send = true;
}
}
/* Verify if device can recv */
iso_conn->info.can_recv = false;
if (rx != NULL) {
if (iso->role == BT_HCI_ROLE_PERIPHERAL &&
evt->c_bn > 0) {
iso_conn->info.can_recv = true;
} else if (iso->role == BT_HCI_ROLE_CENTRAL &&
evt->p_bn > 0) {
iso_conn->info.can_recv = true;
}
}
store_cis_info(evt, &iso_conn->info);
bt_conn_set_state(iso, BT_CONN_CONNECTED);
bt_conn_unref(iso);
return;