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
134
134
135
135
ifneq (,$(filter sntp,$(USEMODULE)))
136
136
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
142
139
endif
143
140
144
141
ifneq (,$(filter sock_%,$(USEMODULE)))
Original file line number Diff line number Diff line change 14
14
* @brief The NTP packet module provides functionality to manipulate the NTP header
15
15
* @{
16
16
*
17
+ * @see An implementation of Simple NTP can be found in @ref net_sntp.
18
+ *
17
19
* @file
18
20
* @brief NTP packet definitions
19
21
*
@@ -46,7 +48,7 @@ extern "C" {
46
48
#define NTP_PORT (123U) /**< NTP port number */
47
49
48
50
/**
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)
50
52
* to UNIX timestamp (seconds from 1970-01-01 00:00:00 UTC).
51
53
*/
52
54
#define NTP_UNIX_OFFSET (2208988800)
Original file line number Diff line number Diff line change 15
15
* @brief Simple Network Time Protocol (SNTP) implementation
16
16
* @{
17
17
*
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
+ *
18
22
* @file
19
23
* @brief SNTP definitions
20
24
*
27
31
28
32
#include "net/ntp_packet.h"
29
33
#include "net/sock/udp.h"
30
- #include "xtimer .h"
34
+ #include "ztimer64 .h"
31
35
32
36
#ifdef __cplusplus
33
37
extern "C" {
@@ -45,7 +49,7 @@ extern "C" {
45
49
int sntp_sync (sock_udp_ep_t * server , uint32_t timeout );
46
50
47
51
/**
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 ()
49
53
*
50
54
* @return Real time offset in microseconds relative to 1900-01-01 00:00 UTC
51
55
*/
@@ -58,7 +62,8 @@ int64_t sntp_get_offset(void);
58
62
*/
59
63
static inline uint64_t sntp_get_unix_usec (void )
60
64
{
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 ));
62
67
}
63
68
64
69
#ifdef __cplusplus
Original file line number Diff line number Diff line change 22
22
#include "net/sntp.h"
23
23
#include "net/ntp_packet.h"
24
24
#include "net/sock/udp.h"
25
- #include "xtimer .h"
25
+ #include "ztimer64 .h"
26
26
#include "mutex.h"
27
27
#include "byteorder.h"
28
28
@@ -70,7 +70,7 @@ int sntp_sync(sock_udp_ep_t *server, uint32_t timeout)
70
70
mutex_lock (& _sntp_mutex );
71
71
_sntp_offset = (((int64_t )byteorder_ntohl (_sntp_packet .transmit .seconds )) * US_PER_SEC ) +
72
72
((((int64_t )byteorder_ntohl (_sntp_packet .transmit .fraction )) * 232 )
73
- / 1000000 ) - xtimer_now_usec64 ( );
73
+ / 1000000 ) - ztimer64_now ( ZTIMER64_USEC );
74
74
mutex_unlock (& _sntp_mutex );
75
75
return 0 ;
76
76
}
You can’t perform that action at this time.
0 commit comments