hi list, I'm playing with arduino yun bridge example
https://www.arduino.cc/en/Tutorial/Bridge.
I wrote this little sketch to turn on and off a led.
import processing.net.*;
Client myClient;
String data;
boolean flag=true;
String requestON="/arduino/digital/13/1";
String requestOFF="/arduino/digital/13/0";
void setup() {
size(200, 200);
frameRate(25);
// Connect to the local machine at port 5204.
// This example will not run if you haven't
// previously started a server on this port.
myClient = new Client(this, "192.168.1.106", 80); // arduino yun IP
myClient.write("GET "+requestON+" HTTP/1.0\r\n"); // turn on the led
myClient.write("\r\n");
}
void draw() {
if (frameCount%12==0) {
if (flag) {
performRequest(requestON);
} else {
performRequest(requestOFF);
}
flag=!flag;
}
/*
if (myClient.available() > 0) {
data = myClient.readString(); // ...then grab it and print it
println(data);
}
*/
}
void stop() {
myClient.stop();
}
void performRequest(String myRequest) {
myClient = new Client(this, "192.168.1.106", 80);
myClient.write("GET "+myRequest+" HTTP/1.0\r\n"); // Use the HTTP "GET" command to ask for a Web page
myClient.write("\r\n");
}
every cycle i got this error "Client got end-of-stream."
How can avoid this?
Then I have another question, it is correct to close the client on stop?
thanks.