Update library (02 Feb 2015)
Dependencies: EthernetInterface NTPClient mbed-rtos mbed
Fork of NTPClient_HelloWorld by
main.cpp
- Committer:
- ban4jp
- Date:
- 2015-02-01
- Revision:
- 3:cefa72855d43
- Parent:
- 2:bf7dc5f5bca9
- Child:
- 4:06cde8b92c77
File content as of revision 3:cefa72855d43:
#include "mbed.h" #include "EthernetInterface.h" #include "NTPClient.h" EthernetInterface eth; NTPClient ntp; int main() { eth.init(); //Use DHCP eth.connect(); printf("Trying to update time...\r\n"); if (ntp.setTime("0.pool.ntp.org") == 0) { printf("Set time successfully\r\n"); time_t ctTime; ctTime = time(NULL); printf("Time is set to (UTC): %s\r\n", ctime(&ctTime)); } else { printf("Error\r\n"); } eth.disconnect(); while(1) { } }