-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
IDF v4 Ethernet/Network Fixes #4526
base: main
Are you sure you want to change the base?
Changes from all commits
e989152
8ed918d
5fca0e7
de660a8
d54c9c4
9b5b26d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,6 +169,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) | ||
|
@@ -178,12 +184,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()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need to check if this is Ethernet? After all, this is Ethernet event. On a side note there is a bug in network.cpp dependency. bool NetworkClass::isConnected()
{
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET)
return (WiFi.localIP()[0] != 0 && WiFi.status() == WL_CONNECTED) || (ETH.localIP()[0] != 0 && ETH.linkUp());
#else
return (WiFi.localIP()[0] != 0 && WiFi.status() == WL_CONNECTED);
#endif
}
bool NetworkClass::isEthernet()
{
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET)
return (ETH.localIP()[0] != 0) && WiFi.getMode() == WIFI_MODE_NULL;
#endif
return false;
} This is the correct implementation if you care to add it to this PR. |
||
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 (multiWiFi[0].staticIP != (uint32_t)0x00000000 && multiWiFi[0].staticGW != (uint32_t)0x00000000) { | ||
ETH.config(multiWiFi[0].staticIP, multiWiFi[0].staticGW, multiWiFi[0].staticSN, dnsAddress); | ||
} else { | ||
|
@@ -207,8 +222,6 @@ void WiFiEvent(WiFiEvent_t event) | |
break; | ||
#endif | ||
default: | ||
DEBUG_PRINTF_P(PSTR("Network event: %d\n"), (int)event); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is still valuable debugging info. Can you please revert? |
||
break; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1010,8 +1010,17 @@ void WLED::handleConnection() | |
} | ||
} else if (!interfacesInited) { //newly connected | ||
DEBUG_PRINTLN(); | ||
DEBUG_PRINT(F("Connected! IP address: ")); | ||
DEBUG_PRINTLN(Network.localIP()); | ||
DEBUG_PRINTLN(""); | ||
DEBUG_PRINT(F("Connected! IP address: http://")); | ||
DEBUG_PRINT(Network.localIP()); | ||
if (Network.isEthernet()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless network.cpp is updated this will return true if static IP is set. |
||
#if ESP32 | ||
DEBUG_PRINTLN(" via Ethernet (disabling WiFi)"); | ||
WiFi.disconnect(true); | ||
#endif | ||
} else { | ||
DEBUG_PRINTLN(" via WiFi"); | ||
} | ||
if (improvActive) { | ||
if (improvError == 3) sendImprovStateResponse(0x00, true); | ||
sendImprovStateResponse(0x04); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went the other way around: