Problem with bt_mesh_resume() - errors -16 and -120

Hi, I'm having an issue with the bt_mesh_resume() function in my project based on Zephyr and Bluetooth Mesh. My code is trying to cycle the Mesh network on and off to save power — it should stay active for 20 seconds and then sleep for 30 seconds. However, when calling bt_mesh_resume(), I encounter the following errors:

  • -16 (EBUSY) - It seems something is blocking the Mesh from resuming.
  • -120 (ENOMSG) - It appears to be a message-related error in the Mesh communication.

I'm using a modified version of the mesh_chat example, which processes messages without needing UART shell. I want the Mesh to work for a set time after provisioning, without using a Friend node or Low Power node features.

Here is a fragment of my logs:

Fullscreen
1
2
3
4
5
6
7
8
9
10
Waiting for provisioning...
[00:00:14.884,521] <inf> bt_mesh_main: Primary Element: 0x007e
[00:00:14.884,521] <dbg> bt_mesh_main: bt_mesh_provision: net_idx 0x0000 flags 0x00 iv_index 0x0000
[00:00:14.893,432] <inf> chat: The mesh node is provisioned. The client address is 0x007e.
[00:00:14.893,493] <inf> chat: Current presence: available
[00:00:15.011,077] <inf> chat: Mesh cycle start
Failed to resume Mesh (err -120)
[00:00:35.011,169] <err> bt_adv: No valid legacy adv
Entering sleep mode
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX



Here is a fragment of my code:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
static void exit_sleep(void)
{
int err;
err = bt_mesh_resume();
if (err) {
printk("Failed to resume Mesh (err %d)\n", err);
// I'm considering using bt_mesh_reset() or reinitializing the Mesh.
} else {
mesh_active = true;
set_adv_parameters();
bt_mesh_prov_enable(BT_MESH_PROV_ADV | BT_MESH_PROV_GATT);
printk("Mesh resumed\n");
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Has anyone encountered similar issues? I've tried resetting the Mesh with bt_mesh_reset() and reinitializing it, but it hasn't resolved the problem. I'm using nRF52832 with Zephyr 2.6.1.

Any help would be greatly appreciated!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <zephyr/bluetooth/bluetooth.h>
#include <bluetooth/mesh/models.h>
#include <bluetooth/mesh/dk_prov.h>
#include <dk_buttons_and_leds.h>
#include <zephyr/logging/log.h>
#include <zephyr/kernel.h>
#include <nrfx_power.h>
#define SLEEP_TIME K_SECONDS(30) // Czas snu - zwiększony dla oszczędności energii
#define WAKE_TIME K_SECONDS(20) // Krótszy czas aktywności
LOG_MODULE_REGISTER(chat, CONFIG_LOG_DEFAULT_LEVEL);
static bool mesh_active = false;
static void configure_low_power(void)
{
// Konfiguracja niskiego poboru mocy dla nRF52832
NRF_POWER->DCDCEN = 1; // Włączenie przetwornika DC/DC
NRF_POWER->TASKS_LOWPWR = 1; // Przełączenie w tryb niskiego poboru mocy
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <bluetooth/mesh/models.h>
#include <dk_buttons_and_leds.h>
#include <zephyr/kernel.h>
#include "sleep_config.h"
#include <zephyr/drivers/gpio.h>
#include "chat_cli.h"
#include "model_handler.h"
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(chat);
#define TIMER_INST_IDX 0
#define TIME_TO_WAIT_MS 5000UL
/******************************************************************************/
/***************************** Chat model setup *******************************/
/******************************************************************************/
struct presence_cache {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX