File tree Expand file tree Collapse file tree 1 file changed +27
-3
lines changed
subsys/mgmt/mcumgr/grp/os_mgmt/src Expand file tree Collapse file tree 1 file changed +27
-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+ 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+
2344static 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 ;
You can’t perform that action at this time.
0 commit comments