Makes ethernet get an IP when connected (#4234)

This commit is contained in:
copercini
2020-10-01 08:40:15 -03:00
committed by GitHub
parent 291c519642
commit 8d9d7bbca9

View File

@ -116,6 +116,16 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
tcpipInit();
tcpip_adapter_set_default_eth_handlers();
esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH();
esp_netif_t *eth_netif = esp_netif_new(&cfg);
if(esp_eth_set_default_handlers(eth_netif) != ESP_OK){
log_e("esp_eth_set_default_handlers failed");
return false;
}
esp_eth_mac_t *eth_mac = NULL;
#if CONFIG_ETH_SPI_ETHERNET_DM9051
if(type == ETH_PHY_DM9051){
@ -176,6 +186,12 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
log_e("esp_eth_driver_install failed");
return false;
}
/* attach Ethernet driver to TCP/IP stack */
if(esp_netif_attach(eth_netif, esp_eth_new_netif_glue(eth_handle)) != ESP_OK){
log_e("esp_netif_attach failed");
return false;
}
if(esp_eth_start(eth_handle) != ESP_OK){
log_e("esp_eth_start failed");