MBED clock sync using NTP Server from from internet
Dependencies: EthernetInterface NTPClient mbed-rtos mbed
Fork of MbedClock by
Diff: main.cpp
- Revision:
- 11:4d4334d909d3
- Parent:
- 10:d9ed3d95e5eb
- Child:
- 12:bcced6833b8f
--- a/main.cpp Thu Feb 11 13:28:37 2016 +0000 +++ b/main.cpp Thu Feb 11 13:42:13 2016 +0000 @@ -8,9 +8,24 @@ EthernetInterface eth; TCPSocketConnection server; NTPClient ntp; -DigitalOut myled(LED2); +DigitalOut led1(LED1); +DigitalOut led2(LED2); time_t ctTime; + +void thread_func1(void const *args) { + while (1) { + led1 = !led1; + Thread::wait(1000); + } +} + +void thread_func2(void const *args) { + while (1) { + led2 = !led2; + Thread::wait(500); + } +} int main() { printf("Setting up ethernet interface...\r\n"); @@ -41,11 +56,12 @@ } eth.disconnect(); ctTime = time(NULL); + + Thread thread1(thread_func1); + Thread thread2(thread_func2); + while(1) { - myled = 1; + printf("Current time is: %s\r\n", ctime(&ctTime)); wait(1); - myled = 0; - wait(1); - printf("Current time is: %s\r\n", ctime(&ctTime)); } }