Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion NTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ bool NTPClient::forceUpdate() {

this->_currentEpoc = secsSince1900 - SEVENZYYEARS;

// get also the most significant 16 bits of the fraction of the second
unsigned long fracWord = word(this->_packetBuffer[44], this->_packetBuffer[45]);

// Account for fraction of the second.
this->_lastUpdate -= (fracWord/66); // should be devided by 2^16/1000 = 65.536 but 66 is close enough

return true; // return true after successful update
}

Expand Down Expand Up @@ -207,4 +213,4 @@ void NTPClient::sendNTPPacket() {
void NTPClient::setRandomPort(unsigned int minValue, unsigned int maxValue) {
randomSeed(analogRead(0));
this->_port = random(minValue, maxValue);
}
}