Skip to content

Commit d9629b1

Browse files
ludvigsjrlubos
authored andcommitted
Samples: Bluetooth: Mesh: Fix MPSL uninit in light_ctrl
This fixes a problem in the light_ctrl sample where the call to `mpsl_lib_uninit` would not do anything because the required Kconfig options were not set. * Add the required Kconfig options * Add error checking for the call to `mpsl_lib_uninit` and a call to `log_panic` to make sure this error message is actually printed before the sample halts after pressing the EMDS button. Signed-off-by: Ludvig Jordet <[email protected]>
1 parent abb1738 commit d9629b1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

samples/bluetooth/mesh/light_ctrl/overlay-emds.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@
55
#
66
CONFIG_EMDS=y
77
CONFIG_BT_MESH_RPL_STORAGE_MODE_EMDS=y
8+
9+
# MPSL dynamic interrupts required to be able to uninitialize MPSL before
10+
# storing EMDS data.
11+
CONFIG_DYNAMIC_INTERRUPTS=y
12+
CONFIG_DYNAMIC_DIRECT_INTERRUPTS=y
13+
CONFIG_MPSL_DYNAMIC_INTERRUPTS=y

samples/bluetooth/mesh/light_ctrl/src/main.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/** @file
88
* @brief Nordic mesh light fixture sample
99
*/
10+
#include <zephyr/logging/log_ctrl.h>
1011
#include <zephyr/bluetooth/bluetooth.h>
1112
#include <bluetooth/mesh/models.h>
1213
#include <bluetooth/mesh/dk_prov.h>
@@ -46,6 +47,8 @@ static void button_handler_cb(uint32_t pressed, uint32_t changed)
4647

4748
static void app_emds_cb(void)
4849
{
50+
/* Flush logs before halting. */
51+
log_panic();
4952
dk_set_leds(DK_LED2_MSK | DK_LED3_MSK | DK_LED4_MSK);
5053
k_fatal_halt(K_ERR_CPU_EXCEPTION);
5154
}
@@ -55,8 +58,11 @@ static void isr_emds_cb(void *arg)
5558
ARG_UNUSED(arg);
5659

5760
#if defined(CONFIG_BT_CTLR)
58-
/* Stop mpsl to reduce power usage. */
59-
mpsl_lib_uninit();
61+
int32_t err = mpsl_lib_uninit();
62+
63+
if (err != 0) {
64+
printk("Could not stop MPSL (err %d)\n", err);
65+
}
6066
#endif
6167

6268
emds_store();

0 commit comments

Comments
 (0)