From 58875acdabbdb682aecef08cca0247c30cf9cb72 Mon Sep 17 00:00:00 2001 From: devsaurus Date: Fri, 15 Aug 2025 19:41:27 +0200 Subject: [PATCH 1/7] Add support for ESP32 RMII PHY, wesp32 variant --- src/DebugConfiguration.h | 13 +++++-- src/Power.cpp | 11 ++++-- src/main.cpp | 4 +- src/mesh/InterfacesTemplates.cpp | 2 +- src/mesh/api/WiFiServerAPI.h | 11 ++++-- src/mesh/api/ethServerAPI.cpp | 2 +- src/mesh/api/ethServerAPI.h | 2 +- src/mesh/http/WebServer.cpp | 11 ++++-- src/mesh/udp/UdpMulticastHandler.h | 11 ++++-- src/mesh/wifi/WiFiAPClient.cpp | 32 +++++++++++----- src/mesh/wifi/WiFiAPClient.h | 13 +++++-- src/modules/AdminModule.cpp | 2 +- src/mqtt/MQTT.cpp | 17 +++++++-- src/mqtt/MQTT.h | 2 +- src/platform/esp32/main-esp32.cpp | 2 +- variants/esp32/wesp32/platformio.ini | 20 ++++++++++ variants/esp32/wesp32/variant.h | 55 ++++++++++++++++++++++++++++ 17 files changed, 169 insertions(+), 41 deletions(-) create mode 100644 variants/esp32/wesp32/platformio.ini create mode 100644 variants/esp32/wesp32/variant.h diff --git a/src/DebugConfiguration.h b/src/DebugConfiguration.h index a34710eb0..dc1def176 100644 --- a/src/DebugConfiguration.h +++ b/src/DebugConfiguration.h @@ -121,13 +121,18 @@ extern "C" void logLegacy(const char *level, const char *fmt, ...); // Default Bluetooth PIN #define defaultBLEPin 123456 -#if HAS_ETHERNET && !defined(USE_WS5500) +#if HAS_ETHERNET && !(defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY)) #include #endif // HAS_ETHERNET -#if HAS_ETHERNET && defined(USE_WS5500) -#include -#define ETH ETH2 +#if HAS_ETHERNET +# if defined(USE_WS5500) +# include +# define ETH ETH2 +# endif +# if defined(USE_ESP32_RMIIPHY) +# include +# endif #endif // HAS_ETHERNET #if HAS_WIFI diff --git a/src/Power.cpp b/src/Power.cpp index 8a16132f1..a05e6c3a5 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -37,9 +37,14 @@ #include #endif -#if HAS_ETHERNET && defined(USE_WS5500) -#include -#define ETH ETH2 +#if HAS_ETHERNET +# if defined(USE_WS5500) +# include +# define ETH ETH2 +# endif +# if defined(USE_ESP32_RMIIPHY) +# include +# endif #endif // HAS_ETHERNET #endif diff --git a/src/main.cpp b/src/main.cpp index 9e46021c9..9b7170e9f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,12 +58,12 @@ NimbleBluetooth *nimbleBluetooth = nullptr; NRF52Bluetooth *nrf52Bluetooth = nullptr; #endif -#if HAS_WIFI || defined(USE_WS5500) +#if HAS_WIFI || (defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY)) #include "mesh/api/WiFiServerAPI.h" #include "mesh/wifi/WiFiAPClient.h" #endif -#if HAS_ETHERNET && !defined(USE_WS5500) +#if HAS_ETHERNET && !(defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY)) #include "mesh/api/ethServerAPI.h" #include "mesh/eth/ethClient.h" #endif diff --git a/src/mesh/InterfacesTemplates.cpp b/src/mesh/InterfacesTemplates.cpp index 57abbf0ee..78e7f951d 100644 --- a/src/mesh/InterfacesTemplates.cpp +++ b/src/mesh/InterfacesTemplates.cpp @@ -25,7 +25,7 @@ template class LR11x0Interface; template class SX126xInterface; #endif -#if HAS_ETHERNET && !defined(USE_WS5500) +#if HAS_ETHERNET && !(defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY)) #include "api/ethServerAPI.h" template class ServerAPI; template class APIServerPort; diff --git a/src/mesh/api/WiFiServerAPI.h b/src/mesh/api/WiFiServerAPI.h index 5f2019983..8823d2c70 100644 --- a/src/mesh/api/WiFiServerAPI.h +++ b/src/mesh/api/WiFiServerAPI.h @@ -3,9 +3,14 @@ #include "ServerAPI.h" #include -#if HAS_ETHERNET && defined(USE_WS5500) -#include -#define ETH ETH2 +#if HAS_ETHERNET +# if defined(USE_WS5500) +# include +# define ETH ETH2 +# endif +# if defined(USE_ESP32_RMIIPHY) +# include +# endif #endif // HAS_ETHERNET /** diff --git a/src/mesh/api/ethServerAPI.cpp b/src/mesh/api/ethServerAPI.cpp index 0ccf92df7..c5f73ee27 100644 --- a/src/mesh/api/ethServerAPI.cpp +++ b/src/mesh/api/ethServerAPI.cpp @@ -1,7 +1,7 @@ #include "configuration.h" #include -#if HAS_ETHERNET && !defined(USE_WS5500) +#if HAS_ETHERNET && !(defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY)) #include "ethServerAPI.h" diff --git a/src/mesh/api/ethServerAPI.h b/src/mesh/api/ethServerAPI.h index c616c87be..b9beb3ee1 100644 --- a/src/mesh/api/ethServerAPI.h +++ b/src/mesh/api/ethServerAPI.h @@ -1,7 +1,7 @@ #pragma once #include "ServerAPI.h" -#ifndef USE_WS5500 +#if !(defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY)) #include /** diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index bf170de59..3a422cbda 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -12,9 +12,14 @@ #include #include -#if HAS_ETHERNET && defined(USE_WS5500) -#include -#define ETH ETH2 +#if HAS_ETHERNET +# if defined(USE_WS5500) +# include +# define ETH ETH2 +# endif +# if defined(USE_ESP32_RMIIPHY) +# include +# endif #endif // HAS_ETHERNET #ifdef ARCH_ESP32 diff --git a/src/mesh/udp/UdpMulticastHandler.h b/src/mesh/udp/UdpMulticastHandler.h index 9650668a8..651ae49f4 100644 --- a/src/mesh/udp/UdpMulticastHandler.h +++ b/src/mesh/udp/UdpMulticastHandler.h @@ -12,9 +12,14 @@ #include -#if HAS_ETHERNET && defined(USE_WS5500) -#include -#define ETH ETH2 +#if HAS_ETHERNET +# if defined(USE_WS5500) +# include +# define ETH ETH2 +# endif +# if defined(USE_ESP32_RMIIPHY) +# include +# endif #endif // HAS_ETHERNET #define UDP_MULTICAST_DEFAUL_PORT 4403 // Default port for UDP multicast is same as TCP api server diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index 1133ad424..f0ea7a277 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -10,9 +10,14 @@ #include "target_specific.h" #include -#if HAS_ETHERNET && defined(USE_WS5500) -#include -#define ETH ETH2 +#if HAS_ETHERNET +# if defined(USE_WS5500) +# include +# define ETH ETH2 +# endif +# if defined(USE_ESP32_RMIIPHY) +# include +# endif #endif // HAS_ETHERNET #include @@ -62,13 +67,22 @@ Syslog syslog(syslogClient); Periodic *wifiReconnect; -#ifdef USE_WS5500 +#if defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY) // Startup Ethernet bool initEthernet() { - if ((config.network.eth_enabled) && (ETH.begin(ETH_PHY_W5500, 1, ETH_CS_PIN, ETH_INT_PIN, ETH_RST_PIN, SPI3_HOST, - ETH_SCLK_PIN, ETH_MISO_PIN, ETH_MOSI_PIN))) { + if (config.network.eth_enabled) { WiFi.onEvent(WiFiEvent); +#if defined(USE_WS5500) + ETH.begin(ETH_PHY_W5500, 1, ETH_CS_PIN, ETH_INT_PIN, ETH_RST_PIN, SPI3_HOST, + ETH_SCLK_PIN, ETH_MISO_PIN, ETH_MOSI_PIN); +#endif +#if defined(USE_ESP32_RMIIPHY) + ETH.begin(ESP32_RMIIPHY_ADDR, ESP32_RMIIPHY_PWR, + ESP32_RMIIPHY_MDC, ESP32_RMIIPHY_MDIO, + ESP32_RMIIPHY_TYPE, ESP32_RMIIPHY_CLKTYPE); +#endif + #if !MESHTASTIC_EXCLUDE_WEBSERVER createSSLCert(); // For WebServer #endif @@ -232,7 +246,7 @@ bool isWifiAvailable() if (config.network.wifi_enabled && (config.network.wifi_ssid[0])) { return true; -#ifdef USE_WS5500 +#if defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY) } else if (config.network.eth_enabled) { return true; #endif @@ -453,14 +467,14 @@ static void WiFiEvent(WiFiEvent_t event) LOG_INFO("Ethernet disconnected"); break; case ARDUINO_EVENT_ETH_GOT_IP: -#ifdef USE_WS5500 +#if defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY) LOG_INFO("Obtained IP address: %s, %u Mbps, %s", ETH.localIP().toString().c_str(), ETH.linkSpeed(), ETH.fullDuplex() ? "FULL_DUPLEX" : "HALF_DUPLEX"); onNetworkConnected(); #endif break; case ARDUINO_EVENT_ETH_GOT_IP6: -#ifdef USE_WS5500 +#if defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY) #if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0) LOG_INFO("Obtained Local IP6 address: %s", ETH.linkLocalIPv6().toString().c_str()); LOG_INFO("Obtained GlobalIP6 address: %s", ETH.globalIPv6().toString().c_str()); diff --git a/src/mesh/wifi/WiFiAPClient.h b/src/mesh/wifi/WiFiAPClient.h index 078c40193..98d88c35c 100644 --- a/src/mesh/wifi/WiFiAPClient.h +++ b/src/mesh/wifi/WiFiAPClient.h @@ -9,9 +9,14 @@ #include #endif -#if HAS_ETHERNET && defined(USE_WS5500) -#include -#define ETH ETH2 +#if HAS_ETHERNET +# if defined(USE_WS5500) +# include +# define ETH ETH2 +# endif +# if defined(USE_ESP32_RMIIPHY) +# include +# endif #endif // HAS_ETHERNET extern bool needReconnect; @@ -26,7 +31,7 @@ bool isWifiAvailable(); uint8_t getWifiDisconnectReason(); -#ifdef USE_WS5500 +#if defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY) // Startup Ethernet bool initEthernet(); #endif \ No newline at end of file diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 4014e1c36..cf2981e7c 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -1152,7 +1152,7 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r } #endif -#if HAS_ETHERNET && !defined(USE_WS5500) +#if HAS_ETHERNET && !(defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY)) conn.has_ethernet = true; conn.ethernet.has_status = true; if (Ethernet.linkStatus() == LinkON) { diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index d94aeff95..b5e5e0038 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -19,9 +19,14 @@ #include "mesh/wifi/WiFiAPClient.h" #include #endif -#if HAS_ETHERNET && defined(USE_WS5500) -#include -#define ETH ETH2 +#if HAS_ETHERNET +# if defined(USE_WS5500) +# include +# define ETH ETH2 +# endif +# if defined(USE_ESP32_RMIIPHY) +# include +# endif #endif // HAS_ETHERNET #include "Default.h" #if !defined(ARCH_NRF52) || NRF52_USE_JSON @@ -307,10 +312,14 @@ bool connectPubSub(const PubSubConfig &config, PubSubClient &pubSub, Client &cli inline bool isConnectedToNetwork() { -#ifdef USE_WS5500 +#if defined(USE_WS5500) if (ETH.connected()) return true; #endif +#if defined(USE_ESP32_RMIIPHY) + if (ETH.linkUp()) + return true; +#endif #if HAS_WIFI return WiFi.isConnected(); diff --git a/src/mqtt/MQTT.h b/src/mqtt/MQTT.h index 7d5715602..e4e4f0412 100644 --- a/src/mqtt/MQTT.h +++ b/src/mqtt/MQTT.h @@ -15,7 +15,7 @@ #include #endif #endif -#if HAS_ETHERNET && !defined(USE_WS5500) +#if HAS_ETHERNET && !(defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY)) #include #endif diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index cdea53c9a..e60cc4bff 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -28,7 +28,7 @@ #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !MESHTASTIC_EXCLUDE_BLUETOOTH void setBluetoothEnable(bool enable) { -#ifdef USE_WS5500 +#if defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY) if ((config.bluetooth.enabled == true) && (config.network.wifi_enabled == false)) #elif HAS_WIFI if (!isWifiAvailable() && config.bluetooth.enabled == true) diff --git a/variants/esp32/wesp32/platformio.ini b/variants/esp32/wesp32/platformio.ini new file mode 100644 index 000000000..f80a2582c --- /dev/null +++ b/variants/esp32/wesp32/platformio.ini @@ -0,0 +1,20 @@ +[env:wesp32] +extends = esp32_base +board = esp32dev +board_level = extra + +build_flags = + ${esp32_base.build_flags} + -D PRIVATE_HW + -I variants/esp32/wesp32 + -DMESHTASTIC_EXCLUDE_SCREEN=1 + -DMESHTASTIC_EXCLUDE_INPUTBROKER=1 + ;-DMESHTASTIC_EXCLUDE_I2C=1 + ;-DMESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1 + +build_src_filter = ${esp32_base.build_src_filter} + +monitor_speed = 115200 +upload_protocol = esptool +;upload_port = /dev/ttyUSB0 +upload_speed = 921600 diff --git a/variants/esp32/wesp32/variant.h b/variants/esp32/wesp32/variant.h new file mode 100644 index 000000000..97551435d --- /dev/null +++ b/variants/esp32/wesp32/variant.h @@ -0,0 +1,55 @@ +// +// WESP32, https://wesp32.com/ +// ESP-32-WROOM with RTL8201FI/LAN8720 and PoE +// + +#define HAS_BUTTON 0 +#undef BUTTON_PIN + +#undef LED_PIN + +#define HAS_SCREEN 0 + +#define HAS_GPS 0 +#undef GPS_RX_PIN +#undef GPS_TX_PIN + +// QWIIC connector on Revision 8 +#define I2C_SDA 15 +#define I2C_SCL 4 + +#define USE_SX1262 +// +// GPIOs on JP1 connected to a Wio-SX1262 (nRF version) LoRa board +// +#define LORA_SCK 33 +#define LORA_MISO 35 +#define LORA_MOSI 32 +#define LORA_CS 5 + +#define LORA_DIO0 RADIOLIB_NC +#define LORA_RESET 39 +#define LORA_DIO1 18 +#define LORA_BUSY 13 + +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY LORA_BUSY +#define SX126X_RESET LORA_RESET +#define SX126X_RXEN 14 +#define SX126X_CS LORA_CS +#define SX126X_TXEN RADIOLIB_NC +#define SX126X_DIO2_AS_RF_SWITCH // DIO2 is used to control the TX side of the RF switch +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 + + +#define HAS_ETHERNET 1 + +// Configure ESP32 RMII PHY +#define USE_ESP32_RMIIPHY +//#define ESP32_RMIIPHY_TYPE ETH_PHY_LAN8720 // Before revision 7 +#define ESP32_RMIIPHY_TYPE ETH_PHY_RTL8201 // Revision 7 and later +#define ESP32_RMIIPHY_ADDR 0 +#define ESP32_RMIIPHY_PWR -1 +#define ESP32_RMIIPHY_MDC 16 +#define ESP32_RMIIPHY_MDIO 17 +#define ESP32_RMIIPHY_CLKTYPE ETH_CLOCK_GPIO0_IN From 91c1f6fc78f5a553e314fac49dd69d5ecad020f4 Mon Sep 17 00:00:00 2001 From: devsaurus Date: Fri, 15 Aug 2025 19:46:18 +0200 Subject: [PATCH 2/7] nl --- src/mesh/wifi/WiFiAPClient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/wifi/WiFiAPClient.h b/src/mesh/wifi/WiFiAPClient.h index 98d88c35c..7fa65f36c 100644 --- a/src/mesh/wifi/WiFiAPClient.h +++ b/src/mesh/wifi/WiFiAPClient.h @@ -34,4 +34,4 @@ uint8_t getWifiDisconnectReason(); #if defined(USE_WS5500) || defined(USE_ESP32_RMIIPHY) // Startup Ethernet bool initEthernet(); -#endif \ No newline at end of file +#endif From c9a36520215e32a96a8dfb85caf5b281b8444305 Mon Sep 17 00:00:00 2001 From: devsaurus Date: Fri, 15 Aug 2025 20:39:33 +0200 Subject: [PATCH 3/7] move to diy --- variants/esp32/{ => diy}/wesp32/platformio.ini | 0 variants/esp32/{ => diy}/wesp32/variant.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename variants/esp32/{ => diy}/wesp32/platformio.ini (100%) rename variants/esp32/{ => diy}/wesp32/variant.h (100%) diff --git a/variants/esp32/wesp32/platformio.ini b/variants/esp32/diy/wesp32/platformio.ini similarity index 100% rename from variants/esp32/wesp32/platformio.ini rename to variants/esp32/diy/wesp32/platformio.ini diff --git a/variants/esp32/wesp32/variant.h b/variants/esp32/diy/wesp32/variant.h similarity index 100% rename from variants/esp32/wesp32/variant.h rename to variants/esp32/diy/wesp32/variant.h From 72aefbc567a096f235f08ce2fa8e5511b26e8f2d Mon Sep 17 00:00:00 2001 From: devsaurus Date: Fri, 15 Aug 2025 20:40:15 +0200 Subject: [PATCH 4/7] clean up platform.ini --- variants/esp32/diy/wesp32/platformio.ini | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/variants/esp32/diy/wesp32/platformio.ini b/variants/esp32/diy/wesp32/platformio.ini index f80a2582c..f3ab565eb 100644 --- a/variants/esp32/diy/wesp32/platformio.ini +++ b/variants/esp32/diy/wesp32/platformio.ini @@ -6,15 +6,12 @@ board_level = extra build_flags = ${esp32_base.build_flags} -D PRIVATE_HW - -I variants/esp32/wesp32 + -I variants/esp32/diy/wesp32 -DMESHTASTIC_EXCLUDE_SCREEN=1 -DMESHTASTIC_EXCLUDE_INPUTBROKER=1 - ;-DMESHTASTIC_EXCLUDE_I2C=1 - ;-DMESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1 build_src_filter = ${esp32_base.build_src_filter} monitor_speed = 115200 upload_protocol = esptool -;upload_port = /dev/ttyUSB0 upload_speed = 921600 From 5ef83675a37a74f2ca532eb86c6e4ece326f3564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnim=20L=C3=A4uger?= Date: Fri, 15 Aug 2025 22:46:03 +0200 Subject: [PATCH 5/7] check ETH.begin() result Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/mesh/wifi/WiFiAPClient.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index f0ea7a277..6cd6f387e 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -74,13 +74,21 @@ bool initEthernet() if (config.network.eth_enabled) { WiFi.onEvent(WiFiEvent); #if defined(USE_WS5500) - ETH.begin(ETH_PHY_W5500, 1, ETH_CS_PIN, ETH_INT_PIN, ETH_RST_PIN, SPI3_HOST, - ETH_SCLK_PIN, ETH_MISO_PIN, ETH_MOSI_PIN); + if (!ETH.begin(ETH_PHY_W5500, 1, ETH_CS_PIN, ETH_INT_PIN, ETH_RST_PIN, SPI3_HOST, + ETH_SCLK_PIN, ETH_MISO_PIN, ETH_MOSI_PIN)) { + LOG_ERROR("ETH.begin() failed for WS5500"); + return false; + } #endif #if defined(USE_ESP32_RMIIPHY) ETH.begin(ESP32_RMIIPHY_ADDR, ESP32_RMIIPHY_PWR, ESP32_RMIIPHY_MDC, ESP32_RMIIPHY_MDIO, - ESP32_RMIIPHY_TYPE, ESP32_RMIIPHY_CLKTYPE); + if (!ETH.begin(ESP32_RMIIPHY_ADDR, ESP32_RMIIPHY_PWR, + ESP32_RMIIPHY_MDC, ESP32_RMIIPHY_MDIO, + ESP32_RMIIPHY_TYPE, ESP32_RMIIPHY_CLKTYPE)) { + LOG_ERROR("ETH.begin() failed for ESP32 RMII PHY"); + return false; + } #endif #if !MESHTASTIC_EXCLUDE_WEBSERVER From 296339351e1287876271cd3ce8c2cc0c9a0ee433 Mon Sep 17 00:00:00 2001 From: devsaurus Date: Fri, 15 Aug 2025 22:51:01 +0200 Subject: [PATCH 6/7] fix wrongly applied suggestion --- src/mesh/wifi/WiFiAPClient.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index 6cd6f387e..d647ab1a2 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -81,8 +81,6 @@ bool initEthernet() } #endif #if defined(USE_ESP32_RMIIPHY) - ETH.begin(ESP32_RMIIPHY_ADDR, ESP32_RMIIPHY_PWR, - ESP32_RMIIPHY_MDC, ESP32_RMIIPHY_MDIO, if (!ETH.begin(ESP32_RMIIPHY_ADDR, ESP32_RMIIPHY_PWR, ESP32_RMIIPHY_MDC, ESP32_RMIIPHY_MDIO, ESP32_RMIIPHY_TYPE, ESP32_RMIIPHY_CLKTYPE)) { @@ -90,7 +88,7 @@ bool initEthernet() return false; } #endif - + #if !MESHTASTIC_EXCLUDE_WEBSERVER createSSLCert(); // For WebServer #endif From 58775b46617eda47ad9b221a466ee19284bd904c Mon Sep 17 00:00:00 2001 From: devsaurus Date: Sat, 16 Aug 2025 10:23:53 +0200 Subject: [PATCH 7/7] fix trunk check errors --- src/DebugConfiguration.h | 14 +++++++------- src/Power.cpp | 14 +++++++------- src/mesh/api/WiFiServerAPI.h | 14 +++++++------- src/mesh/http/WebServer.cpp | 14 +++++++------- src/mesh/udp/UdpMulticastHandler.h | 14 +++++++------- src/mesh/wifi/WiFiAPClient.cpp | 23 +++++++++++------------ src/mesh/wifi/WiFiAPClient.h | 14 +++++++------- src/mqtt/MQTT.cpp | 14 +++++++------- variants/esp32/diy/wesp32/variant.h | 11 +++++------ 9 files changed, 65 insertions(+), 67 deletions(-) diff --git a/src/DebugConfiguration.h b/src/DebugConfiguration.h index dc1def176..5f72a56d8 100644 --- a/src/DebugConfiguration.h +++ b/src/DebugConfiguration.h @@ -126,13 +126,13 @@ extern "C" void logLegacy(const char *level, const char *fmt, ...); #endif // HAS_ETHERNET #if HAS_ETHERNET -# if defined(USE_WS5500) -# include -# define ETH ETH2 -# endif -# if defined(USE_ESP32_RMIIPHY) -# include -# endif +#if defined(USE_WS5500) +#include +#define ETH ETH2 +#endif +#if defined(USE_ESP32_RMIIPHY) +#include +#endif #endif // HAS_ETHERNET #if HAS_WIFI diff --git a/src/Power.cpp b/src/Power.cpp index a05e6c3a5..7a0d94f2f 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -38,13 +38,13 @@ #endif #if HAS_ETHERNET -# if defined(USE_WS5500) -# include -# define ETH ETH2 -# endif -# if defined(USE_ESP32_RMIIPHY) -# include -# endif +#if defined(USE_WS5500) +#include +#define ETH ETH2 +#endif +#if defined(USE_ESP32_RMIIPHY) +#include +#endif #endif // HAS_ETHERNET #endif diff --git a/src/mesh/api/WiFiServerAPI.h b/src/mesh/api/WiFiServerAPI.h index 8823d2c70..77b964ed5 100644 --- a/src/mesh/api/WiFiServerAPI.h +++ b/src/mesh/api/WiFiServerAPI.h @@ -4,13 +4,13 @@ #include #if HAS_ETHERNET -# if defined(USE_WS5500) -# include -# define ETH ETH2 -# endif -# if defined(USE_ESP32_RMIIPHY) -# include -# endif +#if defined(USE_WS5500) +#include +#define ETH ETH2 +#endif +#if defined(USE_ESP32_RMIIPHY) +#include +#endif #endif // HAS_ETHERNET /** diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index 3a422cbda..63d6743c4 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -13,13 +13,13 @@ #include #if HAS_ETHERNET -# if defined(USE_WS5500) -# include -# define ETH ETH2 -# endif -# if defined(USE_ESP32_RMIIPHY) -# include -# endif +#if defined(USE_WS5500) +#include +#define ETH ETH2 +#endif +#if defined(USE_ESP32_RMIIPHY) +#include +#endif #endif // HAS_ETHERNET #ifdef ARCH_ESP32 diff --git a/src/mesh/udp/UdpMulticastHandler.h b/src/mesh/udp/UdpMulticastHandler.h index 651ae49f4..0986b6f44 100644 --- a/src/mesh/udp/UdpMulticastHandler.h +++ b/src/mesh/udp/UdpMulticastHandler.h @@ -13,13 +13,13 @@ #include #if HAS_ETHERNET -# if defined(USE_WS5500) -# include -# define ETH ETH2 -# endif -# if defined(USE_ESP32_RMIIPHY) -# include -# endif +#if defined(USE_WS5500) +#include +#define ETH ETH2 +#endif +#if defined(USE_ESP32_RMIIPHY) +#include +#endif #endif // HAS_ETHERNET #define UDP_MULTICAST_DEFAUL_PORT 4403 // Default port for UDP multicast is same as TCP api server diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index d647ab1a2..de7afe7b9 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -11,13 +11,13 @@ #include #if HAS_ETHERNET -# if defined(USE_WS5500) -# include -# define ETH ETH2 -# endif -# if defined(USE_ESP32_RMIIPHY) -# include -# endif +#if defined(USE_WS5500) +#include +#define ETH ETH2 +#endif +#if defined(USE_ESP32_RMIIPHY) +#include +#endif #endif // HAS_ETHERNET #include @@ -74,16 +74,15 @@ bool initEthernet() if (config.network.eth_enabled) { WiFi.onEvent(WiFiEvent); #if defined(USE_WS5500) - if (!ETH.begin(ETH_PHY_W5500, 1, ETH_CS_PIN, ETH_INT_PIN, ETH_RST_PIN, SPI3_HOST, - ETH_SCLK_PIN, ETH_MISO_PIN, ETH_MOSI_PIN)) { + if (!ETH.begin(ETH_PHY_W5500, 1, ETH_CS_PIN, ETH_INT_PIN, ETH_RST_PIN, SPI3_HOST, ETH_SCLK_PIN, ETH_MISO_PIN, + ETH_MOSI_PIN)) { LOG_ERROR("ETH.begin() failed for WS5500"); return false; } #endif #if defined(USE_ESP32_RMIIPHY) - if (!ETH.begin(ESP32_RMIIPHY_ADDR, ESP32_RMIIPHY_PWR, - ESP32_RMIIPHY_MDC, ESP32_RMIIPHY_MDIO, - ESP32_RMIIPHY_TYPE, ESP32_RMIIPHY_CLKTYPE)) { + if (!ETH.begin(ESP32_RMIIPHY_ADDR, ESP32_RMIIPHY_PWR, ESP32_RMIIPHY_MDC, ESP32_RMIIPHY_MDIO, ESP32_RMIIPHY_TYPE, + ESP32_RMIIPHY_CLKTYPE)) { LOG_ERROR("ETH.begin() failed for ESP32 RMII PHY"); return false; } diff --git a/src/mesh/wifi/WiFiAPClient.h b/src/mesh/wifi/WiFiAPClient.h index 7fa65f36c..9808ac429 100644 --- a/src/mesh/wifi/WiFiAPClient.h +++ b/src/mesh/wifi/WiFiAPClient.h @@ -10,13 +10,13 @@ #endif #if HAS_ETHERNET -# if defined(USE_WS5500) -# include -# define ETH ETH2 -# endif -# if defined(USE_ESP32_RMIIPHY) -# include -# endif +#if defined(USE_WS5500) +#include +#define ETH ETH2 +#endif +#if defined(USE_ESP32_RMIIPHY) +#include +#endif #endif // HAS_ETHERNET extern bool needReconnect; diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index b5e5e0038..75fbb3706 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -20,13 +20,13 @@ #include #endif #if HAS_ETHERNET -# if defined(USE_WS5500) -# include -# define ETH ETH2 -# endif -# if defined(USE_ESP32_RMIIPHY) -# include -# endif +#if defined(USE_WS5500) +#include +#define ETH ETH2 +#endif +#if defined(USE_ESP32_RMIIPHY) +#include +#endif #endif // HAS_ETHERNET #include "Default.h" #if !defined(ARCH_NRF52) || NRF52_USE_JSON diff --git a/variants/esp32/diy/wesp32/variant.h b/variants/esp32/diy/wesp32/variant.h index 97551435d..8f4f7de9a 100644 --- a/variants/esp32/diy/wesp32/variant.h +++ b/variants/esp32/diy/wesp32/variant.h @@ -16,7 +16,7 @@ // QWIIC connector on Revision 8 #define I2C_SDA 15 -#define I2C_SCL 4 +#define I2C_SCL 4 #define USE_SX1262 // @@ -41,15 +41,14 @@ #define SX126X_DIO2_AS_RF_SWITCH // DIO2 is used to control the TX side of the RF switch #define SX126X_DIO3_TCXO_VOLTAGE 1.8 - #define HAS_ETHERNET 1 // Configure ESP32 RMII PHY #define USE_ESP32_RMIIPHY -//#define ESP32_RMIIPHY_TYPE ETH_PHY_LAN8720 // Before revision 7 +// #define ESP32_RMIIPHY_TYPE ETH_PHY_LAN8720 // Before revision 7 #define ESP32_RMIIPHY_TYPE ETH_PHY_RTL8201 // Revision 7 and later -#define ESP32_RMIIPHY_ADDR 0 -#define ESP32_RMIIPHY_PWR -1 -#define ESP32_RMIIPHY_MDC 16 +#define ESP32_RMIIPHY_ADDR 0 +#define ESP32_RMIIPHY_PWR -1 +#define ESP32_RMIIPHY_MDC 16 #define ESP32_RMIIPHY_MDIO 17 #define ESP32_RMIIPHY_CLKTYPE ETH_CLOCK_GPIO0_IN