Class EthernetServiceProvider

implements ServiceHandler
Service provider for networking via the Ethernet peripheral.
This provider must be installed before Ethernet networking can be used on the ESP32. The provider can be installed in a separate container or in the same container as the application.
Example
An example of how to install the service provider in the same container. This example is for the Olimex ESP32-POE board.

import gpio
import net.ethernet
import esp32.net.ethernet as esp32

main:
  power := gpio.Pin --output 12
  power.set 1
  provider := esp32.EthernetServiceProvider.mac-esp32
      --phy-chip=esp32.PHY-CHIP-LAN8720
      --phy-address=0
      --mac-mdc=23
      --mac-mdio=18
  provider.install
  network := ethernet.open
  try:
    use network
  finally:
    network.close
    provider.uninstall
    power.close
Olimex Ethernet boards
The Olimex Ethernet boards (Gateway and ESP32-POE) need an envelope with an RMII clock output: esp32-eth-clk-out17 (WROOM) or esp32-eth-clk-out0-spiram (WROVER).
This firmware contains the sdk-config change to enable CONFIG_ETH_RMII_CLK_OUTPUT (here shown for the WROOM):

--- b/toolchains/esp32/sdkconfig
+++ a/toolchains/esp32/sdkconfig
@@ -505,9 +505,10 @@
 CONFIG_ETH_ENABLED=y
 CONFIG_ETH_USE_ESP32_EMAC=y
 CONFIG_ETH_PHY_INTERFACE_RMII=y
-CONFIG_ETH_RMII_CLK_INPUT=y
-# CONFIG_ETH_RMII_CLK_OUTPUT is not set
-CONFIG_ETH_RMII_CLK_IN_GPIO=0
+# CONFIG_ETH_RMII_CLK_INPUT is not set
+CONFIG_ETH_RMII_CLK_OUTPUT=y
+# CONFIG_ETH_RMII_CLK_OUTPUT_GPIO0 is not set
+CONFIG_ETH_RMII_CLK_OUT_GPIO=17
 CONFIG_ETH_DMA_BUFFER_SIZE=512
 CONFIG_ETH_DMA_RX_BUFFER_NUM=10
 CONFIG_ETH_DMA_TX_BUFFER_NUM=10
Lilygo T-Internet-COM
The [Lilygo T-Internet-COM](https://lilygo.cc/products/t-internet-com) is similar to the Olimex board. It uses the esp32-eth-clk-out0-spiram envelope and GPIO 4 as power pin. The rest is the same.

Class summary


constructor --phy-chip/int --phy-address/int= --phy-reset/any= --mac-chip/int --mac-mdc/any --mac-mdio/any --mac-spi-device/Device --mac-interrupt/any
The mac-chip must be one of MAC-CHIP-ESP32 or MAC-CHIP-OPENETH.

Constructors

constructor --phy-chip/int --phy-address/int=-1 --phy-reset/any=null --mac-chip/int --mac-mdc/any --mac-mdio/any --mac-spi-device/Device --mac-interrupt/any

Statics

mac-esp32 --phy-chip/int --phy-address/int=-1 --phy-reset/any=null --mac-mdc/any=null --mac-mdio/any=null -> EthernetServiceProvider
The phy-chip must be one of PHY-CHIP-IP101, PHY-CHIP-LAN8720, or PHY-CHIP-DP83848.
The phy-reset, mac-mdc, and mac-mdio are GPIO numbers.
Passing a gpio.Pin is deprecated; provide the integer GPIO number instead. The gpio.Pin form will be removed in a future release.

mac-openeth --phy-chip/int --phy-address/int=-1 --phy-reset/any=null -> EthernetServiceProvider
The phy-chip must be one of PHY-CHIP-IP101, PHY-CHIP-LAN8720, or PHY-CHIP-DP83848.
The phy-reset is a GPIO number.
Passing a gpio.Pin is deprecated; provide the integer GPIO number instead. The gpio.Pin form will be removed in a future release.

w5500 --bus/Bus --frequency/int --cs/any --interrupt/any -> EthernetServiceProvider
The cs and interrupt are GPIO numbers.
Passing a gpio.Pin is deprecated; provide the integer GPIO number instead. The gpio.Pin form will be removed in a future release.

Methods

connect client/int -> List

handle index/int arguments/any --gid/int --client/int -> any

install -> none

on-closed client/int -> none

on-module-closed module/ -> none
Called when the module is closed, for example through network.close.
Inheritance
This method must be called by any subclass that overrides it.

on-module-opened module/ -> none
Called when the module is first opened, for example through ethernet.open.
Inheritance
This method must be called by any subclass that overrides it.

on-opened client/int -> none

operator == other/any -> bool
Whether this object is equal to the other.
By default, identical is used for equality.
Inheritance
Classes overwrite this operator to get an equality specific to their needs. Equality operators often compare the type and field contents. For example:

class Pin:
  number/int

  constructor .number:

  operator == other:
    if other is not Pin: return false
    return number == other.number
A class doesn't have to follow the above format, but it must keep the operator in sync with any hash-code method. That is, if a class has a hash-code member, then the equality and hash-code must agree. If two instances are equal (a == b), then their hash codes must also be equal (a.hash-code == b.hash-code).

pid --client/int -> int

provides selector/ServiceSelector --handler/ServiceHandler --id/int=null --priority/int=PRIORITY-NORMAL --tags/List=null -> none
Registers a handler for the given selector.
This function should only be called from subclasses (typically in their constructor).

resource client/int handle/int -> ServiceResource

resources-do [block] -> none

uninstall --wait/bool=false -> none

Fields

inherited

inherited

inherited

inherited

inherited