1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-02-16 22:19:14 +01:00

fix static IP addr

This commit is contained in:
Harald Barth 2022-12-04 20:09:14 +01:00
parent 45b36c48cb
commit b671d70dfe

View File

@ -60,14 +60,14 @@ EthernetInterface::EthernetInterface()
connected=false; connected=false;
#ifdef IP_ADDRESS #ifdef IP_ADDRESS
if (Ethernet.begin(mac, IP_ADDRESS) == 0) Ethernet.begin(mac, IP_ADDRESS);
#else #else
if (Ethernet.begin(mac) == 0) if (Ethernet.begin(mac) == 0)
#endif
{ {
DIAG(F("Ethernet.begin FAILED")); DIAG(F("Ethernet.begin FAILED"));
return; return;
} }
#endif
if (Ethernet.hardwareStatus() == EthernetNoHardware) { if (Ethernet.hardwareStatus() == EthernetNoHardware) {
DIAG(F("Ethernet shield not found or W5100")); DIAG(F("Ethernet shield not found or W5100"));
} }
@ -135,7 +135,10 @@ bool EthernetInterface::checkLink() {
if(!connected) { if(!connected) {
DIAG(F("Ethernet cable connected")); DIAG(F("Ethernet cable connected"));
connected=true; connected=true;
IPAddress ip = Ethernet.localIP(); // reassign the obtained ip address #ifdef IP_ADDRESS
setLocalIP(IP_ADDRESS); // 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 server = new EthernetServer(IP_PORT); // Ethernet Server listening on default port IP_PORT
server->begin(); server->begin();
LCD(4,F("IP: %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]); LCD(4,F("IP: %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);