File tree Expand file tree Collapse file tree 4 files changed +15
-11
lines changed
net/application_layer/sntp Expand file tree Collapse file tree 4 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -134,11 +134,8 @@ endif
134134
135135ifneq (,$(filter sntp,$(USEMODULE)))
136136 USEMODULE += sock_udp
137- USEMODULE += xtimer
138- ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE)))
139- # requires 64bit ftimestamps
140- USEMODULE += ztimer64_xtimer_compat
141- endif
137+ USEMODULE += ztimer64
138+ USEMODULE += ztimer64_usec
142139endif
143140
144141ifneq (,$(filter sock_%,$(USEMODULE)))
Original file line number Diff line number Diff line change 1414 * @brief The NTP packet module provides functionality to manipulate the NTP header
1515 * @{
1616 *
17+ * @see An implementation of Simple NTP can be found in @ref net_sntp.
18+ *
1719 * @file
1820 * @brief NTP packet definitions
1921 *
@@ -46,7 +48,7 @@ extern "C" {
4648#define NTP_PORT (123U) /**< NTP port number */
4749
4850/**
49- * @brief Offset in seconds of NTP timestamp (seconds from 1990 -01-01 00:00:00 UTC)
51+ * @brief Offset in seconds of NTP timestamp (seconds from 1900 -01-01 00:00:00 UTC)
5052 * to UNIX timestamp (seconds from 1970-01-01 00:00:00 UTC).
5153 */
5254#define NTP_UNIX_OFFSET (2208988800)
Original file line number Diff line number Diff line change 1515 * @brief Simple Network Time Protocol (SNTP) implementation
1616 * @{
1717 *
18+ * @note The current implementation of SNTP uses @ref sys_ztimer64 with
19+ * microsecond accuracy, which can have a strong impact on
20+ * the power consumption of your device.
21+ *
1822 * @file
1923 * @brief SNTP definitions
2024 *
2731
2832#include "net/ntp_packet.h"
2933#include "net/sock/udp.h"
30- #include "xtimer .h"
34+ #include "ztimer64 .h"
3135
3236#ifdef __cplusplus
3337extern "C" {
@@ -45,7 +49,7 @@ extern "C" {
4549int sntp_sync (sock_udp_ep_t * server , uint32_t timeout );
4650
4751/**
48- * @brief Get real time offset from system time as returned by @ref xtimer_now64 ()
52+ * @brief Get real time offset from system time as returned by @ref ztimer64_now ()
4953 *
5054 * @return Real time offset in microseconds relative to 1900-01-01 00:00 UTC
5155 */
@@ -58,7 +62,8 @@ int64_t sntp_get_offset(void);
5862 */
5963static inline uint64_t sntp_get_unix_usec (void )
6064{
61- return (uint64_t )(sntp_get_offset () - (NTP_UNIX_OFFSET * US_PER_SEC ) + xtimer_now_usec64 ());
65+ return (uint64_t )(sntp_get_offset () - (NTP_UNIX_OFFSET * US_PER_SEC ) + \
66+ ztimer64_now (ZTIMER64_USEC ));
6267}
6368
6469#ifdef __cplusplus
Original file line number Diff line number Diff line change 2222#include "net/sntp.h"
2323#include "net/ntp_packet.h"
2424#include "net/sock/udp.h"
25- #include "xtimer .h"
25+ #include "ztimer64 .h"
2626#include "mutex.h"
2727#include "byteorder.h"
2828
@@ -70,7 +70,7 @@ int sntp_sync(sock_udp_ep_t *server, uint32_t timeout)
7070 mutex_lock (& _sntp_mutex );
7171 _sntp_offset = (((int64_t )byteorder_ntohl (_sntp_packet .transmit .seconds )) * US_PER_SEC ) +
7272 ((((int64_t )byteorder_ntohl (_sntp_packet .transmit .fraction )) * 232 )
73- / 1000000 ) - xtimer_now_usec64 ( );
73+ / 1000000 ) - ztimer64_now ( ZTIMER64_USEC );
7474 mutex_unlock (& _sntp_mutex );
7575 return 0 ;
7676}
You can’t perform that action at this time.
0 commit comments