Skip to content

Commit 0b36e5f

Browse files
committed
Added more checks on NTP client example
1 parent feebff6 commit 0b36e5f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

examples/udp_ntp_client/udp_ntp_client.ino

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ void sendNTPpacket(const char * address) {
9999

100100
// all NTP fields have been given values, now
101101
// you can send a packet requesting a timestamp:
102-
Udp.beginPacket(address, 123); // NTP requests are to port 123
103-
Udp.write(packetBuffer, NTP_PACKET_SIZE);
104-
Udp.endPacket();
102+
if (Udp.beginPacket(address, 123)) { // NTP requests are to port 123
103+
Udp.write(packetBuffer, NTP_PACKET_SIZE);
104+
Udp.endPacket();
105+
} else {
106+
Monitor.println("Failed to send NTP request.");
107+
}
105108
}
106109

0 commit comments

Comments
 (0)