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 <andreas.rudolf@husqvarnagroup.com>
This commit is contained in:
Andreas Rudolf 2021-12-08 16:50:01 +01:00 committed by Carles Cufí
commit 92fbd7da14

View file

@ -415,7 +415,7 @@ void le_phy_updated(struct bt_conn *conn,
} }
#endif #endif
BT_CONN_CB_DEFINE(conn_callbacks) = { static struct bt_conn_cb conn_callbacks = {
.connected = connected, .connected = connected,
.disconnected = disconnected, .disconnected = disconnected,
.le_param_req = le_param_req, .le_param_req = le_param_req,
@ -573,6 +573,8 @@ static void bt_ready(int err)
#if defined(CONFIG_BT_CONN) #if defined(CONFIG_BT_CONN)
default_conn = NULL; default_conn = NULL;
bt_conn_cb_register(&conn_callbacks);
#endif /* CONFIG_BT_CONN */ #endif /* CONFIG_BT_CONN */
#if defined(CONFIG_BT_PER_ADV_SYNC) #if defined(CONFIG_BT_PER_ADV_SYNC)