Skip to content

Commit 92fbd7d

Browse files
anrudolfcarlescufi
authored andcommitted
Bluetooth: shell: Register callbacks dynamically
Bluetooth callbacks are now registered dynamically again. When Bluetooth callbacks were registered statically, they could be invoked before the Bluetooth shell (ctx_shell) is initialized. The callbacks try to shell_print(ctx_shell, ...), which results in a fatal error if ctx_shell is undefined. Fixes #40881. Signed-off-by: Andreas Rudolf <[email protected]>
1 parent 646951a commit 92fbd7d

File tree

1 file changed

+3
-1
lines changed
  • subsys/bluetooth/shell

1 file changed

+3
-1
lines changed

subsys/bluetooth/shell/bt.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ void le_phy_updated(struct bt_conn *conn,
415415
}
416416
#endif
417417

418-
BT_CONN_CB_DEFINE(conn_callbacks) = {
418+
static struct bt_conn_cb conn_callbacks = {
419419
.connected = connected,
420420
.disconnected = disconnected,
421421
.le_param_req = le_param_req,
@@ -573,6 +573,8 @@ static void bt_ready(int err)
573573

574574
#if defined(CONFIG_BT_CONN)
575575
default_conn = NULL;
576+
577+
bt_conn_cb_register(&conn_callbacks);
576578
#endif /* CONFIG_BT_CONN */
577579

578580
#if defined(CONFIG_BT_PER_ADV_SYNC)

0 commit comments

Comments
 (0)