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 mbed-rtos mbed
Diff: main.cpp
- Revision:
- 3:150e1413e660
- Parent:
- 1:2bdce5c2162d
- Child:
- 4:39d4e34e26ae
diff -r 33d3ece457b2 -r 150e1413e660 main.cpp
--- a/main.cpp Thu Dec 08 21:58:27 2016 +0000
+++ b/main.cpp Thu Dec 08 22:42:47 2016 +0000
@@ -1,45 +1,14 @@
#include "mbed.h"
#include "EthernetInterface.h"
-#include "rtos.h"
-
-#define MBED_DEV_IP "192.168.0.52"
-#define MBED_DEV_MASK "255.255.255.0"
-#define MBED_DEV_GW "0.0.0.0"
-#define ECHO_SERVER_PORT 5000
+
+#define MBED_DEV_IP "192.168.0.52"
+#define MBED_DEV_MASK "255.255.255.0"
+#define MBED_DEV_GW "0.0.0.0"
-
-
-int main (void) {
+int main() {
EthernetInterface eth;
-
- //to do
-
+ eth.init(MBED_DEV_IP, MBED_DEV_MASK, MBED_DEV_GW);
eth.connect();
printf("IP Address is %s\n", eth.getIPAddress());
-
- TCPSocketServer server;
- server.bind(ECHO_SERVER_PORT);
- server.listen();
-
- while(1) {
- TCPSocketConnection client;
- server.accept(client);
- client.set_blocking(false, 1500); // Timeout after (1.5)s
- if((int)phy_link_status()){
- printf("Cable is connected\n");
- if((int)phy_get_duplex())
- printf("Full duplex\n");
- else
- printf("Half duplex\n");
- if((int)phy_get_speed())
- printf("100 Mbit per second\n");
- else
- printf("10 Mbit per second\n");
- }
- else
- printf("Cable is disconnected\n");
- wait(1);
-
- }
-}
-
\ No newline at end of file
+ eth.disconnect();
+ }
\ No newline at end of file