The basic use of my sketch is to measure the themperature in the cabinet the box with the arduino is placed in and the temperature in the arduino box, bypass the UPS if it fails, activate and deactivate my alarmsystem and reset my router, POE camera and HDD recorder.
I have a cisco 881-3G router and a VPN connection to my home all is working fine for normal use (streaming video, documents, pictures and so on).
if i use my sketch on my local network (HP switch) I can send the alarm messages to my TCP receiver at home, but if i try to do so with the arduino behind the cisco router over the VPN tunnel nothing is received bij the TCP receiver (no single hit on wireshark).
I can ping the arduino from all places in both networks. I also can connect the web interface on the arduino.
The only thing that is not working is the TCPsend function to the TCP receiver at home.
The complete sketch is attatched as .txt .
void TCPsend(){
Serial.println("Bezig met verbinden...");
delay(100);
// Maak de TCP verbinding en geef aan als er een verbinding is
Serial.println(ipserver);
Serial.println(serverpoort);
if (TCPclient.connect(ipserver, serverpoort)) {
Serial.println("Verbonden");
//delay(100);
// Verstuur het alarmbericht naar de server en de seriële poort
Serial.print("Verzend bericht : ");
TCPclient.print(String(AlarmMSG));
Serial.println(AlarmMSG);
AlarmMSG = "";
}
else {
// Als de verbinding mislukt is geef dit dan aan
Serial.println("Verbinding mislukt");
delay(1000);
TCPsend(); // probeer opnieuw te versturen
}
// Als er een reactie van de server komt print
// deze dan op de seriële poort
// Even de server de tijd geven om iets terug te sturen
delay (50);
if (TCPclient.available() > 0) {
Serial.print("Antwoord van server : ");
}
// Ontvang de daadwerkelijke reactie van de server
while (TCPclient.available() > 0) {
char c = TCPclient.read();
Serial.print(c);
}
TCPclient.stop();
serverpoort = 900;
// Als de server verbinding verbroken is, stop dan de client:
if (!TCPclient.connected()) {
Serial.println();
Serial.println("Verbinding verbroken.");
TCPclient.stop();
}
}
complete sketch.txt (12.9 KB)