Recent changes
Slingshot user guide
tag Guide, user
NFCLamp user guide
tag Guide, user
Homepage
MPL115A2
Compiler Error 42
From the mbed microcontroller Cookbook.  

Ethernet

Hardware

First of all you have to connect your mbed to a RJ45 jack. These instructions can be found here : Ethernet RJ45.

Packages

Precompiled version:

Library

Getting started

This is essentially a tri-liner:

First include the header file:

Code

#include "EthernetNetIf.h"

Instantiate the interface: If you are using DHCP:

Code

EthernetNetIf eth;

Or if you want to set your own parameters:

Code

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:

Code

eth.setup();

That's it!

Includes

Code

#include "EthernetNetIf.h"

Reference

» Import this program

Public Member Functions

EthernetNetIf ()
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.

Implementation

This interface is built around the mbed's Ethernet class and the LwIP stack. For more information about LwIP, you can visit the project's development site or its Wiki.




calendar Page history
Last modified 22 Jul 2011, by   user Eui-Seok Hong   tag No tags | 2 comments  

2 comments on Ethernet:

19 Oct 2011

For our network, the default timeout of 15 seconds was too short when using DHCP. It needs to be around 30 seconds or more.

I suspect that is the case at many large organizations that lock down the network a bit for more security.

So if you get an error trying to get an IP address, try increasing the timeout a bit with eth.setup(30000);

26 Feb 2012

I am using internet through a proxy server. Will you please told me how can i configure these 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 );

IP address of my proxy server is 192.168.1.1(private) and HTTP/HTTPS port number is 8070.

Thanks in advance

Please login to post comments.