You are viewing an older revision! See the latest version

Ethernet

Table of Contents

  1. Ethernet
  2. Hardware
  3. Library

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

Bring the interface up.


All wikipages