diff --git a/pkg/tinydtls/Makefile.dep b/pkg/tinydtls/Makefile.dep index e21d3e02ce..70e9b16f95 100644 --- a/pkg/tinydtls/Makefile.dep +++ b/pkg/tinydtls/Makefile.dep @@ -12,4 +12,5 @@ FEATURES_REQUIRED += arch_32bit ifneq (,$(filter sock_dtls,$(USEMODULE))) USEMODULE += tinydtls_sock_dtls + USEMODULE += ztimer_usec endif diff --git a/pkg/tinydtls/contrib/sock_dtls.c b/pkg/tinydtls/contrib/sock_dtls.c index 1dc82dc285..145aa28078 100644 --- a/pkg/tinydtls/contrib/sock_dtls.c +++ b/pkg/tinydtls/contrib/sock_dtls.c @@ -22,7 +22,7 @@ #include "log.h" #include "net/sock/dtls.h" #include "net/credman.h" -#include "xtimer.h" +#include "ztimer.h" #if SOCK_HAS_ASYNC #include "net/sock/async.h" @@ -624,8 +624,8 @@ ssize_t sock_dtls_send_aux(sock_dtls_t *sock, sock_dtls_session_t *remote, msg_t msg; bool is_timed_out = false; do { - uint32_t start = xtimer_now_usec(); - res = xtimer_msg_receive_timeout(&msg, timeout); + uint32_t start = ztimer_now(ZTIMER_USEC); + res = ztimer_msg_receive_timeout(ZTIMER_USEC, &msg, timeout); if (timeout != SOCK_NO_TIMEOUT) { timeout = _update_timeout(start, timeout); @@ -768,7 +768,7 @@ ssize_t sock_dtls_recv_aux(sock_dtls_t *sock, sock_dtls_session_t *remote, /* loop breaks when timeout or application data read */ while (1) { ssize_t res; - uint32_t start_recv = xtimer_now_usec(); + uint32_t start_recv = ztimer_now(ZTIMER_USEC); msg_t msg; if (sock->buffer.data != NULL) { @@ -840,7 +840,7 @@ static void _session_to_ep(const session_t *session, sock_udp_ep_t *ep) static inline uint32_t _update_timeout(uint32_t start, uint32_t timeout) { - uint32_t diff = (xtimer_now_usec() - start); + uint32_t diff = (ztimer_now(ZTIMER_USEC) - start); return (diff > timeout) ? 0: timeout - diff; }