Temp fork

Dependencies:   EthernetInterface NTPClient mbed-rtos mbed

Fork of NTPClient_HelloWorld by Donatien Garnier

Committer:
screamer
Date:
Fri Oct 18 00:06:15 2013 +0000
Revision:
3:98ea1225561f
Parent:
2:bf7dc5f5bca9
Updated all libraries

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:0e0debc29569 1 #include "mbed.h"
donatien 0:0e0debc29569 2 #include "EthernetInterface.h"
donatien 2:bf7dc5f5bca9 3 #include "NTPClient.h"
donatien 0:0e0debc29569 4
donatien 1:d263603373ac 5 EthernetInterface eth;
donatien 2:bf7dc5f5bca9 6 NTPClient ntp;
donatien 1:d263603373ac 7
donatien 0:0e0debc29569 8 int main()
donatien 0:0e0debc29569 9 {
donatien 0:0e0debc29569 10 eth.init(); //Use DHCP
donatien 0:0e0debc29569 11
donatien 0:0e0debc29569 12 eth.connect();
donatien 2:bf7dc5f5bca9 13
donatien 2:bf7dc5f5bca9 14 printf("Trying to update time...\r\n");
donatien 2:bf7dc5f5bca9 15 if (ntp.setTime("0.pool.ntp.org") == 0)
donatien 0:0e0debc29569 16 {
donatien 2:bf7dc5f5bca9 17 printf("Set time successfully\r\n");
donatien 2:bf7dc5f5bca9 18 time_t ctTime;
donatien 2:bf7dc5f5bca9 19 ctTime = time(NULL);
donatien 2:bf7dc5f5bca9 20 printf("Time is set to (UTC): %s\r\n", ctime(&ctTime));
donatien 0:0e0debc29569 21 }
donatien 0:0e0debc29569 22 else
donatien 0:0e0debc29569 23 {
donatien 2:bf7dc5f5bca9 24 printf("Error\r\n");
donatien 2:bf7dc5f5bca9 25 }
donatien 2:bf7dc5f5bca9 26
donatien 0:0e0debc29569 27 eth.disconnect();
donatien 0:0e0debc29569 28
donatien 0:0e0debc29569 29 while(1) {
donatien 0:0e0debc29569 30 }
donatien 0:0e0debc29569 31 }