I wonder if there's a smarter way to get these 4 consecutive bytes from a buffer, concatenated in a unsigned long.
// the timestamp starts at byte 40 of the received packet and is four bytes, // or two words, long. First, extract the two words: unsigned long highWord = word(packetBuffer, packetBuffer); unsigned long lowWord = word(packetBuffer, packetBuffer); // combine the four bytes (two words) into a long integer // this is NTP time (seconds since Jan 1 1900): unsigned long secsSince1900 = highWord << 16 | lowWord; Serial.print("Seconds since Jan 1 1900 = "); Serial.println(secsSince1900);
Seems overkill to me, thinking these 4 bytes are already consecutive in the buffer.
Result should be unchanged i.e. having the value in a variable.