Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth: ISO: Make setting ISO data explicit #75549

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

Thalley
Copy link
Collaborator

@Thalley Thalley commented Jul 7, 2024

The stack will no longer implicitly set the data path for ISO channel, and the responsibility for doing that is now for the upper layers/applications.

This provides additional flexibility for the higher layers as they can better control the values and timing of the data path, as well as support removing and even reconfiguring the data path at will.

Finally this also removes some complexity from the stack.

fixes #68359

@Thalley Thalley force-pushed the iso_data_path_refactor branch from 817b7dc to 9088297 Compare January 21, 2025 13:25
@Thalley Thalley force-pushed the iso_data_path_refactor branch from 9088297 to 40bb978 Compare February 4, 2025 11:58
@Thalley Thalley marked this pull request as ready for review February 6, 2025 06:10
@Thalley Thalley added this to the v4.1.0 milestone Feb 6, 2025
@Thalley Thalley requested review from cvinayak and removed request for theob-pro February 14, 2025 12:47
@@ -404,6 +404,10 @@ Bluetooth Audio
Bluetooth Host
==============

* The ISO data paths are not longer setup automatically, and shall explicitly be setup and removd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* The ISO data paths are not longer setup automatically, and shall explicitly be setup and removd
* The ISO data paths are not longer setup automatically, and shall explicitly be setup and removed

@Thalley Thalley force-pushed the iso_data_path_refactor branch 2 times, most recently from 770a9c4 to 505cedd Compare February 14, 2025 13:10
@Thalley
Copy link
Collaborator Author

Thalley commented Feb 14, 2025

ideally #83539 would get merged first to add additional TX and RX verification

@Thalley Thalley requested a review from cvinayak February 17, 2025 10:28
@Thalley Thalley force-pushed the iso_data_path_refactor branch from 505cedd to bd0219c Compare February 17, 2025 10:28
@Thalley Thalley force-pushed the iso_data_path_refactor branch from bd0219c to 3a1f2c7 Compare February 28, 2025 09:32
@Thalley Thalley modified the milestones: v4.1.0, v4.2.0 Mar 4, 2025
@Thalley Thalley force-pushed the iso_data_path_refactor branch 2 times, most recently from b80bdac to 2dd043a Compare March 9, 2025 21:34
@Thalley Thalley requested review from rugeGerritsen and removed request for jori-nordic March 11, 2025 14:54
@Thalley Thalley force-pushed the iso_data_path_refactor branch from 2dd043a to abd66d0 Compare March 11, 2025 14:57
Copy link
Collaborator

@rugeGerritsen rugeGerritsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked at API docs only.
Will you also add a new test testing adding a data path twice/removing it twice?

Comment on lines +189 to +190
BT_ISO_CHAN_TYPE_CENTRAL, /**< Connected as central */
BT_ISO_CHAN_TYPE_PERIPHERAL, /**< Connected as peripheral */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also an API change which would need an entry in the migration guide

*/
uint32_t delay;
/** Codec Configuration length */
uint8_t cc_len;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhat unrelated: Now that we are changing the API, would it make sense to change the name to make it easier to understand? cc_len -> codec_config_len

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not. This PR is already large enough, and adding more API changes will just make it larger. If we want to do any renames, then I suggest to do that in a follow-up PR while the API is still considered unstable.

Comment on lines 713 to 719
* If the channel was established then it still contain references to the BIS/CIS handles
* and is not completely free'd at this point. The memory of the channel shall not be
* memset to 0 or free'd.
* To avoid any issue it is recommended to use a @ref k_work_submit or similar to not
* overwrite any data while in the callback.
*
* For the above reason it is still possible to use bt_iso_chan_get_info() on the @p chan.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't really understand what is meant with this section. Could you elaborate a bit on this?

From a controller point of view, the CIS Central handles remain valid after a disconnection, but this is not the case for a peripheral.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redid the text a bit. The main purpose was to document that this callback is similar to the bt_conn.disconnected callback, and the chan object is still valid in the host until after this function returns.

*
* Removes the ISO data path configured by bt_iso_setup_data_path() for the provided @p dir.
*
* As per Bluetooth Core specification 5.4, Vol 4, Part E, Section 7.7.5, the data paths of CIS for
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Here we should reference the newest core spec (6.0.)

*
* Removes the ISO data path configured by bt_iso_setup_data_path() for the provided @p dir.
*
* As per Bluetooth Core specification 5.4, Vol 4, Part E, Section 7.7.5, the data paths of CIS for
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The important part of the sentence comes at the very end of a long sentence. I would suggest to flip it around to make it easier to read:

Suggested change
* As per Bluetooth Core specification 5.4, Vol 4, Part E, Section 7.7.5, the data paths of CIS for
* The data paths for a CIS for a Peripheral are removed upon disconnection as per ....

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did that for all paragraphs

@@ -1,12 +1,13 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
* Copyright (c) 2021-2024 Nordic Semiconductor ASA
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we are in 2025 now :)

@Thalley Thalley force-pushed the iso_data_path_refactor branch from abd66d0 to 8ab1ec8 Compare March 12, 2025 08:14
@Thalley Thalley requested a review from rugeGerritsen March 12, 2025 08:14
The stack will no longer implicitly set the data path
for ISO channel, and the responsibility for doing that is
now for the upper layers/applications.

This provides additional flexibility for the higher layers
as they can better control the values and timing of the data
path, as well as support removing and even reconfiguring the
data path at will.
This also removes some complexity from the stack.

This commit also fixed a inconsistency in the disconnected
handler. CIS for centrals as well as BIS were still valid
bt_iso_chan channels in the disconnected callback,
but CIS for peripherals were completely cleaned up at this
point. This issue is fixed by moving the disconnected callback
handling to before the code to cleanup the channel for
peripherals.

Since there is a difference in how you remove data paths
depending on the GAP role (central/peripheral), the
iso_info struct type has been expanded to be more
concise of which type of CIS it is.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
@Thalley Thalley force-pushed the iso_data_path_refactor branch from 8ab1ec8 to c65b2e6 Compare March 13, 2025 10:00
Copy link
Contributor

@larsgk larsgk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but would like to have an extra set of eyes on it (trying to poke someone)

@kartben kartben merged commit 065dca7 into zephyrproject-rtos:main Mar 19, 2025
23 checks passed
@Thalley Thalley deleted the iso_data_path_refactor branch March 19, 2025 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Audio area: Bluetooth Controller area: Bluetooth Host Bluetooth Host (excluding BR/EDR) area: Bluetooth ISO Bluetooth LE Isochronous Channels area: Bluetooth area: Samples Samples Release Notes To be mentioned in the release notes
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Bluetooth: ISO: Change implicit ISO data path setup to explicit ISO data path setup
9 participants