summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Beattie <mike@ethernal.org>2012-03-23 18:19:14 +1300
committerMike Beattie <mike@ethernal.org>2012-03-23 18:19:14 +1300
commitd4217feeb0c0bcd3c02c691a110808681dd4e093 (patch)
tree401528389967f644662e10250e12e2c308cbe6d6
parent3c371406b058f27afdfbe6baeb8544937aaa67cd (diff)
Use global buffer for NTP receive
Signed-off-by: Mike Beattie <mike@ethernal.org>
-rw-r--r--HouseControl.ino8
1 files changed, 4 insertions, 4 deletions
diff --git a/HouseControl.ino b/HouseControl.ino
index b62d743..75cf9be 100644
--- a/HouseControl.ino
+++ b/HouseControl.ino
@@ -176,23 +176,23 @@ void sendNTPpacket() {
}
void parseNTPresponse() {
- byte pb[48];
+// byte pb[48];
unsigned long ntp_time = 0;
float ntp_time_frac;
// read the packet into the buffer
- NTPSocket.read(pb, sizeof(pb));
+ NTPSocket.read(buf1, sizeof(buf1));
// NTP contains four timestamps with an integer part and a fraction part
// we only use the integer part here
for (int i=40; i<44; i++)
- ntp_time = ntp_time << 8 | pb[i];
+ ntp_time = ntp_time << 8 | buf1[i];
// part of the fractional part
// could be 4 bytes but this is more precise than the 1307 RTC
// which has a precision of ONE second
// in fact one byte is sufficient for 1307
- ntp_time_frac = ((long)pb[44] * 256 + pb[45]) / 65536.0;
+ ntp_time_frac = ((long)buf1[44] * 256 + buf1[45]) / 65536.0;
// convert NTP to UNIX time, differs seventy years = 2208988800 seconds
// NTP starts Jan 1, 1900