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
4 changes: 2 additions & 2 deletions app/src/modules/app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,9 @@ static void app_callback(const struct zbus_channel *chan)
app_state.interval_sec = config->update_interval;
}
} else if (&CLOUD_CHAN == chan) {
const enum cloud_msg_type *status = zbus_chan_const_msg(chan);
const struct cloud_msg *cloud_msg = zbus_chan_const_msg(chan);

app_state.status = *status;
app_state.status = cloud_msg->type;
} else if (&FOTA_CHAN == chan) {
const enum fota_msg_type *fota_status = zbus_chan_const_msg(chan);

Expand Down
22 changes: 14 additions & 8 deletions app/src/modules/cloud/cloud_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ ZBUS_CHAN_DEFINE(PAYLOAD_CHAN,
);

ZBUS_CHAN_DEFINE(CLOUD_CHAN,
enum cloud_msg_type,
struct cloud_msg,
NULL,
NULL,
ZBUS_OBSERVERS_EMPTY,
CLOUD_DISCONNECTED
ZBUS_MSG_INIT(.type = CLOUD_DISCONNECTED)
);

/* Enumerator to be used in privat cloud channel */
Expand Down Expand Up @@ -346,13 +346,15 @@ static void state_running_run(void *o)
static void state_disconnected_entry(void *o)
{
int err;
enum cloud_msg_type cloud_status = CLOUD_DISCONNECTED;
struct cloud_msg cloud_msg = {
.type = CLOUD_DISCONNECTED,
};

ARG_UNUSED(o);

LOG_DBG("%s", __func__);

err = zbus_chan_pub(&CLOUD_CHAN, &cloud_status, K_SECONDS(1));
err = zbus_chan_pub(&CLOUD_CHAN, &cloud_msg, K_SECONDS(1));
if (err) {
LOG_ERR("zbus_chan_pub, error: %d", err);
SEND_FATAL_ERROR();
Expand Down Expand Up @@ -491,13 +493,15 @@ static void shadow_get(bool delta_only)
static void state_connected_ready_entry(void *o)
{
int err;
enum cloud_msg_type cloud_status = CLOUD_CONNECTED_READY_TO_SEND;
struct cloud_msg cloud_msg = {
.type = CLOUD_CONNECTED_READY_TO_SEND,
};

ARG_UNUSED(o);

LOG_DBG("%s", __func__);

err = zbus_chan_pub(&CLOUD_CHAN, &cloud_status, K_SECONDS(1));
err = zbus_chan_pub(&CLOUD_CHAN, &cloud_msg, K_SECONDS(1));
if (err) {
LOG_ERR("zbus_chan_pub, error: %d", err);
SEND_FATAL_ERROR();
Expand Down Expand Up @@ -629,13 +633,15 @@ static void state_connected_ready_run(void *o)
static void state_connected_paused_entry(void *o)
{
int err;
enum cloud_msg_type cloud_status = CLOUD_CONNECTED_PAUSED;
struct cloud_msg cloud_msg = {
.type = CLOUD_CONNECTED_PAUSED,
};

ARG_UNUSED(o);

LOG_DBG("%s", __func__);

err = zbus_chan_pub(&CLOUD_CHAN, &cloud_status, K_SECONDS(1));
err = zbus_chan_pub(&CLOUD_CHAN, &cloud_msg, K_SECONDS(1));
if (err) {
LOG_ERR("zbus_chan_pub, error: %d", err);
SEND_FATAL_ERROR();
Expand Down
2 changes: 1 addition & 1 deletion app/src/modules/location/location.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ZBUS_CHAN_ADD_OBS(NETWORK_CHAN, location, 0);

#define MAX_MSG_SIZE \
(MAX(sizeof(enum location_msg_type), \
(MAX(sizeof(enum cloud_msg_type), \
(MAX(sizeof(struct cloud_msg), \
(MAX(sizeof(struct configuration), \
sizeof(struct network_msg)))))))

Expand Down
18 changes: 12 additions & 6 deletions tests/module/app/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ ZBUS_CHAN_DEFINE(NETWORK_CHAN,
ZBUS_MSG_INIT(.type = NETWORK_DISCONNECTED)
);
ZBUS_CHAN_DEFINE(CLOUD_CHAN,
enum cloud_msg_type,
struct cloud_msg,
NULL,
NULL,
ZBUS_OBSERVERS_EMPTY,
ZBUS_MSG_INIT(CLOUD_DISCONNECTED)
ZBUS_MSG_INIT(.type = CLOUD_DISCONNECTED)
);
ZBUS_CHAN_DEFINE(ENVIRONMENTAL_CHAN,
struct environmental_msg,
Expand Down Expand Up @@ -125,8 +125,11 @@ static void button_handler(uint32_t button_states, uint32_t has_changed)

static void send_cloud_connected_ready_to_send(void)
{
enum cloud_msg_type status = CLOUD_CONNECTED_READY_TO_SEND;
int err = zbus_chan_pub(&CLOUD_CHAN, &status, K_SECONDS(1));
struct cloud_msg cloud_msg = {
.type = CLOUD_CONNECTED_READY_TO_SEND,
};

int err = zbus_chan_pub(&CLOUD_CHAN, &cloud_msg, K_SECONDS(1));

TEST_ASSERT_EQUAL(0, err);
}
Expand All @@ -145,8 +148,11 @@ static void send_config(uint64_t interval)

static void send_cloud_disconnected(void)
{
enum cloud_msg_type status = CLOUD_DISCONNECTED;
int err = zbus_chan_pub(&CLOUD_CHAN, &status, K_SECONDS(1));
struct cloud_msg cloud_msg = {
.type = CLOUD_DISCONNECTED,
};

int err = zbus_chan_pub(&CLOUD_CHAN, &cloud_msg, K_SECONDS(1));

TEST_ASSERT_EQUAL(0, err);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/module/cloud/src/cloud_module_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ static void dummy_cb(const struct zbus_channel *chan)
static void cloud_chan_cb(const struct zbus_channel *chan)
{
if (chan == &CLOUD_CHAN) {
enum cloud_msg_type status = *(enum cloud_msg_type *)chan->message;
const struct cloud_msg *cloud_msg = zbus_chan_const_msg(chan);
enum cloud_msg_type status = cloud_msg->type;

if (status == CLOUD_DISCONNECTED) {
k_sem_give(&cloud_disconnected);
Expand Down
Loading