Customize IP:2000/wifi server

Basic / Standard Reef Angel hardware
Post Reply
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Customize IP:2000/wifi server

Post by chachew »

Ill have to look around when i get home but where is the RA server housed? I see that it pretty much gets all the layout/images from the reefangel site as well as all the .css and .js, but the server itself is being hosted by the RA arduino board correct?

I was thinking about customizing this and housing it on my own webserver and customizing it with some jquery or something but was wondering if i can directly access the files that are being hosted by the RA unit. Any suggestions? :ugeek:
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Customize IP:2000/wifi server

Post by rimai »

Cool :)
I'd love to see what you come up with!!
All you need from the controller is actually the XML data that contains all the data.
http://ipaddress:2000/r99
Roberto.
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Customize IP:2000/wifi server

Post by chachew »

Oh sweet, all i have to do is parse the XML, easy enough. Does no one really run the server on their own? Figured that would be a pretty popular project..

Thanks Roberto
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Customize IP:2000/wifi server

Post by chachew »

Roberto, i saw somewhere but i cannot seem to find it now. There was some documentation on http://ipaddress:2000/r12 values and such. I think it was a doc on how to control relays based on the RA webserver XML values. Where can i find that?

On a side note, it would be cool if the ./r99 was stored in a JSON string for easy crossDomain access
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Customize IP:2000/wifi server

Post by rimai »

http://forum.reefangel.com/viewtopic.php?f=7&t=1541
You are right about the JSON. I had to create a proxy on the portal server to talk to external controllers.
There hasn't been the need yet.
I'll include in the issues list. It would probably have to be an additional optional feature since we wouldn't be able to fit it in the standard RA memory.
How would the JSON data look like?? Just the values with no labels in a predetermined format? So, column 1 would always be id, column 2 always T1 and so forth?
Roberto.
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Customize IP:2000/wifi server

Post by chachew »

Yes thats the link that i saw, thanks.

The JSON string would be really simple, something like:
{ "key" : "value", "key2" : "value2", "key3" : "value3" }

Or an array
{ "reefangel" : [ { "key" : "value", "key" : "value2", "key" : "value3" },
{ "key" : "value4", "key" : "value5", "key" : "value6" } ] }

Then you can parse through the string based on the key value or the array index if you go that route. Its also easy to access crossDomain with JSONP
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Customize IP:2000/wifi server

Post by rimai »

We already do have json data that can be pulled from the server for historical graphing:
http://forum.reefangel.com/status/jsonp ... &filter=t1

I could also easily create a proxy on the webserver to pull xml from controller, parse and return json formatted data just like you posted above without incurring any overhead on the controller code size.
What do you think?
Roberto.
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Customize IP:2000/wifi server

Post by chachew »

rimai wrote:We already do have json data that can be pulled from the server for historical graphing:
http://forum.reefangel.com/status/jsonp ... &filter=t1
Oh sweet that was going to be my next question, the historic data. Awesome thanks for the info on that! This is some good information to know, i just change out my ID and the filter criteria and boom i get my data! How far back does the data go back, just 7 days like the web chart displays and im assuming that the first value is the epoch date? [1344296765000,80.4] ~ [date(),temp.]

So this would all be server information from the reefangel webserver (reefangel.com) or from the actually RA unit i purchased? Im assuming all the historic data gets stored in a SQL database on your end? Is there no way to directly access the RA webserver locally to get direct access/control of the settings and readings?

IMO it would be super awesome if i could get JSON data returned from the controller, makes life a whole lot easier to access and parse through. :D
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Customize IP:2000/wifi server

Post by rimai »

Yes, you can get your own data.
7 days is what you get from MySQL on the RA server.
The controller does not store data, only settings. Well, it does store minimal data to plot the tiny graph, but that's only 24hrs at 12min rate.
So, from the controller itself, you can read and write to internal memory to change settings, such as heater temps, light schedule etc. You can also get the latest data on the XML data you already know (/r99).
Is there any other info you think you could need from the controller itself?
Yes, the data on that link is epoch and data for whatever filter you choose.
You can use any filter from this list:
http://forum.reefangel.com/viewtopic.php?p=5957#p5957
Roberto.
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Customize IP:2000/wifi server

Post by chachew »

rimai wrote: So, from the controller itself, you can read and write to internal memory to change settings, such as heater temps, light schedule etc. You can also get the latest data on the XML data you already know (/r99).
Is there any other info you think you could need from the controller itself?
Ok, thats really all the data i would need i guess because i can control every aspect of the settings with the /rxy commands correct?

Hopefully when i get back from Florida vacation this weekend i will start to put a custom site together for monitoring/controlling my RA ;)

Thanks Roberto
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Customize IP:2000/wifi server

Post by DrewPalmer04 »

I would be interested in seeing how you do this...very cool idea...a walkthrough with pics would be awesome.
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Customize IP:2000/wifi server

Post by binder »

chachew wrote: Ok, thats really all the data i would need i guess because i can control every aspect of the settings with the /rxy commands correct?
Yes, you can control just about every aspect of the settings with the commands. That's exactly how the apps work (Android, iPhone, Portal). You just have to make sure that your controller uses the internal memory settings and is not hard coded with the values and you are good.
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Customize IP:2000/wifi server

Post by chachew »

I am currently having an issue with polling the data through a php script.

<?
$file = 'http://www.yoursite.com:2000/r99.xml';
$xml = simplexml_load_file($file);
$json = json_encode($xml);
print_r($json);
?>

If i save the /r99 file and run the script it will work but i think its not working due to the port numbers....other external xml url's work just fine
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Customize IP:2000/wifi server

Post by binder »

the /r99 does not have ".xml" after it. try removing it and it should work.
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Customize IP:2000/wifi server

Post by chachew »

binder wrote:the /r99 does not have ".xml" after it. try removing it and it should work.
Yea i have tried both ways and its not currently working. You can actually access the r99 with the .xml extension

...its beginning to look like i cannot get the contents of that file for some reason... argg :roll:
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Customize IP:2000/wifi server

Post by chachew »

OK, i was able to get the file to load, it was actually my hosting company blocking me from port 2000 through their webservers.. So i have a php script get the file and encode it straight to json format and return the string. After that i parse the JSON string and go from there
Last edited by chachew on Fri Aug 17, 2012 12:56 pm, edited 1 time in total.
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Customize IP:2000/wifi server

Post by chachew »

<T1> = Temperature Probe 1
<T2> = Temperature Probe 2
<T3> = Temperature Probe 3
<PH> = pH
<R> = Main Relay Box Port Status
<RON> = Main Relay Box Port Mask On
<ROFF> = = Main Relay Box Port Maxk Off
<EM> = Enabled Expansion Modules
<REM> = Enabled Relay Expansion Boxes
<PWMA> = Dimming Port - Actinic Channel
<PWMD> = Dimming Port - Daylight Channel
<SAL> = Salinity
<ORP> = ORP
<PHE> = pH Expansion
<WL> = Water Level
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Customize IP:2000/wifi server

Post by rimai »

Looks good progress :)
Are you planning on a fancy jquery ui?
I'd love to see what you come up with and possibly even put into the webserver js file.
We need a new interface :(
Roberto.
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Customize IP:2000/wifi server

Post by chachew »

rimai wrote:Looks good progress :)
Are you planning on a fancy jquery ui?
I really like jquery so im sure it will be written in that. :)
Are you referring to a refresh on the /wifi interface?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Customize IP:2000/wifi server

Post by rimai »

Yeah. that's what I was refering to :)
Roberto.
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Customize IP:2000/wifi server

Post by chachew »

Cool, i just got back from a dive trip in south Florida so ill start working on some things this week. Ill keep you posted. ;)
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Customize IP:2000/wifi server

Post by chachew »

binder wrote:
chachew wrote: Ok, thats really all the data i would need i guess because i can control every aspect of the settings with the /rxy commands correct?
Yes, you can control just about every aspect of the settings with the commands. That's exactly how the apps work (Android, iPhone, Portal). You just have to make sure that your controller uses the internal memory settings and is not hard coded with the values and you are good.
Is there a list that details all of the memory locations and what they control??
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Customize IP:2000/wifi server

Post by rimai »

Roberto.
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Customize IP:2000/wifi server

Post by chachew »

Mmm, i dont know c++, any pointers?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Customize IP:2000/wifi server

Post by rimai »

This is the list of all memory locations so far:

Code: Select all

#define VarsStart                 200
#define Mem_B_MHOnHour            VarsStart
#define Mem_B_MHOnMinute          VarsStart+1
#define Mem_B_MHOffHour           VarsStart+2
#define Mem_B_MHOffMinute         VarsStart+3
#define Mem_B_StdLightsOnHour     VarsStart+4
#define Mem_B_StdLightsOnMinute   VarsStart+5
#define Mem_B_StdLightsOffHour    VarsStart+6
#define Mem_B_StdLightsOffMinute  VarsStart+7
#define Mem_I_WM1Timer            VarsStart+8
#define Mem_I_WM2Timer            VarsStart+10
#define Mem_B_DP1Timer            VarsStart+12
#define Mem_B_DP2Timer            VarsStart+13
#define Mem_I_FeedingTimer        VarsStart+14
#define Mem_I_LCDTimer            VarsStart+16
#define Mem_I_OverheatTemp        VarsStart+18
#define Mem_B_LEDPWMDaylight      VarsStart+20
#define Mem_B_LEDPWMActinic       VarsStart+21
#define Mem_I_HeaterTempOn        VarsStart+22
#define Mem_I_HeaterTempOff       VarsStart+24
#define Mem_I_ChillerTempOn       VarsStart+26
#define Mem_I_ChillerTempOff      VarsStart+28
#define Mem_B_ATOTimeout          VarsStart+30
#define Mem_I_PHMax               VarsStart+31
#define Mem_I_PHMin               VarsStart+33
#define Mem_B_MHDelay             VarsStart+35
#define Mem_B_DP1OnHour           VarsStart+36
#define Mem_B_DP1OnMinute         VarsStart+37
#define Mem_B_DP2OnHour           VarsStart+38
#define Mem_B_DP2OnMinute         VarsStart+39
#define Mem_B_ATOHourInterval     VarsStart+40
#define Mem_B_ATOHighHourInterval VarsStart+41
#define Mem_B_ATOHighTimeout      VarsStart+42
#define Mem_I_DP1RepeatInterval	  VarsStart+43
#define Mem_I_DP2RepeatInterval	  VarsStart+45
#define Mem_I_SalMax			  VarsStart+47
#define Mem_B_PWMSlopeStartD      VarsStart+49
#define Mem_B_PWMSlopeEndD	      VarsStart+50
#define Mem_B_PWMSlopeDurationD   VarsStart+51
#define Mem_B_PWMSlopeStartA      VarsStart+52
#define Mem_B_PWMSlopeEndA	      VarsStart+53
#define Mem_B_PWMSlopeDurationA   VarsStart+54
#define Mem_B_RFMode			  VarsStart+55
#define Mem_B_RFSpeed			  VarsStart+56
#define Mem_B_RFDuration		  VarsStart+57
#define Mem_B_PWMSlopeStart0      VarsStart+58
#define Mem_B_PWMSlopeEnd0	      VarsStart+59
#define Mem_B_PWMSlopeDuration0   VarsStart+60
#define Mem_B_PWMSlopeStart1      VarsStart+61
#define Mem_B_PWMSlopeEnd1	      VarsStart+62
#define Mem_B_PWMSlopeDuration1   VarsStart+63
#define Mem_B_PWMSlopeStart2      VarsStart+64
#define Mem_B_PWMSlopeEnd2	      VarsStart+65
#define Mem_B_PWMSlopeDuration2   VarsStart+66
#define Mem_B_PWMSlopeStart3      VarsStart+67
#define Mem_B_PWMSlopeEnd3	      VarsStart+68
#define Mem_B_PWMSlopeDuration3   VarsStart+69
#define Mem_B_PWMSlopeStart4      VarsStart+70
#define Mem_B_PWMSlopeEnd4	      VarsStart+71
#define Mem_B_PWMSlopeDuration4   VarsStart+72
#define Mem_B_PWMSlopeStart5      VarsStart+73
#define Mem_B_PWMSlopeEnd5	      VarsStart+74
#define Mem_B_PWMSlopeDuration5   VarsStart+75
#define Mem_I_ATOExtendedTimeout  VarsStart+76
#define Mem_I_ATOHighExtendedTimeout  VarsStart+78
#define Mem_I_ORPMin			  VarsStart+80
#define Mem_I_ORPMax			  VarsStart+82
#define Mem_B_ActinicOffset		  VarsStart+84
#define Mem_I_CO2ControlOn        VarsStart+85
#define Mem_I_CO2ControlOff       VarsStart+87
#define Mem_I_PHControlOn         VarsStart+89
#define Mem_I_PHControlOff        VarsStart+91
#define Mem_B_AISlopeStartW       VarsStart+93
#define Mem_B_AISlopeEndW	      VarsStart+94
#define Mem_B_AISlopeDurationW    VarsStart+95
#define Mem_B_AISlopeStartB       VarsStart+96
#define Mem_B_AISlopeEndB	      VarsStart+97
#define Mem_B_AISlopeDurationB    VarsStart+98
#define Mem_B_AISlopeStartRB      VarsStart+99
#define Mem_B_AISlopeEndRB	      VarsStart+100
#define Mem_B_AISlopeDurationRB   VarsStart+101
#define Mem_B_RadionSlopeStartW       VarsStart+102
#define Mem_B_RadionSlopeEndW	      VarsStart+103
#define Mem_B_RadionSlopeDurationW    VarsStart+104
#define Mem_B_RadionSlopeStartRB      VarsStart+105
#define Mem_B_RadionSlopeEndRB	      VarsStart+106
#define Mem_B_RadionSlopeDurationRB   VarsStart+107
#define Mem_B_RadionSlopeStartR       VarsStart+108
#define Mem_B_RadionSlopeEndR	      VarsStart+109
#define Mem_B_RadionSlopeDurationR    VarsStart+110
#define Mem_B_RadionSlopeStartG       VarsStart+111
#define Mem_B_RadionSlopeEndG	      VarsStart+112
#define Mem_B_RadionSlopeDurationG    VarsStart+113
#define Mem_B_RadionSlopeStartB       VarsStart+114
#define Mem_B_RadionSlopeEndB	      VarsStart+115
#define Mem_B_RadionSlopeDurationB    VarsStart+116
#define Mem_B_RadionSlopeStartI       VarsStart+117
#define Mem_B_RadionSlopeEndI	      VarsStart+118
#define Mem_B_RadionSlopeDurationI    VarsStart+119
#define Mem_B_DelayedStart            VarsStart+120
#define Mem_I_PHExpMin			  VarsStart+121
#define Mem_I_PHExpMax			  VarsStart+123
#define Mem_I_WaterLevelMin			  VarsStart+125
#define Mem_I_WaterLevelMax			  VarsStart+127

#define VarsEnd                 VarsStart+129
It starts at 200 and go to 329.
Each one can be read or written with the command /mb.
So for example you would like to read the hour that StandardLights will turn on, you are going to use memory location 204.
To read that memory location, use command /mb204
To write to that memory location, use command /mb204,10 where 10 is the number of hours in military time.
The trick part is that there are two types of memory. the memory with byte size, which can store values from 0 and 255 and the int size that can store values from 0 to 65536.
The size of the variable can easily be identified by the list above. Mem_B_ means byte size location and Mem_I_ means int size location.
To read and write an int size location, you need to use /mi
For example, you want to read the temperature the StandardHeater function will turn on, you will use memory location 222.
To read that memory location, use command /mi222
To write to that memory location, use command /mi222,775 where 775 is the temperature that the heater will turn on without the decimal point.
I hope this explains a bit.
Let me know if it is still confusing.
Roberto.
Piper
Posts: 298
Joined: Fri Jul 20, 2012 7:13 am
Location: Oakley, CA

Re: Customize IP:2000/wifi server

Post by Piper »

Roberto - Are the labels from the Portal available via XML or JSON by chance?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Customize IP:2000/wifi server

Post by rimai »

Roberto.
Piper
Posts: 298
Joined: Fri Jul 20, 2012 7:13 am
Location: Oakley, CA

Re: Customize IP:2000/wifi server

Post by Piper »

Perfect! Thanks Roberto!!
Post Reply