Bluetooth: BAP: Add ISO state callbacks

Add callbacks to the stream objects that reflects the
state of the isochronous channel. The connected callback
is called when the isochronous channel is connected, and
similarly the disconnected callback is called when it is
disconnected.

There is a special case for unicast, where if the ACL
disconnects first, then we won't get a ISO disconnect
callback. It should be assumed that the isochronous channel
is no longer valid when the BAP stream enters the idle state,
i.e. when the "released" callback is called.

The purpose of the new callbacks is to provide additional
information to the application. Especially the unicast client
can use this to determine when the stream_start function
can be called again, as there can only ever be 1 outstanding
CIS connection request at a time, but there can be multiple
GATT requests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2023-12-28 13:50:56 +01:00 committed by Carles Cufí
commit b857ef7f83
13 changed files with 264 additions and 29 deletions

View file

@ -166,10 +166,13 @@ static void broadcast_source_iso_connected(struct bt_iso_chan *chan)
return;
}
ops = stream->ops;
LOG_DBG("stream %p ep %p", stream, ep);
ops = stream->ops;
if (ops != NULL && ops->connected != NULL) {
ops->connected(stream);
}
broadcast_source_set_ep_state(ep, BT_BAP_EP_STATE_STREAMING);
if (ops != NULL && ops->started != NULL) {
@ -197,10 +200,13 @@ static void broadcast_source_iso_disconnected(struct bt_iso_chan *chan, uint8_t
return;
}
ops = stream->ops;
LOG_DBG("stream %p ep %p reason 0x%02x", stream, stream->ep, reason);
ops = stream->ops;
if (ops != NULL && ops->disconnected != NULL) {
ops->disconnected(stream, reason);
}
broadcast_source_set_ep_state(ep, BT_BAP_EP_STATE_QOS_CONFIGURED);
if (ops != NULL && ops->stopped != NULL) {