1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

examples/gnrc_net: use ztimer_msec if available

This commit is contained in:
Hauke Petersen 2021-04-15 13:17:33 +02:00
parent 5c1781f7f3
commit 75202417e1

View File

@ -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 "
"<addr> <port> <data> [<num> [<delay in ms>]]\n", argv[0]);
#else
printf("usage: %s send "
"<addr> <port> <data> [<num> [<delay in us>]]\n", argv[0]);
#endif
return 1;
}
if (argc > 5) {