Update library (02 Feb 2015)

Dependencies:   EthernetInterface NTPClient mbed-rtos mbed

Fork of NTPClient_HelloWorld by Donatien Garnier

main.cpp

Committer:
ban4jp
Date:
2015-02-01
Revision:
4:06cde8b92c77
Parent:
3:cefa72855d43
Child:
5:ef9b500c56e2

File content as of revision 4:06cde8b92c77:

#include "mbed.h"
#include "EthernetInterface.h"
#include "NTPClient.h"

EthernetInterface eth;
NTPClient ntp;

int main()
{
    int ret = eth.init(); //Use DHCP

    ret = eth.connect();

    printf("Trying to update time...\n");
    if (ntp.setTime("0.pool.ntp.org") == 0) {
        printf("Set time successfully\n");
        time_t ctTime;
        ctTime = time(NULL);
        printf("Time is set to (UTC): %s\n", ctime(&ctTime));
    } else {
        printf("Error\n");
    }

    ret = eth.disconnect();

    while(1) {
    }
}