mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 04:52:59 +01:00
suit: start worker thread on demand
This commit is contained in:
parent
db701de094
commit
15a43f28f2
@ -211,8 +211,6 @@ int main(void)
|
||||
#endif
|
||||
/* initialize suit storage */
|
||||
suit_storage_init_all();
|
||||
/* start suit updater thread */
|
||||
suit_worker_run();
|
||||
|
||||
/* start nanocoap server thread */
|
||||
thread_create(_nanocoap_server_stack, sizeof(_nanocoap_server_stack),
|
||||
|
@ -35,12 +35,10 @@ extern "C" {
|
||||
/**
|
||||
* @brief Start SUIT CoAP thread
|
||||
*
|
||||
* @deprecated This is an alias for @ref suit_worker_run and will be removed
|
||||
* after after the 2023.01 release.
|
||||
* @deprecated This will be removed after after the 2023.01 release.
|
||||
*/
|
||||
static inline void suit_coap_run(void)
|
||||
{
|
||||
suit_worker_run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,11 +31,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Start SUIT worker thread
|
||||
*/
|
||||
void suit_worker_run(void);
|
||||
|
||||
/**
|
||||
* @brief Trigger a SUIT udate via a worker thread
|
||||
*
|
||||
|
@ -78,7 +78,7 @@ static char _stack[SUIT_WORKER_STACKSIZE];
|
||||
static char _url[CONFIG_SOCK_URLPATH_MAXLEN];
|
||||
static uint8_t _manifest_buf[SUIT_MANIFEST_BUFSIZE];
|
||||
|
||||
static mutex_t _worker_lock = MUTEX_INIT_LOCKED;
|
||||
static mutex_t _worker_lock;
|
||||
|
||||
int suit_handle_url(const char *url)
|
||||
{
|
||||
@ -141,33 +141,29 @@ static void *_suit_worker_thread(void *arg)
|
||||
|
||||
LOG_INFO("suit_worker: started.\n");
|
||||
|
||||
while (true) {
|
||||
mutex_lock(&_worker_lock);
|
||||
|
||||
if (suit_handle_url(_url) == 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 ");
|
||||
if (suit_handle_url(_url) == 0) {
|
||||
LOG_INFO("suit_worker: update successful\n");
|
||||
if (IS_USED(MODULE_SUIT_STORAGE_FLASHWRITE)) {
|
||||
LOG_INFO("suit_worker: rebooting...\n");
|
||||
pm_reboot();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
LOG_INFO("suit_worker: update failed, hdr invalid\n ");
|
||||
}
|
||||
|
||||
void suit_worker_run(void)
|
||||
{
|
||||
thread_create(_stack, SUIT_WORKER_STACKSIZE, SUIT_COAP_WORKER_PRIO,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
_suit_worker_thread, NULL, "suit worker");
|
||||
mutex_unlock(&_worker_lock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void suit_worker_trigger(const char *url, size_t len)
|
||||
{
|
||||
mutex_lock(&_worker_lock);
|
||||
|
||||
memcpy(_url, url, len);
|
||||
_url[len] = '\0';
|
||||
mutex_unlock(&_worker_lock);
|
||||
|
||||
thread_create(_stack, SUIT_WORKER_STACKSIZE, SUIT_COAP_WORKER_PRIO,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
_suit_worker_thread, NULL, "suit worker");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user