mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-23 21:01:25 +01:00
Fixes to Ethernet cable handling and STM32
This commit is contained in:
parent
15c2b5af04
commit
d591309efd
@ -47,9 +47,9 @@ void EthernetInterface::setup()
|
|||||||
DIAG(F("Prog Error!"));
|
DIAG(F("Prog Error!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DIAG(F("Ethernet Class setup, attempting to instantiate"));
|
DIAG(F("Ethernet starting... please be patient, especially if no cable is connected!"));
|
||||||
if ((singleton=new EthernetInterface())) {
|
if ((singleton=new EthernetInterface())) {
|
||||||
DIAG(F("Ethernet Class initialized"));
|
// DIAG(F("Ethernet Class initialized"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DIAG(F("Ethernet not initialized"));
|
DIAG(F("Ethernet not initialized"));
|
||||||
@ -83,11 +83,7 @@ EthernetInterface::EthernetInterface()
|
|||||||
#ifdef IP_ADDRESS
|
#ifdef IP_ADDRESS
|
||||||
Ethernet.begin(myIP);
|
Ethernet.begin(myIP);
|
||||||
#else
|
#else
|
||||||
if (Ethernet.begin() == 0)
|
Ethernet.begin();
|
||||||
{
|
|
||||||
DIAG(F("Ethernet.begin FAILED"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif // IP_ADDRESS
|
#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 };
|
||||||
@ -112,15 +108,22 @@ EthernetInterface::EthernetInterface()
|
|||||||
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
|
||||||
if (Ethernet.linkStatus() == LinkON)
|
if (Ethernet.linkStatus() == LinkON)
|
||||||
break;
|
break;
|
||||||
DIAG(F("Ethernet waiting for link (1sec) "));
|
DIAG(F("Ethernet cable connected? Waiting for link (1sec) "));
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
// now we either do have link of we have a W5100
|
// Now we either do have link or we have a W5100 where we do not know if we have link.
|
||||||
// where we do not know if we have link. That's
|
// So now run checkLink() which also sets up outboundRing if it does not exist.
|
||||||
// the reason to now run checkLink.
|
// A false returned means we know we booted without an Ethernet cable, or perhaps there
|
||||||
// CheckLinks sets up outboundRing if it does
|
// is no W5100 and we should say so
|
||||||
// not exist yet as well.
|
if (!checkLink())
|
||||||
checkLink();
|
{
|
||||||
|
#if defined(STM32_ETHERNET)
|
||||||
|
DIAG(F("Ethernet cable disconnected!"));
|
||||||
|
#else
|
||||||
|
DIAG(F("Ethernet cable disconnected, or W5100 hardware not present"));
|
||||||
|
#endif
|
||||||
|
LCD(4,F("Ethernet DOWN"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -176,14 +179,30 @@ bool EthernetInterface::checkLink() {
|
|||||||
Ethernet.setLocalIP(myIP); // for static IP, set it again
|
Ethernet.setLocalIP(myIP); // for static IP, set it again
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#if defined (STM32_ETHERNET)
|
||||||
|
netif_set_hostname(&gnetif, WIFI_HOSTNAME); // Should probably be passed in the contructor...
|
||||||
|
#ifdef IP_ADDRESS
|
||||||
|
Ethernet.begin(myIP);
|
||||||
|
#else
|
||||||
|
Ethernet.begin();
|
||||||
|
#endif // IP_ADDRESS
|
||||||
|
#endif // STM32_ETHERNET
|
||||||
|
|
||||||
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();
|
||||||
IPAddress ip = Ethernet.localIP(); // look what IP was obtained (dynamic or static)
|
#ifndef IP_ADDRESS
|
||||||
if (ip[0] == 0)
|
|
||||||
LCD(4,F("Awaiting DHCP..."));
|
LCD(4,F("Awaiting DHCP..."));
|
||||||
|
IPAddress ip = Ethernet.localIP(); // look what IP was obtained (dynamic or static)
|
||||||
|
if (ip[0] == 0) {
|
||||||
|
DIAG(F("Awaiting DHCP... ip was %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
|
||||||
|
}
|
||||||
while (ip[0] == 0) { // wait until we are given an IP address from the DHCP server
|
while (ip[0] == 0) { // wait until we are given an IP address from the DHCP server
|
||||||
|
DIAG(F("Awaiting DHCP... ip was %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
|
||||||
ip = Ethernet.localIP(); // look what IP was obtained (dynamic or static)
|
ip = Ethernet.localIP(); // look what IP was obtained (dynamic or static)
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
IPAddress ip = Ethernet.localIP(); // look what IP was obtained (dynamic or static)
|
||||||
|
#endif
|
||||||
if (MAX_MSG_SIZE < 20) {
|
if (MAX_MSG_SIZE < 20) {
|
||||||
LCD(4,F("%d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
|
LCD(4,F("%d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
|
||||||
LCD(5,F("Port:%d Eth"), IP_PORT);
|
LCD(5,F("Port:%d Eth"), IP_PORT);
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
|
|
||||||
#define VERSION "5.3.5"
|
#define VERSION "5.3.5e"
|
||||||
|
// 5.3.5e - Fixes to ethernet cable handling, and STM32 related handling as well
|
||||||
// 5.3.5 - Exrail JMRI_SENSORS(vpin [,count]) creates <S> types.
|
// 5.3.5 - Exrail JMRI_SENSORS(vpin [,count]) creates <S> types.
|
||||||
// 5.3.4 - Bugfix: WiThrottle sendIntro after initial N message as well
|
// 5.3.4 - Bugfix: WiThrottle sendIntro after initial N message as well
|
||||||
// 5.3.3 - Fix Ethernet cable disconnected message, wait for DHCP
|
// 5.3.3 - Fix Ethernet cable disconnected message, wait for DHCP
|
||||||
|
Loading…
Reference in New Issue
Block a user