Bluetooth: ISO: Add sent callback

Add a sent callback to bt_iso_chan_ops so that the application
can be notified when an SDU has been sent. This can help the
application decide whether to queue up multiple, or only
have a single ISO PDU enqueue for reduced latency.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2021-08-31 23:02:20 +02:00 committed by Christopher Friedt
commit 3a77308c97
2 changed files with 24 additions and 1 deletions

View file

@ -437,6 +437,15 @@ struct bt_iso_chan_ops {
*/ */
void (*recv)(struct bt_iso_chan *chan, const struct bt_iso_recv_info *info, void (*recv)(struct bt_iso_chan *chan, const struct bt_iso_recv_info *info,
struct net_buf *buf); struct net_buf *buf);
/** @brief Channel sent callback
*
* If this callback is provided it will be called whenever a SDU has
* been completely sent.
*
* @param chan The channel which has sent data.
*/
void (*sent)(struct bt_iso_chan *chan);
}; };
/** @brief ISO Server structure. */ /** @brief ISO Server structure. */

View file

@ -74,6 +74,20 @@ struct net_buf *bt_iso_get_rx(k_timeout_t timeout)
return buf; return buf;
} }
static void bt_iso_send_cb(struct bt_conn *iso, void *user_data)
{
struct bt_iso_chan *chan = iso->iso.chan;
struct bt_iso_chan_ops *ops;
__ASSERT(chan != NULL, "NULL chan for iso %p", iso);
ops = chan->ops;
if (ops != NULL && ops->sent != NULL) {
ops->sent(chan);
}
}
void hci_iso(struct net_buf *buf) void hci_iso(struct net_buf *buf)
{ {
struct bt_hci_iso_hdr *hdr; struct bt_hci_iso_hdr *hdr;
@ -650,7 +664,7 @@ int bt_iso_chan_send(struct bt_iso_chan *chan, struct net_buf *buf)
- sizeof(*hdr), - sizeof(*hdr),
BT_ISO_DATA_VALID)); BT_ISO_DATA_VALID));
return bt_conn_send(chan->iso, buf); return bt_conn_send_cb(chan->iso, buf, bt_iso_send_cb, NULL);
} }
struct bt_conn_iso *bt_conn_iso(struct bt_conn *conn) struct bt_conn_iso *bt_conn_iso(struct bt_conn *conn)