MCPcopy Create free account
hub / github.com/SmingHub/Sming / internalRequestTime

Method internalRequestTime

Sming/Components/Network/src/Network/NtpClient.cpp:80–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80void NtpClient::internalRequestTime(IpAddress serverIp)
81{
82 debug_d("NtpClient::internalRequestTime()");
83
84 // connect to current active serverIp, on NTP_PORT
85 connect(serverIp, NTP_PORT);
86
87 // Setup the NTP request packet
88 char packet[NTP_PACKET_SIZE] = {0};
89
90 // These are the only required values for a SNTP request. See page 14:
91 // https://tools.ietf.org/html/rfc4330
92 // However size of packet should still be 48 bytes.
93 packet[0] = (NTP_VERSION << 3 | 0x03); // LI (0 = no warning), Protocol version (4), Client mode (3)
94 packet[1] = 0; // Stratum, or type of clock, unspecified.
95
96 // Start timer to retry if no response received
97 startTimer(NTP_RESPONSE_TIMEOUT_MS);
98
99 // Send to server, serverAddress & port is set in connect
100 NtpClient::send(packet, NTP_PACKET_SIZE);
101}
102
103void NtpClient::setAutoQuery(bool autoQuery)
104{

Callers 1

requestTimeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected