Paul, thanks, I actually don't know how to correct post subject here I think it could be done only by forum admin?
Also, I thought there may be some function in that lib that does this and I don't know..
Ok so my question is data streaming, I actually still didn't write the complete code but simple 'proof of concept test code' to make sure I can send and receive servo pos and rgb-led set values ok. No servo pos code yet written, I only realized example I found in that Ethernet lib, and without standard detail this is the code:
try {
socket = new Socket("162.122.1.1", 80);//my arduino ip
OutputStream out = socket.getOutputStream();
PrintWriter outw = new PrintWriter(out, false);
String strHttpGET = "GET /?" + textOut.getText().toString() + " HTTP/1.0\r\n";
outw.print(strHttpGET);
outw.print("Accept: text/plain, text/html, text/*\r\n");
outw.print("\r\n");
outw.flush();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
finally{
if (socket != null){
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
........
in Arduino side, I used simply the example from that lib this way:
void loop()
{
char* params;
if (params = e.serviceRequest())
{
e.print("<H1>Web Remote</H1>");
if (strcmp(params, "?cmd=on") == 0)
{
digitalWrite(outputPin, HIGH);
e.print("<A HREF='?cmd=off'>Turn off</A>");
}
else
{
digitalWrite(outputPin, LOW);
e.print("<A HREF='?cmd=on'>Turn on</A>");
}
e.respond();
}
}
Now right here, I came to this question of how to send values. As I understand, you mean I have to extract the string between '?' and & characters and between two '&' characters for my command:
"http://162.122.1.1/?servopos=120&led=on&r=20&g=10&b=30"
Then in Arduino side, I will use these:
- strtok() for parsing
- atoi() to get integer
- some substring functions
Did I get all right please?