]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/tests/net/protocols/NTPClient_HelloWorld/main.cpp
3 #include "EthernetInterface.h"
7 MBED_HOSTTEST_TIMEOUT(15);
8 MBED_HOSTTEST_SELECT(default_auto
);
9 MBED_HOSTTEST_DESCRIPTION(NTP client
);
10 MBED_HOSTTEST_START("NET_8");
12 EthernetInterface eth
;
14 eth
.init(); //Use DHCP
20 const char *url_ntp_server
= "0.pool.ntp.org";
21 printf("NTP_SETTIME: Trying to update time... \r\n");
22 const int ret
= ntp
.setTime(url_ntp_server
);
24 time_t ctTime
= time(NULL
);
25 printf("NTP_SETTIME: UTC Time read successfully ... [OK]\r\n");
26 printf("NTP_SETTIME: %s\r\n", ctime(&ctTime
));
29 printf("NTP_SETTIME: Error(%d) ... [FAIL]\r\n", ret
);
33 if (result
== false) {
34 MBED_HOSTTEST_RESULT(false);
38 MBED_HOSTTEST_RESULT(true);