Skip to content

Commit 8d9d7bb

Browse files
authored
Makes ethernet get an IP when connected (espressif#4234)
1 parent 291c519 commit 8d9d7bb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

libraries/WiFi/src/ETH.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
116116
tcpipInit();
117117

118118
tcpip_adapter_set_default_eth_handlers();
119+
120+
esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH();
121+
esp_netif_t *eth_netif = esp_netif_new(&cfg);
122+
123+
if(esp_eth_set_default_handlers(eth_netif) != ESP_OK){
124+
log_e("esp_eth_set_default_handlers failed");
125+
return false;
126+
}
127+
128+
119129
esp_eth_mac_t *eth_mac = NULL;
120130
#if CONFIG_ETH_SPI_ETHERNET_DM9051
121131
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
176186
log_e("esp_eth_driver_install failed");
177187
return false;
178188
}
189+
190+
/* attach Ethernet driver to TCP/IP stack */
191+
if(esp_netif_attach(eth_netif, esp_eth_new_netif_glue(eth_handle)) != ESP_OK){
192+
log_e("esp_netif_attach failed");
193+
return false;
194+
}
179195

180196
if(esp_eth_start(eth_handle) != ESP_OK){
181197
log_e("esp_eth_start failed");

0 commit comments

Comments
 (0)