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

sys/suit: introduce suit_worker_done_cb() #20237

Merged
merged 1 commit into from
Jan 9, 2024
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
9 changes: 9 additions & 0 deletions sys/include/suit/transport/worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ void suit_worker_trigger_prepared(const uint8_t *manifest, size_t size);
*/
int suit_worker_try_prepare(uint8_t **buffer, size_t *size);

/**
* @brief Callback that is executed after the SUIT process has finished
*
* @param[in] res Result of the SUIT update, 0 on success
*
* By default this will reboot the board, can be overwritten by the application.
*/
void suit_worker_done_cb(int res);

/**
* @brief Trigger a SUIT update
*
Expand Down
26 changes: 16 additions & 10 deletions sys/suit/transport/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,21 @@ int suit_handle_manifest_buf(const uint8_t *buffer, size_t size)
return res;
}

__attribute__((weak))
void suit_worker_done_cb(int res)
maribu marked this conversation as resolved.
Show resolved Hide resolved
{
if (res == 0) {
LOG_INFO("suit_worker: update successful\n");
if (IS_USED(MODULE_SUIT_STORAGE_FLASHWRITE)) {
LOG_INFO("suit_worker: rebooting...\n");
pm_reboot();
}
}
else {
LOG_INFO("suit_worker: update failed, hdr invalid\n ");
}
}

static void *_suit_worker_thread(void *arg)
{
(void)arg;
Expand All @@ -159,16 +174,7 @@ static void *_suit_worker_thread(void *arg)
res = suit_handle_url(_url);
}

if (res == 0) {
LOG_INFO("suit_worker: update successful\n");
if (IS_USED(MODULE_SUIT_STORAGE_FLASHWRITE)) {
LOG_INFO("suit_worker: rebooting...\n");
pm_reboot();
}
}
else {
LOG_INFO("suit_worker: update failed, hdr invalid\n ");
}
suit_worker_done_cb(res);

mutex_unlock(&_worker_lock);
thread_zombify();
Expand Down
Loading