@@ -54,11 +54,8 @@ void setup() {
5454}
5555
5656void loop () {
57- if (Ethernet.linkStatus () != LinkON) {
58- Serial.println (Ethernet.linkStatus ());
59- connectEth ();
60- }
61- sendNTPpacket (timeServer); // send an NTP packet to a time server
57+ // send an NTP packet to a time server
58+ sendNTPpacket (timeServer);
6259
6360 // wait to see if a reply is available
6461 delay (1000 );
@@ -129,35 +126,3 @@ void sendNTPpacket(const char* address) {
129126 Udp.write (packetBuffer, NTP_PACKET_SIZE);
130127 Udp.endPacket ();
131128}
132- 133- void connectEth () {
134- // in Zephyr system check if Ethernet is ready before proceeding to initialize
135- Serial.print (" Waiting for link on" );
136- while (Ethernet.linkStatus () != LinkON) {
137- Serial.print (" ." );
138- delay (100 );
139- }
140- Serial.println ();
141- 142- // start the Ethernet connection:
143- Serial.println (" Initialize Ethernet with DHCP:" );
144- if (Ethernet.begin (nullptr ) == 0 ) {
145- Serial.println (" Failed to configure Ethernet using DHCP" );
146- // Check for Ethernet hardware present
147- if (Ethernet.hardwareStatus () == EthernetNoHardware) {
148- Serial.println (" Ethernet shield was not found. Sorry, can't run without hardware. :(" );
149- while (true ) {
150- delay (1 ); // do nothing, no point running without Ethernet hardware
151- }
152- }
153- if (Ethernet.linkStatus () == LinkOFF) {
154- Serial.println (" Ethernet cable is not connected." );
155- }
156- } else {
157- Serial.print (" DHCP assigned IP " );
158- Serial.println (Ethernet.localIP ());
159- }
160- 161- Serial.println (" You're connected to the network" );
162- Serial.println ();
163- }
0 commit comments