First of all you have to connect your mbed to a RJ45 jack. These instructions can be found here : Ethernet RJ45.
See: Ethernet Interface library.
Legacy Networking Libraries
This is essentially a tri-liner:
First include the header file:
Instantiate the interface: If you are using DHCP:
Or if you want to set your own parameters:
EthernetNetIf eth( IpAddr(192,168,0,101), //IP Address IpAddr(255,255,255,0), //Network Mask IpAddr(192,168,0,1), //Gateway IpAddr(192,168,0,1) //DNS );
And set it up:
Instantiates the Interface and register it against the stack, DHCP will be used.
|EthernetNetIf ( IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns)|
Instantiates the Interface and register it against the stack, DHCP will not be used.
|EthernetErr||setup (int timeout_ms=15000)|
Brings the interface up.
|IpAddr||getIp () const|
Returns the IP of the interface once it's connected.