Support eth boards without power pin, extend docs (#2855)

* fix handling of optional power pin

* add init example for wESP32

* add example for eth.on()
This commit is contained in:
Arnim Läuger 2019-08-12 22:31:19 +02:00 committed by GitHub
parent 7ad6bc1be7
commit d20778ed09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -26,7 +26,8 @@ typedef enum {
static struct { static struct {
const eth_config_t *eth_config; 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; } module_config;

View File

@ -74,12 +74,20 @@ An error is thrown in case of invalid parameters or if the ethernet driver faile
#### Example #### Example
```lua ```lua
-- Initialize ESP32-GATEWAY
eth.init({phy = eth.PHY_LAN8720, eth.init({phy = eth.PHY_LAN8720,
addr = 0, addr = 0,
clock_mode = eth.CLOCK_GPIO17_OUT, clock_mode = eth.CLOCK_GPIO17_OUT,
power = 5, power = 5,
mdc = 23, mdc = 23,
mdio = 18}) 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 - `netmask`: the IP netmask
- `gw`: the gateway ("0.0.0.0" if no gateway) - `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() ## eth.set_mac()
Set MAC address. Set MAC address.