@@ -36,8 +36,7 @@ byte packetBuffer[ NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing pack
3636// A UDP instance to let us send and receive packets over UDP
3737WiFiUDP Udp;
3838
39- void setup ()
40- {
39+ void setup () {
4140 // Open serial communications and wait for port to open:
4241 Serial.begin (9600 );
4342 while (!Serial) {
@@ -52,11 +51,12 @@ void setup()
5251 }
5352
5453 String fv = WiFi.firmwareVersion ();
55- if ( fv != " 1.1.0" )
54+ if (fv != " 1.1.0" ) {
5655 Serial.println (" Please upgrade the firmware" );
56+ }
5757
5858 // attempt to connect to Wifi network:
59- while ( status != WL_CONNECTED) {
59+ while (status != WL_CONNECTED) {
6060 Serial.print (" Attempting to connect to SSID: " );
6161 Serial.println (ssid);
6262 // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
@@ -73,13 +73,12 @@ void setup()
7373 Udp.begin (localPort);
7474}
7575
76- void loop ()
77- {
76+ void loop () {
7877 sendNTPpacket (timeServer); // send an NTP packet to a time server
7978 // wait to see if a reply is available
8079 delay (1000 );
81- Serial.println ( Udp.parsePacket () );
82- if ( Udp.parsePacket () ) {
80+ Serial.println (Udp.parsePacket ());
81+ if (Udp.parsePacket ()) {
8382 Serial.println (" packet received" );
8483 // We've received a packet, read the data from it
8584 Udp.read (packetBuffer, NTP_PACKET_SIZE); // read the packet into the buffer
@@ -92,7 +91,7 @@ void loop()
9291 // combine the four bytes (two words) into a long integer
9392 // this is NTP time (seconds since Jan 1 1900):
9493 unsigned long secsSince1900 = highWord << 16 | lowWord;
95- Serial.print (" Seconds since Jan 1 1900 = " );
94+ Serial.print (" Seconds since Jan 1 1900 = " );
9695 Serial.println (secsSince1900);
9796
9897 // now convert NTP time into everyday time:
@@ -109,13 +108,13 @@ void loop()
109108 Serial.print (" The UTC time is " ); // UTC is the time at Greenwich Meridian (GMT)
110109 Serial.print ((epoch % 86400L ) / 3600 ); // print the hour (86400 equals secs per day)
111110 Serial.print (' :' );
112- if ( ((epoch % 3600 ) / 60 ) < 10 ) {
111+ if (((epoch % 3600 ) / 60 ) < 10 ) {
113112 // In the first 10 minutes of each hour, we'll want a leading '0'
114113 Serial.print (' 0' );
115114 }
116115 Serial.print ((epoch % 3600 ) / 60 ); // print the minute (3600 equals secs per minute)
117116 Serial.print (' :' );
118- if ( (epoch % 60 ) < 10 ) {
117+ if ((epoch % 60 ) < 10 ) {
119118 // In the first 10 seconds of each minute, we'll want a leading '0'
120119 Serial.print (' 0' );
121120 }
@@ -126,8 +125,7 @@ void loop()
126125}
127126
128127// send an NTP request to the time server at the given address
129- unsigned long sendNTPpacket (IPAddress& address)
130- {
128+ unsigned long sendNTPpacket (IPAddress& address) {
131129 // Serial.println("1");
132130 // set all bytes in the buffer to 0
133131 memset (packetBuffer, 0 , NTP_PACKET_SIZE);
0 commit comments