Add support for WT32-ETH01 ethernet board and make ethernet support configurable (#1583)

* Initial support for WT32-ETH01 board

* Initial ethernet config option, doesn't save yet

* Fixed saving/restoring ethernet option, works now!

* Fixed ESP32-POE pin config (thanks to tbnobody)

* Remove esp32_eth target (use poe), minor cleanup

* Fix BTNPIN for WT32-ETH01, as found by @k7bbr

* Various fixes to ethernet option

Co-authored-by: cschwinne <dev.aircoookie@gmail.com>
This commit is contained in:
lonestriker 2021-01-15 03:37:45 -06:00 committed by GitHub
parent d6b366c77f
commit 82e7328903
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 96 additions and 7 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "wled",
"version": "0.11.0",
"version": "0.11.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -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

View File

@ -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");

View File

@ -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

View File

@ -63,7 +63,13 @@
<h3>Experimental</h3>
Disable WiFi sleep: <input type="checkbox" name="WS"><br>
<i>Can help with connectivity issues.<br>
Do not enable if WiFi is working correctly, increases power consumption.</i>
Do not enable if WiFi is working correctly, increases power consumption.</i>
<div id="ethd">
<h3>Ethernet Type</h3>
<select name="ETH">
<option value="0">None</option>
<option value="1">WT32-ETH01</option>
<option value="2">ESP32-POE</option></select><br><br></div>
<hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save & Connect</button>
</form>

View File

@ -61,9 +61,11 @@ value="2">Always</option><option value="3">Never (not recommended)</option>
</select><br>AP IP: <span class="sip">Not active</span><br><h3>Experimental</h3>
Disable WiFi sleep: <input type="checkbox" name="WS"><br><i>
Can help with connectivity issues.<br>
Do not enable if WiFi is working correctly, increases power consumption.</i><hr>
<button type="button" onclick="B()">Back</button><button type="submit">
Save & Connect</button></form></body></html>)=====";
Do not enable if WiFi is working correctly, increases power consumption.</i><div
id="ethd"><h3>Ethernet Type</h3><select name="ETH"><option value="0">None
</option><option value="1">WT32-ETH01</option><option value="2">ESP32-POE
</option></select><br><br></div><hr><button type="button" onclick="B()">Back
</button><button type="submit">Save & Connect</button></form></body></html>)=====";
// Autogenerated from wled00/data/settings_leds.htm, do not edit!!

View File

@ -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++)
{

View File

@ -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

View File

@ -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

View File

@ -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
{