diff --git a/components/modules/eth.c b/components/modules/eth.c index 714efd19..cc3a98b1 100644 --- a/components/modules/eth.c +++ b/components/modules/eth.c @@ -26,7 +26,8 @@ typedef enum { static struct { const eth_config_t *eth_config; - gpio_num_t pin_power, pin_mdc, pin_mdio; + int pin_power; + gpio_num_t pin_mdc, pin_mdio; } module_config; diff --git a/docs/modules/eth.md b/docs/modules/eth.md index 106487f2..0cec6632 100644 --- a/docs/modules/eth.md +++ b/docs/modules/eth.md @@ -74,12 +74,20 @@ An error is thrown in case of invalid parameters or if the ethernet driver faile #### Example ```lua +-- Initialize ESP32-GATEWAY eth.init({phy = eth.PHY_LAN8720, addr = 0, clock_mode = eth.CLOCK_GPIO17_OUT, power = 5, mdc = 23, mdio = 18}) + +-- Initialize wESP32 +eth.init({phy = eth.PHY_LAN8720, + addr = 0, + clock_mode = eth.CLOCK_GPIO0_IN, + mdc = 16, + mdio = 17}) ``` @@ -111,6 +119,25 @@ Event information provided for each event is as follows: - `netmask`: the IP netmask - `gw`: the gateway ("0.0.0.0" if no gateway) +#### Example +```lua +function ev(event, info) + print("event", event) + if event == "got_ip" then + print("ip:"..info.ip..", nm:"..info.netmask..", gw:"..info.gw) + elseif event == "connected" then + print("speed:", eth.get_speed()) + print("mac:", eth.get_mac()) + end +end + +eth.on("connected", ev) +eth.on("disconnected", ev) +eth.on("start", ev) +eth.on("stop", ev) +eth.on("got_ip", ev) +``` + ## eth.set_mac() Set MAC address.