diff --git a/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c b/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c index 360385a1b95c..cdc4a92aa95b 100644 --- a/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c @@ -27,6 +27,12 @@ #ifdef CONFIG_REBOOT #include +#ifdef CONFIG_BT +#include +#endif +#ifdef CONFIG_MPSL +#include +#endif #endif #ifdef CONFIG_MCUMGR_MGMT_NOTIFICATION_HOOKS @@ -362,6 +368,16 @@ static int os_mgmt_taskstat_read(struct smp_streamer *ctxt) #ifdef CONFIG_MULTITHREADING static void os_mgmt_reset_work_handler(struct k_work *work) { +#ifdef CONFIG_BT + int ret = bt_disable(); + + if (ret) { + LOG_ERR("BT disable failed before reboot: %d\n", ret); + } +#endif +#ifdef CONFIG_MPSL + mpsl_uninit(); +#endif ARG_UNUSED(work); sys_reboot(SYS_REBOOT_WARM); @@ -454,6 +470,16 @@ static int os_mgmt_reset(struct smp_streamer *ctxt) /* Reboot the system from the system workqueue thread. */ k_work_schedule(&os_mgmt_reset_work, K_MSEC(CONFIG_MCUMGR_GRP_OS_RESET_MS)); #else +#ifdef CONFIG_BT + err_rc = bt_disable(); + if (err_rc) { + LOG_ERR("BT disable failed before reboot: %d\n", err_rc); + } +#endif +#ifdef CONFIG_MPSL + mpsl_uninit(); +#endif + sys_reboot(SYS_REBOOT_WARM); #endif