Navigation Menu

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: Audio: CSIP set member register fix #56034

Merged

Conversation

Thalley
Copy link
Collaborator

@Thalley Thalley commented Mar 21, 2023

Fixes a bug with the CSIP set member register. Fixing this issue and adding tests for it, also found a few other issues that were found and fixed in order to get the tests parsing.

Fixes #55457

Copy link
Collaborator

@MariuszSkamra MariuszSkamra left a comment

Choose a reason for hiding this comment

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

One minor comment, otherwise looks good to me

Comment on lines +785 to +795
if (param->rank == 0U) {
remove_csis_char(BT_UUID_CSIS_RANK, inst->service_p);
}

if (param->set_size == 0U) {
remove_csis_char(BT_UUID_CSIS_SET_SIZE, inst->service_p);
}

if (!param->lockable) {
remove_csis_char(BT_UUID_CSIS_SET_LOCK, inst->service_p);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't it be easier and cleaner to do the opposite? I mean to compose the service attributes based on parameters given?
Luckily, there is no bt_csip_set_member_unregister method, because, currently, this does not restore the csip_set_member_service_list initial state.

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's a good point, but the reason why it is done this way, is that the list of CSIS instances are declared using BT_GATT_SERVICE_INSTANCE_DEFINE.

We could modify BT_CSIP_SERVICE_DEFINITION to have these 3 characteristics as empty by default and then populate them when requested. That might indeed by the cleaner solution, even if takes a bit more effort :)

Let me know if that makes sense to you

@Thalley Thalley requested a review from MariuszSkamra May 1, 2023 11:54
} else {
cur_inst = NULL;
if (!busy && err == 0) {
/* Not lock states are being read, can just call the ordered access callback
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is not clear to me, possibly there is a typo in it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that could be improved. While improving the comment, figured that the code could also be improved for this if statement, so that was also changed

The bt_csip_set_member_register function would register
the connection, and connection auth info, callbacks for
each CSIS instance, which could give errors when/if the
callbacks are called too many times. In any case, they
should not be registered multiple times.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Whenever a CSIS instance is registered with
bt_csip_set_member_register we now properly check if the
set size, rank and lock characteristics should be present.
If not, then remove them from the service declaration.

It is done this way, as it is easier (read: possible) to
remove characteristics from the service declarations,
than it is to add the optional characteristics, as the
optional characteristics may be present in some CSIS
instances, but not in others.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Enable the CSIP Set Member debug log.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
@@ -681,7 +684,7 @@ static bool valid_register_param(const struct bt_csip_set_member_register_param
return false;
}

if (param->rank > 0 && param->rank > param->set_size) {
if (param->rank > 0 && param->set_size > 0 && param->rank > param->set_size) {
LOG_DBG("Invalid rank: %u (shall be less than set_size: %u)", param->set_size,
Copy link
Contributor

Choose a reason for hiding this comment

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

first arg should be param->rank and should it be 'less than' or 'less than or equal', which seems to be what the test checks for

@Thalley Thalley force-pushed the csip_set_member_register_fix branch from 18f6fb4 to 98359f8 Compare May 9, 2023 14:03
The set size and rank validation did not allow setting e.g.
rank = 2 and set_size = 0, which should be allowed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The set info returned by the Set Coordinator did not contain
information about the lockable state. Furthermore the
set info was not properly initiated, as it was missing the
rank, which was set somewhere else.

This commit adds the lockable state to the set info.
This commit removes the rank from internal structure,
and uses a reference to the set info instead, and only
store the rank there.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Split the CSIP tests to multiple scripts to make them
more specific and able to run in parallel.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fixed issue when performing the ordered access procedure on
a set of devices where none had the lock characteristics.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add tests for cases where the rank characteristic, the size
characteristic and the lock characteristics are not set on the
set members.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
@Thalley Thalley force-pushed the csip_set_member_register_fix branch from 98359f8 to 1fb3225 Compare May 9, 2023 14:03
@Thalley Thalley requested a review from larsgk May 9, 2023 19:34
@carlescufi carlescufi merged commit 4b31f8c into zephyrproject-rtos:main May 10, 2023
26 checks passed
@Thalley Thalley deleted the csip_set_member_register_fix branch August 21, 2023 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LE Audio: CSIP not disabling option characteristics for size and rank
7 participants