Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main fixups #130

Merged
merged 3 commits into from
Mar 24, 2025
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,5 @@ The template is open-source for a reason, and we encourage users to contribute b
- [Button](docs/modules/button.md)
- [Cloud](docs/modules/cloud.md)
- [Environmental](docs/modules/environmental.md)
- [Main](docs/modules/main.md)
- [Network](docs/modules/network.md)
- [Power](docs/modules/power.md)
21 changes: 10 additions & 11 deletions app/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ static void task_wdt_callback(int channel_id, void *user_data)
static void sensor_and_poll_triggers_send(void)
{
int err;
struct cloud_msg cloud_msg = {
.type = CLOUD_POLL_SHADOW
};

err = zbus_chan_pub(&CLOUD_CHAN, &cloud_msg, K_SECONDS(1));
if (err) {
LOG_ERR("zbus_chan_pub shadow trigger, error: %d", err);
SEND_FATAL_ERROR();
return;
}

#if defined(CONFIG_APP_REQUEST_NETWORK_QUALITY)
struct network_msg network_msg = {
Expand Down Expand Up @@ -478,24 +488,13 @@ static void sample_data_entry(void *o)
{
int err;
enum location_msg_type location_msg = LOCATION_SEARCH_TRIGGER;
struct cloud_msg cloud_msg = {
.type = CLOUD_POLL_SHADOW
};
struct main_state *state_object = (struct main_state *)o;


LOG_DBG("%s", __func__);

/* Record the start time of sampling */
state_object->sample_start_time = k_uptime_seconds();

err = zbus_chan_pub(&CLOUD_CHAN, &cloud_msg, K_SECONDS(1));
if (err) {
LOG_ERR("zbus_chan_pub shadow trigger, error: %d", err);
SEND_FATAL_ERROR();
return;
}

err = zbus_chan_pub(&LOCATION_CHAN, &location_msg, K_SECONDS(1));
if (err) {
LOG_ERR("zbus_chan_pub data sample trigger, error: %d", err);
Expand Down
6 changes: 2 additions & 4 deletions tests/module/main/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ void test_trigger_interval_change_in_connected(void)

send_location_search_done();
check_location_event(LOCATION_SEARCH_DONE);
check_network_event(NETWORK_QUALITY_SAMPLE_REQUEST);
check_power_event(POWER_BATTERY_PERCENTAGE_SAMPLE_REQUEST);
}

/* Cleanup */
purge_all_events();

send_cloud_disconnected();
check_no_events(WEEK_IN_SECONDS);
}
Expand Down Expand Up @@ -310,8 +310,6 @@ void test_trigger_disconnect_and_connect_when_triggering(void)
}

/* Cleanup */
purge_all_events();

send_cloud_disconnected();
check_no_events(WEEK_IN_SECONDS);
}
Expand Down
Loading