1- /* *
1+ /* *
22 * The MIT License (MIT)
33 * Copyright (c) 2015 by Fabrice Weinberg
4- *
4+ *
55 * Permission is hereby granted, free of charge, to any person obtaining a copy
66 * of this software and associated documentation files (the "Software"), to deal
77 * in the Software without restriction, including without limitation the rights
@@ -50,14 +50,14 @@ void NTPClient::begin() {
5050 this ->forceUpdate ();
5151}
5252
53- void NTPClient::forceUpdate () {
53+ void NTPClient::forceUpdate () {
5454 #ifdef DEBUG_NTPClient
5555 Serial.println (" Update from NTP Server" );
5656 #endif
57-
57+
5858 IPAddress address;
5959 WiFi.hostByName (this ->_poolServerName , address);
60-
60+
6161 this ->sendNTPPacket (address);
6262
6363 // Wait till data is there or timeout...
@@ -69,23 +69,23 @@ void NTPClient::forceUpdate() {
6969 if (timeout > 100 ) return ; // timeout after 1000 ms
7070 timeout++;
7171 } while (cb == 0 );
72-
73- this ->_lastUpdate = millis () - (10 * (timeout + 1 )); // Account for delay in reading the time
74-
72+
73+ this ->_lastUpdate = millis () - (10 * (timeout + 1 )); // Account for delay in reading the time
74+
7575 this ->_udp .read (this ->_packetBuffer , NTP_PACKET_SIZE);
7676
7777 unsigned long highWord = word (this ->_packetBuffer [40 ], this ->_packetBuffer [41 ]);
7878 unsigned long lowWord = word (this ->_packetBuffer [42 ], this ->_packetBuffer [43 ]);
7979 // combine the four bytes (two words) into a long integer
8080 // this is NTP time (seconds since Jan 1 1900):
8181 unsigned long secsSince1900 = highWord << 16 | lowWord;
82-
82+
8383 this ->_currentEpoc = secsSince1900 - SEVENZYYEARS;
8484}
8585
8686void NTPClient::update () {
8787 unsigned long runtime = millis ();
88- if (runtime - this ->_lastUpdate >= this ->_updateInterval && this ->_updateInterval != 0 ) {
88+ if (runtime - this ->_lastUpdate >= this ->_updateInterval && this ->_updateInterval != 0 ) {
8989 this ->forceUpdate ();
9090 }
9191}
@@ -111,10 +111,10 @@ String NTPClient::getFormattedTime() {
111111 unsigned long rawTime = this ->getRawTime ();
112112 unsigned long hours = (rawTime % 86400L ) / 3600 ;
113113 String hoursStr = hours < 10 ? " 0" + String (hours) : String (hours);
114-
114+
115115 unsigned long minutes = (rawTime % 3600 ) / 60 ;
116116 String minuteStr = minutes < 10 ? " 0" + String (minutes) : String (minutes);
117-
117+
118118 unsigned long seconds = rawTime % 60 ;
119119 String secondStr = seconds < 10 ? " 0" + String (seconds) : String (seconds);
120120
0 commit comments