From 69f1236657e01a496e85a85223ac763d63db4b77 Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Wed, 20 Oct 2021 14:48:58 +0200 Subject: [PATCH] Bluetooth: ISO: Store SDU and PHY for peripheral When an CIS is connected, the peripheral did not have any information about the QoS settings. This commit adds information about the PHY and SDU. For some reason the peripheral won't ever have information about the RTN. The remaining values in the event (interval, delay and latency) are still not exposed, nor is framing or packing, the latter of which are not part of the event. Signed-off-by: Emil Gydesen --- include/bluetooth/iso.h | 4 ++++ subsys/bluetooth/host/iso.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/bluetooth/iso.h b/include/bluetooth/iso.h index e43b1cd31c4..93f69649ae9 100644 --- a/include/bluetooth/iso.h +++ b/include/bluetooth/iso.h @@ -405,6 +405,10 @@ struct bt_iso_chan_ops { * If this callback is provided it will be called whenever the * connection completes. * + * For a peripheral, the QoS values (see @ref bt_iso_chan_io_qos) + * are set when this is called. The peripheral does not have any + * information about the RTN though. + * * @param chan The channel that has been connected */ void (*connected)(struct bt_iso_chan *chan); diff --git a/subsys/bluetooth/host/iso.c b/subsys/bluetooth/host/iso.c index d14e93fb63b..964d788b471 100644 --- a/subsys/bluetooth/host/iso.c +++ b/subsys/bluetooth/host/iso.c @@ -815,6 +815,28 @@ void hci_le_cis_established(struct net_buf *buf) } if (!evt->status) { + if (iso->role == BT_HCI_ROLE_PERIPHERAL) { + struct bt_iso_chan *chan = iso->iso.chan; + struct bt_iso_chan_io_qos *rx; + struct bt_iso_chan_io_qos *tx; + + __ASSERT(chan != NULL && chan->qos != NULL, + "Invalid ISO chan"); + + rx = chan->qos->rx; + tx = chan->qos->tx; + + if (rx != NULL) { + rx->phy = evt->c_phy; + rx->sdu = evt->c_max_pdu; + } + + if (tx != NULL) { + tx->phy = evt->p_phy; + tx->sdu = evt->p_max_pdu; + } + } /* values are already set for central */ + /* TODO: Add CIG sync delay */ bt_conn_set_state(iso, BT_CONN_CONNECTED); bt_conn_unref(iso);