Skip to content

Commit

Permalink
app: transport: Rewrite state handling
Browse files Browse the repository at this point in the history
Rewrite of the state machine, which affects pretty much all code
in the module.
A few new states have been added, and all state transitions
will now happen from within the state handlers to avoid
races and ensure run-to-completion for all events.

Signed-off-by: Jan Tore Guggedal <[email protected]>
  • Loading branch information
jtguggedal committed Jun 12, 2024
1 parent 56a3f38 commit f1bd44e
Show file tree
Hide file tree
Showing 6 changed files with 473 additions and 157 deletions.
2 changes: 2 additions & 0 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ CONFIG_FPU=y
CONFIG_ZBUS=y
CONFIG_ZBUS_MSG_SUBSCRIBER=y
CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_POOL_SIZE=32

# Zephyr State Machine Framework
CONFIG_SMF=y
CONFIG_SMF_ANCESTOR_SUPPORT=y
CONFIG_SMF_INITIAL_TRANSITION=y
Expand Down
5 changes: 3 additions & 2 deletions app/src/common/message_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ enum network_status {
};

enum cloud_status {
CLOUD_CONNECTED = 0x1,
CLOUD_DISCONNECTED,
CLOUD_DISCONNECTED = 0x1,
CLOUD_CONNECTED_READY_TO_SEND,
CLOUD_CONNECTED_PAUSED,
};

enum trigger_type {
Expand Down
2 changes: 1 addition & 1 deletion app/src/modules/app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static void app_task(void)
return;
}

if (cloud_status == CLOUD_CONNECTED) {
if (cloud_status == CLOUD_CONNECTED_READY_TO_SEND) {
LOG_DBG("Cloud connected");
LOG_DBG("Getting latest device configuration from device shadow");

Expand Down
2 changes: 1 addition & 1 deletion app/src/modules/fota/fota.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void fota_callback(const struct zbus_channel *chan)
{
const enum cloud_status *status = zbus_chan_const_msg(chan);

if (*status == CLOUD_CONNECTED)
if (*status == CLOUD_CONNECTED_READY_TO_SEND)
{
LOG_DBG("Cloud connected, initializing FOTA");
err = nrf_cloud_fota_poll_init(&ctx);
Expand Down
Loading

0 comments on commit f1bd44e

Please sign in to comment.