Example using NTClient

Dependencies:   NTPClient

Files at this revision

API Documentation at this revision

Comitter:
lmussier
Date:
Fri Jan 06 13:51:45 2017 +0000
Commit message:
Initial commit

Changed in this revision

NTPClient.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NTPClient.lib	Fri Jan 06 13:51:45 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/lmussier/code/NTPClient/#175284afeb38
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jan 06 13:51:45 2017 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+#include "NTPClient.h"
+#include "EthernetInterface.h"
+  
+int main() {
+
+  EthernetInterface eth;
+
+  printf("Setting up...\n");
+  
+  int ethError = eth.connect();
+    
+  if(ethError == 0)
+  {
+    NTPClient ntp(eth);
+    printf("ETH is up : %s\n", eth.get_ip_address());
+    time_t ctTime;
+    ctTime = time(NULL);  
+    printf("Current time is (UTC): %s\n", ctime(&ctTime));  
+
+    ntp.setTime("0.uk.pool.ntp.org");
+    
+    ctTime = time(NULL);  
+    printf("\nTime is now (UTC): %s\n", ctime(&ctTime)); 
+  
+    eth.disconnect();
+  } else {
+      printf("Connect failed (%d)", ethError);
+  }
+  
+  return 0;
+  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Fri Jan 06 13:51:45 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#0789928ee7f2db08a419fa4a032fffd9bd477aa7