diff --git a/package-lock.json b/package-lock.json index 42f12801..c6b006a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "wled", - "version": "0.11.0", + "version": "0.11.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/platformio.ini b/platformio.ini index 416bd52c..b61cd88b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -284,7 +284,7 @@ board = esp32-poe platform = espressif32@2.0 upload_speed = 921600 build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags_esp32} -D RLYPIN=-1 -D WLED_USE_ETHERNET +build_flags = ${common.build_flags_esp32} -D RLYPIN=-1 -D WLED_USE_ETHERNET -D BTNPIN=-1 lib_ignore = ESPAsyncTCP ESPAsyncUDP diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 9b4f99f9..43d2615e 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -71,6 +71,11 @@ void deserializeConfig() { if (apHide > 1) apHide = 1; CJSON(apBehavior, ap[F("behav")]); + + #ifdef WLED_USE_ETHERNET + JsonObject ethernet = doc[F("eth")]; + CJSON(ethernetType, ethernet[F("type")]); + #endif /* JsonArray ap_ip = ap[F("ip")]; @@ -383,6 +388,11 @@ void serializeConfig() { wifi[F("sleep")] = !noWifiSleep; wifi[F("phy")] = 1; + #ifdef WLED_USE_ETHERNET + JsonObject ethernet = doc.createNestedObject("eth"); + ethernet[F("type")] = ethernetType; + #endif + JsonObject hw = doc.createNestedObject("hw"); JsonObject hw_led = hw.createNestedObject("led"); diff --git a/wled00/const.h b/wled00/const.h index ee675536..a7a155b6 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -122,6 +122,10 @@ #define BTN_TYPE_SWITCH 4 //not implemented #define BTN_TYPE_SWITCH_ACT_HIGH 5 //not implemented +//Ethernet board types +#define WLED_ETH_NONE 0 +#define WLED_ETH_WT32_ETH01 1 +#define WLED_ETH_ESP32_POE 2 //Hue error codes #define HUE_ERROR_INACTIVE 0 diff --git a/wled00/data/settings_wifi.htm b/wled00/data/settings_wifi.htm index 819fc58a..3e58609b 100644 --- a/wled00/data/settings_wifi.htm +++ b/wled00/data/settings_wifi.htm @@ -63,7 +63,13 @@

Experimental

Disable WiFi sleep:
Can help with connectivity issues.
- Do not enable if WiFi is working correctly, increases power consumption.
+ Do not enable if WiFi is working correctly, increases power consumption. +
+

Ethernet Type

+


diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 318205bc..acd39d9b 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -61,9 +61,11 @@ value="2">Always
AP IP: Not active

Experimental

Disable WiFi sleep:
Can help with connectivity issues.
-Do not enable if WiFi is working correctly, increases power consumption.

-)====="; +Do not enable if WiFi is working correctly, increases power consumption.

Ethernet Type




)====="; // Autogenerated from wled00/data/settings_leds.htm, do not edit!! diff --git a/wled00/set.cpp b/wled00/set.cpp index 735fdfda..db54ab31 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -52,6 +52,10 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) noWifiSleep = request->hasArg(F("WS")); + #ifdef WLED_USE_ETHERNET + ethernetType = request->arg(F("ETH")).toInt(); + #endif + char k[3]; k[2] = 0; for (int i = 0; i<4; i++) { diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 0dd3704c..9cb6be1e 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -10,6 +10,49 @@ WLED::WLED() { } +#ifdef WLED_USE_ETHERNET +// settings for various ethernet boards +typedef struct EthernetSettings { + uint8_t eth_address; + int eth_power; + int eth_mdc; + int eth_mdio; + eth_phy_type_t eth_type; + eth_clock_mode_t eth_clk_mode; +} ethernet_settings; + +ethernet_settings ethernetBoards[] = { + // None + { + }, + + // WT32-EHT01 + // Please note, from my testing only these pins work for LED outputs: + // IO2, IO4, IO12, IO14, IO15 + // These pins do not appear to work from my testing: + // IO35, IO36, IO39 + { + 1, // eth_address, + 16, // eth_power, + 23, // eth_mdc, + 18, // eth_mdio, + ETH_PHY_LAN8720, // eth_type, + ETH_CLOCK_GPIO0_IN // eth_clk_mode + }, + + // ESP32-POE + { + 0, // eth_address, + 12, // eth_power, + 23, // eth_mdc, + 18, // eth_mdio, + ETH_PHY_LAN8720, // eth_type, + ETH_CLOCK_GPIO17_OUT // eth_clk_mode + } +}; + +#endif + // turns all LEDs off and restarts ESP void WLED::reset() { @@ -393,7 +436,18 @@ void WLED::initConnection() #endif #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) - ETH.begin(); + // Only initialize ethernet board if not NONE + if (ethernetType != WLED_ETH_NONE) { + ethernet_settings es = ethernetBoards[ethernetType]; + ETH.begin( + (uint8_t) es.eth_address, + (int) es.eth_power, + (int) es.eth_mdc, + (int) es.eth_mdio, + (eth_phy_type_t) es.eth_type, + (eth_clock_mode_t) es.eth_clk_mode + ); + } #endif WiFi.disconnect(true); // close old connections diff --git a/wled00/wled.h b/wled00/wled.h index c2ec4659..b4a8a87f 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -204,6 +204,9 @@ WLED_GLOBAL IPAddress staticIP _INIT_N((( 0, 0, 0, 0))); // static IP WLED_GLOBAL IPAddress staticGateway _INIT_N((( 0, 0, 0, 0))); // gateway (router) IP WLED_GLOBAL IPAddress staticSubnet _INIT_N(((255, 255, 255, 0))); // most common subnet in home networks WLED_GLOBAL bool noWifiSleep _INIT(false); // disabling modem sleep modes will increase heat output and power usage, but may help with connection issues +#ifdef WLED_USE_ETHERNET +WLED_GLOBAL int ethernetType _INIT(WLED_ETH_ESP32_POE); // ethernet board type +#endif // LED CONFIG WLED_GLOBAL uint16_t ledCount _INIT(30); // overcurrent prevented by ABL diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 1a64eb5c..ebfda269 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -219,6 +219,12 @@ void getSettingsJS(byte subPage, char* dest) sappend('v',SET_F("AC"),apChannel); sappend('c',SET_F("WS"),noWifiSleep); + #ifdef WLED_USE_ETHERNET + sappend('i',SET_F("ETH"),ethernetType); + #else + //hide ethernet setting if not compiled in + oappend(SET_F("document.getElementById('ethd').style.display='none';")); + #endif if (Network.isConnected()) //is connected {