I have a photon which listens for multicast udp packets and whenever someone sends a message to the multicast address it should retrieve the IPAddress of the endpoint that did it and start a TCP connection with it.
So in my Ubuntu I have a program that using boost opens a TCP server and sends the UDP message to the photon. This steps are don properly, and the photon detects the udp message.
Then in the phothon I have this piece of code:
// At the beggining
// Inside loop function, after receiving a connection
IPAddress multicastSenderIP = multicastUDP.remoteIP();
Serial.println("Discovery message received from " + multicastSenderIP.toString());
while(multicastUDP.available()) multicastUDP.read(); // ignore all data
if(tcpClient.connect(multicastSenderIP, tcpPort)) // Connect to the tcp server (at same address as multicast)
Serial.println("Connected to tcp server");
Serial.println("Can't connect to tcp server");
I'm receiving the multicast packet and can't seem to connect to the TCP server. I tried writing a little program with unix sockets and it does work to open a connection with ip/port of my computer.
Also note that when receiving the udp packet it only prints:
Discovery message received from and no IP address is printed.
Could someone point out what I'm doing wrong?