You are viewing an older revision! See the latest version
Ethernet
Ethernet¶
Hardware¶
First of all you have to connect your mbed to a RJ45 jack. These instructions can be found here : Networking Ethernet RJ45.
Library¶
Getting started¶
This is essentially a tri-liner:
First include the header file:
#include "if/eth/ethIf.h"
Instantiate the interface: If you are using DHCP:
EthernetNetIf eth;
Or if you want to set your own parameters:
EthernetNetIf( 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:
eth.setup();
That's it!
Reference¶
EthernetNetIf()
Instantiate the Interface & register it against the stack. DHCP will be used.
EthernetNetIf(IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns)
Instantiate the Interface & register it against the stack. DHCP will not be used. IpAddr is a container class that can be constructed with either 4 bytes or no parameters for a null IP address.
void setup() === Architecture === This interface is build around the mbed's Ethernet class and the LwIP stack. For more information about LwIP, you can visit its [[http://savannah.nongnu.org/projects/lwip/ | development site] or its [[http://lwip.wikia.com/wiki/LwIP_Wiki |Wiki]].
Bring the interface up.