At the top of the file I have #EthernetUdp.h but when I compile it I get the error;
EthernetFindIPAddress.ino: In function 'void setup()':
EthernetFindIPAddress.ino:33:3: error: 'EthernetUdp' was not declared in this scope
Here is the code
//#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
//#include <EthernetClient.h>
//#include <EthernetServer.h>
//#include <EthernetUdp.h>
#include <SPI.h>
// MAC address and IP for arduino
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip( 192, 168, 100, 100 ); // IP Address of Ethernet Shield.
IPAddress subnet( 255, 255, 255, 0 );
IPAddress gateway( 192, 168, 10, 251 );
IPAddress dnsServer( 192, 168, 10, 1 );
unsigned int localPort = 8888; // local port to listen on
//unsigned int IPlength = 12;
// SenderIP and SenderPort are set when message is received
byte SenderIP[] = {0,0,0,0}; // holds received packet's originating IP
unsigned int SenderPort; // holds received packet's originating port
// buffer for receiving data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet
int packetSize = 0;
void setup()
{
Ethernet.begin(mac, ip, dnsServer, gateway, subnet);
//Ethernet.begin(mac,ip); //start Ethernet
EthernetUdp.begin(localPort); //start UDP
}
void loop()
{
if(NewPortMessage())
{
// Do stuff, SenderIP is the IP where the UDP message was received from
}
}
boolean NewPortMessage()
{
packetSize = EthernetUdp.available();
if(packetSize > 0)
{
packetSize -= 8; //subtract UDP 8-byte header
// read the packet into packetBufffer and get the senders IP addr and port number
EthernetUdp.readPacket(packetBuffer,UDP_TX_PACKET_MAX_SIZE, SenderIP, SenderPort);
return true;
}
clearPacketBuffer();
return false;
}
void clearPacketBuffer()
{
for(int i=0; i < packetSize; i++)
packetBuffer = 0;
}
Here is the compiler error mesaages (in full);
EthernetFindIPAddress.ino: In function 'void setup()':
EthernetFindIPAddress.ino:33:3: error: 'EthernetUdp' was not declared in this scope
EthernetFindIPAddress.ino: In function 'boolean NewPortMessage()':
EthernetFindIPAddress.ino:46:16: error: 'EthernetUdp' was not declared in this scope
Error compiling.
Can someone see what the issue is? - because I have tried everything I can think of with no solution!!
Sincerely,
Sciencez