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: CAP: Commander Reception start procedure #69593

Merged

Conversation

kruithofa
Copy link
Collaborator

@kruithofa kruithofa commented Feb 29, 2024

Add the CAP commander reception start procedure which starts reception on one or more CAP acceptors

fixes #64358

include/zephyr/bluetooth/audio/cap.h Outdated Show resolved Hide resolved
*
* @param conn Pointer to the connection where the error
* occurred. NULL if @p err is 0 or if cancelled by
* bt_cap_initiator_unucast_audio_cancel()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* bt_cap_initiator_unucast_audio_cancel()
* bt_cap_commander_cancel()

Copy link
Collaborator

Choose a reason for hiding this comment

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

@kruithofa you may also have missed this one

subsys/bluetooth/audio/cap_commander.c Outdated Show resolved Hide resolved
subsys/bluetooth/audio/cap_commander.c Outdated Show resolved Hide resolved
subsys/bluetooth/audio/cap_commander.c Outdated Show resolved Hide resolved
subsys/bluetooth/audio/cap_commander.c Show resolved Hide resolved
subsys/bluetooth/audio/cap_internal.h Outdated Show resolved Hide resolved
subsys/bluetooth/audio/cap_internal.h Outdated Show resolved Hide resolved
@kruithofa kruithofa force-pushed the CAP_broadcast_start_impl branch 4 times, most recently from 0e78935 to c11044f Compare April 17, 2024 07:03
@Thalley Thalley self-requested a review April 17, 2024 07:21
Copy link
Collaborator

@Thalley Thalley left a comment

Choose a reason for hiding this comment

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

Some additional comments, and some comments still remaining from previous review

subsys/bluetooth/audio/cap_commander.c Outdated Show resolved Hide resolved
subsys/bluetooth/audio/cap_commander.c Outdated Show resolved Hide resolved
subsys/bluetooth/audio/cap_commander.c Outdated Show resolved Hide resolved
subsys/bluetooth/audio/cap_commander.c Show resolved Hide resolved
@kruithofa kruithofa force-pushed the CAP_broadcast_start_impl branch 2 times, most recently from 2986d41 to fcb5de1 Compare April 23, 2024 11:16
Copy link
Collaborator

@Thalley Thalley left a comment

Choose a reason for hiding this comment

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

A few minor comments (and some old comments that are still missing responses

return false;
}

if (start_param->num_subgroups > CONFIG_BT_BAP_BASS_MAX_SUBGROUPS) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (start_param->num_subgroups > CONFIG_BT_BAP_BASS_MAX_SUBGROUPS) {
CHECKIF(start_param->num_subgroups > CONFIG_BT_BAP_BASS_MAX_SUBGROUPS) {

Comment on lines 247 to 267
CHECKIF(!valid_bis_syncs(start_param->subgroups[j].bis_sync)) {
LOG_DBG("param->param[%zu].subgroup[%zu].bis_sync is invalid", i,
j);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should also consider validating that the bis_sync of each subgroup are distinct, e.g. subgroup 1 and 2 cannot both have index 0x02.

This can be done by something like

uint32_t total_bis_sync = 0U;

for (...) {
    if (total_bis_sync & start_param->subgroups[j].bis_sync != 0) {
        /* invalid parameters */
    }

    total_bis_sync |= start_param->subgroups[j].bis_sync;
}

Comment on lines 252 to 253
if (start_param->subgroups[j].metadata_len >
CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since metadata is always LTV encoded, we could (should?) check if it's valid. You can use bt_audio_valid_ltv for that

@kruithofa kruithofa force-pushed the CAP_broadcast_start_impl branch from fcb5de1 to de76a25 Compare April 24, 2024 13:29
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That creates conflicts in other unittests. Instead I'll compile in the complete bap_stream.c file (even though that adds a lot that we do not need)

Copy link
Collaborator

Choose a reason for hiding this comment

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

That creates conflicts in other unittests.

Oh :O What conflicts? Adding an implementation of a single function seems unlikely to cause such issues.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are some other unittests which include the original bap_stream.c (from subsys/bluetooth/audio), which causes multiple definitions of a function.

subsys/bluetooth/audio/cap_commander.c Outdated Show resolved Hide resolved
subsys/bluetooth/audio/cap_commander.c Outdated Show resolved Hide resolved
subsys/bluetooth/audio/cap_commander.c Outdated Show resolved Hide resolved
subsys/bluetooth/audio/cap_commander.c Outdated Show resolved Hide resolved
subsys/bluetooth/audio/cap_commander.c Outdated Show resolved Hide resolved
subsys/bluetooth/audio/cap_commander.c Outdated Show resolved Hide resolved
@kruithofa kruithofa force-pushed the CAP_broadcast_start_impl branch 2 times, most recently from d4062b6 to 3c908dc Compare April 25, 2024 07:38
Add the CAP commander reception start procedure which starts reception
on one or more CAP acceptors

With the implementation of broadcast reception start procedure we also need
some mockups for unit testing

Signed-off-by: Andries Kruithof <[email protected]>
@kruithofa kruithofa force-pushed the CAP_broadcast_start_impl branch from 3c908dc to bcc1205 Compare April 25, 2024 07:41
Comment on lines +74 to +84
#if defined(CONFIG_BT_BAP_BROADCAST_ASSISTANT)
struct cap_broadcast_reception_start {

bt_addr_le_t addr;
uint8_t adv_sid;
uint32_t broadcast_id;
uint16_t pa_interval;
uint8_t num_subgroups;
struct bt_bap_bass_subgroup subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
};
#endif /* CONFIG_BT_BAP_BROADCAST_ASSISTANT */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#if defined(CONFIG_BT_BAP_BROADCAST_ASSISTANT)
struct cap_broadcast_reception_start {
bt_addr_le_t addr;
uint8_t adv_sid;
uint32_t broadcast_id;
uint16_t pa_interval;
uint8_t num_subgroups;
struct bt_bap_bass_subgroup subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
};
#endif /* CONFIG_BT_BAP_BROADCAST_ASSISTANT */
#if defined(CONFIG_BT_BAP_BROADCAST_ASSISTANT)
struct cap_broadcast_reception_start {
bt_addr_le_t addr;
uint8_t adv_sid;
uint32_t broadcast_id;
uint16_t pa_interval;
uint8_t num_subgroups;
struct bt_bap_bass_subgroup subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
};
#endif /* CONFIG_BT_BAP_BROADCAST_ASSISTANT */

Didn't consider that we'd have to move this out of the union to pass it on as an argument, but of course that's required.

It's OK as is, but you can also revert this if you like

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 think I like it this way, and it can be argued that the union is more readable if we move all structs outside of it

Copy link
Collaborator

@pin-zephyr pin-zephyr left a comment

Choose a reason for hiding this comment

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

LGTM

@aescolar aescolar merged commit 6a0cdb4 into zephyrproject-rtos:main May 7, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

LE Audio: CAP Commander: Broadcast Reception Start procedure implemenation
5 participants