Skip to content

Commit

Permalink
Makes ethernet get an IP when connected (#4234)
Browse files Browse the repository at this point in the history
  • Loading branch information
copercini authored and me-no-dev committed Nov 3, 2020
1 parent fa852c9 commit bae722f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions libraries/WiFi/src/ETH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit bae722f

Please sign in to comment.