From 6eeaacdf90d646c9c38568e3530edf7a2ec8be7d Mon Sep 17 00:00:00 2001 From: Fred Date: Thu, 10 Jun 2021 19:02:20 -0400 Subject: [PATCH] Add loop to retry Ethernet cable connection (#173) Implement PaulS's change to delay in a loop to give more time for sensing an Ethernet cable connection --- EthernetInterface.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/EthernetInterface.cpp b/EthernetInterface.cpp index c0b43d3..22b61f3 100644 --- a/EthernetInterface.cpp +++ b/EthernetInterface.cpp @@ -68,6 +68,16 @@ EthernetInterface::EthernetInterface() DIAG(F("Ethernet shield not found")); return; } + + unsigned long startmilli = millis(); + while ((millis() - startmilli) < 5500) // Loop to give time to check for cable connection + { + if (Ethernet.linkStatus() == LinkON) + break; + DIAG(F("Ethernet waiting for link (1sec) ")); + delay(1000); + } + if (Ethernet.linkStatus() == LinkOFF) { DIAG(F("Ethernet cable not connected")); return;