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[4];
unsigned long highWord = word(timebuffer[0], timebuffer[1]);
unsigned long lowWord = word(timebuffer[2], timebuffer[3]);
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[4];
timebuffer[0] = (byte) epoch;
timebuffer[1] = (byte) epoch >> 8;
timebuffer[2] = (byte) epoch >> 16;
timebuffer[3] = (byte) epoch >> 24;