Teensy 3.6 UDP broadcast

Status
Not open for further replies.

RogerdeValle

New member
I have been attempting a UDP broadcast using the Teensy Ethernet library (Teensy 3.6 with Wiz8820io). I want to broadcast a UDP packet to a local subnet by using an IP address such as 192.168.0.255, the core of my code looks something like this..

IPAddress broadcastIp(192,168,0,255);

EthernetUDP UDP;

void setup()
{
char tmp[30];

UDP.begin(30305);
strcpy(tmp,"Hello from 192.168.0.140");

UDP.beginPacket(broadcastIp,30304);
UDP.write(tmp);
UDP.endPacket();
}

If I use the broadcastIp address as 192.168.0.3 the target gets the packet across the network, if however I use 192.168.0..255 there is nothing received. In fact using Wireshark I can see that the Teensy never transmits a UDP packet whenever the broadcast address is used (It transmits the fully qualified IP address packet fine). Is this a library issue and does someone have fix or am I missing something very fundamental

Regards, Roger d
 
Thanks Ryan but it turns out I was the culprit. I was recovering my subnet mask from Eeprom and it was incorrect, fixed it and tidied up my libraries, it work as expected now. A bit older and wiser now.
Regards. Roger d
 
Status
Not open for further replies.
Back
Top