33
33
* PUBLIC MEMBER FUNCTIONS
34
34
**************************************************************************************/
35
35
36
- unsigned long NTPUtils::getTime (UDP & udp)
36
+ unsigned long NTPUtils::getTime (UDP * udp)
37
37
{
38
38
#ifdef NTP_USE_RANDOM_PORT
39
- udp. begin (NTPUtils::getRandomPort (MIN_NTP_PORT, MAX_NTP_PORT));
39
+ udp-> begin (NTPUtils::getRandomPort (MIN_NTP_PORT, MAX_NTP_PORT));
40
40
#else
41
- udp. begin (NTP_LOCAL_PORT);
41
+ udp-> begin (NTP_LOCAL_PORT);
42
42
#endif
43
43
44
44
sendNTPpacket (udp);
@@ -48,16 +48,16 @@ unsigned long NTPUtils::getTime(UDP & udp)
48
48
do
49
49
{
50
50
is_timeout = (millis () - start) >= NTP_TIMEOUT_MS;
51
- } while (!is_timeout && !udp. parsePacket ());
51
+ } while (!is_timeout && !udp-> parsePacket ());
52
52
53
53
if (is_timeout) {
54
- udp. stop ();
54
+ udp-> stop ();
55
55
return 0 ;
56
56
}
57
57
58
58
uint8_t ntp_packet_buf[NTP_PACKET_SIZE];
59
- udp. read (ntp_packet_buf, NTP_PACKET_SIZE);
60
- udp. stop ();
59
+ udp-> read (ntp_packet_buf, NTP_PACKET_SIZE);
60
+ udp-> stop ();
61
61
62
62
unsigned long const highWord = word (ntp_packet_buf[40 ], ntp_packet_buf[41 ]);
63
63
unsigned long const lowWord = word (ntp_packet_buf[42 ], ntp_packet_buf[43 ]);
@@ -72,7 +72,7 @@ unsigned long NTPUtils::getTime(UDP & udp)
72
72
* PRIVATE MEMBER FUNCTIONS
73
73
**************************************************************************************/
74
74
75
- void NTPUtils::sendNTPpacket (UDP & udp)
75
+ void NTPUtils::sendNTPpacket (UDP * udp)
76
76
{
77
77
uint8_t ntp_packet_buf[NTP_PACKET_SIZE] = {0 };
78
78
@@ -85,9 +85,9 @@ void NTPUtils::sendNTPpacket(UDP & udp)
85
85
ntp_packet_buf[14 ] = 49 ;
86
86
ntp_packet_buf[15 ] = 52 ;
87
87
88
- udp. beginPacket (NTP_TIME_SERVER, NTP_TIME_SERVER_PORT);
89
- udp. write (ntp_packet_buf, NTP_PACKET_SIZE);
90
- udp. endPacket ();
88
+ udp-> beginPacket (NTP_TIME_SERVER, NTP_TIME_SERVER_PORT);
89
+ udp-> write (ntp_packet_buf, NTP_PACKET_SIZE);
90
+ udp-> endPacket ();
91
91
}
92
92
93
93
int NTPUtils::getRandomPort (int const min_port, int const max_port)
0 commit comments