diff --git a/EthernetInterface.cpp b/EthernetInterface.cpp index 7d8d7b0..34e209a 100644 --- a/EthernetInterface.cpp +++ b/EthernetInterface.cpp @@ -47,6 +47,10 @@ void EthernetInterface::setup() }; +#ifdef IP_ADDRESS +static IPAddress myIP(IP_ADDRESS); +#endif + /** * @brief Aquire IP Address from DHCP and start server * @@ -60,14 +64,14 @@ EthernetInterface::EthernetInterface() connected=false; #ifdef IP_ADDRESS - if (Ethernet.begin(mac, IP_ADDRESS) == 0) + Ethernet.begin(mac, myIP); #else if (Ethernet.begin(mac) == 0) -#endif { DIAG(F("Ethernet.begin FAILED")); return; } +#endif if (Ethernet.hardwareStatus() == EthernetNoHardware) { DIAG(F("Ethernet shield not found or W5100")); } @@ -136,7 +140,7 @@ bool EthernetInterface::checkLink() { DIAG(F("Ethernet cable connected")); connected=true; #ifdef IP_ADDRESS - Ethernet.setLocalIP(IP_ADDRESS); // for static IP, set it again + Ethernet.setLocalIP(myIP); // for static IP, set it again #endif IPAddress ip = Ethernet.localIP(); // look what IP was obtained (dynamic or static) server = new EthernetServer(IP_PORT); // Ethernet Server listening on default port IP_PORT