Hi,
I am using sensor observer sample to get the data from sensor sample. However, I notice the power consuption is too high. I have look thourgh the forum and found this technique to reduce the power consumtion. I write one driver for this tehcnique.
After I flash my board, it can work well for around 30s and then will have "<err> bt_mesh_access: Failed to publish (err -105) <err> bt_mesh_transport: Out of network advs" and cannot print "People count is %". I also notice that the Bluetooth Mesh: Sensor can still be trigger and generate data correctly.
Here is my code:
model handler
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#include <zephyr/bluetooth/bluetooth.h>
#include <bluetooth/mesh/models.h>
#include "model_handler.h"
#include "nus_handler.h"
#include "pm.h"
#define GET_DATA_INTERVAL 999
static struct k_work_delayable get_data_work;
/* 传感器客户端回调函数 - 只处理People Count */
static void sensor_cli_data_cb(struct bt_mesh_sensor_cli *cli,
struct bt_mesh_msg_ctx *ctx,
const struct bt_mesh_sensor_type *sensor,
const struct bt_mesh_sensor_value *value)
pm.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "pm.h"
#include <zephyr/device.h>
#include <zephyr/pm/pm.h>
#include <zephyr/pm/device.h>
#include <zephyr/bluetooth/mesh.h>
// void set_pm_state()
// {
// struct pm_state_info info =
// {
// .exit_latency_us = 0,
// .min_residency_us = 0,
// .state = PM_STATE_SUSPEND_TO_RAM,
// .substate_id = 0,
// };
// pm_device_action_run(CPU_ID, &info);
// }
void pre_sleep()
config
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# Copyright (c) 2020 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
CONFIG_NCS_SAMPLES_DEFAULTS=y
# Deferred logging helps improve LPN power consumption
# when friendship is established.
CONFIG_LOG_MODE_DEFERRED=y
# General configuration
CONFIG_NCS_APPLICATION_BOOT_BANNER_STRING="Mesh Sensor Observer"
#CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 在后面加了个大的
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
# Flash shell module uses 8k of RAM for testing buffers, disable to save RAM
CONFIG_FLASH_SHELL=n
CONFIG_NVS=y
CONFIG_NVS_LOOKUP_CACHE=y
CONFIG_SETTINGS=y
Thank you for your time!