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:
parent
6f797b2e15
commit
7ae6ff27f5
|
@ -50,6 +50,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
|
||||||
*
|
*
|
||||||
|
@ -71,33 +75,32 @@ EthernetInterface::EthernetInterface()
|
||||||
// Which seems more useful! We should propose the patch... so the following line actually works!
|
// Which seems more useful! We should propose the patch... so the following line actually works!
|
||||||
netif_set_hostname(&gnetif, WIFI_HOSTNAME); // Should probably be passed in the contructor...
|
netif_set_hostname(&gnetif, WIFI_HOSTNAME); // Should probably be passed in the contructor...
|
||||||
#ifdef IP_ADDRESS
|
#ifdef IP_ADDRESS
|
||||||
if (Ethernet.begin(IP_ADDRESS) == 0)
|
Ethernet.begin(myIP);
|
||||||
#else
|
#else
|
||||||
if (Ethernet.begin() == 0)
|
if (Ethernet.begin() == 0)
|
||||||
#endif // IP_ADDRESS
|
|
||||||
{
|
{
|
||||||
DIAG(F("Ethernet.begin FAILED"));
|
DIAG(F("Ethernet.begin FAILED"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif // IP_ADDRESS
|
||||||
#else // All other architectures
|
#else // All other architectures
|
||||||
byte mac[6]= { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
|
byte mac[6]= { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
|
||||||
DIAG(F("Ethernet attempting to get MAC address"));
|
DIAG(F("Ethernet attempting to get MAC address"));
|
||||||
DCCTimer::getSimulatedMacAddress(mac);
|
DCCTimer::getSimulatedMacAddress(mac);
|
||||||
DIAG(F("Ethernet got MAC address"));
|
DIAG(F("Ethernet got MAC address"));
|
||||||
#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 // IP_ADDRESS
|
||||||
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
|
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
|
||||||
DIAG(F("Ethernet shield not found or W5100"));
|
DIAG(F("Ethernet shield not found or W5100"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif STM32_ETHERNET
|
||||||
|
|
||||||
uint32_t startmilli = millis();
|
uint32_t startmilli = millis();
|
||||||
while ((millis() - startmilli) < 5500) { // Loop to give time to check for cable connection
|
while ((millis() - startmilli) < 5500) { // Loop to give time to check for cable connection
|
||||||
|
@ -163,7 +166,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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user