Skip to content

Commit f7b4959

Browse files
authored
fix(ethernet): move event listener earlier to avoid missing event ETH_CONNECTED (#9481)
* Ethernet: Move event listener earlier * fix(ethernet): move network listener after initNetif
1 parent 8c75c35 commit f7b4959

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: libraries/Ethernet/src/ETH.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
287287
/* attach to receive events */
288288
initNetif((Network_Interface_ID)(ESP_NETIF_ID_ETH+_eth_index));
289289

290+
Network.onSysEvent(onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);
291+
290292
ret = esp_eth_start(_eth_handle);
291293
if(ret != ESP_OK){
292294
log_e("esp_eth_start failed: %d", ret);
@@ -308,8 +310,6 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
308310
if(!perimanSetPinBus(_pin_power, ESP32_BUS_TYPE_ETHERNET_PWR, (void *)(this), -1, -1)){ goto err; }
309311
}
310312

311-
Network.onSysEvent(onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);
312-
313313
// holds a few milliseconds to let DHCP start and enter into a good state
314314
// FIX ME -- adresses issue https://github.com/espressif/arduino-esp32/issues/5733
315315
delay(50);

0 commit comments

Comments
 (0)