Hello,
I have an Ethernet shield and relay board hooked up to my Arduino. I have a webpage set up and its working fine. At the moment I have on/off buttons for the relay that, when clicked, append a couple letters with tokens onto the URL. This is then tokenized using strtok, etc. and the switch is turned on or off...
...
...
char *response = strtok(readString, "?");
response = strtok(NULL, "=");
if(strcmp (response, "A") == 0){
val = 1;
}
else {
val = atoi(response);
}
response = strtok(NULL, ".");
tempHr = atoi(response);
response = strtok(NULL, ".");
tempMin = atoi(response);
response = strtok(NULL, ";");
if(strcmp (response, "T") == 0){
trueFalse = 'T';
}
else
trueFalse = 'F';
...
...
So now I'm working on a different part of the code where I need to have the user be able to set a weekly schedule for the relays. I'd like to create text boxes for each day of the week in which the user can input a time like "5:30" and then a GET HTTP request will be sent so that the Arduino can change the time accordingly.
I have it somewhat working, however I'm having problems with tokenizing the requests. The following code sends the request and works fine:
client.print("<form action='http://192.168.1.134:8088/' method='GET'>");
client.print("<input type='text' name='2' maxlength='5' size='5' />");
client.print("<intput type='submit' value='Submit' /></form>
");
But I don't know how I can tokenize it when I already have code in the loop that is tokenizing a different type of information for the individual on/off buttons. For example, when the on/off button is pressed for relay 2 the URL will look like this:
http://192.168.1.134:8088/?2=T;
And when I type in the text box to change the time to "5:30" for relay 2the URL will be:
http://192.168.1.134:8088/?2=5%3A30
I realize the ":" is encoded to %3A so I will have to deal with that as well (although 5.30 works fine but I'd rather not use that);
So as you can see, my problem is that I need to tokenize the URL differently depending on the request. Is there an easy way of doing this?
Thanks for any help! I hope this all made sense...
EDIT: I've been thinking of adapting my project using the concepts here http://www.cs.helsinki.fi/u/ljlukkar/iot/#conclusions but I don't know anything about java. Would it make more sense for me to try and learn to do this?