Dependencies: EthernetNetIf NTPClient_NetServices mbed
NTPClientExample.cpp
- Committer:
- donatien
- Date:
- 2010-06-14
- Revision:
- 0:8c53aefc68af
File content as of revision 0:8c53aefc68af:
#include "mbed.h" #include "EthernetNetIf.h" #include "NTPClient.h" EthernetNetIf eth; NTPClient ntp; int main() { printf("Start\n"); printf("Setting up...\n"); EthernetErr ethErr = eth.setup(); if(ethErr) { printf("Error %d in setup.\n", ethErr); return -1; } printf("Setup OK\r\n"); time_t ctTime; ctTime = time(NULL); printf("Current time is (UTC): %s\n", ctime(&ctTime)); Host server(IpAddr(), 123, "0.uk.pool.ntp.org"); ntp.setTime(server); ctTime = time(NULL); printf("\nTime is now (UTC): %s\n", ctime(&ctTime)); while(1) { } return 0; }