Skip to content

Bluetooth: CSIP: Set member: Fix issue with re-registration #89089

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

Merged
merged 1 commit into from
May 27, 2025

Conversation

Thalley
Copy link
Collaborator

@Thalley Thalley commented Apr 25, 2025

The bt_csip_set_member_register kept a counter that was not decreased when bt_csip_set_member_unregister was called. This meant that we could register and unregister CSIS, but we could not re-register once it had been unregistered.

This commit fixes this by removing the counter and instead rely on the service instance state, which also requires restoring the original service definition, as well as adding a test that would have failed with the previous version.

@Thalley Thalley force-pushed the csip_register_fix branch 2 times, most recently from 6e09f61 to c0ceb01 Compare April 25, 2025 11:42
@Thalley Thalley requested a review from Copilot April 25, 2025 11:42
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the re‐registration issue for CSIS by removing the static counter and instead scanning the service instance array to locate available entries. It also restores the original service definition during unregistration and adds a test to verify that re‐registration works as expected.

  • Removed the instance counter in bt_csip_set_member_register and replaced it with an iterative search.
  • Restored the original attribute declaration during unregistration.
  • Introduced a new test (test_register) to validate repeated register/unregister cycles.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/bsim/bluetooth/audio/src/csip_set_member_test.c Added test_register function to iterate through registration/unregistration scenarios.
subsys/bluetooth/audio/csip_set_member.c Updated bt_csip_set_member_register to remove the counter and restore service definitions in bt_csip_set_member_unregister to enable re-registration.
Files not reviewed (1)
  • tests/bsim/bluetooth/audio/test_scripts/csip_register.sh: Language not supported
Comments suppressed due to low confidence (1)

subsys/bluetooth/audio/csip_set_member.c:852

  • The flag 'first_register' is never updated after the first registration, which could result in repeated callback registrations. Set 'first_register' to true after the first successful registration to prevent duplicate registrations.
if (!first_register) {

@Thalley Thalley force-pushed the csip_register_fix branch 3 times, most recently from 1931b39 to 5ec06c3 Compare April 25, 2025 12:42
@Thalley Thalley marked this pull request as ready for review April 25, 2025 13:20
@Thalley Thalley requested a review from Copilot April 25, 2025 13:20
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the re-registration issue with CSIS by removing the outdated counter mechanism and restoring the original service definition. It also adds a new test to ensure the fix works as expected.

  • Updated test to validate re-registration behavior
  • Modified the service registration logic to search for a free service instance slot and restore original attributes on unregistration

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
tests/bsim/bluetooth/audio/src/csip_set_member_test.c Added the test_register function to validate correct re-registration handling
subsys/bluetooth/audio/csip_set_member.c Revised registration logic, fixed formatting, and restored original service attributes
Files not reviewed (1)
  • tests/bsim/bluetooth/audio/test_scripts/csip_register.sh: Language not supported

@Thalley Thalley force-pushed the csip_register_fix branch from 5ec06c3 to a3d69c8 Compare April 28, 2025 10:50
@aescolar aescolar dismissed their stale review April 28, 2025 11:00

addressed

@Thalley Thalley force-pushed the csip_register_fix branch from a3d69c8 to 0683f6c Compare April 28, 2025 11:47
@Thalley Thalley requested a review from aescolar April 28, 2025 11:47
aescolar
aescolar previously approved these changes Apr 28, 2025
.pairing_complete = auth_pairing_complete,
.bond_deleted = csip_bond_deleted
};
static struct bt_conn_auth_info_cb auth_callbacks = {.pairing_complete = auth_pairing_complete,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this really done on purpuse? This is not how we usually format a statically defined callback structure!? Pre-changed looks more consistent

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Welp, my editor done goofed and formatted the entire file. Will revert the formatting lines

Copy link
Collaborator

Choose a reason for hiding this comment

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

Haha, I was pondering whether I should make a comment on that - it did seem like a lot of formatting without mentioning it :D

@Thalley Thalley force-pushed the csip_register_fix branch from b259c06 to b736abf Compare May 5, 2025 11:06
The bt_csip_set_member_register kept a counter that was not
decreased when bt_csip_set_member_unregister was called.
This meant that we could register and unregister CSIS,
but we could not re-register once it had been unregistered.

This commit fixes this by removing the counter and instead
rely on the service instance state, which also requires restoring
the original service definition, as well as adding a test that would
have failed with the previous version.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
@Thalley Thalley added the bug The issue is a bug, or the PR is fixing a bug label May 19, 2025
@Thalley Thalley force-pushed the csip_register_fix branch from b736abf to efe484c Compare May 19, 2025 08:57
Copy link

@kartben kartben merged commit 52f089a into zephyrproject-rtos:main May 27, 2025
29 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Bluetooth LE Audio May 27, 2025
@Thalley Thalley deleted the csip_register_fix branch May 27, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Audio area: Bluetooth bug The issue is a bug, or the PR is fixing a bug platform: nRF BSIM Nordic Semiconductors, nRF BabbleSim
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants