1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #20237 from benpicco/suit_worker_done_cb

sys/suit: introduce suit_worker_done_cb()
This commit is contained in:
benpicco 2024-01-09 08:01:28 +00:00 committed by GitHub
commit 45bc3bbcdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 10 deletions

View File

@ -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
*

View File

@ -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)
{
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;
@ -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();