NTP clock example
Dependencies: C12832_lcd EthernetInterface NTPClient mbed-rtos mbed
Fork of app_board-NTPclock by
Revision 2:a1840d0972c0, committed 2017-07-04
- Comitter:
- dwijaybane
- Date:
- Tue Jul 04 06:32:51 2017 +0000
- Parent:
- 1:9095ffb76813
- Commit message:
- NTP clock example
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9095ffb76813 -r a1840d0972c0 main.cpp --- a/main.cpp Tue Oct 01 19:53:45 2013 +0000 +++ b/main.cpp Tue Jul 04 06:32:51 2017 +0000 @@ -7,19 +7,17 @@ EthernetInterface eth; NTPClient ntp; +static const char* mbedIp = "192.168.0.160"; //IP +static const char* mbedMask = "255.255.255.0"; // Mask +static const char* mbedGateway = "192.168.0.254"; //Gateway + int main() { - eth.init(); //Use DHCP - wait(2); - lcd.cls(); - lcd.printf("Getting IP Address\r\n"); - if(eth.connect(60000)!=0) { - lcd.printf("DHCP error - No IP"); - wait(10); - } else { - lcd.printf("IP is %s\n", eth.getIPAddress()); - wait(2); - } + EthernetInterface eth; + eth.init(mbedIp,mbedMask,mbedGateway); //Use these parameters for static IP + eth.connect(); + lcd.printf("Connected! IP Address is %s\n", eth.getIPAddress()); + lcd.cls(); lcd.printf("Trying to update time...\r\n"); if (ntp.setTime("0.pool.ntp.org") == 0) {