RB:
SUPERB!!Thank you Marque!!!
This is just what I needed. I just started on my room-automation project today, so I'm sure I'll come up with some suggestions soon enough
I tried rating the app, but unfortunately i don't have a Google+ account as yet -- will get around to that soon!
Thanks,
RPS - Though I've made some changes and its working great, i have no clue what the following code does. Could you please explain it to me in just a brief overview sentence or two? Thanks!
{readString.concat(c);}
if (c == 'H')
{
Serial.println();
int Is = readString.indexOf("/");
int Iq = readString.indexOf("?");
int Ib = readString.indexOf("b"); //arduino looks for a b
int Ic = readString.indexOf("c"); //arduino looks for a c
if(readString.indexOf("?") > 1)
{
if (Ib == (Iq+1)) // if there is a b
{
char carray[5];
readString.toCharArray( carray,5,(Ib+1)); // read the value after the "b"
Serial.println(carray);
valueB = atof(carray); //set the found value to variable "valueB"
Serial.print("B is now: ");
Serial.println(valueB); //print the found value
client.print (content_main_top);
client.print("B is now: ");
client.print(valueB);
}
else if (Ic == (Iq+1)) // the same for "c"
{
char carray[5];
readString.toCharArray( carray,5,(Ic+1));
Serial.println(carray);
valueC = atof(carray);
Serial.print("C is now: ");
Serial.println(valueC);
client.print (content_main_top);
client.print("C is now: ");
client.print(valueC);
}
in thise piece of code you can set two variable with you android app. In the settings screen you can set a prefix in the two textboxes top right. in the first one put a "b" and in the second one put a "c". on the main screen you can put a value in the two text views top left and hit the send button. the app will send a HTTP GET request in the following format: "http://yourip:yourport/?prefixvalue" , "http://192.168.1.120:80/?b2800". where the "b" is the prefix you have set in the settingsscreen and 2800 is the value you set in the main screen. The arduino sketch will look for a "b" or a "c" and sets the variable to the value that follows.
I have commented the code above, hope it clears it up for you.