Yun is based on Linux that has full stack of TCP/UDP. It answer PnP problem by implemented Zero-configuration networking via Avahi (similar to Apple Bonjour). Avahi uses IP multicast User Datagram Protocol (UDP) packets.
Beside broadcast, anytime low-latency, real-time overweight guarantee packet delivery and sequencing such as audio or video stream use UDP at most case.
My "Let's stay in TCP" which only stay bridge between Arduino and Yun.
When I send the command 'echo "G" | nc -u 192.168.1.123 8888' to an Arduino Uno on my network from the Terminal app in OS X I receive the expected response of G,42
When I try to send the same command from a Yun, using the script shown below, the p.runShellCommand never seems to finish.
Sending 'echo "L12" | nc -u 192.168.1.123 8888' to my Uno from the Yun should switch on one of my Wi-Fi lights but this does not happen, although the same command issued in the Terminal app does.
How can I check that the UDP message is being sent?
/*
Running shell commands using Process class.
*/
#include <Process.h>
// cmd = echo "G" | nc -u 192.168.1.123 8888
String cmd = "echo \"G\" | nc -u 192.168.1.123 8888";
void setup() {
Bridge.begin(); // Initialize the Bridge
Serial.begin(9600); // Initialize the Serial
// Wait until a Serial Monitor is connected.
while(!Serial);
}
void loop() {
Process p;
p.runShellCommand(cmd);
// do nothing until the process finishes, so you get the whole output:
while(p.running());
// Read command output.
while (p.available() > 0) {
char c = p.read();
Serial.print(c);
}
Serial.flush();
delay(5000); // wait 5 seconds before you do it again
}
Thank you for putting me on the right track I am now able to control my Wi-Fi lights from the Yun.
I have learnt a lot with your help.
However, I am missing one feature now. Some of my UDP commands have replies and I would like to retrieve them. I think that I can modify the Python script to get the reply but how do I pass the reply back to the Arduino side of the Yun?
Thank you once again. I have tried your code that uses the Yun Bridge and it works. I am using it to control my Wi-Fi lights and to retrieve the reply sent by the Uno controlling them.
Without your help I would have given up long ago. I have learnt a lot about the Yun with your help.
Okay, so nothing to reset is coming up on the arduino.local page. I used my computer to put the file on the SD card.
The SD card is called SD and I put the file in the root folder
EDIT: Tried using terminal too, same message as before, no such file or directory