![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
NTP clock example
Dependencies: C12832_lcd EthernetInterface NTPClient mbed-rtos mbed
Fork of app_board-NTPclock by
Diff: main.cpp
- Revision:
- 2:a1840d0972c0
- Parent:
- 1:9095ffb76813
--- 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) {