Skip to content

Commit 2b03595

Browse files
committed
mcumgr/grp/os_mgmt: hook for disabling BT on nrf54Lx
Postpone disabling till half of waiting of reset time. Ref: NCSDK-36564 Signed-off-by: Andrzej Puzdrowski <[email protected]>
1 parent 25c3197 commit 2b03595

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt_reboot_bt.c

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include <zcbor_common.h>
88
#include <zcbor_encode.h>
9-
#include <pm_config.h>
109
#include <zephyr/mgmt/mcumgr/mgmt/callbacks.h>
1110
#include <zephyr/mgmt/mcumgr/grp/os_mgmt/os_mgmt.h>
1211
#include <zephyr/logging/log.h>
@@ -20,26 +19,52 @@
2019

2120
LOG_MODULE_REGISTER(os_mgmt_reboot_bt, CONFIG_MCUMGR_GRP_OS_LOG_LEVEL);
2221

22+
#ifdef CONFIG_MULTITHREADING
23+
static void bt_disable_work_handler(struct k_work *work);
24+
25+
static K_WORK_DELAYABLE_DEFINE(bt_disable_work, bt_disable_work_handler);
26+
27+
static void bt_disable_work_handler(struct k_work *work)
28+
{
29+
ARG_UNUSED(work);
30+
31+
#ifdef CONFIG_BT
32+
int err_rc = bt_disable();
33+
34+
if (err_rc) {
35+
LOG_ERR("BT disable failed before reboot: %d", err_rc);
36+
}
37+
#endif
38+
#ifdef CONFIG_MPSL
39+
mpsl_uninit();
40+
#endif
41+
}
42+
#endif
43+
2344
static enum mgmt_cb_return reboot_bt_hook(uint32_t event, enum mgmt_cb_return prev_status,
2445
int32_t *rc, uint16_t *group, bool *abort_more,
2546
void *data, size_t data_size)
2647
{
27-
int err_rc;
2848
struct os_mgmt_reset_data *reboot_data = (struct os_mgmt_reset_data *)data;
2949

3050
if (event != MGMT_EVT_OP_OS_MGMT_RESET || data_size != sizeof(*reboot_data)) {
3151
*rc = MGMT_ERR_EUNKNOWN;
3252
return MGMT_CB_ERROR_RC;
3353
}
34-
54+
#ifdef CONFIG_MULTITHREADING
55+
/* disable bluetooth from the system workqueue thread. */
56+
k_work_schedule(&bt_disable_work, K_MSEC(CONFIG_MCUMGR_GRP_OS_RESET_MS/2));
57+
#else
3558
#ifdef CONFIG_BT
36-
err_rc = bt_disable();
59+
int err_rc = bt_disable();
60+
3761
if (err_rc) {
3862
LOG_ERR("BT disable failed before reboot: %d", err_rc);
3963
}
4064
#endif
4165
#ifdef CONFIG_MPSL
4266
mpsl_uninit();
67+
#endif
4368
#endif
4469

4570
return MGMT_CB_OK;

0 commit comments

Comments
 (0)