From 75202417e13105c379fc7f586f18fbe5ff3317f4 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Thu, 15 Apr 2021 13:17:33 +0200 Subject: [PATCH] examples/gnrc_net: use ztimer_msec if available --- examples/gnrc_networking/udp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/examples/gnrc_networking/udp.c b/examples/gnrc_networking/udp.c index c89f621da1..f7ae44df6d 100644 --- a/examples/gnrc_networking/udp.c +++ b/examples/gnrc_networking/udp.c @@ -30,7 +30,11 @@ #include "net/gnrc/pktdump.h" #include "timex.h" #include "utlist.h" +#if IS_USED(MODULE_ZTIMER_MSEC) +#include "ztimer.h" +#else #include "xtimer.h" +#endif static gnrc_netreg_entry_t server = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX_CTX_ALL, @@ -108,7 +112,11 @@ static void send(char *addr_str, char *port_str, char *data, unsigned int num, * => use temporary variable for output */ printf("Success: sent %u byte(s) to [%s]:%u\n", payload_size, addr_str, port); +#if IS_USED(MODULE_ZTIMER_MSEC) + ztimer_sleep(ZTIMER_MSEC, delay); +#else xtimer_usleep(delay); +#endif } } @@ -159,8 +167,13 @@ int udp_cmd(int argc, char **argv) uint32_t num = 1; uint32_t delay = 1000000; if (argc < 5) { +#if IS_USED(MODULE_ZTIMER_MSEC) + printf("usage: %s send " + " [ []]\n", argv[0]); +#else printf("usage: %s send " " [ []]\n", argv[0]); +#endif return 1; } if (argc > 5) {