Ethernet

Currently only supported on ESP32 using embedded MAC.

Warning

doxygenclass: Cannot find class “EmbeddedEthernet” in doxygen xml output for project “api” from directory: ../api/xml/

namespace Ethernet

Typedefs

using EventDelegate = Delegate<void(Ethernet::Event event)>

Delegate type for Ethernet events.

Parameters

event – Which event occurred

using GotIpDelegate = Delegate<void(IpAddress ip, IpAddress netmask, IpAddress gateway)>

Delegate type for ‘got IP address’ event.

Enums

enum Event

Ethernet event codes.

Values:

enumerator XX
enum Speed

Link speed.

Values:

enumerator MBPS10
enumerator MBPS100

Variables

constexpr int8_t PIN_DEFAULT = {-2}

Use default pin for platform.

constexpr int8_t PIN_UNUSED = {-1}

Do not configure this pin.

Only applies if pin is optional, otherwise it will be interpreted as ‘auto detect’.

constexpr int8_t PHY_ADDR_AUTO = {-1}

Automatically detect PHY address during initialization.

class Dp83848 : public Ethernet::PhyFactory
#include <Dp83848.h>

DP 83848 PHY interface.

Public Functions

virtual PhyInstance *create(const PhyConfig &config) override

Called by the Service to construct a PHY instance.

virtual void destroy(PhyInstance *inst) override

Called by the Service to destroy a PHY instance.

class Ip101 : public Ethernet::PhyFactory
#include <Ip101.h>

IP101 PHY interface.

Public Functions

virtual PhyInstance *create(const PhyConfig &config) override

Called by the Service to construct a PHY instance.

virtual void destroy(PhyInstance *inst) override

Called by the Service to destroy a PHY instance.

class Ksz8041 : public Ethernet::PhyFactory
#include <Ksz8041.h>

KSZ 8041 PHY interface.

Public Functions

virtual PhyInstance *create(const PhyConfig &config) override

Called by the Service to construct a PHY instance.

virtual void destroy(PhyInstance *inst) override

Called by the Service to destroy a PHY instance.

class Lan8720 : public Ethernet::PhyFactory
#include <Lan8720.h>

LAN 8720 PHY interface.

Public Functions

virtual PhyInstance *create(const PhyConfig &config) override

Called by the Service to construct a PHY instance.

virtual void destroy(PhyInstance *inst) override

Called by the Service to destroy a PHY instance.

struct PhyConfig
#include <Ethernet.h>

PHY configuration.

Public Members

int8_t phyAddr = PHY_ADDR_AUTO

PHY address.

int8_t resetPin = PIN_UNUSED

Reset GPIO number */.

uint16_t resetTimeout = 100

Reset timeout value in milliseconds.

uint16_t autoNegTimeout = 4000

Auto-negotiation timeout in milliseconds.

class PhyFactory
#include <Ethernet.h>

Virtual class used to construct a specific PHY instance.

Applications provide an instance of this factory class so that the Service can create and configure it at the correct point in initialisation or teardown.

Subclassed by Ethernet::Dp83848, Ethernet::Ip101, Ethernet::Ksz8041, Ethernet::Lan8720, Ethernet::Rtl8201

Public Functions

virtual PhyInstance *create(const PhyConfig &config) = 0

Called by the Service to construct a PHY instance.

virtual void destroy(PhyInstance *inst) = 0

Called by the Service to destroy a PHY instance.

class Rtl8201 : public Ethernet::PhyFactory
#include <Rtl8201.h>

RTL 8201 PHY interface.

Public Functions

virtual PhyInstance *create(const PhyConfig &config) override

Called by the Service to construct a PHY instance.

virtual void destroy(PhyInstance *inst) override

Called by the Service to destroy a PHY instance.

class Service
#include <Ethernet.h>

Abstract Service class.

Provides a common implementation for TCP/IP ethernet support.

An Ethernet interface requires a MAC layer plus PHY.

The ESP32, for example, contains a MAC but requires an external PHY. Other solutions, such as the W5500, contain MAC+PHY and require the correct PhyFactory to work.

Ethernet implementations should provide appropriate setup methods which are called by the application before invoking begin().

Public Functions

virtual void end() = 0

Tear down the ethernet connection.

virtual MacAddress getMacAddress() const = 0

Get MAC address.

virtual bool setMacAddress(const MacAddress &addr) = 0

Set MAC address.

virtual bool setSpeed(Speed speed) = 0

Set speed of MAC.

virtual bool setFullDuplex(bool enable) = 0

Set duplex mode of MAC.

virtual bool setLinkState(bool up) = 0

Set link status of MAC.

virtual bool setPromiscuous(bool enable) = 0

Set MAC promiscuous mode.

virtual void setHostname(const String &hostname) = 0

Set DHCP hostname.

virtual String getHostname() const = 0

Get DHCP hostname.

virtual IpAddress getIP() const = 0

Get current IP address.

virtual bool setIP(IpAddress address, IpAddress netmask, IpAddress gateway) = 0

Set static IP address.

virtual bool isEnabledDHCP() const = 0

Determine if DHCP is active for this interface.

virtual bool enableDHCP(bool enable) = 0

Enable/disable DHCP on this interface.

inline void onEvent(EventDelegate callback)

Set callback for ethernet events.

inline void onGotIp(GotIpDelegate callback)

Set callback for ‘station connected with IP address’ event.