Skip to content

Commit

Permalink
allow static IP (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
habazut committed Aug 19, 2024
1 parent 5db19a0 commit edb02a0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions EthernetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,21 @@ void EthernetInterface::setup()
byte mac[6];
DCCTimer::getSimulatedMacAddress(mac);
DIAG(F("Ethernet begin"));
#ifdef IP_ADDRESS
static IPAddress myIP(IP_ADDRESS);
Ethernet.begin(mac, myIP);
#else
if (Ethernet.begin(mac) == 0)
{
DIAG(F("Ethernet.begin FAILED"));
return;
}
LCD(4,F("IP: No DHCP"));
return;
}
#endif
auto ip = Ethernet.localIP(); // look what IP was obtained (dynamic or static)
if (!ip) {
LCD(4,F("IP: None"));
return;
}
server = new EthernetServer(IP_PORT); // Ethernet Server listening on default port IP_PORT
server->begin();
LCD(4,F("IP: %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
Expand Down

0 comments on commit edb02a0

Please sign in to comment.