You are viewing an older revision! See the latest version

Ethernet

Table of Contents

  1. Hardware
  2. Packages
  3. Library

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:

Import libraryEthernetNetIf

This library is deprecated.

Library

Getting started

This is essentially a tri-liner:

First include the header file:

#include "EthernetNetIf.h"

Instantiate the interface: If you are using DHCP:

EthernetNetIf eth;

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:

eth.setup();

That's it!

Includes

#include "EthernetNetIf.h"

Reference

Import 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.


All wikipages