Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions app/src/modules/app/Kconfig.app
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ config APP_MODULE_THREAD_STACK_SIZE
int "Thread stack size"
default 3200

config APP_MODULE_WATCHDOG_TIMEOUT_SECONDS
int "Watchdog timeout seconds"
default 330

config APP_MODULE_EXEC_TIME_SECONDS_MAX
int "Maximum execution time seconds"
default 270
help
Maximum time allowed for a single execution of the module thread loop.

config APP_MODULE_RECV_BUFFER_SIZE
int "Receive buffer size"
default 1024
Expand Down
20 changes: 15 additions & 5 deletions app/src/modules/battery/Kconfig.battery
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,24 @@ config APP_BATTERY_THREAD_STACK_SIZE
default 1536

config APP_BATTERY_WATCHDOG_TIMEOUT_SECONDS
int "Watchdog timeout seconds"
int "Watchdog timeout"
default 120

config APP_BATTERY_EXEC_TIME_SECONDS_MAX
int "Maximum execution time seconds"
help
Timeout in seconds for the battery module watchdog.
The timeout given in this option covers both:
* Waiting for an incoming message in zbus_sub_wait_msg().
* Time spent processing the message, defined by
CONFIG_APP_BATTERY_MSG_PROCESSING_TIMEOUT_SECONDS.
Ensure that this value exceeds CONFIG_APP_BATTERY_MSG_PROCESSING_TIMEOUT_SECONDS.
A small difference between the two can mean more frequent watchdog feeds, which increases
power consumption.

config APP_BATTERY_MSG_PROCESSING_TIMEOUT_SECONDS
int "Maximum message processing time"
default 3
help
Maximum time allowed for a single execution of the module thread loop.
Maximum time allowed for processing a single message in the module's state machine.
The value must be smaller than CONFIG_APP_BATTERY_WATCHDOG_TIMEOUT_SECONDS.

module = APP_BATTERY
module-str = Battery
Expand Down
10 changes: 6 additions & 4 deletions app/src/modules/battery/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ ZBUS_CHAN_ADD_OBS(BATTERY_CHAN, battery, 0);
#define MAX_MSG_SIZE sizeof(struct battery_msg)

BUILD_ASSERT(CONFIG_APP_BATTERY_WATCHDOG_TIMEOUT_SECONDS >
CONFIG_APP_BATTERY_EXEC_TIME_SECONDS_MAX,
"Watchdog timeout must be greater than maximum execution time");
CONFIG_APP_BATTERY_MSG_PROCESSING_TIMEOUT_SECONDS,
"Watchdog timeout must be greater than maximum message processing time");

/* nPM1300 register bitmasks */

Expand Down Expand Up @@ -234,8 +234,10 @@ static void battery_task(void)
{
int err;
int task_wdt_id;
const uint32_t wdt_timeout_ms = (CONFIG_APP_BATTERY_WATCHDOG_TIMEOUT_SECONDS * MSEC_PER_SEC);
const uint32_t execution_time_ms = (CONFIG_APP_BATTERY_EXEC_TIME_SECONDS_MAX * MSEC_PER_SEC);
const uint32_t wdt_timeout_ms =
(CONFIG_APP_BATTERY_WATCHDOG_TIMEOUT_SECONDS * MSEC_PER_SEC);
const uint32_t execution_time_ms =
(CONFIG_APP_BATTERY_MSG_PROCESSING_TIMEOUT_SECONDS * MSEC_PER_SEC);
const k_timeout_t zbus_wait_ms = K_MSEC(wdt_timeout_ms - execution_time_ms);

LOG_DBG("Battery module task started");
Expand Down
21 changes: 16 additions & 5 deletions app/src/modules/cloud/Kconfig.cloud
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,25 @@ config APP_CLOUD_POLL_INTERVAL_SECONDS
Interval in seconds between polling nRF Cloud CoAP.

config APP_CLOUD_WATCHDOG_TIMEOUT_SECONDS
int "Watchdog timeout seconds"
int "Watchdog timeout"
default 180

config APP_CLOUD_EXEC_TIME_SECONDS_MAX
int "Maximum execution time seconds"
help
Timeout in seconds for the cloud module watchdog.
The timeout given in this option covers both:
* Waiting for an incoming message in zbus_sub_wait_msg().
* Time spent processing the message, defined by
CONFIG_APP_CLOUD_MSG_PROCESSING_TIMEOUT_SECONDS.
Ensure that this value exceeds CONFIG_APP_CLOUD_MSG_PROCESSING_TIMEOUT_SECONDS.
A small difference between the two can mean more frequent watchdog feeds, which increases
power consumption.


config APP_CLOUD_MSG_PROCESSING_TIMEOUT_SECONDS
int "Maximum message processing time"
default 120
help
Maximum time allowed for a single execution of the module's thread loop.
Maximum time allowed for processing a single message in the module's state machine.
The value must be smaller than CONFIG_APP_CLOUD_WATCHDOG_TIMEOUT_SECONDS.

module = APP_CLOUD
module-str = Cloud
Expand Down
7 changes: 4 additions & 3 deletions app/src/modules/cloud/cloud_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ LOG_MODULE_REGISTER(cloud, CONFIG_APP_CLOUD_LOG_LEVEL);
MAX(BAT_MSG_SIZE, ENV_MSG_SIZE))))

BUILD_ASSERT(CONFIG_APP_CLOUD_WATCHDOG_TIMEOUT_SECONDS >
CONFIG_APP_CLOUD_EXEC_TIME_SECONDS_MAX,
"Watchdog timeout must be greater than maximum execution time");
CONFIG_APP_CLOUD_MSG_PROCESSING_TIMEOUT_SECONDS,
"Watchdog timeout must be greater than maximum message processing time");

/* Register subscriber */
ZBUS_MSG_SUBSCRIBER_DEFINE(cloud);
Expand Down Expand Up @@ -669,7 +669,8 @@ static void cloud_module_thread(void)
int err;
int task_wdt_id;
const uint32_t wdt_timeout_ms = (CONFIG_APP_CLOUD_WATCHDOG_TIMEOUT_SECONDS * MSEC_PER_SEC);
const uint32_t execution_time_ms = (CONFIG_APP_CLOUD_EXEC_TIME_SECONDS_MAX * MSEC_PER_SEC);
const uint32_t execution_time_ms =
(CONFIG_APP_CLOUD_MSG_PROCESSING_TIMEOUT_SECONDS * MSEC_PER_SEC);
const k_timeout_t zbus_wait_ms = K_MSEC(wdt_timeout_ms - execution_time_ms);

LOG_DBG("cloud module task started");
Expand Down
18 changes: 14 additions & 4 deletions app/src/modules/environmental/Kconfig.environmental
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,24 @@ config APP_ENVIRONMENTAL_THREAD_STACK_SIZE
default 1280

config APP_ENVIRONMENTAL_WATCHDOG_TIMEOUT_SECONDS
int "Watchdog timeout seconds"
int "Watchdog timeout"
default 120
help
Timeout in seconds for the environmental module watchdog.
The timeout given in this option covers both:
* Waiting for an incoming message in zbus_sub_wait_msg().
* Time spent processing the message, defined by
CONFIG_APP_ENVIRONMENTAL_MSG_PROCESSING_TIMEOUT_SECONDS.
Ensure that this value exceeds CONFIG_APP_ENVIRONMENTAL_MSG_PROCESSING_TIMEOUT_SECONDS.
A small difference between the two can mean more frequent watchdog feeds, which increases
power consumption.

config APP_ENVIRONMENTAL_EXEC_TIME_SECONDS_MAX
int "Maximum execution time seconds"
config APP_ENVIRONMENTAL_MSG_PROCESSING_TIMEOUT_SECONDS
int "Maximum message processing time"
default 3
help
Maximum time allowed for a single execution of the module's thread loop.
Maximum time allowed for processing a single message in the module's state machine.
The value must be smaller than CONFIG_APP_ENVIRONMENTAL_WATCHDOG_TIMEOUT_SECONDS.

module = APP_ENVIRONMENTAL
module-str = ENVIRONMENTAL
Expand Down
10 changes: 6 additions & 4 deletions app/src/modules/environmental/environmental.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ ZBUS_CHAN_ADD_OBS(ENVIRONMENTAL_CHAN, environmental, 0);
#define MAX_MSG_SIZE sizeof(struct environmental_msg)

BUILD_ASSERT(CONFIG_APP_ENVIRONMENTAL_WATCHDOG_TIMEOUT_SECONDS >
CONFIG_APP_ENVIRONMENTAL_EXEC_TIME_SECONDS_MAX,
"Watchdog timeout must be greater than maximum execution time");
CONFIG_APP_ENVIRONMENTAL_MSG_PROCESSING_TIMEOUT_SECONDS,
"Watchdog timeout must be greater than maximum message processing time");

static const struct device *const sensor_dev = DEVICE_DT_GET(DT_NODELABEL(bme680));

Expand Down Expand Up @@ -148,8 +148,10 @@ static void environmental_task(void)
{
int err;
int task_wdt_id;
const uint32_t wdt_timeout_ms = (CONFIG_APP_ENVIRONMENTAL_WATCHDOG_TIMEOUT_SECONDS * MSEC_PER_SEC);
const uint32_t execution_time_ms = (CONFIG_APP_ENVIRONMENTAL_EXEC_TIME_SECONDS_MAX * MSEC_PER_SEC);
const uint32_t wdt_timeout_ms =
(CONFIG_APP_ENVIRONMENTAL_WATCHDOG_TIMEOUT_SECONDS * MSEC_PER_SEC);
const uint32_t execution_time_ms =
(CONFIG_APP_ENVIRONMENTAL_MSG_PROCESSING_TIMEOUT_SECONDS * MSEC_PER_SEC);
const k_timeout_t zbus_wait_ms = K_MSEC(wdt_timeout_ms - execution_time_ms);

LOG_DBG("Environmental module task started");
Expand Down
18 changes: 14 additions & 4 deletions app/src/modules/fota/Kconfig.fota
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,24 @@ config APP_FOTA_THREAD_STACK_SIZE
default 2500

config APP_FOTA_WATCHDOG_TIMEOUT_SECONDS
int "Watchdog timeout seconds"
int "Watchdog timeout"
default 210
help
Timeout in seconds for the FOTA module watchdog.
The timeout given in this option covers both:
* Waiting for an incoming message in zbus_sub_wait_msg().
* Time spent processing the message, defined by
CONFIG_APP_FOTA_MSG_PROCESSING_TIMEOUT_SECONDS.
Ensure that this value exceeds CONFIG_APP_FOTA_MSG_PROCESSING_TIMEOUT_SECONDS.
A small difference between the two can mean more frequent watchdog feeds, which increases
power consumption.

config APP_FOTA_EXEC_TIME_SECONDS_MAX
int "Maximum execution time seconds"
config APP_FOTA_MSG_PROCESSING_TIMEOUT_SECONDS
int "Maximum message processing time"
default 180
help
Watchdog timeout in seconds for a state machine run.
Maximum time allowed for processing a single message in the module's state machine.
The value must be smaller than CONFIG_APP_FOTA_WATCHDOG_TIMEOUT_SECONDS.

if APP_FOTA

Expand Down
7 changes: 6 additions & 1 deletion app/src/modules/fota/fota.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
/* Register log module */
LOG_MODULE_REGISTER(fota, CONFIG_APP_FOTA_LOG_LEVEL);

BUILD_ASSERT(CONFIG_APP_FOTA_WATCHDOG_TIMEOUT_SECONDS >
CONFIG_APP_FOTA_MSG_PROCESSING_TIMEOUT_SECONDS,
"Watchdog timeout must be greater than maximum message processing time");

/* Register message subscriber - will be called everytime a channel that the module listens on
* receives a new message.
*/
Expand Down Expand Up @@ -432,7 +436,8 @@ static void fota_task(void)
int err;
int task_wdt_id;
const uint32_t wdt_timeout_ms = (CONFIG_APP_FOTA_WATCHDOG_TIMEOUT_SECONDS * MSEC_PER_SEC);
const uint32_t execution_time_ms = (CONFIG_APP_FOTA_EXEC_TIME_SECONDS_MAX * MSEC_PER_SEC);
const uint32_t execution_time_ms =
(CONFIG_APP_FOTA_MSG_PROCESSING_TIMEOUT_SECONDS * MSEC_PER_SEC);
const k_timeout_t zbus_wait_ms = K_MSEC(wdt_timeout_ms - execution_time_ms);

LOG_DBG("FOTA module task started");
Expand Down
18 changes: 15 additions & 3 deletions app/src/modules/location/Kconfig.location
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,24 @@ config APP_LOCATION_THREAD_STACK_SIZE
default 2048

config APP_LOCATION_WATCHDOG_TIMEOUT_SECONDS
int "Watchdog timeout seconds"
int "Watchdog timeout"
default 120
help
Timeout in seconds for the location module watchdog.
The timeout given in this option covers both:
* Waiting for an incoming message in zbus_sub_wait_msg().
* Time spent processing the message, defined by
CONFIG_APP_LOCATION_MSG_PROCESSING_TIMEOUT_SECONDS.
Ensure that this value exceeds CONFIG_APP_LOCATION_MSG_PROCESSING_TIMEOUT_SECONDS.
A small difference between the two can mean more frequent watchdog feeds, which increases
power consumption.

config APP_LOCATION_ZBUS_TIMEOUT_SECONDS
int "Wait for zbus timeout seconds"
config APP_LOCATION_MSG_PROCESSING_TIMEOUT_SECONDS
int "Maximum message processing time"
default 60
help
Maximum time allowed for processing a single message in the module's state machine.
The value must be smaller than CONFIG_APP_LOCATION_WATCHDOG_TIMEOUT_SECONDS.

module = APP_LOCATION
module-str = Location
Expand Down
13 changes: 8 additions & 5 deletions app/src/modules/location/location.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
LOG_MODULE_REGISTER(location_module, CONFIG_APP_LOCATION_LOG_LEVEL);

BUILD_ASSERT(CONFIG_APP_LOCATION_WATCHDOG_TIMEOUT_SECONDS >
CONFIG_APP_LOCATION_ZBUS_TIMEOUT_SECONDS,
"Watchdog timeout must be greater than trigger timeout");
CONFIG_APP_LOCATION_MSG_PROCESSING_TIMEOUT_SECONDS,
"Watchdog timeout must be greater than maximum message processing time");

/* Define channels provided by this module */
ZBUS_CHAN_DEFINE(LOCATION_CHAN,
Expand Down Expand Up @@ -179,8 +179,11 @@ void location_task(void)
int err = 0;
const struct zbus_channel *chan;
int task_wdt_id;
const uint32_t wdt_timeout_ms = (CONFIG_APP_LOCATION_WATCHDOG_TIMEOUT_SECONDS * MSEC_PER_SEC);
const k_timeout_t zbus_timeout = K_SECONDS(CONFIG_APP_LOCATION_ZBUS_TIMEOUT_SECONDS);
const uint32_t wdt_timeout_ms =
(CONFIG_APP_LOCATION_WATCHDOG_TIMEOUT_SECONDS * MSEC_PER_SEC);
const uint32_t execution_time_ms =
(CONFIG_APP_LOCATION_MSG_PROCESSING_TIMEOUT_SECONDS * MSEC_PER_SEC);
const k_timeout_t zbus_wait_ms = K_MSEC(wdt_timeout_ms - execution_time_ms);
uint8_t msg_buf[MAX_MSG_SIZE];

LOG_DBG("Location module task started");
Expand Down Expand Up @@ -209,7 +212,7 @@ void location_task(void)
return;
}

err = zbus_sub_wait_msg(&location, &chan, &msg_buf, zbus_timeout);
err = zbus_sub_wait_msg(&location, &chan, &msg_buf, zbus_wait_ms);
if (err == -ENOMSG) {
continue;
} else if (err) {
Expand Down
18 changes: 14 additions & 4 deletions app/src/modules/network/Kconfig.network
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,24 @@ config APP_NETWORK_THREAD_STACK_SIZE
default 2048

config APP_NETWORK_WATCHDOG_TIMEOUT_SECONDS
int "Watchdog timeout seconds"
int "Watchdog timeout"
default 600
help
Timeout in seconds for the network module watchdog.
The timeout given in this option covers both:
* Waiting for an incoming message in zbus_sub_wait_msg().
* Time spent processing the message, defined by
CONFIG_APP_NETWORK__MSG_PROCESSING_TIMEOUT_SECONDS.
Ensure that this value exceeds CONFIG_APP_NETWORK__MSG_PROCESSING_TIMEOUT_SECONDS.
A small difference between the two can mean more frequent watchdog feeds, which increases
power consumption.

config APP_NETWORK_EXEC_TIME_SECONDS_MAX
int "Maximum execution time seconds"
config APP_NETWORK_MSG_PROCESSING_TIMEOUT_SECONDS
int "Maximum message processing time"
default 570
help
Maximum time allowed for a single execution of the module's thread loop.
Maximum time allowed for processing a single message in the module's state machine.
The value must be smaller than CONFIG_APP_NETWORK__WATCHDOG_TIMEOUT_SECONDS.

config APP_NETWORK_SEARCH_NETWORK_ON_STARTUP
bool "Search for network on startup"
Expand Down
10 changes: 8 additions & 2 deletions app/src/modules/network/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
/* Register log module */
LOG_MODULE_REGISTER(network, CONFIG_APP_NETWORK_LOG_LEVEL);

BUILD_ASSERT(CONFIG_APP_NETWORK_WATCHDOG_TIMEOUT_SECONDS >
CONFIG_APP_NETWORK_MSG_PROCESSING_TIMEOUT_SECONDS,
"Watchdog timeout must be greater than maximum message processing time");

/* Define channels provided by this module */
ZBUS_CHAN_DEFINE(NETWORK_CHAN,
struct network_msg,
Expand Down Expand Up @@ -569,8 +573,10 @@ static void network_module_thread(void)
{
int err;
int task_wdt_id;
const uint32_t wdt_timeout_ms = (CONFIG_APP_NETWORK_WATCHDOG_TIMEOUT_SECONDS * MSEC_PER_SEC);
const uint32_t execution_time_ms = (CONFIG_APP_NETWORK_EXEC_TIME_SECONDS_MAX * MSEC_PER_SEC);
const uint32_t wdt_timeout_ms =
(CONFIG_APP_NETWORK_WATCHDOG_TIMEOUT_SECONDS * MSEC_PER_SEC);
const uint32_t execution_time_ms =
(CONFIG_APP_NETWORK_MSG_PROCESSING_TIMEOUT_SECONDS * MSEC_PER_SEC);
const k_timeout_t zbus_wait_ms = K_MSEC(wdt_timeout_ms - execution_time_ms);

task_wdt_id = task_wdt_add(wdt_timeout_ms, network_wdt_callback, (void *)k_current_get());
Expand Down
20 changes: 15 additions & 5 deletions app/src/modules/shell/Kconfig.shell
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,24 @@ config APP_SHELL_THREAD_STACK_SIZE
default 1024

config APP_SHELL_WATCHDOG_TIMEOUT_SECONDS
int "Watchdog timeout seconds"
int "Watchdog timeout"
default 120

config APP_SHELL_EXEC_TIME_SECONDS_MAX
int "Maximum execution time seconds"
help
Timeout in seconds for the shell module watchdog.
The timeout given in this option covers both:
* Waiting for an incoming message in zbus_sub_wait_msg().
* Time spent processing the message, defined by
CONFIG_APP_SHELL_MSG_PROCESSING_TIMEOUT_SECONDS.
Ensure that this value exceeds CONFIG_APP_SHELL_MSG_PROCESSING_TIMEOUT_SECONDS.
A small difference between the two can mean more frequent watchdog feeds, which increases
power consumption.

config APP_SHELL_MSG_PROCESSING_TIMEOUT_SECONDS
int "Maximum message processing time"
default 3
help
Maximum time allowed for a single execution of the module thread loop.
Maximum time allowed for processing a single message in the module's state machine.
The value must be smaller than CONFIG_APP_SHELL_WATCHDOG_TIMEOUT_SECONDS.

config APP_SHELL_UART_PM_ENABLE
bool "Enable UART power management feature"
Expand Down
7 changes: 6 additions & 1 deletion app/src/modules/shell/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

LOG_MODULE_REGISTER(shell, CONFIG_APP_SHELL_LOG_LEVEL);

BUILD_ASSERT(CONFIG_APP_SHELL_WATCHDOG_TIMEOUT_SECONDS >
CONFIG_APP_SHELL_MSG_PROCESSING_TIMEOUT_SECONDS,
"Watchdog timeout must be greater than maximum message processing time");

#define PAYLOAD_MSG_TEMPLATE \
"{\""NRF_CLOUD_JSON_MSG_TYPE_KEY"\":\""NRF_CLOUD_JSON_MSG_TYPE_VAL_DATA"\"," \
"\""NRF_CLOUD_JSON_APPID_KEY"\":\"%s\"," \
Expand Down Expand Up @@ -282,7 +286,8 @@ static void shell_task(void)
const struct zbus_channel *chan;
int task_wdt_id;
const uint32_t wdt_timeout_ms = (CONFIG_APP_SHELL_WATCHDOG_TIMEOUT_SECONDS * MSEC_PER_SEC);
const uint32_t execution_time_ms = (CONFIG_APP_SHELL_EXEC_TIME_SECONDS_MAX * MSEC_PER_SEC);
const uint32_t execution_time_ms =
(CONFIG_APP_SHELL_MSG_PROCESSING_TIMEOUT_SECONDS * MSEC_PER_SEC);
const k_timeout_t zbus_wait_ms = K_MSEC(wdt_timeout_ms - execution_time_ms);
uint8_t msg_buf[MAX_MSG_SIZE];

Expand Down
Loading
Loading