Skip to content

Bluetooth: Add configuration to control the dynamic connection callbacks #93703

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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions subsys/bluetooth/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ config BT_MAX_CONN
Maximum number of simultaneous Bluetooth connections
supported.

config BT_CONN_DYNAMIC_CALLBACKS
bool "Dynamic connection callbacks"
depends on BT_CONN
default y
help
Enable support for dynamic connection callbacks. This allows
applications to register and unregister callbacks at runtime.
If disabled, the application must register all callbacks at
compile time using the BT_CONN_CB_DEFINE() macro.

config BT_CONN_TX
bool
default BT_CONN || BT_ISO_TX
Expand Down
8 changes: 1 addition & 7 deletions subsys/bluetooth/audio/bap_unicast_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -4467,14 +4467,13 @@ static void unicast_client_disconnected(struct bt_conn *conn, uint8_t reason)
unicast_client_ep_reset(conn, reason);
}

static struct bt_conn_cb conn_cbs = {
BT_CONN_CB_DEFINE(conn_cbs) = {
.disconnected = unicast_client_disconnected,
};

int bt_bap_unicast_client_discover(struct bt_conn *conn, enum bt_audio_dir dir)
{
struct unicast_client *client;
static bool conn_cb_registered;
uint8_t role;
int err;

Expand Down Expand Up @@ -4507,11 +4506,6 @@ int bt_bap_unicast_client_discover(struct bt_conn *conn, enum bt_audio_dir dir)
client->disc_params.start_handle = BT_ATT_FIRST_ATTRIBUTE_HANDLE;
client->disc_params.end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE;

if (!conn_cb_registered) {
bt_conn_cb_register(&conn_cbs);
conn_cb_registered = true;
}

err = bt_gatt_discover(conn, &client->disc_params);
if (err != 0) {
atomic_clear_bit(client->flags, UNICAST_CLIENT_FLAG_BUSY);
Expand Down
3 changes: 1 addition & 2 deletions subsys/bluetooth/audio/csip_set_member.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ static void csip_bond_deleted(uint8_t id, const bt_addr_le_t *peer)
}
}

static struct bt_conn_cb conn_callbacks = {
BT_CONN_CB_DEFINE(conn_callbacks) = {
.disconnected = csip_disconnected,
.security_changed = csip_security_changed,
};
Expand Down Expand Up @@ -926,7 +926,6 @@ int bt_csip_set_member_register(const struct bt_csip_set_member_register_param *
for (size_t i = 0U; i < ARRAY_SIZE(svc_insts); i++) {
k_mutex_init(&svc_insts[i].mutex);
}
bt_conn_cb_register(&conn_callbacks);
bt_conn_auth_info_cb_register(&auth_callbacks);
first_register = true;
}
Expand Down
Loading
Loading