Skip to content

Commit 13d4623

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 13d4623

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,50 @@
2020

2121
LOG_MODULE_REGISTER(os_mgmt_reboot_bt, CONFIG_MCUMGR_GRP_OS_LOG_LEVEL);
2222

23+
#ifdef CONFIG_MULTITHREADING
24+
static void bt_disable_work_handler(struct k_work *work);
25+
26+
static K_WORK_DELAYABLE_DEFINE(bt_disable_work, bt_disable_work_handler);
27+
28+
static void bt_disable_work_handler(struct k_work *work)
29+
{
30+
ARG_UNUSED(work);
31+
32+
#ifdef CONFIG_BT
33+
int err_rc = bt_disable();
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();
3760
if (err_rc) {
3861
LOG_ERR("BT disable failed before reboot: %d", err_rc);
3962
}
4063
#endif
4164
#ifdef CONFIG_MPSL
4265
mpsl_uninit();
66+
#endif
4367
#endif
4468

4569
return MGMT_CB_OK;

0 commit comments

Comments
 (0)