Time Sync with external server

Requests for new functions or software apps
Post Reply
Paul Viscovich
Posts: 26
Joined: Mon Jul 18, 2011 8:06 pm
Location: Dublin Ca
Contact:

Re: Time Sync with external server

Post by Paul Viscovich »

Ok so i had this long post going untill i figured out that the date is a moving date for DST and every year it is changing.. what is needed is a world database that could be used to tell if or when you change then a code could be sent to the server to calculate based on the est rules your server goes by..


Oh boy this is a pain....

like this http://twiki.org/cgi-bin/xtra/tzdatepick.html#GMT
http://forum.reefangel.com/status/banner_3.aspx?id=Paul Viscovich&t=-7

14 Gallon Bio Cube with INTANK filtration Thanks Diablo Corals
Paul Viscovich
Posts: 26
Joined: Mon Jul 18, 2011 8:06 pm
Location: Dublin Ca
Contact:

Re: Time Sync with external server

Post by Paul Viscovich »

Ok new Idea

http://api.geonames.org/timezone?lat=37 ... rname=demo

can you send a string like this from the wifi and then read the responce

or maybe you can get this api for your site

then all you would need to do is pass the lat and lng to it and it would do the rest

you can use just about anything these days to het the long and lat of your location

http://www.geonames.org/export/web-serv ... l#timezone

Timezone
Webservice Type : REST
Url : api.geonames.org/timezone?
Parameters : lat,lng, radius (buffer in km for closest timezone in coastal areas), date (date for sunrise/sunset);
Result : the timezone at the lat/lng with gmt offset (1. January) and dst offset (1. July)
Example http://api.geonames.org/timezone?lat=47 ... rname=demo

This service is also available in JSON format : http://api.geonames.org/timezoneJSON?la ... rname=demo


Element:
timezoneId: name of the timezone (according to olson), this information is sufficient to work with the timezone and defines DST rules, consult the documentation of your development environment.
time: the local current time
rawOffset: the amount of time in hours to add to UTC to get standard time in this time zone. Because this value is not affected by daylight saving time, it is called raw offset.
gmtOffset: offset to GMT at 1. January (deprecated)
dstOffset: offset to GMT at 1. July (deprecated)


<?xml version="1.0" encoding="UTF-8"?>
-<geonames>
-<timezone>
<countryCode>US</countryCode>
<countryName>United States</countryName>
<lat>37.71</lat>
<lng>-121.9</lng>
<timezoneId>America/Los_Angeles</timezoneId>
<dstOffset>-7.0</dstOffset>
<gmtOffset>-8.0</gmtOffset>
<rawOffset>-8.0</rawOffset>
<time>2011-07-19 00:01</time>
<sunrise>2011-07-19 06:00</sunrise>
<sunset>2011-07-19 20:26</sunset>
</timezone>
</geonames>
http://forum.reefangel.com/status/banner_3.aspx?id=Paul Viscovich&t=-7

14 Gallon Bio Cube with INTANK filtration Thanks Diablo Corals
Paul Viscovich
Posts: 26
Joined: Mon Jul 18, 2011 8:06 pm
Location: Dublin Ca
Contact:

Re: Time Sync with external server

Post by Paul Viscovich »

http://api.geonames.org/timezone?lat=37 ... ablocorals

signed up and made an account that means that i can do 33000 time requests a day..

maybe you could set up a free reefangle account

and the

http://api.geonames.org/timezone?lat=37 ... ablocorals

out put could be read back in

Of cource this also could be done server side if teh users cointroller posts to reefangle and the page there posts the data and collects the data and then send the time info back to the controller

Again i may be off base but it is what i have found sofare with out knowing the limmits it is hard to tell what you can do
http://forum.reefangel.com/status/banner_3.aspx?id=Paul Viscovich&t=-7

14 Gallon Bio Cube with INTANK filtration Thanks Diablo Corals
Paul Viscovich
Posts: 26
Joined: Mon Jul 18, 2011 8:06 pm
Location: Dublin Ca
Contact:

Re: Time Sync with external server

Post by Paul Viscovich »

too bad jess needs both of his controllers or i would be working on this from my end ... I cant go wipe his code to play :( maybe one of these days i can buy one for dev work...

Ok enough rambling for one night im off to bed...
http://forum.reefangel.com/status/banner_3.aspx?id=Paul Viscovich&t=-7

14 Gallon Bio Cube with INTANK filtration Thanks Diablo Corals
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Time Sync with external server

Post by rimai »

The server can always give me GMT (or if you prefer calling UTC), and also the current time (Eastern Time) with the daylight savings offset that follows the Eastern Time USA daylight savings rules.
But, I actually love that site you refered.
It's got exactly what we need:
http://download.geonames.org/export/dump/timeZones.txt
That XML data also gave me other ideas.
Exact sunset and sunrise hours for a particular area.
So, if one would like to replicate Fiji sunrise and sunset hours, the controller could adjust itself and dim the LED strings according to those hours. Well, this is topic for another thread.
Anyway, I'm going to enter the data into a database and generate an id for each timezone. Then, instead of passing offset to SyncTime function, we pass the id for the timezone to get the correct time adjusted for daylight savings.
Thanks for the research :)
Roberto.
Paul Viscovich
Posts: 26
Joined: Mon Jul 18, 2011 8:06 pm
Location: Dublin Ca
Contact:

Re: Time Sync with external server

Post by Paul Viscovich »

i was thinking the same thing about the sunset sun rise it seems like it could be levraged for many things..
http://forum.reefangel.com/status/banner_3.aspx?id=Paul Viscovich&t=-7

14 Gallon Bio Cube with INTANK filtration Thanks Diablo Corals
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Time Sync with external server

Post by rimai »

Ok, so the more I try to come up with a solution, the more I come to realize that it is so much easier to just sync with your computer by using the Client 2.2 twice a year when daylight savings changes.
With the new Client 2.2, you can simply sync it with a click of a button and it can be done through USB or wifi.
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Time Sync with external server

Post by binder »

yeah, it is pretty simple and easy to do now that we have the web server responding to the date command.

curt
lukeluke
Posts: 88
Joined: Mon Apr 04, 2011 4:12 am
Location: Rome, Italy

Re: Time Sync with external server

Post by lukeluke »

curt, have you enable this on your .16 version ?
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Time Sync with external server

Post by binder »

lukeluke wrote:curt, have you enable this on your .16 version ?
No I did not add in the external time sync functionality to my libraries because of how the discussion went. It's simpler to just either set the date manually or update it via the wifi interface.
I know you do not run Windows (I believe you run Ubuntu linux or some other variant) so you cannot run the client suite. For now, you would have to manually set the date/time yourself via the memory command.

Code: Select all

http://CONTROLLER_IP:2000/dHHMM,MMDD,YY
The format is as follows:
  • HH - hours
  • MM - minutes
  • , - comma
  • MM - month
  • DD - day
  • , - comma
  • YY - year (since 2000)
Everything MUST be in 2 digit format. So single digits (like 8) must have a 0 prefix. Here's an example:

Set the date to August 8th, 2011 at 9:30am

Code: Select all

http://CONTROLLER_IP:2000/d0930,0808,11
The controller will respond with OK and set the date/time on the controller.

NOTE: Type this in the URL box in your web browser to set the date/time.

curt
lukeluke
Posts: 88
Joined: Mon Apr 04, 2011 4:12 am
Location: Rome, Italy

Re: Time Sync with external server

Post by lukeluke »

ok thanks ;-)
lukeluke
Posts: 88
Joined: Mon Apr 04, 2011 4:12 am
Location: Rome, Italy

Re: Time Sync with external server

Post by lukeluke »

curt is possible modify other internal memory parameters trought the browser ?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Time Sync with external server

Post by rimai »

Yes, it is indeed, but the Real Time Clock (RTC) data is not within the internal memory block.
The RTC chip is the one that holds the time and keeps it up.
The controller also syncs with it periodically.
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Time Sync with external server

Post by binder »

lukeluke wrote:curt is possible modify other internal memory parameters trought the browser ?
Yes, you most certainly can. It is slightly more complex in doing this though. You must know the location and what type of value is stored there (byte or integer). These locations are stored inside ReefAngel_Globals.h and whether it is a byte or integer.

For working with Bytes:

Code: Select all

// Read the memory value
http://CONTROLLER_IP:2000/mbLOC
// LOC is the memory location

// Write the memory value
http://CONTROLLER_IP:2000/mbLOC,VAL
// there must be a comma (,) between LOC and VAL (which is the value)
For working with Integers:

Code: Select all

// Read the memory value
http://CONTROLLER_IP:2000/miLOC
// LOC is the memory location

// Write the memory value
http://CONTROLLER_IP:2000/miLOC,VAL
// there must be a comma (,) between LOC and VAL (which is the value)
I'm working on a program that will allow you to update the values from it without having to open up a web browser. I'm almost ready for an "alpha" release and hoping to have something later this weekend.

curt
Post Reply