Skip to content

Commit

Permalink
samples: bluetooth: central_iso: remove latency
Browse files Browse the repository at this point in the history
Zephyr's OSS bluetooth controller implementation has distinct timing
approaches for SDUs that are scheduled from within the controller stack
(with well-known phase information) and SDUs scheduled via HCI (with
unknown phase information). The former will be scheduled for the next
ISO event, the latter one ISO interval in the future, to avoid race
conditions.

The change caters for this detail by incrementing the sequence number
once after the first SDU has been sent out to avoid unnecessary latency
in subsequent package scheduling. This should not lead to a race
condition as we start our timer from the connection callback which
provides a sufficiently repeatable anchor point for timing.

Signed-off-by: Florian Grandel <[email protected]>
  • Loading branch information
Florian Grandel committed May 11, 2024
1 parent 1dc8470 commit fb95936
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions samples/bluetooth/central_iso/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ static void iso_timer_timeout(struct k_timer *timer)

seq_num++;

/* The first packet will be delivered while not active in an ISO event,
* therefore the controller stack adds an extra CIS interval to allow for
* ISO-AL processing, see @ref hci_iso_handle().
*/
if (unlikely(seq_num == 2)) {
seq_num++;
}

/* iso_send_sdu_work will access seq_num, so be sure to update it
* before submitting the work.
*/
Expand Down

0 comments on commit fb95936

Please sign in to comment.