I had fix a translation code between diffrent UDP-package. So I recive a UDP-package on port 8001 and send another package to diffrent IP and ports depending of what I would control.
The code is working, even If I don´t spell everything ok. ![]()
#include <Bridge.h> // Conenct Arduino and Linux-shield on Arduino Yün togheter.
#include <BridgeUdp.h>
#include <YunClient.h>
//Setting up CTB-server IP/Port, OSC-port for Arduino Yün.
IPAddress CTB_ip(10, 101, 1, 11);
IPAddress HELVAR_ip(10, 101, 202, 101);
const int CTB_port = 1100;
const int HELVAR_port = 50001;
const int OSC_UDP_port = 8001;
YunClient client;
BridgeUDP Udp;
void setup() {
Bridge.begin();
Serial.println("Bridge started...");
Udp.begin(OSC_UDP_port);
Serial.println("Start listning to UDP-port: " + String(OSC_UDP_port));
}
In my loop i recieve UDP-package..
// the loop function runs over and over again forever
void loop() {
//Recive UDP-package
Udp.beginBroadcastPacket(OSC_UDP_port);
int packetSize = Udp.parsePacket();
if (packetSize) {
int udp_recived = Udp.available();
char udp_buffer[udp_recived];
Udp.read(udp_buffer, udp_recived + 1);
udp_buffer[udp_recived] = '\0';
incomingUDP(udp_buffer);
}
}
Everything works when I start up my project and after a day, I need to restart my Arduino and then it works again during the day. Is there a way to check that Udp.begin(OSC_UDP_port); is still running so I can restart it? Is there something simple to empty the ev. memory buffers or variables after I run "incomingUDP(udp_buffer);"?
The only variables I declare outside each function is what I wrote in code above before "setup". I use some String, int and byte buf[udp_message.length() + 1] to split my incoming UDP-string in own functions.
I turned of WIFI, so I use RJ45-cable connected to network.