Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 51848ac

Browse files
committed
ethernet: UdpNtpClient, avoid double checking link status
1 parent 464ab15 commit 51848ac

File tree

1 file changed

+2
-37
lines changed

1 file changed

+2
-37
lines changed

‎libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino‎

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,8 @@ void setup() {
5454
}
5555

5656
void 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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /