Neste momento queria apenas estabelecer uma ligaçao e posteriormente enviar uma string ou input para que no outro yun ao receber esse input acendesse um LED.
por exemplo se colocar 2 yun em dois locais diferentes com um motion sensor ao detectarem movimento enviavam o sinal atraves da ethernet para um yun principal em k acendia um LED correspondente ao local.... algo deste genero
neste momento tenho o codigo assim mas nao tenho ligaçao:
server
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>
YunServer Server;
void setup() {
Serial.begin(9600);
Bridge.begin();
Server.listenOnLocalhost();
Server.begin();
}
void loop() {
YunClient client = Server.accept();
if (client) {
Serial.println("Client Connected");
//Console.println(request);
//process(client);
client.stop();
}
delay(50);
IPAddress server(192,168,1,2); // adresse IP de la YUN1
if(client.connect(server,5555)){ // si on est connecté au serveur
Serial.println("connected");
}
client.stop();
delay(500);
}
client
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 1, 2);
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
YunClient client;
void setup() {
Serial.begin(9600);
Bridge.begin();
}
void loop()
{
// if you get a connection, report back via serial:
if (client.connect(server, 5555)) {
Serial.println("connected");
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
client.stop();
delay(500);
}