Skip to content

Bluetooth: BAP: BA: Refactor discover to not do read #91587

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Thalley
Copy link
Collaborator

@Thalley Thalley commented Jun 13, 2025

Refactor the bt_bap_broadcast_assistant_discover function to not read receives at the end of discovery.
This makes the function more true to what it is supposed to do, and significantly reduces the complexity of the procedure and the read callback.

Users will be required to, if wanted, to read the
receive state themselves with the existing
bt_bap_broadcast_assistant_read_recv_state.

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 refactors bt_bap_broadcast_assistant_discover to stop performing GATT reads of receive states automatically, requiring users to call bt_bap_broadcast_assistant_read_recv_state themselves. It simplifies the discovery callback logic and updates the migration guide.

  • Removed automatic read loop in read_recv_state_cb and caller
  • Updated char_discover_func to complete discovery immediately
  • Added migration note in documentation

Reviewed Changes

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

File Description
subsys/bluetooth/audio/bap_broadcast_assistant.c Simplified read_recv_state_cb, removed automatic read loop, and updated discovery completion logic
doc/releases/migration-guide-4.2.rst Added note about manual receive-state reads after discovery
Comments suppressed due to low confidence (4)

subsys/bluetooth/audio/bap_broadcast_assistant.c:565

  • The callback signature no longer includes the struct bt_gatt_read_params *params parameter, but the function still references params inside. Restore the params argument or remove its usages to resolve the compile error.
static uint8_t read_recv_state_cb(struct bt_conn *conn, uint8_t err, const void *data, uint16_t length)

subsys/bluetooth/audio/bap_broadcast_assistant.c:568

  • [nitpick] Consider renaming active_recv_state to something like has_recv_state or recv_state_present for clearer boolean semantics.
bool active_recv_state = data != NULL && length != 0;

subsys/bluetooth/audio/bap_broadcast_assistant.c:648

  • With discovery no longer reading receive states, add or update unit tests to cover the new manual bt_bap_broadcast_assistant_read_recv_state flow and verify discover_complete is called correctly.
bap_broadcast_assistant_discover_complete(conn, 0, inst->recv_state_cnt);

doc/releases/migration-guide-4.2.rst:374

  • It may help to include a brief example or note about the asynchronous nature of bt_bap_broadcast_assistant_read_recv_state so users know to wait for the callback before proceeding.
* :c:func:`bt_bap_broadcast_assistant_discover` will now no longer perform reads of the remote BASS

@Thalley Thalley force-pushed the bap_broadcast_assistant_discov_refact branch from 953bea5 to ec091ef Compare June 16, 2025 11:43
Refactor the bt_bap_broadcast_assistant_discover function
to not read receives at the end of discovery.
This makes the function more true to what it is supposed to
do, and significantly reduces the complexity of the
procedure and the read callback.

Users will be required to, if wanted, to read the
receive state themselves with the existing
bt_bap_broadcast_assistant_read_recv_state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
@Thalley Thalley force-pushed the bap_broadcast_assistant_discov_refact branch from ec091ef to 34ffd28 Compare July 1, 2025 12:24
Copy link

sonarqubecloud bot commented Jul 1, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

3 participants