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: F7_Ethernet WebSocketClient mbed mcp3008
Fork of Nucleo_F746ZG_Ethernet by
Diff: main.cpp
- Revision:
- 0:f9b6112278fe
- Child:
- 3:0fc17139f828
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sat Jun 18 10:49:12 2016 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+#include "rtos.h"
+#include "EthernetInterface.h"
+#include "NTPClient.h"
+#include <stdio.h>
+
+EthernetInterface eth;
+
+DigitalOut led1(LED1);
+
+int main()
+{
+ NTPClient ntp;
+ char buff[64];
+ printf("\n\n*** Ethernet Demo uses NTP to set the clock ***\r\n");
+
+ if(eth.init()!=0) //for DHCP Server
+ {
+ //if(eth.init(IP,MASK,GATEWAY)!=0) { //for Static IP Address
+ printf("EthernetInterface Initialize Error \r\n");
+
+ while (1)
+ {
+ }
+ }
+ if(eth.connect()!=0)
+ {
+ printf("EthernetInterface Connect Error \r\n");
+ while (1)
+ {
+ }
+ }
+ printf("IP Address is %s\r\n", eth.getIPAddress());
+ printf("NetMask is %s\r\n", eth.getNetworkMask());
+ printf("Gateway Address is %s\r\n", eth.getGateway());
+ printf("Ethernet Setup OK\r\n");
+ printf("Getting time, 10s timeout. \r\n");
+
+ if (ntp.setTime("0.uk.pool.ntp.org") == 0)
+ {
+ time_t ctTime;
+ ctTime = time(NULL);
+ printf("Time is set to : %s \r\n", ctime(&ctTime));
+ }
+ else
+ {
+ printf("Error getting time \r\n");
+ }
+
+ printf("end of programm\r\n");
+ while (true) {
+ led1 = !led1;
+ Thread::wait(500);
+ }
+}
