Hello
I am using EtherCard lib on my Arduino Uno.
I'm sending uDP broadcasts using a laptop on 255.255.255.255 .
The broadcast is received on another laptop without issue on the same network.
The arduino won't react to it.
BUT if i send a UDP to the arduino's IP, that works !
Any idea on how to get the arduino to listen to broadcast udp ?
Code is pretty much the udp listener example.
Any ideas ?
#include <EtherCard.h>
#include <IPAddress.h>
static byte mymac[] = {0x74,0x69,0x69,0x2D,0x31,0x01 };
byte Ethernet::buffer[700];
void setup()
{
Serial.begin(9600);
Serial.println("\n0.1");
for(int i = 0;i< sizeof mymac;i++)
{
Serial.print(mymac[i],HEX);
Serial.print(" ");
}
Serial.println("");
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println( "Failed to access Ethernet controller");
if(!ether.dhcpSetup())
Serial.println("DHCP Failed");
ether.printIp("IP: ", ether.myip);
ether.udpServerListenOnPort(&udpSerialPrint, 5000); // callback to function
}
void loop()
{
ether.packetLoop(ether.packetReceive());
}
void udpSerialPrint(word port, byte ip[4], const char *data, word len) {
IPAddress src(ip[0], ip[1], ip[2], ip[3]);
Serial.println(src);
Serial.println(port);
Serial.println(data);
Serial.println(len);
}