Skip to content

fix(ethernet): move event listener earlier to avoid missing event ETH_CONNECTED #9481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libraries/Ethernet/src/ETH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
/* attach to receive events */
initNetif((Network_Interface_ID)(ESP_NETIF_ID_ETH+_eth_index));

Network.onSysEvent(onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);

ret = esp_eth_start(_eth_handle);
if(ret != ESP_OK){
log_e("esp_eth_start failed: %d", ret);
Expand All @@ -308,8 +310,6 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
if(!perimanSetPinBus(_pin_power, ESP32_BUS_TYPE_ETHERNET_PWR, (void *)(this), -1, -1)){ goto err; }
}

Network.onSysEvent(onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);

// holds a few milliseconds to let DHCP start and enter into a good state
// FIX ME -- adresses issue https://github.com/espressif/arduino-esp32/issues/5733
delay(50);
Expand Down