![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
sfs
Dependencies: EthernetInterface mbed-rtos mbed
main.cpp
- Committer:
- grzemich
- Date:
- 2016-12-08
- Revision:
- 1:2bdce5c2162d
- Parent:
- 0:8864e30d7121
- Child:
- 3:150e1413e660
File content as of revision 1:2bdce5c2162d:
#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 int main (void) { EthernetInterface eth; //to do 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); } }