Skip to content

Commit

Permalink
tests/riotboot_flashwrite: make use of nanocoap_server_auto_init
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Feb 12, 2024
1 parent 3062d43 commit d02d194
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 31 deletions.
5 changes: 2 additions & 3 deletions tests/riotboot_flashwrite/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ USEMODULE += sock_udp
# Additional networking modules that can be dropped if not needed
USEMODULE += gnrc_icmpv6_echo

# Required for nanocoap server
USEMODULE += nanocoap_sock
USEMODULE += nanocoap_resources
# Enable nanocoap server
USEMODULE += nanocoap_server_auto_init

# include this for printing IP addresses
USEMODULE += shell_cmds_default
Expand Down
28 changes: 0 additions & 28 deletions tests/riotboot_flashwrite/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,9 @@
#include "riotboot/slot.h"
#include "riotboot/flashwrite.h"

#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];

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;
}

static int cmd_print_riotboot_hdr(int argc, char **argv)
{
(void)argc;
Expand Down Expand Up @@ -111,12 +89,6 @@ int main(void)
cmd_print_current_slot(0, NULL);
cmd_print_riotboot_hdr(0, NULL);

/* 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);
Expand Down

0 comments on commit d02d194

Please sign in to comment.