1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-27 01:56:14 +01:00

Bugfix: Ethernet fixed IP start

This commit is contained in:
Harald Barth 2024-01-10 15:09:22 +01:00
parent 796d5c4774
commit 9ab6b3d4ea

View File

@ -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 * @brief Aquire IP Address from DHCP and start server
* *
@ -60,14 +64,14 @@ EthernetInterface::EthernetInterface()
connected=false; connected=false;
#ifdef IP_ADDRESS #ifdef IP_ADDRESS
if (Ethernet.begin(mac, IP_ADDRESS) == 0) Ethernet.begin(mac, myIP);
#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"));
} }
@ -136,7 +140,7 @@ bool EthernetInterface::checkLink() {
DIAG(F("Ethernet cable connected")); DIAG(F("Ethernet cable connected"));
connected=true; connected=true;
#ifdef IP_ADDRESS #ifdef IP_ADDRESS
Ethernet.setLocalIP(IP_ADDRESS); // for static IP, set it again Ethernet.setLocalIP(myIP); // for static IP, set it again
#endif #endif
IPAddress ip = Ethernet.localIP(); // look what IP was obtained (dynamic or static) 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