Wifi attachment commands

Related to the development libraries, released by Curt Binder
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Wifi attachment commands

Post by rimai »

These are the commands available so far, extracted from RA_wifi.cpp:

/wifi - simple internal webserver

/rxy - override relay where
x=relay
y=0 - mask off
y=1 - mask on
y=2 - auto

/mbx - read memory location (byte size) where
x=memory location

/mbx,y - write memory location (byte size) where
x=memory location
y=value to be written

/mix - read memory location (int size) where
x=memory location

/mix,y - write memory location (int size) where
x=memory location
y=value to be written

/mr - returns a string with all memory values in hexdecimal

/mrx,y - returns a string with memory values in hexdecimal between x and y location

/v - dev libs version

/dhhmm,MMdd,yy - sets date/time where
hh=hours of the day, including leading 0 if hour<10
mm=minutes of the hour, including leading 0 if minutes<10
MM=month of the year, including leading 0 if month<10
dd=day of the month, including leading 0 if day<10
yy=last 2 digits of the year

/sr - returns XML with all parameters

/sa -same as above

/bp - call joystick button press

/mf - call feeding mode

/mw - call water change mode

/mt - clear ATO timeout flag

/mo - clear Overheat flag

/ml - clear Leak flag

/pox,y - override dimming signal where
x=override id
Valid ids:
0-Daylight
1-Actinic
2-Dimming expansion channel 0
3-Dimming expansion channel 1
4-Dimming expansion channel 2
5-Dimming expansion channel 3
6-Dimming expansion channel 4
7-Dimming expansion channel 5
8-Aqua Illumination - White Channel
9-Aqua Illumination - Royal Blue Channel
10-Aqua Illumination - Blue Channel
11-Radion - White Channel
12-Radion - Royal Blue Channel
13-Radion - Red Channel
14-Radion - Green Channel
15-Radion - Blue Channel
16-Radion - Intensity Channel

y=value to be overwritten. Values <=100 enables override and values > 100 disables it

/boot - force reboot

/cvarx,y - set custom variable (byte size) where
x=custom variable index
y=value to be written

/calx - starts the calibration where
x=parameter id
Valid ids:
0 - pH
1 - Salinity
2 - ORP
3 - pH Expansion
4 - Water Level
Roberto.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Wifi attachment commands

Post by binder »

When using the /rxy command, x is the relay (like roberto said).
The values for x can be:
  • 1-8 - main relay
  • 11-18 - expansion relay 1
  • 21-28 - expansion relay 2
  • 31-38 - expansion relay 3
  • 41-48 - expansion relay 4
  • 51-58 - expansion relay 5
  • 61-68 - expansion relay 6
  • 71-78 - expansion relay 7
  • 81-88 - expansion relay 8
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: Wifi attachment commands

Post by rossbryant1956 »

was there a pre-post to this that explains how we might use this? Thx in advance.

I found it:

http://forum.reefangel.com/viewtopic.ph ... ead#unread
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Wifi attachment commands

Post by rimai »

To use the commands, all you need to do is browse to your controller with your favorite internet browser.
For example:
http://ipaddress:2000/wifi
You can use any command above after the port number.
This is what the Portal and apps use underneath the pretty user interface :)
Roberto.
thekameleon
Posts: 137
Joined: Sat Feb 16, 2013 7:44 am

Re: Wifi attachment commands

Post by thekameleon »

Quick question, is there a schema for the data that /sr or /sa will return?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Wifi attachment commands

Post by rimai »

They are both the same :)
/r99 is also the same thing.
XML formatted data with the parameters your RA is monitoring/controlling.
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

Does anyone have insight into how to read the /mr information? I want to populate some variables to display on a web page.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Wifi attachment commands

Post by binder »

lnevo wrote:Does anyone have insight into how to read the /mr information? I want to populate some variables to display on a web page.
This should give you some insight. From RA_Wifi.cpp

Code: Select all

//... exert
byte m;
for ( int x = VarsStart; x < VarsEnd; x++ )
{
	m=InternalMemory.read(x);
	if (m<16) WIFI_SERIAL.print("0");
	WIFI_SERIAL.print(m,HEX);
}  // for x
It goes through all the locations, one by one and prints out the hex value for them. The function read() only reads a byte value. So you should plan on 2 digits per memory location. Your code will need to know the start and stop values (which can be obtained from the Globals.h file). Then you will also need to know if you are dealing with 1 or 2 memory locations (2 or 4 digits in the string).
I don't personally use this string in the Android app. I think the Client Suite uses it. I also think Roberto uses it for something otherwise he wouldn't have created it.
Hopefully that helps you out.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

Yeah that helped. It looks like /mr only prints the standard values, so I'm going to have to add a function. More work to do :) if my ReefAngel doesn't blow up when I finally load my code I'll be pretty impressed.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

I'm gonna try this

Code: Select all

			case REQ_M_CUSTOM:
			{
				int s = 11;  // start with the base size of the mem tags
				int CustomVarsStart=100;
				s += (VarsStart-CustomVarsStart)*2;
				PrintHeader(s,1);
				PROGMEMprint(XML_MEM_OPEN);
				byte m; 
				for ( int x = CustomVarsStart; x < VarStart; x++ )
				{
					m=InternalMemory.read(x);
					if (m<16) WIFI_SERIAL.print("0");
					WIFI_SERIAL.print(m,HEX);
				}  // for x
				PROGMEMprint(XML_MEM_CLOSE);
				break;
			}  // REQ_M_CUSTOM 
I add /mc to access it.

And now I found another Relay.Write I have to consider for my override mask :) gonna be a challenge to get that back into git.
thekameleon
Posts: 137
Joined: Sat Feb 16, 2013 7:44 am

Re: Wifi attachment commands

Post by thekameleon »

I have never been a fan of modifying the libraries as it introduces unnecessary hassle when trying to upgrade to the latest and greatest. I think it would be great if a CustomWifiRequest() call could be made. So add a define CUSTOM_WIFI_REQUEST in the ReefAngel_Features.h and if it is there add the call to CustomWifiRequest with the appropriate parameters and return value. Then the IDE would do its magic.

Thoughts?
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

I did this one for myself...the other problem is the defines for where to start and end custom memory...i say its your turn to make a pull request :) but yes that would be the better way to go.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Wifi attachment commands

Post by rimai »

There is already a ticket for this. :)
I just didn't do anything yet.
https://github.com/reefangel/Libraries/issues/75
I wanted to have someone test the wifi key authentication (issue #71) and channel overrides (issue #73) before I add more to the wifi stuff.
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Wifi attachment commands

Post by lnevo »

Roberto,

The issue you posted is a different request... the one I have hacked in for now was to get custom used memory variables dumped out like /mr
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Wifi attachment commands

Post by lnevo »

Roberto, for what you have planned or are thinking about for issue75... would that be able to return data to the web browser or just call functions on the RA?

I would like to have function that returns through http the memory values in my custom memory fields... like /mr
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Wifi attachment commands

Post by rimai »

I was thinking of calling functions with only OK as return
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

I have an idea...

What if we extended /mr to take two options which /mb /mi already parse.

Default stays the same
/mrx,y would return that memory range.

Technically we could do a memory write as well with

/mrx,y would write y starting at value x

That solves how i was going to figure out how i get my custom variable locations into the global ra_wifi files.

It also enables a mechanism to backup/restore memory locations.

What you guys think?
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

It also creates a workaround for my negative number situation since i can just convert it from hex.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Wifi attachment commands

Post by rimai »

I like it and it may just work.
Roberto.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Wifi attachment commands

Post by binder »

how would you differentiate between a read and a write then?
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

How hard is it to add weboption3?
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

Oh i had originally meant to write another slash command for write..whats your thoughts...
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Wifi attachment commands

Post by binder »

Well, having a weboption3 would keep the consistency for the way the storing of data works. We already parse for weboption3 with the date/time command. The logic would need to be modified to put in some sanity checks for the command to handle 3 options (to ensure all three exist before writing, etc). The drawback is the amount of data you would be sending to the controller. We couldn't send the whole raw hex memory dump up because of how things get parsed. It's parsed 1 char at a time and reading in a long string would not work because the value would have to be stored in memory before it can be written or processed.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Wifi attachment commands

Post by binder »

The incoming read buffer is a

Code: Select all

static char m_pushback[32];
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

Looks like the set date method can take three args...

So, I'll see about doing this:

/mr - returns standard memory values VarsStart-VarsEnd

/mrx,y - returns location x-y

/mrx,y,z -set memory location x-y with value z
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

binder wrote:Well, having a weboption3 would keep the consistency for the way the storing of data works. We already parse for weboption3 with the date/time command. The logic would need to be modified to put in some sanity checks for the command to handle 3 options (to ensure all three exist before writing, etc). The drawback is the amount of data you would be sending to the controller. We couldn't send the whole raw hex memory dump up because of how things get parsed. It's parsed 1 char at a time and reading in a long string would not work because the value would have to be stored in memory before it can be written or processed.
Hmmmm well writing can be shelved for now...I'd be more interested in solving the negative number issue in that case.

But displaying locations x-y is definitely doable for now...
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

binder wrote: We couldn't send the whole raw hex memory dump up because of how things get parsed. It's parsed 1 char at a time and reading in a long string would not work because the value would have to be stored in memory before it can be written or processed.
What I'd we didn't store it and just start writing as we read each character.

We could write a loop from x-y and then start reading in char z writing and discarding as we go. If we y-x > strlen(z) then we can just write 0 or F and if it's less than, we just drop the rest on the floor.

Don't know if this is feasible...
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Wifi attachment commands

Post by rimai »

I think you will overrun your buffer and loose incoming data by trying to do that loop.
In the other hand, the reading of negative number is easy fixed. The writing of negative numbers can be interpreted as a very large byte or integer.
In reality, there is no such thing as negative number for the controller. The controller only understands 0s or 1s... :shock: , so technically for the controller -1 is the same as 65535.
I just confirmed that you can send "GET /mi,65535" and it will return -1.
This is the workaround for storing negative numbers for now.
I'll look into a more permanent solution later.
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

That doesn't help if i want to store a value like negative 73... The controller stores it just fine with write_int function. I don't quite follow the 0/1 analogy. Or the statement that the controller doesn't understand negative numbers...they are just another int, whats to understand?

With the writing of a range shelved, what about writing byte or int as a hex value?
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Wifi attachment commands

Post by lnevo »

Ok, anyway, based on what you said regarding 65535, the way to enter negative numbers is to subtract the number for UINT_MAX which in this case would be 65536. So in your case, writing 65535 gets -1. For me to get -73 back into the variable, I had to write 65463. I can handle that situation in the html I am working on. All I need to do is if it's a negative number, then add 65536 to it :)

Anyway, so now the only thing left is to fix the display for reading and implement reading custom memory ranges.
Post Reply