Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface NTPClient mbed-rtos mbed
Codes/ntpc.cpp@0:fac116e94d44, 2016-01-05 (annotated)
- Committer:
- rebonatto
- Date:
- Tue Jan 05 11:47:35 2016 +0000
- Revision:
- 0:fac116e94d44
Vers?o est?vel sem DMA e FFT. 128 amostras.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| rebonatto | 0:fac116e94d44 | 1 | #include "ntpc.h" |
| rebonatto | 0:fac116e94d44 | 2 | |
| rebonatto | 0:fac116e94d44 | 3 | void ntpc::ntpc_Thread(void const* arg) |
| rebonatto | 0:fac116e94d44 | 4 | { |
| rebonatto | 0:fac116e94d44 | 5 | printf("\r\nTrhead NTP client\r\n"); |
| rebonatto | 0:fac116e94d44 | 6 | while (true) |
| rebonatto | 0:fac116e94d44 | 7 | { |
| rebonatto | 0:fac116e94d44 | 8 | ntpcDo(); |
| rebonatto | 0:fac116e94d44 | 9 | wait(30); |
| rebonatto | 0:fac116e94d44 | 10 | } |
| rebonatto | 0:fac116e94d44 | 11 | } |
| rebonatto | 0:fac116e94d44 | 12 | |
| rebonatto | 0:fac116e94d44 | 13 | void ntpc::ntpcDo() |
| rebonatto | 0:fac116e94d44 | 14 | { |
| rebonatto | 0:fac116e94d44 | 15 | printf("Pegando NTP...\r\n"); |
| rebonatto | 0:fac116e94d44 | 16 | if (ntpClient.setTime("ntp.ubuntu.com") == 0) { |
| rebonatto | 0:fac116e94d44 | 17 | printf("NTP OK!\r\n"); |
| rebonatto | 0:fac116e94d44 | 18 | time_t ctTime; |
| rebonatto | 0:fac116e94d44 | 19 | ctTime = time(NULL); |
| rebonatto | 0:fac116e94d44 | 20 | printf("Setando para hora (UTC): %s\r\n", ctime(&ctTime)); |
| rebonatto | 0:fac116e94d44 | 21 | } else { |
| rebonatto | 0:fac116e94d44 | 22 | printf("NTP Erro!\r\n"); |
| rebonatto | 0:fac116e94d44 | 23 | } |
| rebonatto | 0:fac116e94d44 | 24 | } |
