Help with - creating an IP address from variables.
Posted: Wed May 18, 2016 5:18 pm
Hi, I’m using the Arduino IDE 2.0 & WiFiUdp.h to send sCAN packets. With the way I need it to work, it has to send to various multicast addresses that are defined by variables. If I could pre-set these it would be easy, but I can’t and there are 65,535 (0xffff) possible options,
so a look up is not going to work unless I have to.
Does anyone know how to construct an IP address from variables?
I'm currently using:
followed by
which works fine for Udp.writes to a single IP. If I try to introduce variables at any point (that I've tried - to many to list) it doesn't compile or sends to 0.0.0.0 .
I'm guessing the 'IPAddress' format is something I'm missing, any help appreciated.
Code: Select all
239.255.0.1 through to 239.255.255.255
so a look up is not going to work unless I have to.
Does anyone know how to construct an IP address from variables?
I'm currently using:
Code: Select all
IPAddress IP_Multicast_Out(239, 255, 0, 1);
unsigned int Port_Multicast_Out = 5568;
followed by
Code: Select all
Udp.beginPacketMulticast(IP_Multicast_Out, Port_Multicast_Out, WiFi.localIP());
which works fine for Udp.writes to a single IP. If I try to introduce variables at any point (that I've tried - to many to list) it doesn't compile or sends to 0.0.0.0 .
I'm guessing the 'IPAddress' format is something I'm missing, any help appreciated.