diff --git a/sys/include/net/gnrc/netif/conf.h b/sys/include/net/gnrc/netif/conf.h index 7704ee639b..b1d88b1832 100644 --- a/sys/include/net/gnrc/netif/conf.h +++ b/sys/include/net/gnrc/netif/conf.h @@ -137,6 +137,17 @@ extern "C" { #define GNRC_NETIF_DEFAULT_HL (64U) /**< default hop limit */ #endif +/** + * @brief Minimum wait time in microseconds after a send operation + * + * @experimental + * + * This is purely meant as a debugging feature to slow down a radios sending. + */ +#ifndef GNRC_NETIF_MIN_WAIT_AFTER_SEND_US +#define GNRC_NETIF_MIN_WAIT_AFTER_SEND_US (0U) +#endif + #ifdef __cplusplus } #endif diff --git a/sys/net/gnrc/netif/gnrc_netif.c b/sys/net/gnrc/netif/gnrc_netif.c index 404c430a01..de5ca4f6c4 100644 --- a/sys/net/gnrc/netif/gnrc_netif.c +++ b/sys/net/gnrc/netif/gnrc_netif.c @@ -31,6 +31,7 @@ #include "fmt.h" #include "log.h" #include "sched.h" +#include "xtimer.h" #include "net/gnrc/netif.h" #include "net/gnrc/netif/internal.h" @@ -1314,6 +1315,9 @@ static void *_gnrc_netif_thread(void *args) #endif /* now let rest of GNRC use the interface */ gnrc_netif_release(netif); +#if (GNRC_NETIF_MIN_WAIT_AFTER_SEND_US > 0U) + xtimer_ticks32_t last_wakeup = xtimer_now(); +#endif while (1) { DEBUG("gnrc_netif: waiting for incoming messages\n"); @@ -1335,6 +1339,13 @@ static void *_gnrc_netif_thread(void *args) else { netif->stats.tx_bytes += res; } +#endif +#if (GNRC_NETIF_MIN_WAIT_AFTER_SEND_US > 0U) + xtimer_periodic_wakeup(&last_wakeup, + GNRC_NETIF_MIN_WAIT_AFTER_SEND_US); + /* override last_wakeup in case last_wakeup + + * GNRC_NETIF_MIN_WAIT_AFTER_SEND_US was in the past */ + last_wakeup = xtimer_now(); #endif break; case GNRC_NETAPI_MSG_TYPE_SET: