Skip to content

Commit 4a42d32

Browse files
committed
Modify WiFiUdpNtpClient for DA16200
1 parent 6162899 commit 4a42d32

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
/*
2-
Udp NTP Client
2+
Udp NTP Client
33
4-
Get the time from a Network Time Protocol (NTP) time server
5-
Demonstrates use of UDP sendPacket and ReceivePacket
6-
For more on NTP time servers and the messages needed to communicate with them,
7-
see http://en.wikipedia.org/wiki/Network_Time_Protocol
4+
Get the time from a Network Time Protocol (NTP) time server
5+
Demonstrates use of UDP sendPacket and ReceivePacket
6+
For more on NTP time servers and the messages needed to communicate with them,
7+
see http://en.wikipedia.org/wiki/Network_Time_Protocol
88
9-
created 4 Sep 2010
10-
by Michael Margolis
11-
modified 9 Apr 2012
12-
by Tom Igoe
9+
Circuit:
10+
- SparkFun Qwiic WiFi Shield - DA16200 attached
1311
14-
This code is in the public domain.
12+
created 4 Sep 2010
13+
by Michael Margolis
14+
modified 9 Apr 2012
15+
by Tom Igoe
16+
modified 15 October 2021
17+
by Sandeep Mistry to port to DA16200
1518
16-
*/
19+
This code is in the public domain.
1720
18-
#include <SPI.h>
19-
#include <WiFiNINA.h>
21+
*/
22+
23+
#include <DA16200_WiFi.h>
2024
#include <WiFiUdp.h>
2125

22-
int status = WL_IDLE_STATUS;
23-
#include "arduino_secrets.h"
2426
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
27+
#include "arduino_secrets.h"
28+
29+
int status = WL_IDLE_STATUS;
30+
2531
char ssid[] = SECRET_SSID; // your network SSID (name)
2632
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
2733
int keyIndex = 0; // your network key index number (needed only for WEP)
@@ -62,9 +68,6 @@ void setup() {
6268
Serial.println(ssid);
6369
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
6470
status = WiFi.begin(ssid, pass);
65-
66-
// wait 10 seconds for connection:
67-
delay(10000);
6871
}
6972

7073
Serial.println("Connected to WiFi");
@@ -126,12 +129,10 @@ void loop() {
126129

127130
// send an NTP request to the time server at the given address
128131
unsigned long sendNTPpacket(IPAddress& address) {
129-
//Serial.println("1");
130132
// set all bytes in the buffer to 0
131133
memset(packetBuffer, 0, NTP_PACKET_SIZE);
132134
// Initialize values needed to form NTP request
133135
// (see URL above for details on the packets)
134-
//Serial.println("2");
135136
packetBuffer[0] = 0b11100011; // LI, Version, Mode
136137
packetBuffer[1] = 0; // Stratum, or type of clock
137138
packetBuffer[2] = 6; // Polling Interval
@@ -142,16 +143,11 @@ unsigned long sendNTPpacket(IPAddress& address) {
142143
packetBuffer[14] = 49;
143144
packetBuffer[15] = 52;
144145

145-
//Serial.println("3");
146-
147146
// all NTP fields have been given values, now
148147
// you can send a packet requesting a timestamp:
149148
Udp.beginPacket(address, 123); //NTP requests are to port 123
150-
//Serial.println("4");
151149
Udp.write(packetBuffer, NTP_PACKET_SIZE);
152-
//Serial.println("5");
153150
Udp.endPacket();
154-
//Serial.println("6");
155151
}
156152

157153

0 commit comments

Comments
 (0)