Class EthernetServiceProvider
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
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 | |
|---|
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
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.
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.
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
Called when the module is closed, for example through network.close.
Inheritance
This method must be called by any subclass that overrides it.
Called when the module is first opened, for example through ethernet.open.
Inheritance
This method must be called by any subclass that overrides it.
Whether this object is equal to the other.
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).