From 3062d43a1dc6c6876943b2771f1a250d8bcd41b8 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 12 Feb 2024 18:11:31 +0100 Subject: [PATCH] examples/suit_update: make use of nanocoap_server_auto_init --- examples/suit_update/Makefile | 2 +- examples/suit_update/main.c | 28 ---------------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/examples/suit_update/Makefile b/examples/suit_update/Makefile index 7416456e1a..9ceef16004 100644 --- a/examples/suit_update/Makefile +++ b/examples/suit_update/Makefile @@ -38,7 +38,7 @@ QUIET ?= 1 # USEMODULE += suit suit_transport_coap -USEMODULE += nanocoap_resources +USEMODULE += nanocoap_server_auto_init # enable VFS transport (only works on boards with external storage) USEMODULE += suit_transport_vfs diff --git a/examples/suit_update/main.c b/examples/suit_update/main.c index a2995d2ae2..9fbc99063b 100644 --- a/examples/suit_update/main.c +++ b/examples/suit_update/main.c @@ -44,13 +44,6 @@ #include "periph/gpio.h" #endif -#define COAP_INBUF_SIZE (256U) - -/* Extend stacksize of nanocoap server thread */ -static char _nanocoap_server_stack[THREAD_STACKSIZE_DEFAULT + THREAD_EXTRA_STACKSIZE_PRINTF]; -#define NANOCOAP_SERVER_QUEUE_SIZE (8) -static msg_t _nanocoap_server_msg_queue[NANOCOAP_SERVER_QUEUE_SIZE]; - #define MAIN_QUEUE_SIZE (8) static msg_t _main_msg_queue[MAIN_QUEUE_SIZE]; @@ -63,21 +56,6 @@ XFA(suit_storage_files_reg, 1) char* _slot1 = VFS_DEFAULT_DATA "/SLOT1.txt"; #endif #endif -static void *_nanocoap_server_thread(void *arg) -{ - (void)arg; - - /* nanocoap_server uses gnrc sock which uses gnrc which needs a msg queue */ - msg_init_queue(_nanocoap_server_msg_queue, NANOCOAP_SERVER_QUEUE_SIZE); - - /* initialize nanocoap server instance */ - uint8_t buf[COAP_INBUF_SIZE]; - sock_udp_ep_t local = { .port=COAP_PORT, .family=AF_INET6 }; - nanocoap_server(&local, buf, sizeof(buf)); - - return NULL; -} - /* assuming that first button is always BTN0 */ #if defined(MODULE_PERIPH_GPIO_IRQ) && defined(BTN0_PIN) static void cb(void *arg) @@ -213,12 +191,6 @@ int main(void) /* initialize suit storage */ suit_storage_init_all(); - /* start nanocoap server thread */ - thread_create(_nanocoap_server_stack, sizeof(_nanocoap_server_stack), - THREAD_PRIORITY_MAIN - 1, - THREAD_CREATE_STACKTEST, - _nanocoap_server_thread, NULL, "nanocoap server"); - /* the shell contains commands that receive packets via GNRC and thus needs a msg queue */ msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);