We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
While using this function I came up with a few improvements. Recommended additions:
- more debug outputs for easier trackingwhat is going on in the background if problems appear
if (timeout > 100) { #ifdef DEBUG_NTPClient Serial.println("NTP Timeout!"); #endif return false; // timeout after 1000 ms ......... this->_udp->read(this->_packetBuffer, NTP_PACKET_SIZE); #ifdef DEBUG_NTPClient Serial.print("NTP Data:"); char s1[4]; for (int i = 0; i < NTP_PACKET_SIZE; i++) { sprintf(s1, " %02X", _packetBuffer[i]); Serial.print(s1); } Serial.println("."); #endif
- clearing data buffer before contacting server to have a clean start and easier track errors
this->sendNTPPacket(); // clear buffer before receiving data from server memset(this->_packetBuffer, 0, sizeof(_packetBuffer));
- checking NTP protocol version, if incorrect data is received, this should catch it
unsigned char version = this->_packetBuffer[0]; version = (version >> 3) & 0x07; if (version != 4) { #ifdef DEBUG_NTPClient Serial.println("Incorrect NTP version!"); #endif return false; } unsigned long highWord = word(this->_packetBuffer[40], this->_packetBuffer[41]);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
While using this function I came up with a few improvements.
Recommended additions:
- more debug outputs for easier trackingwhat is going on in the background if problems appear
- clearing data buffer before contacting server to have a clean start and easier track errors
- checking NTP protocol version, if incorrect data is received, this should catch it
The text was updated successfully, but these errors were encountered: