I have tried to wrap my head around this one, but I simple can’t figure it out.
Thanks to the TimeNTP example I do know how to get 4 bytes into 1 long, like this:
byte timebuffer; unsigned long highWord = word(timebuffer, timebuffer); unsigned long lowWord = word(timebuffer, timebuffer); unsigned long epoch = highWord << 16 | lowWord; setTime(epoch);
but now I want to put the unsigned long epoch into 4 bytes, so I can transmit them.
I tried this, but it is incorrect:
unsigned long epoch; byte timebuffer; timebuffer = (byte) epoch; timebuffer = (byte) epoch >> 8; timebuffer = (byte) epoch >> 16; timebuffer = (byte) epoch >> 24;