Ethernet
Currently only supported on ESP32 using embedded MAC.
-
class EmbeddedEthernet : public Ethernet::IdfService
Ethernet provider using ESP32 embedded MAC. Requires an external PHY.
See https://docs.espressif.com/projects/esp-idf/en/v4.3/esp32/api-reference/network/esp_eth.html.
These are the reduced (RMII) PHY connections. Note that the high-speed signals may not be re-allocated.
Signal GPIO Direction ------ ---- --------- TXD0 19 OUT TXD1 22 OUT TX_EN 21 OUT RXD0 25 IN RXD1 26 IN CRS_DV 27 IN Receive Data Valid MDC 23 OUT: configurable MDIO 18 OUT: configurable CLK_MII 0 IN: No other pins supported OUT: alternate pins: 16, 17 50MHz clock provided either by the PHY or the MAC. Default is PHY.
Note: Configuring clock options must be done via SDK (make sdk-menuconfig). ESP-IDF v4.4 will add the ability to override these in software.
The following connections are optional:
PHY_RESET - OUT (set via PhyConfig)
Public Functions
-
struct Config
-
struct Config
-
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
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 DM9051PhyFactory : public Ethernet::PhyFactory
- #include <DM9051.h>
-
class DM9051Service : public Ethernet::SpiService
- #include <DM9051.h>
Ethernet provider using W5500 SPI.
-
class Dp83848 : public Ethernet::PhyFactory
- #include <Dp83848.h>
DP 83848 PHY interface.
-
class IdfService : public Ethernet::Service
- #include <IdfService.h>
Base Ethernet service for IDF SDK.
Subclassed by EmbeddedEthernet, Ethernet::SpiService
Public Functions
-
virtual void end() override
Tear down the ethernet connection.
-
virtual MacAddress getMacAddress() const override
Get MAC address.
-
virtual bool setMacAddress(const MacAddress &addr) override
Set MAC address.
-
virtual bool setFullDuplex(bool enable) override
Set duplex mode of MAC.
-
virtual bool setLinkState(bool up) override
Set link status of MAC.
-
virtual bool setPromiscuous(bool enable) override
Set MAC promiscuous mode.
-
virtual IpAddress getIP() const override
Get current IP address.
-
virtual bool setIP(IpAddress address, IpAddress netmask, IpAddress gateway) override
Set static IP address.
-
virtual bool isEnabledDHCP() const override
Determine if DHCP is active for this interface.
-
virtual bool enableDHCP(bool enable) override
Enable/disable DHCP on this interface.
-
virtual void end() override
-
class Ip101 : public Ethernet::PhyFactory
- #include <Ip101.h>
IP101 PHY interface.
-
class Ksz8041 : public Ethernet::PhyFactory
- #include <Ksz8041.h>
KSZ 8041 PHY interface.
-
class Lan8720 : public Ethernet::PhyFactory
- #include <Lan8720.h>
LAN 8720 PHY interface.
-
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.
-
int8_t phyAddr = PHY_ADDR_AUTO
-
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::DM9051PhyFactory, Ethernet::Dp83848, Ethernet::Ip101, Ethernet::Ksz8041, Ethernet::Lan8720, Ethernet::Rtl8201, Ethernet::W5500PhyFactory
-
class Rtl8201 : public Ethernet::PhyFactory
- #include <Rtl8201.h>
RTL 8201 PHY interface.
-
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()
.Subclassed by Ethernet::IdfService
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 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 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.
-
virtual void end() = 0
-
class SpiService : public Ethernet::IdfService
- #include <SpiService.h>
SPI ethernet provider.
Subclassed by Ethernet::DM9051Service, Ethernet::W5500Service
-
struct Config
- #include <SpiService.h>
-
struct Config
-
class W5500PhyFactory : public Ethernet::PhyFactory
- #include <W5500.h>
-
class W5500Service : public Ethernet::SpiService
- #include <W5500.h>
Ethernet provider using W5500 SPI.
-
using EventDelegate = Delegate<void(Ethernet::Event event)>