File tree Expand file tree Collapse file tree 1 file changed +29
-3
lines changed
subsys/mgmt/mcumgr/grp/os_mgmt/src Expand file tree Collapse file tree 1 file changed +29
-3
lines changed Original file line number Diff line number Diff line change 2020
2121LOG_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+
35+ if (err_rc ) {
36+ LOG_ERR ("BT disable failed before reboot: %d" , err_rc );
37+ }
38+ #endif
39+ #ifdef CONFIG_MPSL
40+ mpsl_uninit ();
41+ #endif
42+ }
43+ #endif
44+
2345static enum mgmt_cb_return reboot_bt_hook (uint32_t event , enum mgmt_cb_return prev_status ,
2446 int32_t * rc , uint16_t * group , bool * abort_more ,
2547 void * data , size_t data_size )
2648{
27- int err_rc ;
2849 struct os_mgmt_reset_data * reboot_data = (struct os_mgmt_reset_data * )data ;
2950
3051 if (event != MGMT_EVT_OP_OS_MGMT_RESET || data_size != sizeof (* reboot_data )) {
3152 * rc = MGMT_ERR_EUNKNOWN ;
3253 return MGMT_CB_ERROR_RC ;
3354 }
34-
55+ #ifdef CONFIG_MULTITHREADING
56+ /* disable bluetooth from the system workqueue thread. */
57+ k_work_schedule (& bt_disable_work , K_MSEC (CONFIG_MCUMGR_GRP_OS_RESET_MS /2 ));
58+ #else
3559#ifdef CONFIG_BT
36- err_rc = bt_disable ();
60+ int err_rc = bt_disable ();
61+
3762 if (err_rc ) {
3863 LOG_ERR ("BT disable failed before reboot: %d" , err_rc );
3964 }
4065#endif
4166#ifdef CONFIG_MPSL
4267 mpsl_uninit ();
68+ #endif
4369#endif
4470
4571 return MGMT_CB_OK ;
You can’t perform that action at this time.
0 commit comments