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:
parent
c1a45596c6
commit
3a77308c97
2 changed files with 24 additions and 1 deletions
|
@ -437,6 +437,15 @@ struct bt_iso_chan_ops {
|
|||
*/
|
||||
void (*recv)(struct bt_iso_chan *chan, const struct bt_iso_recv_info *info,
|
||||
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. */
|
||||
|
|
|
@ -74,6 +74,20 @@ struct net_buf *bt_iso_get_rx(k_timeout_t timeout)
|
|||
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)
|
||||
{
|
||||
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),
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue