diff --git a/sys/include/suit/transport/worker.h b/sys/include/suit/transport/worker.h index 175404fbba79..f1013bbd2a9a 100644 --- a/sys/include/suit/transport/worker.h +++ b/sys/include/suit/transport/worker.h @@ -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 * diff --git a/sys/suit/transport/worker.c b/sys/suit/transport/worker.c index 58497d9a928b..f4a0bd445e28 100644 --- a/sys/suit/transport/worker.c +++ b/sys/suit/transport/worker.c @@ -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();