Skip to content

Commit

Permalink
IDF v4 Ethernet Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
troyhacks committed Jan 29, 2025
1 parent a244910 commit 55e9c3d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
21 changes: 18 additions & 3 deletions wled00/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ int getSignalQuality(int rssi)
return quality;
}

#if ESP_IDF_VERSION_MAJOR >= 4
#define SYSTEM_EVENT_ETH_CONNECTED ARDUINO_EVENT_ETH_CONNECTED
#define SYSTEM_EVENT_ETH_DISCONNECTED ARDUINO_EVENT_ETH_DISCONNECTED
#define SYSTEM_EVENT_ETH_START ARDUINO_EVENT_ETH_START
#define SYSTEM_EVENT_ETH_GOT_IP ARDUINO_EVENT_ETH_GOT_IP
#endif

//handle Ethernet connection event
void WiFiEvent(WiFiEvent_t event)
Expand All @@ -170,12 +176,21 @@ void WiFiEvent(WiFiEvent_t event)
case SYSTEM_EVENT_ETH_START:
DEBUG_PRINTLN(F("ETH Started"));
break;
case SYSTEM_EVENT_ETH_GOT_IP:
if (Network.isEthernet()) {
if (!apActive) {
DEBUG_PRINTLN(F("WiFi Connected *and* ETH Connected. Disabling WIFi"));
WiFi.disconnect(true);
} else {
DEBUG_PRINTLN(F("WiFi Connected *and* ETH Connected. Leaving AP WiFi active"));
}
} else {
DEBUG_PRINTLN(F("WiFi Connected. No ETH"));
}
break;
case SYSTEM_EVENT_ETH_CONNECTED:
{
DEBUG_PRINTLN(F("ETH Connected"));
if (!apActive) {
WiFi.disconnect(true);
}
if (staticIP != (uint32_t)0x00000000 && staticGateway != (uint32_t)0x00000000) {
ETH.config(staticIP, staticGateway, staticSubnet, IPAddress(8, 8, 8, 8));
} else {
Expand Down
19 changes: 9 additions & 10 deletions wled00/wled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1370,16 +1370,15 @@ void WLED::handleConnection()
} else if (!interfacesInited) { //newly connected
USER_PRINTLN("");
USER_PRINT(F("Connected! IP address: http://"));
USER_PRINTLN(Network.localIP());
//if (Network.isEthernet()) {
// #if ESP32
// USER_PRINT(ETH.localIP());
// USER_PRINTLN(" via Ethernet");
// #endif
//} else {
// USER_PRINT(Network.localIP());
// USER_PRINTLN(" via WiFi");
//}
USER_PRINT(Network.localIP());
if (Network.isEthernet()) {
#if ESP32
USER_PRINTLN(" via Ethernet (disabling WiFi)");
WiFi.disconnect(true);
#endif
} else {
USER_PRINTLN(" via WiFi");
}

if (improvActive) {
if (improvError == 3) sendImprovStateResponse(0x00, true);
Expand Down

0 comments on commit 55e9c3d

Please sign in to comment.