This time thing is a mess :-/. I’ve configured the WiFly to autosend data ever x or so seconds, it sends the following
GET$/xxxxx.php?data=std&id=xxx&rtc=xxx&mac=xxx…etc
I made a php file send the data to a server, it works great, mostly, here is a sample output
Record ServerTimeStampRaw ServerTimeStampDec RealTimeClockRaw RealTimeClockDec MacAddress BatteryLevel IOStatus
4 1327097439 2012/1/19-15:10.39 3536086242 TBD 00:06:66:71:1c:3a 2997 1d10
I can’t get the WiFly’s RTC timestamp to work correctly. You can see from the post right above it is already messed up. Here is what I’ve found out playing with it.
Raw is supposed to be the internal counter (32768 counts a second), so Raw/32768 should equal RTC. Sometimes it does, sometimes it doesn’t. It appears when you run the time command (or have it auto sync to a server) it sets the RTC correctly but not the RAW RTC, look above
RAW=e948ae62ed4b
divide by 32768 (dec) and you get
7827709125 which corresponds to 1D2915CC5, now I know from experience that my sqlserver will get D2915CC5 (it cuts it to 32 bits before sending to the server) which corresponds to
Fri, 12 Dec 2081 05:10:29 GMT (http://www.onlineconversion.com/unix_time.htm)
Now if you do
Time
show t t
and then manually set rtc by
set time rtc xxxxxxx (where xxxx is the value shown after you type show t t)
then there is a direct relationship between raw and rtc
(rtc = raw/32768 converted to int)
time
show t t
Time=16:23:15
UpTime=18446729075150589 s
RTC=1327098196
Restarts=1
Wake=1
RAW=e96233ea4952
set time rtc 1327098196
AOK
show t t
Time=17:58:34
UpTime=18446722571194495 s
RTC=1327098198
Restarts=1
Wake=1
RAW=278cf4ab18ad
time
show t t
Time=16:24:10
UpTime=18446722571194542 s
RTC=1327098251
Restarts=1
Wake=1
RAW=e9623405a274
After looking at this more, it appears every time it syncs to the server it gives RAW an offset. This is what I think that offset is
2208988800
RAW/32768
0x1D2C4680B (trim 32bits or subtract 0x100000000)
0xD2C4680B - 0x83AA7E80 (2208988800)
=0x4F19E98B = 1327098251 like above (taken from my last example)
Also works on my first example. Fails on my middle one where I set RTC manually. Weird.