A time interface class. This class replicates the normal time functions, but goes a couple of steps further. mbed library 82 and prior has a defective gmtime function. Also, this class enables access to setting the time, and adjusting the accuracy of the RTC.

Dependencies:   CalendarPage

Dependents:   CI-data-logger-server WattEye X10Svr SSDP_Server

Revision:
20:5ca2c94d46b8
Parent:
19:ccdf8b6f6aa1
Child:
21:f3818e2e0370
--- a/TimeInterface.cpp	Sat Jul 29 14:06:45 2017 +0000
+++ b/TimeInterface.cpp	Mon Nov 20 17:09:48 2017 +0000
@@ -31,8 +31,9 @@
 #endif
 
 
-TimeInterface::TimeInterface()
+TimeInterface::TimeInterface(EthernetInterface *net)
 {
+    m_net = net;
     dst = false;
     memset(&dst_pair, 0, sizeof(dst_pair));  // that's enough to keep it from running
 }
@@ -43,7 +44,7 @@
 
 NTPResult TimeInterface::setTime(const char* host, uint16_t port, uint32_t timeout)
 {
-    NTPClient ntp;
+    NTPClient ntp(m_net);
     NTPResult res;
     // int16_t tzomin = get_tzo_min();
     INFO("setTime(%s, %d, %d)\r\n", host, port, timeout);
@@ -450,7 +451,7 @@
 
 
 #ifndef isprint
-#define in_range(c, lo, up)  ((u8_t)c >= lo && (u8_t)c <= up)
+#define in_range(c, lo, up)  ((uint8_t)c >= lo && (uint8_t)c <= up)
 #define isprint(c)           in_range(c, 0x20, 0x7f)
 #define isdigit(c)           in_range(c, '0', '9')
 #define isxdigit(c)          (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F'))