From 965e79409472429a3f5c6b8fec395266c7f63f63 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 14 Aug 2025 18:25:39 +0100 Subject: [PATCH 01/45] Rename Network to WLEDNetwork to prevent clash --- wled00/bus_manager.cpp | 2 +- wled00/e131.cpp | 4 ++-- wled00/improv.cpp | 6 +++--- wled00/json.cpp | 4 ++-- wled00/src/dependencies/espalexa/Espalexa.h | 4 ++-- wled00/src/dependencies/network/Network.cpp | 14 +++++++------- wled00/src/dependencies/network/Network.h | 4 ++-- wled00/wled.h | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index f513029680..ab662ce1ed 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -743,7 +743,7 @@ size_t BusNetwork::getPins(uint8_t* pinArray) const { #ifdef ARDUINO_ARCH_ESP32 void BusNetwork::resolveHostname() { static unsigned long nextResolve = 0; - if (Network.isConnected() && millis() > nextResolve && _hostname.length() > 0) { + if (WLEDNetwork.isConnected() && millis() > nextResolve && _hostname.length() > 0) { nextResolve = millis() + 600000; // resolve only every 10 minutes IPAddress clnt; if (strlen(cmDNS) > 0) clnt = MDNS.queryHost(_hostname); diff --git a/wled00/e131.cpp b/wled00/e131.cpp index 98cfe28fb0..68ebfd1913 100644 --- a/wled00/e131.cpp +++ b/wled00/e131.cpp @@ -407,7 +407,7 @@ void prepareArtnetPollReply(ArtPollReply *reply) { reply->reply_opcode = ARTNET_OPCODE_OPPOLLREPLY; - IPAddress localIP = Network.localIP(); + IPAddress localIP = WLEDNetwork.localIP(); for (unsigned i = 0; i < 4; i++) { reply->reply_ip[i] = localIP[i]; } @@ -482,7 +482,7 @@ void prepareArtnetPollReply(ArtPollReply *reply) { // A DMX to / from Art-Net device reply->reply_style = 0x00; - Network.localMAC(reply->reply_mac); + WLEDNetwork.localMAC(reply->reply_mac); for (unsigned i = 0; i < 4; i++) { reply->reply_bind_ip[i] = localIP[i]; diff --git a/wled00/improv.cpp b/wled00/improv.cpp index 0bc7a6698f..1eb83627db 100644 --- a/wled00/improv.cpp +++ b/wled00/improv.cpp @@ -94,7 +94,7 @@ void handleImprovPacket() { case ImprovRPCType::Request_State: { unsigned improvState = 0x02; //authorized if (WLED_WIFI_CONFIGURED) improvState = 0x03; //provisioning - if (Network.isConnected()) improvState = 0x04; //provisioned + if (WLEDNetwork.isConnected()) improvState = 0x04; //provisioned sendImprovStateResponse(improvState, false); if (improvState == 0x04) sendImprovIPRPCResult(ImprovRPCType::Request_State); break; @@ -178,10 +178,10 @@ void sendImprovRPCResult(ImprovRPCType type, uint8_t n_strings, const char **str } void sendImprovIPRPCResult(ImprovRPCType type) { - if (Network.isConnected()) + if (WLEDNetwork.isConnected()) { char urlStr[64]; - IPAddress localIP = Network.localIP(); + IPAddress localIP = WLEDNetwork.localIP(); unsigned len = sprintf(urlStr, "http://%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]); if (len > 24) return; //sprintf fail? const char *str[1] = {urlStr}; diff --git a/wled00/json.cpp b/wled00/json.cpp index 4414681023..a708378895 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -876,9 +876,9 @@ void serializeInfo(JsonObject root) root[F("product")] = F(WLED_PRODUCT_NAME); root["mac"] = escapedMac; char s[16] = ""; - if (Network.isConnected()) + if (WLEDNetwork.isConnected()) { - IPAddress localIP = Network.localIP(); + IPAddress localIP = WLEDNetwork.localIP(); sprintf(s, "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]); } root["ip"] = s; diff --git a/wled00/src/dependencies/espalexa/Espalexa.h b/wled00/src/dependencies/espalexa/Espalexa.h index ae761e9faa..1e716ab456 100644 --- a/wled00/src/dependencies/espalexa/Espalexa.h +++ b/wled00/src/dependencies/espalexa/Espalexa.h @@ -215,7 +215,7 @@ class Espalexa { void serveDescription() { EA_DEBUGLN("# Responding to description.xml ... #\n"); - IPAddress localIP = Network.localIP(); + IPAddress localIP = WLEDNetwork.localIP(); char s[16]; snprintf(s, sizeof(s), "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]); char buf[1024]; @@ -289,7 +289,7 @@ class Espalexa { //respond to UDP SSDP M-SEARCH void respondToSearch() { - IPAddress localIP = Network.localIP(); + IPAddress localIP = WLEDNetwork.localIP(); char s[16]; sprintf(s, "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]); diff --git a/wled00/src/dependencies/network/Network.cpp b/wled00/src/dependencies/network/Network.cpp index dbc2707887..ed1b6272cc 100644 --- a/wled00/src/dependencies/network/Network.cpp +++ b/wled00/src/dependencies/network/Network.cpp @@ -1,6 +1,6 @@ #include "Network.h" -IPAddress NetworkClass::localIP() +IPAddress WLEDNetworkClass::localIP() { IPAddress localIP; #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) @@ -17,7 +17,7 @@ IPAddress NetworkClass::localIP() return INADDR_NONE; } -IPAddress NetworkClass::subnetMask() +IPAddress WLEDNetworkClass::subnetMask() { #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) if (ETH.localIP()[0] != 0) { @@ -30,7 +30,7 @@ IPAddress NetworkClass::subnetMask() return IPAddress(255, 255, 255, 0); } -IPAddress NetworkClass::gatewayIP() +IPAddress WLEDNetworkClass::gatewayIP() { #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) if (ETH.localIP()[0] != 0) { @@ -43,7 +43,7 @@ IPAddress NetworkClass::gatewayIP() return INADDR_NONE; } -void NetworkClass::localMAC(uint8_t* MAC) +void WLEDNetworkClass::localMAC(uint8_t* MAC) { #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) // ETH.macAddress(MAC); // Does not work because of missing ETHClass:: in ETH.ccp @@ -71,12 +71,12 @@ void NetworkClass::localMAC(uint8_t* MAC) return; } -bool NetworkClass::isConnected() +bool WLEDNetworkClass::isConnected() { return (WiFi.localIP()[0] != 0 && WiFi.status() == WL_CONNECTED) || isEthernet(); } -bool NetworkClass::isEthernet() +bool WLEDNetworkClass::isEthernet() { #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) return (ETH.localIP()[0] != 0) && ETH.linkUp(); @@ -84,4 +84,4 @@ bool NetworkClass::isEthernet() return false; } -NetworkClass Network; \ No newline at end of file +WLEDNetworkClass WLEDNetwork; \ No newline at end of file diff --git a/wled00/src/dependencies/network/Network.h b/wled00/src/dependencies/network/Network.h index 9201d514ea..f0197d30b9 100644 --- a/wled00/src/dependencies/network/Network.h +++ b/wled00/src/dependencies/network/Network.h @@ -8,7 +8,7 @@ #ifndef Network_h #define Network_h -class NetworkClass +class WLEDNetworkClass { public: IPAddress localIP(); @@ -19,6 +19,6 @@ class NetworkClass bool isEthernet(); }; -extern NetworkClass Network; +extern WLEDNetworkClass WLEDNetwork; #endif \ No newline at end of file diff --git a/wled00/wled.h b/wled00/wled.h index 3772fcd1f6..3fc9f9719c 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -1026,7 +1026,7 @@ WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0); WLED_GLOBAL unsigned loops _INIT(0); #endif -#define WLED_CONNECTED (Network.isConnected()) +#define WLED_CONNECTED (WLEDNetwork.isConnected()) #ifndef WLED_AP_SSID_UNIQUE #define WLED_SET_AP_SSID() do { \ From ba2b182bb31ceba4c76dc907f5303d82e841ac43 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 14 Aug 2025 18:26:12 +0100 Subject: [PATCH 02/45] Update platformio.ini for V5 --- platformio.ini | 104 ++++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/platformio.ini b/platformio.ini index d3b22653ff..b57cb13a0e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -108,6 +108,8 @@ ldscript_2m512k = eagle.flash.2m512.ld ldscript_2m1m = eagle.flash.2m1m.ld ldscript_4m1m = eagle.flash.4m1m.ld +default_usermods = ;; TODO: add back audioreactive once V5 compatible + [scripts_defaults] extra_scripts = pre:pio-scripts/set_version.py @@ -138,8 +140,8 @@ upload_speed = 115200 # ------------------------------------------------------------------------------ lib_compat_mode = strict lib_deps = - fastled/FastLED @ 3.6.0 - IRremoteESP8266 @ 2.8.2 + fastled/FastLED @ 3.10.1 +; IRremoteESP8266 @ 2.8.2 makuna/NeoPixelBus @ 2.8.3 #https://github.com/makuna/NeoPixelBus.git#CoreShaderBeta https://github.com/Aircoookie/ESPAsyncWebServer.git#v2.4.2 @@ -243,11 +245,11 @@ build_flags = -D WLED_ENABLE_GIF [esp32] -platform = ${esp32_idf_V4.platform} +platform = ${esp32_idf_V5.platform} platform_packages = build_unflags = ${common.build_unflags} -build_flags = ${esp32_idf_V4.build_flags} -lib_deps = ${esp32_idf_V4.lib_deps} +build_flags = ${esp32_idf_V5.build_flags} +lib_deps = ${esp32_idf_V5.lib_deps} tiny_partitions = tools/WLED_ESP32_2MB_noOTA.csv default_partitions = tools/WLED_ESP32_4MB_1MB_FS.csv @@ -262,28 +264,24 @@ AR_build_flags = ;; -fsingle-precision-constant ;; forces ArduinoFFT to use floa AR_lib_deps = ;; for pre-usermod-library platformio_override compatibility -[esp32_idf_V4] -;; build environment for ESP32 using ESP-IDF 4.4.x / arduino-esp32 v2.0.5 -;; -;; please note that you can NOT update existing ESP32 installs with a "V4" build. Also updating by OTA will not work properly. -;; You need to completely erase your device (esptool erase_flash) first, then install the "V4" build from VSCode+platformio. - -;; select arduino-esp32 v2.0.9 (arduino-esp32 2.0.10 thru 2.0.14 are buggy so avoid them) -platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.06.02/platform-espressif32.zip ;; Tasmota Arduino Core 2.0.9 with IPv6 support, based on IDF 4.4.4 +[esp32_idf_V5] +;; build environment for ESP32 using ESP-IDF 5.3.3 / arduino-esp32 v3.1.3 +platform = https://github.com/tasmota/platform-espressif32/releases/download/2025.08.30/platform-espressif32-2025.08.30.zip ;; Platform 2025.08.30 Tasmota Arduino Core 3.1.3.250808 based on IDF 5.3.3.250801 build_unflags = ${common.build_unflags} build_flags = -g -Wshadow=compatible-local ;; emit warning in case a local variable "shadows" another local one -DARDUINO_ARCH_ESP32 -DESP32 ${esp32_all_variants.build_flags} - -D WLED_ENABLE_DMX_INPUT + -D WLED_DISABLE_INFRARED ;; TODO: remove once we have updated library for V5 +; -D WLED_ENABLE_DMX_INPUT lib_deps = ${esp32_all_variants.lib_deps} - https://github.com/someweisguy/esp_dmx.git#47db25d +; https://github.com/someweisguy/esp_dmx.git#47db25d ${env.lib_deps} [esp32s2] ;; generic definitions for all ESP32-S2 boards -platform = ${esp32_idf_V4.platform} +platform = ${esp32_idf_V5.platform} build_unflags = ${common.build_unflags} build_flags = -g -DARDUINO_ARCH_ESP32 @@ -294,14 +292,14 @@ build_flags = -g -DARDUINO_USB_MODE=0 ;; this flag is mandatory for ESP32-S2 ! ;; please make sure that the following flags are properly set (to 0 or 1) by your board.json, or included in your custom platformio_override.ini entry: ;; ARDUINO_USB_CDC_ON_BOOT - ${esp32_idf_V4.build_flags} + ${esp32_idf_V5.build_flags} lib_deps = - ${esp32_idf_V4.lib_deps} + ${esp32_idf_V5.lib_deps} board_build.partitions = ${esp32.default_partitions} ;; default partioning for 4MB Flash - can be overridden in build envs [esp32c3] ;; generic definitions for all ESP32-C3 boards -platform = ${esp32_idf_V4.platform} +platform = ${esp32_idf_V5.platform} build_unflags = ${common.build_unflags} build_flags = -g -DARDUINO_ARCH_ESP32 @@ -311,15 +309,15 @@ build_flags = -g -DARDUINO_USB_MODE=1 ;; this flag is mandatory for ESP32-C3 ;; please make sure that the following flags are properly set (to 0 or 1) by your board.json, or included in your custom platformio_override.ini entry: ;; ARDUINO_USB_CDC_ON_BOOT - ${esp32_idf_V4.build_flags} + ${esp32_idf_V5.build_flags} lib_deps = - ${esp32_idf_V4.lib_deps} + ${esp32_idf_V5.lib_deps} board_build.partitions = ${esp32.default_partitions} ;; default partioning for 4MB Flash - can be overridden in build envs board_build.flash_mode = qio [esp32s3] ;; generic definitions for all ESP32-S3 boards -platform = ${esp32_idf_V4.platform} +platform = ${esp32_idf_V5.platform} build_unflags = ${common.build_unflags} build_flags = -g -DESP32 @@ -330,9 +328,9 @@ build_flags = -g -DCO ;; please make sure that the following flags are properly set (to 0 or 1) by your board.json, or included in your custom platformio_override.ini entry: ;; ARDUINO_USB_MODE, ARDUINO_USB_CDC_ON_BOOT - ${esp32_idf_V4.build_flags} + ${esp32_idf_V5.build_flags} lib_deps = - ${esp32_idf_V4.lib_deps} + ${esp32_idf_V5.lib_deps} board_build.partitions = ${esp32.large_partitions} ;; default partioning for 8MB flash - can be overridden in build envs @@ -365,7 +363,7 @@ extends = env:nodemcuv2 board_build.f_cpu = 160000000L build_flags = ${common.build_flags} ${esp8266.build_flags} -D WLED_RELEASE_NAME=\"ESP8266_160\" #-DWLED_DISABLE_2D -D WLED_DISABLE_PARTICLESYSTEM2D -custom_usermods = audioreactive +custom_usermods = ${common.default_usermods} [env:esp8266_2m] board = esp_wroom_02 @@ -393,7 +391,7 @@ board_build.f_cpu = 160000000L build_flags = ${common.build_flags} ${esp8266.build_flags} -D WLED_RELEASE_NAME=\"ESP02_160\" -D WLED_DISABLE_PARTICLESYSTEM1D -D WLED_DISABLE_PARTICLESYSTEM2D -custom_usermods = audioreactive +custom_usermods = ${common.default_usermods} [env:esp01_1m_full] board = esp01_1m @@ -423,27 +421,27 @@ build_flags = ${common.build_flags} ${esp8266.build_flags} -D WLED_RELEASE_NAME= ; -D WLED_USE_REAL_MATH ;; may fix wrong sunset/sunrise times, at the cost of 7064 bytes FLASH and 975 bytes RAM -D WLED_DISABLE_PARTICLESYSTEM1D -D WLED_DISABLE_PARTICLESYSTEM2D -custom_usermods = audioreactive +custom_usermods = ${common.default_usermods} [env:esp32dev] board = esp32dev -platform = ${esp32_idf_V4.platform} +platform = ${esp32_idf_V5.platform} build_unflags = ${common.build_unflags} -custom_usermods = audioreactive -build_flags = ${common.build_flags} ${esp32_idf_V4.build_flags} -D WLED_RELEASE_NAME=\"ESP32_V4\" #-D WLED_DISABLE_BROWNOUT_DET +custom_usermods = ${common.default_usermods} +build_flags = ${common.build_flags} ${esp32_idf_V5.build_flags} -D WLED_RELEASE_NAME=\"ESP32_V4\" #-D WLED_DISABLE_BROWNOUT_DET -DARDUINO_USB_CDC_ON_BOOT=0 ;; this flag is mandatory for "classic ESP32" when building with arduino-esp32 >=2.0.3 -lib_deps = ${esp32_idf_V4.lib_deps} +lib_deps = ${esp32_idf_V5.lib_deps} monitor_filters = esp32_exception_decoder board_build.partitions = ${esp32.default_partitions} board_build.flash_mode = dio [env:esp32dev_8M] board = esp32dev -platform = ${esp32_idf_V4.platform} -custom_usermods = audioreactive +platform = ${esp32_idf_V5.platform} +custom_usermods = ${common.default_usermods} build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} ${esp32_idf_V4.build_flags} -D WLED_RELEASE_NAME=\"ESP32_8M\" #-D WLED_DISABLE_BROWNOUT_DET -lib_deps = ${esp32_idf_V4.lib_deps} +build_flags = ${common.build_flags} ${esp32_idf_V5.build_flags} -D WLED_RELEASE_NAME=\"ESP32_8M\" #-D WLED_DISABLE_BROWNOUT_DET +lib_deps = ${esp32_idf_V5.lib_deps} monitor_filters = esp32_exception_decoder board_build.partitions = ${esp32.large_partitions} board_upload.flash_size = 8MB @@ -453,11 +451,11 @@ board_upload.maximum_size = 8388608 [env:esp32dev_16M] board = esp32dev -platform = ${esp32_idf_V4.platform} -custom_usermods = audioreactive +platform = ${esp32_idf_V5.platform} +custom_usermods = ${common.default_usermods} build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} ${esp32_idf_V4.build_flags} -D WLED_RELEASE_NAME=\"ESP32_16M\" #-D WLED_DISABLE_BROWNOUT_DET -lib_deps = ${esp32_idf_V4.lib_deps} +build_flags = ${common.build_flags} ${esp32_idf_V5.build_flags} -D WLED_RELEASE_NAME=\"ESP32_16M\" #-D WLED_DISABLE_BROWNOUT_DET +lib_deps = ${esp32_idf_V5.lib_deps} monitor_filters = esp32_exception_decoder board_build.partitions = ${esp32.extreme_partitions} board_upload.flash_size = 16MB @@ -467,9 +465,9 @@ board_build.flash_mode = dio [env:esp32_eth] board = esp32-poe -platform = ${esp32_idf_V4.platform} +platform = ${esp32_idf_V5.platform} upload_speed = 921600 -custom_usermods = audioreactive +custom_usermods = ${common.default_usermods} build_unflags = ${common.build_unflags} build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\"ESP32_Ethernet\" -D RLYPIN=-1 -D WLED_USE_ETHERNET -D BTNPIN=-1 ; -D WLED_DISABLE_ESPNOW ;; ESP-NOW requires wifi, may crash with ethernet only @@ -478,17 +476,17 @@ board_build.partitions = ${esp32.default_partitions} board_build.flash_mode = dio [env:esp32_wrover] -extends = esp32_idf_V4 +extends = esp32_idf_V5 board = ttgo-t7-v14-mini32 board_build.f_flash = 80000000L board_build.flash_mode = qio board_build.partitions = ${esp32.extended_partitions} -custom_usermods = audioreactive +custom_usermods = ${common.default_usermods} build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} ${esp32_idf_V4.build_flags} -D WLED_RELEASE_NAME=\"ESP32_WROVER\" +build_flags = ${common.build_flags} ${esp32_idf_V5.build_flags} -D WLED_RELEASE_NAME=\"ESP32_WROVER\" -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue ;; Older ESP32 (rev.<3) need a PSRAM fix (increases static RAM used) https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/external-ram.html -D DATA_PINS=25 -lib_deps = ${esp32_idf_V4.lib_deps} +lib_deps = ${esp32_idf_V5.lib_deps} [env:esp32c3dev] extends = esp32c3 @@ -511,7 +509,7 @@ board = esp32-s3-devkitc-1 ;; generic dev board; the next line adds PSRAM suppor board_build.arduino.memory_type = qio_opi ;; use with PSRAM: 8MB or 16MB platform = ${esp32s3.platform} upload_speed = 921600 -custom_usermods = audioreactive +custom_usermods = ${common.default_usermods} build_unflags = ${common.build_unflags} build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_16MB_opi\" -D CONFIG_LITTLEFS_FOR_IDF_3_2 -D WLED_WATCHDOG_TIMEOUT=0 @@ -532,7 +530,7 @@ board = esp32-s3-devkitc-1 ;; generic dev board; the next line adds PSRAM suppor board_build.arduino.memory_type = qio_opi ;; use with PSRAM: 8MB or 16MB platform = ${esp32s3.platform} upload_speed = 921600 -custom_usermods = audioreactive +custom_usermods = ${common.default_usermods} build_unflags = ${common.build_unflags} build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_8MB_opi\" -D CONFIG_LITTLEFS_FOR_IDF_3_2 -D WLED_WATCHDOG_TIMEOUT=0 @@ -552,7 +550,7 @@ platform = ${esp32s3.platform} board = esp32s3camlcd ;; this is the only standard board with "opi_opi" board_build.arduino.memory_type = opi_opi upload_speed = 921600 -custom_usermods = audioreactive +custom_usermods = ${common.default_usermods} build_unflags = ${common.build_unflags} build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_WROOM-2\" -D CONFIG_LITTLEFS_FOR_IDF_3_2 -D WLED_WATCHDOG_TIMEOUT=0 @@ -575,7 +573,7 @@ monitor_filters = esp32_exception_decoder board = lolin_s3_mini ;; -S3 mini, 4MB flash 2MB PSRAM platform = ${esp32s3.platform} upload_speed = 921600 -custom_usermods = audioreactive +custom_usermods = ${common.default_usermods} build_unflags = ${common.build_unflags} build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_4M_qspi\" -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") @@ -594,7 +592,7 @@ board = lolin_s2_mini board_build.partitions = ${esp32.default_partitions} board_build.flash_mode = qio board_build.f_flash = 80000000L -custom_usermods = audioreactive +custom_usermods = ${common.default_usermods} build_unflags = ${common.build_unflags} build_flags = ${common.build_flags} ${esp32s2.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S2\" -DARDUINO_USB_CDC_ON_BOOT=1 @@ -615,11 +613,11 @@ lib_deps = ${esp32s2.lib_deps} [env:usermods] board = esp32dev -platform = ${esp32_idf_V4.platform} +platform = ${esp32_idf_V5.platform} build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} ${esp32_idf_V4.build_flags} -D WLED_RELEASE_NAME=\"ESP32_USERMODS\" +build_flags = ${common.build_flags} ${esp32_idf_V5.build_flags} -D WLED_RELEASE_NAME=\"ESP32_USERMODS\" -DTOUCH_CS=9 -lib_deps = ${esp32_idf_V4.lib_deps} +lib_deps = ${esp32_idf_V5.lib_deps} monitor_filters = esp32_exception_decoder board_build.flash_mode = dio custom_usermods = * ; Expands to all usermods in usermods folder From 07ab6aa3ea9bf9836d6de04a2ee92a3e7fc854a4 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 14 Aug 2025 18:59:06 +0100 Subject: [PATCH 03/45] Rename Network to WLEDNetwork to prevent clash --- wled00/network.cpp | 2 +- wled00/src/dependencies/e131/ESPAsyncE131.cpp | 2 +- wled00/src/dependencies/espalexa/Espalexa.h | 2 +- wled00/udp.cpp | 6 +++--- wled00/wled.cpp | 16 ++++++++-------- wled00/wled_server.cpp | 2 +- wled00/xml.cpp | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/wled00/network.cpp b/wled00/network.cpp index 79209ff5e9..de326bbee6 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -358,7 +358,7 @@ void WiFiEvent(WiFiEvent_t event) DEBUG_PRINTF_P(PSTR("WiFi-E: AP Client Connected (%d) @ %lus.\n"), (int)apClients, millis()/1000); break; case ARDUINO_EVENT_WIFI_STA_GOT_IP: - DEBUG_PRINT(F("WiFi-E: IP address: ")); DEBUG_PRINTLN(Network.localIP()); + DEBUG_PRINT(F("WiFi-E: IP address: ")); DEBUG_PRINTLN(WLEDNetwork.localIP()); break; case ARDUINO_EVENT_WIFI_STA_CONNECTED: // followed by IDLE and SCAN_DONE diff --git a/wled00/src/dependencies/e131/ESPAsyncE131.cpp b/wled00/src/dependencies/e131/ESPAsyncE131.cpp index 75d6b8dc29..f086652d21 100644 --- a/wled00/src/dependencies/e131/ESPAsyncE131.cpp +++ b/wled00/src/dependencies/e131/ESPAsyncE131.cpp @@ -76,7 +76,7 @@ bool ESPAsyncE131::initMulticast(uint16_t port, uint16_t universe, uint8_t n) { ip4_addr_t ifaddr; ip4_addr_t multicast_addr; - ifaddr.addr = static_cast(Network.localIP()); + ifaddr.addr = static_cast(WLEDNetwork.localIP()); for (uint8_t i = 1; i < n; i++) { multicast_addr.addr = static_cast(IPAddress(239, 255, (((universe + i) >> 8) & 0xff), (((universe + i) >> 0) diff --git a/wled00/src/dependencies/espalexa/Espalexa.h b/wled00/src/dependencies/espalexa/Espalexa.h index 1e716ab456..82934c8a9d 100644 --- a/wled00/src/dependencies/espalexa/Espalexa.h +++ b/wled00/src/dependencies/espalexa/Espalexa.h @@ -344,7 +344,7 @@ class Espalexa { #ifdef ARDUINO_ARCH_ESP32 udpConnected = espalexaUdp.beginMulticast(IPAddress(239, 255, 255, 250), 1900); #else - udpConnected = espalexaUdp.beginMulticast(Network.localIP(), IPAddress(239, 255, 255, 250), 1900); + udpConnected = espalexaUdp.beginMulticast(WLEDNetwork.localIP(), IPAddress(239, 255, 255, 250), 1900); #endif if (udpConnected){ diff --git a/wled00/udp.cpp b/wled00/udp.cpp index bdb60c363a..4b96580da7 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -196,7 +196,7 @@ void notify(byte callMode, bool followUp) #endif { DEBUG_PRINTLN(F("UDP sending packet.")); - IPAddress broadcastIp = ~uint32_t(Network.subnetMask()) | uint32_t(Network.gatewayIP()); + IPAddress broadcastIp = ~uint32_t(WLEDNetwork.subnetMask()) | uint32_t(WLEDNetwork.gatewayIP()); notifierUdp.beginPacket(broadcastIp, udpPort); notifierUdp.write(udpOut, WLEDPACKETSIZE); // TODO: add actual used buffer size notifierUdp.endPacket(); @@ -516,7 +516,7 @@ void handleNotifications() } } - localIP = Network.localIP(); + localIP = WLEDNetwork.localIP(); //notifier and UDP realtime if (!packetSize || packetSize > UDP_IN_MAXSIZE) return; if (!isSupp && notifierUdp.remoteIP() == localIP) return; //don't process broadcasts we send ourselves @@ -707,7 +707,7 @@ void sendSysInfoUDP() { if (!udp2Connected) return; - IPAddress ip = Network.localIP(); + IPAddress ip = WLEDNetwork.localIP(); if (!ip || ip == IPAddress(255,255,255,255)) ip = IPAddress(4,3,2,1); // TODO: make a nice struct of it and clean up diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 5826b9ac38..4d535c2856 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -109,7 +109,7 @@ void WLED::loop() { if (apActive) dnsServer.processNextRequest(); #ifdef WLED_ENABLE_AOTA - if (Network.isConnected() && aOtaEnabled && !otaLock && correctPIN) ArduinoOTA.handle(); + if (WLEDNetwork.isConnected() && aOtaEnabled && !otaLock && correctPIN) ArduinoOTA.handle(); #endif handleNightlight(); yield(); @@ -262,7 +262,7 @@ void WLED::loop() lastWifiState = WiFi.status(); DEBUG_PRINTF_P(PSTR("State time: %lu\n"), wifiStateChangedTime); DEBUG_PRINTF_P(PSTR("NTP last sync: %lu\n"), ntpLastSyncTime); - DEBUG_PRINTF_P(PSTR("Client IP: %u.%u.%u.%u\n"), Network.localIP()[0], Network.localIP()[1], Network.localIP()[2], Network.localIP()[3]); + DEBUG_PRINTF_P(PSTR("Client IP: %u.%u.%u.%u\n"), WLEDNetwork.localIP()[0], WLEDNetwork.localIP()[1], WLEDNetwork.localIP()[2], WLEDNetwork.localIP()[3]); if (loops > 0) { // avoid division by zero DEBUG_PRINTF_P(PSTR("Loops/sec: %u\n"), loops / 30); DEBUG_PRINTF_P(PSTR("Loop time[ms]: %u/%lu\n"), avgLoopMillis/loops, maxLoopMillis); @@ -700,7 +700,7 @@ void WLED::initInterfaces() DEBUG_PRINTLN(F("Init STA interfaces")); #ifndef WLED_DISABLE_HUESYNC - IPAddress ipAddress = Network.localIP(); + IPAddress ipAddress = WLEDNetwork.localIP(); if (hueIP[0] == 0) { hueIP[0] = ipAddress[0]; hueIP[1] = ipAddress[1]; @@ -786,7 +786,7 @@ void WLED::handleConnection() if (stac != stacO) { stacO = stac; DEBUG_PRINTF_P(PSTR("Connected AP clients: %d\n"), (int)stac); - if (!Network.isConnected() && wifiConfigured) { // trying to connect, but not connected + if (!WLEDNetwork.isConnected() && wifiConfigured) { // trying to connect, but not connected if (stac) WiFi.disconnect(); // disable search so that AP can work else @@ -795,7 +795,7 @@ void WLED::handleConnection() } } - if (!Network.isConnected()) { + if (!WLEDNetwork.isConnected()) { if (interfacesInited) { if (scanDone && multiWiFi.size() > 1) { DEBUG_PRINTLN(F("WiFi scan initiated on disconnect.")); @@ -839,7 +839,7 @@ void WLED::handleConnection() } else if (!interfacesInited) { //newly connected DEBUG_PRINTLN(); DEBUG_PRINT(F("Connected! IP address: ")); - DEBUG_PRINTLN(Network.localIP()); + DEBUG_PRINTLN(WLEDNetwork.localIP()); if (improvActive) { if (improvError == 3) sendImprovStateResponse(0x00, true); sendImprovStateResponse(0x04); @@ -861,7 +861,7 @@ void WLED::handleConnection() } // If status LED pin is allocated for other uses, does nothing -// else blink at 1Hz when Network.isConnected() is false (no WiFi, ?? no Ethernet ??) +// else blink at 1Hz when WLEDNetwork.isConnected() is false (no WiFi, ?? no Ethernet ??) // else blink at 2Hz when MQTT is enabled but not connected // else turn the status LED off #if defined(STATUSLED) @@ -875,7 +875,7 @@ void WLED::handleStatusLED() } #endif - if (Network.isConnected()) { + if (WLEDNetwork.isConnected()) { c = RGBW32(0,255,0,0); ledStatusType = 2; } else if (WLED_MQTT_CONNECTED) { diff --git a/wled00/wled_server.cpp b/wled00/wled_server.cpp index f12b00ab27..20a6f185b5 100644 --- a/wled00/wled_server.cpp +++ b/wled00/wled_server.cpp @@ -44,7 +44,7 @@ static bool inSubnet(const IPAddress &ip, const IPAddress &subnet, const IPAddre } static bool inSameSubnet(const IPAddress &client) { - return inSubnet(client, Network.localIP(), Network.subnetMask()); + return inSubnet(client, WLEDNetwork.localIP(), WLEDNetwork.subnetMask()); } static bool inLocalSubnet(const IPAddress &client) { diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 987167d79f..e4f165732a 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -233,10 +233,10 @@ void getSettingsJS(byte subPage, Print& settingsScript) settingsScript.print(F("gId('ethd').style.display='none';")); #endif - if (Network.isConnected()) //is connected + if (WLEDNetwork.isConnected()) //is connected { char s[32]; - IPAddress localIP = Network.localIP(); + IPAddress localIP = WLEDNetwork.localIP(); sprintf(s, "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]); #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) From 1de8c2e79b810dc29ea8d870201d411b81956b0e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 16 Aug 2025 11:57:20 +0100 Subject: [PATCH 04/45] Remove local copy of MQTT and disable for now in build --- platformio.ini | 1 + .../async-mqtt-client/AsyncMqttClient.cpp | 877 ------------------ .../async-mqtt-client/AsyncMqttClient.h | 6 - .../async-mqtt-client/AsyncMqttClient.hpp | 166 ---- .../AsyncMqttClient/Callbacks.hpp | 28 - .../AsyncMqttClient/DisconnectReasons.hpp | 15 - .../AsyncMqttClient/Flags.hpp | 57 -- .../AsyncMqttClient/Helpers.hpp | 38 - .../AsyncMqttClient/MessageProperties.hpp | 7 - .../AsyncMqttClient/Packets/ConnAckPacket.cpp | 30 - .../AsyncMqttClient/Packets/ConnAckPacket.hpp | 25 - .../AsyncMqttClient/Packets/Packet.hpp | 11 - .../Packets/PingRespPacket.cpp | 21 - .../Packets/PingRespPacket.hpp | 21 - .../AsyncMqttClient/Packets/PubAckPacket.cpp | 30 - .../AsyncMqttClient/Packets/PubAckPacket.hpp | 25 - .../AsyncMqttClient/Packets/PubCompPacket.cpp | 30 - .../AsyncMqttClient/Packets/PubCompPacket.hpp | 25 - .../AsyncMqttClient/Packets/PubRecPacket.cpp | 30 - .../AsyncMqttClient/Packets/PubRecPacket.hpp | 25 - .../AsyncMqttClient/Packets/PubRelPacket.cpp | 30 - .../AsyncMqttClient/Packets/PubRelPacket.hpp | 25 - .../AsyncMqttClient/Packets/PublishPacket.cpp | 91 -- .../AsyncMqttClient/Packets/PublishPacket.hpp | 38 - .../AsyncMqttClient/Packets/SubAckPacket.cpp | 46 - .../AsyncMqttClient/Packets/SubAckPacket.hpp | 25 - .../Packets/UnsubAckPacket.cpp | 30 - .../Packets/UnsubAckPacket.hpp | 25 - .../AsyncMqttClient/ParsingInformation.hpp | 21 - .../AsyncMqttClient/Storage.hpp | 13 - .../dependencies/async-mqtt-client/LICENSE | 21 - .../dependencies/async-mqtt-client/README.md | 18 - 32 files changed, 1 insertion(+), 1850 deletions(-) delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.cpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.h delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Callbacks.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/DisconnectReasons.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Flags.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Helpers.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/MessageProperties.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/ConnAckPacket.cpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/ConnAckPacket.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/Packet.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PingRespPacket.cpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PingRespPacket.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubAckPacket.cpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubAckPacket.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubCompPacket.cpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubCompPacket.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRecPacket.cpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRecPacket.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRelPacket.cpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRelPacket.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PublishPacket.cpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PublishPacket.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/SubAckPacket.cpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/SubAckPacket.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/UnsubAckPacket.cpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/UnsubAckPacket.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/ParsingInformation.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Storage.hpp delete mode 100644 wled00/src/dependencies/async-mqtt-client/LICENSE delete mode 100644 wled00/src/dependencies/async-mqtt-client/README.md diff --git a/platformio.ini b/platformio.ini index b57cb13a0e..914834ed60 100644 --- a/platformio.ini +++ b/platformio.ini @@ -273,6 +273,7 @@ build_flags = -g -DARDUINO_ARCH_ESP32 -DESP32 ${esp32_all_variants.build_flags} -D WLED_DISABLE_INFRARED ;; TODO: remove once we have updated library for V5 + -D WLED_DISABLE_MQTT ;; TODO: remove once we have updated library for V5 ; -D WLED_ENABLE_DMX_INPUT lib_deps = ${esp32_all_variants.lib_deps} diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.cpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.cpp deleted file mode 100644 index d0c44cb6ba..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.cpp +++ /dev/null @@ -1,877 +0,0 @@ -#include "AsyncMqttClient.hpp" - -AsyncMqttClient::AsyncMqttClient() -: _connected(false) -, _connectPacketNotEnoughSpace(false) -, _disconnectFlagged(false) -, _tlsBadFingerprint(false) -, _lastClientActivity(0) -, _lastServerActivity(0) -, _lastPingRequestTime(0) -, _host(nullptr) -, _useIp(false) -#if ASYNC_TCP_SSL_ENABLED -, _secure(false) -#endif -, _port(0) -, _keepAlive(15) -, _cleanSession(true) -, _clientId(nullptr) -, _username(nullptr) -, _password(nullptr) -, _willTopic(nullptr) -, _willPayload(nullptr) -, _willPayloadLength(0) -, _willQos(0) -, _willRetain(false) -, _parsingInformation { .bufferState = AsyncMqttClientInternals::BufferState::NONE } -, _currentParsedPacket(nullptr) -, _remainingLengthBufferPosition(0) -, _nextPacketId(1) { - _client.onConnect([](void* obj, AsyncClient* c) { (static_cast(obj))->_onConnect(c); }, this); - _client.onDisconnect([](void* obj, AsyncClient* c) { (static_cast(obj))->_onDisconnect(c); }, this); - _client.onError([](void* obj, AsyncClient* c, int8_t error) { (static_cast(obj))->_onError(c, error); }, this); - _client.onTimeout([](void* obj, AsyncClient* c, uint32_t time) { (static_cast(obj))->_onTimeout(c, time); }, this); - _client.onAck([](void* obj, AsyncClient* c, size_t len, uint32_t time) { (static_cast(obj))->_onAck(c, len, time); }, this); - _client.onData([](void* obj, AsyncClient* c, void* data, size_t len) { (static_cast(obj))->_onData(c, static_cast(data), len); }, this); - _client.onPoll([](void* obj, AsyncClient* c) { (static_cast(obj))->_onPoll(c); }, this); - -#ifdef ESP32 - sprintf(_generatedClientId, "esp32%06x", (uint32_t)ESP.getEfuseMac()); - _xSemaphore = xSemaphoreCreateMutex(); -#elif defined(ESP8266) - sprintf(_generatedClientId, "esp8266%06x", (uint32_t)ESP.getChipId()); -#endif - _clientId = _generatedClientId; - - setMaxTopicLength(128); -} - -AsyncMqttClient::~AsyncMqttClient() { - delete _currentParsedPacket; - delete[] _parsingInformation.topicBuffer; -#ifdef ESP32 - vSemaphoreDelete(_xSemaphore); -#endif -} - -AsyncMqttClient& AsyncMqttClient::setKeepAlive(uint16_t keepAlive) { - _keepAlive = keepAlive; - return *this; -} - -AsyncMqttClient& AsyncMqttClient::setClientId(const char* clientId) { - _clientId = clientId; - return *this; -} - -AsyncMqttClient& AsyncMqttClient::setCleanSession(bool cleanSession) { - _cleanSession = cleanSession; - return *this; -} - -AsyncMqttClient& AsyncMqttClient::setMaxTopicLength(uint16_t maxTopicLength) { - _parsingInformation.maxTopicLength = maxTopicLength; - delete[] _parsingInformation.topicBuffer; - _parsingInformation.topicBuffer = new char[maxTopicLength + 1]; - return *this; -} - -AsyncMqttClient& AsyncMqttClient::setCredentials(const char* username, const char* password) { - _username = username; - _password = password; - return *this; -} - -AsyncMqttClient& AsyncMqttClient::setWill(const char* topic, uint8_t qos, bool retain, const char* payload, size_t length) { - _willTopic = topic; - _willQos = qos; - _willRetain = retain; - _willPayload = payload; - _willPayloadLength = length; - return *this; -} - -AsyncMqttClient& AsyncMqttClient::setServer(IPAddress ip, uint16_t port) { - _useIp = true; - _ip = ip; - _port = port; - return *this; -} - -AsyncMqttClient& AsyncMqttClient::setServer(const char* host, uint16_t port) { - _useIp = false; - _host = host; - _port = port; - return *this; -} - -#if ASYNC_TCP_SSL_ENABLED -AsyncMqttClient& AsyncMqttClient::setSecure(bool secure) { - _secure = secure; - return *this; -} - -AsyncMqttClient& AsyncMqttClient::addServerFingerprint(const uint8_t* fingerprint) { - std::array newFingerprint; - memcpy(newFingerprint.data(), fingerprint, SHA1_SIZE); - _secureServerFingerprints.push_back(newFingerprint); - return *this; -} -#endif - -AsyncMqttClient& AsyncMqttClient::onConnect(AsyncMqttClientInternals::OnConnectUserCallback callback) { - _onConnectUserCallbacks.push_back(callback); - return *this; -} - -AsyncMqttClient& AsyncMqttClient::onDisconnect(AsyncMqttClientInternals::OnDisconnectUserCallback callback) { - _onDisconnectUserCallbacks.push_back(callback); - return *this; -} - -AsyncMqttClient& AsyncMqttClient::onSubscribe(AsyncMqttClientInternals::OnSubscribeUserCallback callback) { - _onSubscribeUserCallbacks.push_back(callback); - return *this; -} - -AsyncMqttClient& AsyncMqttClient::onUnsubscribe(AsyncMqttClientInternals::OnUnsubscribeUserCallback callback) { - _onUnsubscribeUserCallbacks.push_back(callback); - return *this; -} - -AsyncMqttClient& AsyncMqttClient::onMessage(AsyncMqttClientInternals::OnMessageUserCallback callback) { - _onMessageUserCallbacks.push_back(callback); - return *this; -} - -AsyncMqttClient& AsyncMqttClient::onPublish(AsyncMqttClientInternals::OnPublishUserCallback callback) { - _onPublishUserCallbacks.push_back(callback); - return *this; -} - -void AsyncMqttClient::_freeCurrentParsedPacket() { - delete _currentParsedPacket; - _currentParsedPacket = nullptr; -} - -void AsyncMqttClient::_clear() { - _lastPingRequestTime = 0; - _connected = false; - _disconnectFlagged = false; - _connectPacketNotEnoughSpace = false; - _tlsBadFingerprint = false; - _freeCurrentParsedPacket(); - - _pendingPubRels.clear(); - _pendingPubRels.shrink_to_fit(); - - _toSendAcks.clear(); - _toSendAcks.shrink_to_fit(); - - _nextPacketId = 1; - _parsingInformation.bufferState = AsyncMqttClientInternals::BufferState::NONE; -} - -/* TCP */ -void AsyncMqttClient::_onConnect(AsyncClient* client) { - (void)client; - -#if ASYNC_TCP_SSL_ENABLED - if (_secure && _secureServerFingerprints.size() > 0) { - SSL* clientSsl = _client.getSSL(); - - bool sslFoundFingerprint = false; - for (std::array fingerprint : _secureServerFingerprints) { - if (ssl_match_fingerprint(clientSsl, fingerprint.data()) == SSL_OK) { - sslFoundFingerprint = true; - break; - } - } - - if (!sslFoundFingerprint) { - _tlsBadFingerprint = true; - _client.close(true); - return; - } - } -#endif - - char fixedHeader[5]; - fixedHeader[0] = AsyncMqttClientInternals::PacketType.CONNECT; - fixedHeader[0] = fixedHeader[0] << 4; - fixedHeader[0] = fixedHeader[0] | AsyncMqttClientInternals::HeaderFlag.CONNECT_RESERVED; - - uint16_t protocolNameLength = 4; - char protocolNameLengthBytes[2]; - protocolNameLengthBytes[0] = protocolNameLength >> 8; - protocolNameLengthBytes[1] = protocolNameLength & 0xFF; - - char protocolLevel[1]; - protocolLevel[0] = 0x04; - - char connectFlags[1]; - connectFlags[0] = 0; - if (_cleanSession) connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.CLEAN_SESSION; - if (_username != nullptr) connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.USERNAME; - if (_password != nullptr) connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.PASSWORD; - if (_willTopic != nullptr) { - connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL; - if (_willRetain) connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL_RETAIN; - switch (_willQos) { - case 0: - connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL_QOS0; - break; - case 1: - connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL_QOS1; - break; - case 2: - connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL_QOS2; - break; - } - } - - char keepAliveBytes[2]; - keepAliveBytes[0] = _keepAlive >> 8; - keepAliveBytes[1] = _keepAlive & 0xFF; - - uint16_t clientIdLength = strlen(_clientId); - char clientIdLengthBytes[2]; - clientIdLengthBytes[0] = clientIdLength >> 8; - clientIdLengthBytes[1] = clientIdLength & 0xFF; - - // Optional fields - uint16_t willTopicLength = 0; - char willTopicLengthBytes[2]; - uint16_t willPayloadLength = _willPayloadLength; - char willPayloadLengthBytes[2]; - if (_willTopic != nullptr) { - willTopicLength = strlen(_willTopic); - willTopicLengthBytes[0] = willTopicLength >> 8; - willTopicLengthBytes[1] = willTopicLength & 0xFF; - - if (_willPayload != nullptr && willPayloadLength == 0) willPayloadLength = strlen(_willPayload); - - willPayloadLengthBytes[0] = willPayloadLength >> 8; - willPayloadLengthBytes[1] = willPayloadLength & 0xFF; - } - - uint16_t usernameLength = 0; - char usernameLengthBytes[2]; - if (_username != nullptr) { - usernameLength = strlen(_username); - usernameLengthBytes[0] = usernameLength >> 8; - usernameLengthBytes[1] = usernameLength & 0xFF; - } - - uint16_t passwordLength = 0; - char passwordLengthBytes[2]; - if (_password != nullptr) { - passwordLength = strlen(_password); - passwordLengthBytes[0] = passwordLength >> 8; - passwordLengthBytes[1] = passwordLength & 0xFF; - } - - uint32_t remainingLength = 2 + protocolNameLength + 1 + 1 + 2 + 2 + clientIdLength; // always present - if (_willTopic != nullptr) remainingLength += 2 + willTopicLength + 2 + willPayloadLength; - if (_username != nullptr) remainingLength += 2 + usernameLength; - if (_password != nullptr) remainingLength += 2 + passwordLength; - uint8_t remainingLengthLength = AsyncMqttClientInternals::Helpers::encodeRemainingLength(remainingLength, fixedHeader + 1); - - uint32_t neededSpace = 1 + remainingLengthLength; - neededSpace += 2; - neededSpace += protocolNameLength; - neededSpace += 1; - neededSpace += 1; - neededSpace += 2; - neededSpace += 2; - neededSpace += clientIdLength; - if (_willTopic != nullptr) { - neededSpace += 2; - neededSpace += willTopicLength; - - neededSpace += 2; - if (_willPayload != nullptr) neededSpace += willPayloadLength; - } - if (_username != nullptr) { - neededSpace += 2; - neededSpace += usernameLength; - } - if (_password != nullptr) { - neededSpace += 2; - neededSpace += passwordLength; - } - - SEMAPHORE_TAKE(); - if (_client.space() < neededSpace) { - _connectPacketNotEnoughSpace = true; - _client.close(true); - SEMAPHORE_GIVE(); - return; - } - - _client.add(fixedHeader, 1 + remainingLengthLength); - _client.add(protocolNameLengthBytes, 2); - _client.add("MQTT", protocolNameLength); - _client.add(protocolLevel, 1); - _client.add(connectFlags, 1); - _client.add(keepAliveBytes, 2); - _client.add(clientIdLengthBytes, 2); - _client.add(_clientId, clientIdLength); - if (_willTopic != nullptr) { - _client.add(willTopicLengthBytes, 2); - _client.add(_willTopic, willTopicLength); - - _client.add(willPayloadLengthBytes, 2); - if (_willPayload != nullptr) _client.add(_willPayload, willPayloadLength); - } - if (_username != nullptr) { - _client.add(usernameLengthBytes, 2); - _client.add(_username, usernameLength); - } - if (_password != nullptr) { - _client.add(passwordLengthBytes, 2); - _client.add(_password, passwordLength); - } - _client.send(); - _lastClientActivity = millis(); - SEMAPHORE_GIVE(); -} - -void AsyncMqttClient::_onDisconnect(AsyncClient* client) { - (void)client; - if (!_disconnectFlagged) { - AsyncMqttClientDisconnectReason reason; - - if (_connectPacketNotEnoughSpace) { - reason = AsyncMqttClientDisconnectReason::ESP8266_NOT_ENOUGH_SPACE; - } else if (_tlsBadFingerprint) { - reason = AsyncMqttClientDisconnectReason::TLS_BAD_FINGERPRINT; - } else { - reason = AsyncMqttClientDisconnectReason::TCP_DISCONNECTED; - } - for (auto callback : _onDisconnectUserCallbacks) callback(reason); - } - _clear(); -} - -void AsyncMqttClient::_onError(AsyncClient* client, int8_t error) { - (void)client; - (void)error; - // _onDisconnect called anyway -} - -void AsyncMqttClient::_onTimeout(AsyncClient* client, uint32_t time) { - (void)client; - (void)time; - // disconnection will be handled by ping/pong management -} - -void AsyncMqttClient::_onAck(AsyncClient* client, size_t len, uint32_t time) { - (void)client; - (void)len; - (void)time; -} - -void AsyncMqttClient::_onData(AsyncClient* client, char* data, size_t len) { - (void)client; - size_t currentBytePosition = 0; - char currentByte; - do { - switch (_parsingInformation.bufferState) { - case AsyncMqttClientInternals::BufferState::NONE: - currentByte = data[currentBytePosition++]; - _parsingInformation.packetType = currentByte >> 4; - _parsingInformation.packetFlags = (currentByte << 4) >> 4; - _parsingInformation.bufferState = AsyncMqttClientInternals::BufferState::REMAINING_LENGTH; - _lastServerActivity = millis(); - switch (_parsingInformation.packetType) { - case AsyncMqttClientInternals::PacketType.CONNACK: - _currentParsedPacket = new AsyncMqttClientInternals::ConnAckPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onConnAck, this, std::placeholders::_1, std::placeholders::_2)); - break; - case AsyncMqttClientInternals::PacketType.PINGRESP: - _currentParsedPacket = new AsyncMqttClientInternals::PingRespPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onPingResp, this)); - break; - case AsyncMqttClientInternals::PacketType.SUBACK: - _currentParsedPacket = new AsyncMqttClientInternals::SubAckPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onSubAck, this, std::placeholders::_1, std::placeholders::_2)); - break; - case AsyncMqttClientInternals::PacketType.UNSUBACK: - _currentParsedPacket = new AsyncMqttClientInternals::UnsubAckPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onUnsubAck, this, std::placeholders::_1)); - break; - case AsyncMqttClientInternals::PacketType.PUBLISH: - _currentParsedPacket = new AsyncMqttClientInternals::PublishPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onMessage, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8, std::placeholders::_9), std::bind(&AsyncMqttClient::_onPublish, this, std::placeholders::_1, std::placeholders::_2)); - break; - case AsyncMqttClientInternals::PacketType.PUBREL: - _currentParsedPacket = new AsyncMqttClientInternals::PubRelPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onPubRel, this, std::placeholders::_1)); - break; - case AsyncMqttClientInternals::PacketType.PUBACK: - _currentParsedPacket = new AsyncMqttClientInternals::PubAckPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onPubAck, this, std::placeholders::_1)); - break; - case AsyncMqttClientInternals::PacketType.PUBREC: - _currentParsedPacket = new AsyncMqttClientInternals::PubRecPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onPubRec, this, std::placeholders::_1)); - break; - case AsyncMqttClientInternals::PacketType.PUBCOMP: - _currentParsedPacket = new AsyncMqttClientInternals::PubCompPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onPubComp, this, std::placeholders::_1)); - break; - default: - break; - } - break; - case AsyncMqttClientInternals::BufferState::REMAINING_LENGTH: - currentByte = data[currentBytePosition++]; - _remainingLengthBuffer[_remainingLengthBufferPosition++] = currentByte; - if (currentByte >> 7 == 0) { - _parsingInformation.remainingLength = AsyncMqttClientInternals::Helpers::decodeRemainingLength(_remainingLengthBuffer); - _remainingLengthBufferPosition = 0; - if (_parsingInformation.remainingLength > 0) { - _parsingInformation.bufferState = AsyncMqttClientInternals::BufferState::VARIABLE_HEADER; - } else { - // PINGRESP is a special case where it has no variable header, so the packet ends right here - _parsingInformation.bufferState = AsyncMqttClientInternals::BufferState::NONE; - _onPingResp(); - } - } - break; - case AsyncMqttClientInternals::BufferState::VARIABLE_HEADER: - _currentParsedPacket->parseVariableHeader(data, len, ¤tBytePosition); - break; - case AsyncMqttClientInternals::BufferState::PAYLOAD: - _currentParsedPacket->parsePayload(data, len, ¤tBytePosition); - break; - default: - currentBytePosition = len; - } - } while (currentBytePosition != len); -} - -void AsyncMqttClient::_onPoll(AsyncClient* client) { - if (!_connected) return; - - // if there is too much time the client has sent a ping request without a response, disconnect client to avoid half open connections - if (_lastPingRequestTime != 0 && (millis() - _lastPingRequestTime) >= (_keepAlive * 1000 * 2)) { - disconnect(); - return; - // send ping to ensure the server will receive at least one message inside keepalive window - } else if (_lastPingRequestTime == 0 && (millis() - _lastClientActivity) >= (_keepAlive * 1000 * 0.7)) { - _sendPing(); - - // send ping to verify if the server is still there (ensure this is not a half connection) - } else if (_connected && _lastPingRequestTime == 0 && (millis() - _lastServerActivity) >= (_keepAlive * 1000 * 0.7)) { - _sendPing(); - } - - // handle to send ack packets - - _sendAcks(); - - // handle disconnect - - if (_disconnectFlagged) { - _sendDisconnect(); - } -} - -/* MQTT */ -void AsyncMqttClient::_onPingResp() { - _freeCurrentParsedPacket(); - _lastPingRequestTime = 0; -} - -void AsyncMqttClient::_onConnAck(bool sessionPresent, uint8_t connectReturnCode) { - (void)sessionPresent; - _freeCurrentParsedPacket(); - - if (connectReturnCode == 0) { - _connected = true; - for (auto callback : _onConnectUserCallbacks) callback(sessionPresent); - } else { - for (auto callback : _onDisconnectUserCallbacks) callback(static_cast(connectReturnCode)); - _disconnectFlagged = true; - } -} - -void AsyncMqttClient::_onSubAck(uint16_t packetId, char status) { - _freeCurrentParsedPacket(); - - for (auto callback : _onSubscribeUserCallbacks) callback(packetId, status); -} - -void AsyncMqttClient::_onUnsubAck(uint16_t packetId) { - _freeCurrentParsedPacket(); - - for (auto callback : _onUnsubscribeUserCallbacks) callback(packetId); -} - -void AsyncMqttClient::_onMessage(char* topic, char* payload, uint8_t qos, bool dup, bool retain, size_t len, size_t index, size_t total, uint16_t packetId) { - bool notifyPublish = true; - - if (qos == 2) { - for (AsyncMqttClientInternals::PendingPubRel pendingPubRel : _pendingPubRels) { - if (pendingPubRel.packetId == packetId) { - notifyPublish = false; - break; - } - } - } - - if (notifyPublish) { - AsyncMqttClientMessageProperties properties; - properties.qos = qos; - properties.dup = dup; - properties.retain = retain; - - for (auto callback : _onMessageUserCallbacks) callback(topic, payload, properties, len, index, total); - } -} - -void AsyncMqttClient::_onPublish(uint16_t packetId, uint8_t qos) { - AsyncMqttClientInternals::PendingAck pendingAck; - - if (qos == 1) { - pendingAck.packetType = AsyncMqttClientInternals::PacketType.PUBACK; - pendingAck.headerFlag = AsyncMqttClientInternals::HeaderFlag.PUBACK_RESERVED; - pendingAck.packetId = packetId; - _toSendAcks.push_back(pendingAck); - } else if (qos == 2) { - pendingAck.packetType = AsyncMqttClientInternals::PacketType.PUBREC; - pendingAck.headerFlag = AsyncMqttClientInternals::HeaderFlag.PUBREC_RESERVED; - pendingAck.packetId = packetId; - _toSendAcks.push_back(pendingAck); - - bool pubRelAwaiting = false; - for (AsyncMqttClientInternals::PendingPubRel pendingPubRel : _pendingPubRels) { - if (pendingPubRel.packetId == packetId) { - pubRelAwaiting = true; - break; - } - } - - if (!pubRelAwaiting) { - AsyncMqttClientInternals::PendingPubRel pendingPubRel; - pendingPubRel.packetId = packetId; - _pendingPubRels.push_back(pendingPubRel); - } - - _sendAcks(); - } - - _freeCurrentParsedPacket(); -} - -void AsyncMqttClient::_onPubRel(uint16_t packetId) { - _freeCurrentParsedPacket(); - - AsyncMqttClientInternals::PendingAck pendingAck; - pendingAck.packetType = AsyncMqttClientInternals::PacketType.PUBCOMP; - pendingAck.headerFlag = AsyncMqttClientInternals::HeaderFlag.PUBCOMP_RESERVED; - pendingAck.packetId = packetId; - _toSendAcks.push_back(pendingAck); - - for (size_t i = 0; i < _pendingPubRels.size(); i++) { - if (_pendingPubRels[i].packetId == packetId) { - _pendingPubRels.erase(_pendingPubRels.begin() + i); - _pendingPubRels.shrink_to_fit(); - } - } - - _sendAcks(); -} - -void AsyncMqttClient::_onPubAck(uint16_t packetId) { - _freeCurrentParsedPacket(); - - for (auto callback : _onPublishUserCallbacks) callback(packetId); -} - -void AsyncMqttClient::_onPubRec(uint16_t packetId) { - _freeCurrentParsedPacket(); - - AsyncMqttClientInternals::PendingAck pendingAck; - pendingAck.packetType = AsyncMqttClientInternals::PacketType.PUBREL; - pendingAck.headerFlag = AsyncMqttClientInternals::HeaderFlag.PUBREL_RESERVED; - pendingAck.packetId = packetId; - _toSendAcks.push_back(pendingAck); - - _sendAcks(); -} - -void AsyncMqttClient::_onPubComp(uint16_t packetId) { - _freeCurrentParsedPacket(); - - for (auto callback : _onPublishUserCallbacks) callback(packetId); -} - -bool AsyncMqttClient::_sendPing() { - char fixedHeader[2]; - fixedHeader[0] = AsyncMqttClientInternals::PacketType.PINGREQ; - fixedHeader[0] = fixedHeader[0] << 4; - fixedHeader[0] = fixedHeader[0] | AsyncMqttClientInternals::HeaderFlag.PINGREQ_RESERVED; - fixedHeader[1] = 0; - - size_t neededSpace = 2; - - SEMAPHORE_TAKE(false); - if (_client.space() < neededSpace) { SEMAPHORE_GIVE(); return false; } - - _client.add(fixedHeader, 2); - _client.send(); - _lastClientActivity = millis(); - _lastPingRequestTime = millis(); - - SEMAPHORE_GIVE(); - return true; -} - -void AsyncMqttClient::_sendAcks() { - uint8_t neededAckSpace = 2 + 2; - - SEMAPHORE_TAKE(); - for (size_t i = 0; i < _toSendAcks.size(); i++) { - if (_client.space() < neededAckSpace) break; - - AsyncMqttClientInternals::PendingAck pendingAck = _toSendAcks[i]; - - char fixedHeader[2]; - fixedHeader[0] = pendingAck.packetType; - fixedHeader[0] = fixedHeader[0] << 4; - fixedHeader[0] = fixedHeader[0] | pendingAck.headerFlag; - fixedHeader[1] = 2; - - char packetIdBytes[2]; - packetIdBytes[0] = pendingAck.packetId >> 8; - packetIdBytes[1] = pendingAck.packetId & 0xFF; - - _client.add(fixedHeader, 2); - _client.add(packetIdBytes, 2); - _client.send(); - - _toSendAcks.erase(_toSendAcks.begin() + i); - _toSendAcks.shrink_to_fit(); - - _lastClientActivity = millis(); - } - SEMAPHORE_GIVE(); -} - -bool AsyncMqttClient::_sendDisconnect() { - if (!_connected) return true; - - const uint8_t neededSpace = 2; - - SEMAPHORE_TAKE(false); - - if (_client.space() < neededSpace) { SEMAPHORE_GIVE(); return false; } - - char fixedHeader[2]; - fixedHeader[0] = AsyncMqttClientInternals::PacketType.DISCONNECT; - fixedHeader[0] = fixedHeader[0] << 4; - fixedHeader[0] = fixedHeader[0] | AsyncMqttClientInternals::HeaderFlag.DISCONNECT_RESERVED; - fixedHeader[1] = 0; - - _client.add(fixedHeader, 2); - _client.send(); - _client.close(true); - - _disconnectFlagged = false; - - SEMAPHORE_GIVE(); - return true; -} - -uint16_t AsyncMqttClient::_getNextPacketId() { - uint16_t nextPacketId = _nextPacketId; - - if (_nextPacketId == 65535) _nextPacketId = 0; // 0 is forbidden - _nextPacketId++; - - return nextPacketId; -} - -bool AsyncMqttClient::connected() const { - return _connected; -} - -void AsyncMqttClient::connect() { - if (_connected) return; - -#if ASYNC_TCP_SSL_ENABLED - if (_useIp) { - _client.connect(_ip, _port, _secure); - } else { - _client.connect(_host, _port, _secure); - } -#else - if (_useIp) { - _client.connect(_ip, _port); - } else { - _client.connect(_host, _port); - } -#endif -} - -void AsyncMqttClient::disconnect(bool force) { - if (!_connected) return; - - if (force) { - _client.close(true); - } else { - _disconnectFlagged = true; - _sendDisconnect(); - } -} - -uint16_t AsyncMqttClient::subscribe(const char* topic, uint8_t qos) { - if (!_connected) return 0; - - char fixedHeader[5]; - fixedHeader[0] = AsyncMqttClientInternals::PacketType.SUBSCRIBE; - fixedHeader[0] = fixedHeader[0] << 4; - fixedHeader[0] = fixedHeader[0] | AsyncMqttClientInternals::HeaderFlag.SUBSCRIBE_RESERVED; - - uint16_t topicLength = strlen(topic); - char topicLengthBytes[2]; - topicLengthBytes[0] = topicLength >> 8; - topicLengthBytes[1] = topicLength & 0xFF; - - char qosByte[1]; - qosByte[0] = qos; - - uint8_t remainingLengthLength = AsyncMqttClientInternals::Helpers::encodeRemainingLength(2 + 2 + topicLength + 1, fixedHeader + 1); - - size_t neededSpace = 0; - neededSpace += 1 + remainingLengthLength; - neededSpace += 2; - neededSpace += 2; - neededSpace += topicLength; - neededSpace += 1; - - SEMAPHORE_TAKE(0); - if (_client.space() < neededSpace) { SEMAPHORE_GIVE(); return 0; } - - uint16_t packetId = _getNextPacketId(); - char packetIdBytes[2]; - packetIdBytes[0] = packetId >> 8; - packetIdBytes[1] = packetId & 0xFF; - - _client.add(fixedHeader, 1 + remainingLengthLength); - _client.add(packetIdBytes, 2); - _client.add(topicLengthBytes, 2); - _client.add(topic, topicLength); - _client.add(qosByte, 1); - _client.send(); - _lastClientActivity = millis(); - - SEMAPHORE_GIVE(); - return packetId; -} - -uint16_t AsyncMqttClient::unsubscribe(const char* topic) { - if (!_connected) return 0; - - char fixedHeader[5]; - fixedHeader[0] = AsyncMqttClientInternals::PacketType.UNSUBSCRIBE; - fixedHeader[0] = fixedHeader[0] << 4; - fixedHeader[0] = fixedHeader[0] | AsyncMqttClientInternals::HeaderFlag.UNSUBSCRIBE_RESERVED; - - uint16_t topicLength = strlen(topic); - char topicLengthBytes[2]; - topicLengthBytes[0] = topicLength >> 8; - topicLengthBytes[1] = topicLength & 0xFF; - - uint8_t remainingLengthLength = AsyncMqttClientInternals::Helpers::encodeRemainingLength(2 + 2 + topicLength, fixedHeader + 1); - - size_t neededSpace = 0; - neededSpace += 1 + remainingLengthLength; - neededSpace += 2; - neededSpace += 2; - neededSpace += topicLength; - - SEMAPHORE_TAKE(0); - if (_client.space() < neededSpace) { SEMAPHORE_GIVE(); return 0; } - - uint16_t packetId = _getNextPacketId(); - char packetIdBytes[2]; - packetIdBytes[0] = packetId >> 8; - packetIdBytes[1] = packetId & 0xFF; - - _client.add(fixedHeader, 1 + remainingLengthLength); - _client.add(packetIdBytes, 2); - _client.add(topicLengthBytes, 2); - _client.add(topic, topicLength); - _client.send(); - _lastClientActivity = millis(); - - SEMAPHORE_GIVE(); - return packetId; -} - -uint16_t AsyncMqttClient::publish(const char* topic, uint8_t qos, bool retain, const char* payload, size_t length, bool dup, uint16_t message_id) { - if (!_connected) return 0; - - char fixedHeader[5]; - fixedHeader[0] = AsyncMqttClientInternals::PacketType.PUBLISH; - fixedHeader[0] = fixedHeader[0] << 4; - if (dup) fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_DUP; - if (retain) fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_RETAIN; - switch (qos) { - case 0: - fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_QOS0; - break; - case 1: - fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_QOS1; - break; - case 2: - fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_QOS2; - break; - } - - uint16_t topicLength = strlen(topic); - char topicLengthBytes[2]; - topicLengthBytes[0] = topicLength >> 8; - topicLengthBytes[1] = topicLength & 0xFF; - - uint32_t payloadLength = length; - if (payload != nullptr && payloadLength == 0) payloadLength = strlen(payload); - - uint32_t remainingLength = 2 + topicLength + payloadLength; - if (qos != 0) remainingLength += 2; - uint8_t remainingLengthLength = AsyncMqttClientInternals::Helpers::encodeRemainingLength(remainingLength, fixedHeader + 1); - - size_t neededSpace = 0; - neededSpace += 1 + remainingLengthLength; - neededSpace += 2; - neededSpace += topicLength; - if (qos != 0) neededSpace += 2; - if (payload != nullptr) neededSpace += payloadLength; - - SEMAPHORE_TAKE(0); - if (_client.space() < neededSpace) { SEMAPHORE_GIVE(); return 0; } - - uint16_t packetId = 0; - char packetIdBytes[2]; - if (qos != 0) { - if (dup && message_id > 0) { - packetId = message_id; - } else { - packetId = _getNextPacketId(); - } - - packetIdBytes[0] = packetId >> 8; - packetIdBytes[1] = packetId & 0xFF; - } - - _client.add(fixedHeader, 1 + remainingLengthLength); - _client.add(topicLengthBytes, 2); - _client.add(topic, topicLength); - if (qos != 0) _client.add(packetIdBytes, 2); - if (payload != nullptr) _client.add(payload, payloadLength); - _client.send(); - _lastClientActivity = millis(); - - SEMAPHORE_GIVE(); - if (qos != 0) { - return packetId; - } else { - return 1; - } -} diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.h b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.h deleted file mode 100644 index 23d30554d8..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef SRC_ASYNCMQTTCLIENT_H_ -#define SRC_ASYNCMQTTCLIENT_H_ - -#include "AsyncMqttClient.hpp" - -#endif // SRC_ASYNCMQTTCLIENT_H_ diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.hpp deleted file mode 100644 index af8332b24e..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.hpp +++ /dev/null @@ -1,166 +0,0 @@ -#pragma once - -#include -#include - -#include "Arduino.h" - -#ifdef ESP32 -#include -#include -#elif defined(ESP8266) -#include -#else -#error Platform not supported -#endif - -#if ASYNC_TCP_SSL_ENABLED -#include -#define SHA1_SIZE 20 -#endif - -#include "AsyncMqttClient/Flags.hpp" -#include "AsyncMqttClient/ParsingInformation.hpp" -#include "AsyncMqttClient/MessageProperties.hpp" -#include "AsyncMqttClient/Helpers.hpp" -#include "AsyncMqttClient/Callbacks.hpp" -#include "AsyncMqttClient/DisconnectReasons.hpp" -#include "AsyncMqttClient/Storage.hpp" - -#include "AsyncMqttClient/Packets/Packet.hpp" -#include "AsyncMqttClient/Packets/ConnAckPacket.hpp" -#include "AsyncMqttClient/Packets/PingRespPacket.hpp" -#include "AsyncMqttClient/Packets/SubAckPacket.hpp" -#include "AsyncMqttClient/Packets/UnsubAckPacket.hpp" -#include "AsyncMqttClient/Packets/PublishPacket.hpp" -#include "AsyncMqttClient/Packets/PubRelPacket.hpp" -#include "AsyncMqttClient/Packets/PubAckPacket.hpp" -#include "AsyncMqttClient/Packets/PubRecPacket.hpp" -#include "AsyncMqttClient/Packets/PubCompPacket.hpp" - -#if ESP32 -#define SEMAPHORE_TAKE(X) if (xSemaphoreTake(_xSemaphore, 1000 / portTICK_PERIOD_MS) != pdTRUE) { return X; } // Waits max 1000ms -#define SEMAPHORE_GIVE() xSemaphoreGive(_xSemaphore); -#elif defined(ESP8266) -#define SEMAPHORE_TAKE(X) void() -#define SEMAPHORE_GIVE() void() -#endif - -class AsyncMqttClient { - public: - AsyncMqttClient(); - ~AsyncMqttClient(); - - AsyncMqttClient& setKeepAlive(uint16_t keepAlive); - AsyncMqttClient& setClientId(const char* clientId); - AsyncMqttClient& setCleanSession(bool cleanSession); - AsyncMqttClient& setMaxTopicLength(uint16_t maxTopicLength); - AsyncMqttClient& setCredentials(const char* username, const char* password = nullptr); - AsyncMqttClient& setWill(const char* topic, uint8_t qos, bool retain, const char* payload = nullptr, size_t length = 0); - AsyncMqttClient& setServer(IPAddress ip, uint16_t port); - AsyncMqttClient& setServer(const char* host, uint16_t port); -#if ASYNC_TCP_SSL_ENABLED - AsyncMqttClient& setSecure(bool secure); - AsyncMqttClient& addServerFingerprint(const uint8_t* fingerprint); -#endif - - AsyncMqttClient& onConnect(AsyncMqttClientInternals::OnConnectUserCallback callback); - AsyncMqttClient& onDisconnect(AsyncMqttClientInternals::OnDisconnectUserCallback callback); - AsyncMqttClient& onSubscribe(AsyncMqttClientInternals::OnSubscribeUserCallback callback); - AsyncMqttClient& onUnsubscribe(AsyncMqttClientInternals::OnUnsubscribeUserCallback callback); - AsyncMqttClient& onMessage(AsyncMqttClientInternals::OnMessageUserCallback callback); - AsyncMqttClient& onPublish(AsyncMqttClientInternals::OnPublishUserCallback callback); - - bool connected() const; - void connect(); - void disconnect(bool force = false); - uint16_t subscribe(const char* topic, uint8_t qos); - uint16_t unsubscribe(const char* topic); - uint16_t publish(const char* topic, uint8_t qos, bool retain, const char* payload = nullptr, size_t length = 0, bool dup = false, uint16_t message_id = 0); - - private: - AsyncClient _client; - - bool _connected; - bool _connectPacketNotEnoughSpace; - bool _disconnectFlagged; - bool _tlsBadFingerprint; - uint32_t _lastClientActivity; - uint32_t _lastServerActivity; - uint32_t _lastPingRequestTime; - - char _generatedClientId[13 + 1]; // esp8266abc123 - IPAddress _ip; - const char* _host; - bool _useIp; -#if ASYNC_TCP_SSL_ENABLED - bool _secure; -#endif - uint16_t _port; - uint16_t _keepAlive; - bool _cleanSession; - const char* _clientId; - const char* _username; - const char* _password; - const char* _willTopic; - const char* _willPayload; - uint16_t _willPayloadLength; - uint8_t _willQos; - bool _willRetain; - -#if ASYNC_TCP_SSL_ENABLED - std::vector> _secureServerFingerprints; -#endif - - std::vector _onConnectUserCallbacks; - std::vector _onDisconnectUserCallbacks; - std::vector _onSubscribeUserCallbacks; - std::vector _onUnsubscribeUserCallbacks; - std::vector _onMessageUserCallbacks; - std::vector _onPublishUserCallbacks; - - AsyncMqttClientInternals::ParsingInformation _parsingInformation; - AsyncMqttClientInternals::Packet* _currentParsedPacket; - uint8_t _remainingLengthBufferPosition; - char _remainingLengthBuffer[4]; - - uint16_t _nextPacketId; - - std::vector _pendingPubRels; - - std::vector _toSendAcks; - -#ifdef ESP32 - SemaphoreHandle_t _xSemaphore = nullptr; -#endif - - void _clear(); - void _freeCurrentParsedPacket(); - - // TCP - void _onConnect(AsyncClient* client); - void _onDisconnect(AsyncClient* client); - static void _onError(AsyncClient* client, int8_t error); - void _onTimeout(AsyncClient* client, uint32_t time); - static void _onAck(AsyncClient* client, size_t len, uint32_t time); - void _onData(AsyncClient* client, char* data, size_t len); - void _onPoll(AsyncClient* client); - - // MQTT - void _onPingResp(); - void _onConnAck(bool sessionPresent, uint8_t connectReturnCode); - void _onSubAck(uint16_t packetId, char status); - void _onUnsubAck(uint16_t packetId); - void _onMessage(char* topic, char* payload, uint8_t qos, bool dup, bool retain, size_t len, size_t index, size_t total, uint16_t packetId); - void _onPublish(uint16_t packetId, uint8_t qos); - void _onPubRel(uint16_t packetId); - void _onPubAck(uint16_t packetId); - void _onPubRec(uint16_t packetId); - void _onPubComp(uint16_t packetId); - - bool _sendPing(); - void _sendAcks(); - bool _sendDisconnect(); - - uint16_t _getNextPacketId(); -}; diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Callbacks.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Callbacks.hpp deleted file mode 100644 index 7c3d63dd04..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Callbacks.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include - -#include "DisconnectReasons.hpp" -#include "MessageProperties.hpp" - -namespace AsyncMqttClientInternals { -// user callbacks -typedef std::function OnConnectUserCallback; -typedef std::function OnDisconnectUserCallback; -typedef std::function OnSubscribeUserCallback; -typedef std::function OnUnsubscribeUserCallback; -typedef std::function OnMessageUserCallback; -typedef std::function OnPublishUserCallback; - -// internal callbacks -typedef std::function OnConnAckInternalCallback; -typedef std::function OnPingRespInternalCallback; -typedef std::function OnSubAckInternalCallback; -typedef std::function OnUnsubAckInternalCallback; -typedef std::function OnMessageInternalCallback; -typedef std::function OnPublishInternalCallback; -typedef std::function OnPubRelInternalCallback; -typedef std::function OnPubAckInternalCallback; -typedef std::function OnPubRecInternalCallback; -typedef std::function OnPubCompInternalCallback; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/DisconnectReasons.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/DisconnectReasons.hpp deleted file mode 100644 index f4cbda8af4..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/DisconnectReasons.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -enum class AsyncMqttClientDisconnectReason : int8_t { - TCP_DISCONNECTED = 0, - - MQTT_UNACCEPTABLE_PROTOCOL_VERSION = 1, - MQTT_IDENTIFIER_REJECTED = 2, - MQTT_SERVER_UNAVAILABLE = 3, - MQTT_MALFORMED_CREDENTIALS = 4, - MQTT_NOT_AUTHORIZED = 5, - - ESP8266_NOT_ENOUGH_SPACE = 6, - - TLS_BAD_FINGERPRINT = 7 -}; diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Flags.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Flags.hpp deleted file mode 100644 index a1fb3e3c83..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Flags.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once - -namespace AsyncMqttClientInternals { -constexpr struct { - const uint8_t RESERVED = 0; - const uint8_t CONNECT = 1; - const uint8_t CONNACK = 2; - const uint8_t PUBLISH = 3; - const uint8_t PUBACK = 4; - const uint8_t PUBREC = 5; - const uint8_t PUBREL = 6; - const uint8_t PUBCOMP = 7; - const uint8_t SUBSCRIBE = 8; - const uint8_t SUBACK = 9; - const uint8_t UNSUBSCRIBE = 10; - const uint8_t UNSUBACK = 11; - const uint8_t PINGREQ = 12; - const uint8_t PINGRESP = 13; - const uint8_t DISCONNECT = 14; - const uint8_t RESERVED2 = 1; -} PacketType; - -constexpr struct { - const uint8_t CONNECT_RESERVED = 0x00; - const uint8_t CONNACK_RESERVED = 0x00; - const uint8_t PUBLISH_DUP = 0x08; - const uint8_t PUBLISH_QOS0 = 0x00; - const uint8_t PUBLISH_QOS1 = 0x02; - const uint8_t PUBLISH_QOS2 = 0x04; - const uint8_t PUBLISH_QOSRESERVED = 0x06; - const uint8_t PUBLISH_RETAIN = 0x01; - const uint8_t PUBACK_RESERVED = 0x00; - const uint8_t PUBREC_RESERVED = 0x00; - const uint8_t PUBREL_RESERVED = 0x02; - const uint8_t PUBCOMP_RESERVED = 0x00; - const uint8_t SUBSCRIBE_RESERVED = 0x02; - const uint8_t SUBACK_RESERVED = 0x00; - const uint8_t UNSUBSCRIBE_RESERVED = 0x02; - const uint8_t UNSUBACK_RESERVED = 0x00; - const uint8_t PINGREQ_RESERVED = 0x00; - const uint8_t PINGRESP_RESERVED = 0x00; - const uint8_t DISCONNECT_RESERVED = 0x00; - const uint8_t RESERVED2_RESERVED = 0x00; -} HeaderFlag; - -constexpr struct { - const uint8_t USERNAME = 0x80; - const uint8_t PASSWORD = 0x40; - const uint8_t WILL_RETAIN = 0x20; - const uint8_t WILL_QOS0 = 0x00; - const uint8_t WILL_QOS1 = 0x08; - const uint8_t WILL_QOS2 = 0x10; - const uint8_t WILL = 0x04; - const uint8_t CLEAN_SESSION = 0x02; - const uint8_t RESERVED = 0x00; -} ConnectFlag; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Helpers.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Helpers.hpp deleted file mode 100644 index 5737c02ef0..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Helpers.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -namespace AsyncMqttClientInternals { -class Helpers { - public: - static uint32_t decodeRemainingLength(char* bytes) { - uint32_t multiplier = 1; - uint32_t value = 0; - uint8_t currentByte = 0; - uint8_t encodedByte; - do { - encodedByte = bytes[currentByte++]; - value += (encodedByte & 127) * multiplier; - multiplier *= 128; - } while ((encodedByte & 128) != 0); - - return value; - } - - static uint8_t encodeRemainingLength(uint32_t remainingLength, char* destination) { - uint8_t currentByte = 0; - uint8_t bytesNeeded = 0; - - do { - uint8_t encodedByte = remainingLength % 128; - remainingLength /= 128; - if (remainingLength > 0) { - encodedByte = encodedByte | 128; - } - - destination[currentByte++] = encodedByte; - bytesNeeded++; - } while (remainingLength > 0); - - return bytesNeeded; - } -}; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/MessageProperties.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/MessageProperties.hpp deleted file mode 100644 index c04b59664f..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/MessageProperties.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -struct AsyncMqttClientMessageProperties { - uint8_t qos; - bool dup; - bool retain; -}; diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/ConnAckPacket.cpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/ConnAckPacket.cpp deleted file mode 100644 index f9091c2152..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/ConnAckPacket.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "ConnAckPacket.hpp" - -using AsyncMqttClientInternals::ConnAckPacket; - -ConnAckPacket::ConnAckPacket(ParsingInformation* parsingInformation, OnConnAckInternalCallback callback) -: _parsingInformation(parsingInformation) -, _callback(callback) -, _bytePosition(0) -, _sessionPresent(false) -, _connectReturnCode(0) { -} - -ConnAckPacket::~ConnAckPacket() { -} - -void ConnAckPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { - char currentByte = data[(*currentBytePosition)++]; - if (_bytePosition++ == 0) { - _sessionPresent = (currentByte << 7) >> 7; - } else { - _connectReturnCode = currentByte; - _parsingInformation->bufferState = BufferState::NONE; - _callback(_sessionPresent, _connectReturnCode); - } -} - -void ConnAckPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { - (void)data; - (void)currentBytePosition; -} diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/ConnAckPacket.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/ConnAckPacket.hpp deleted file mode 100644 index 8be9ab1921..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/ConnAckPacket.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "Arduino.h" -#include "Packet.hpp" -#include "../ParsingInformation.hpp" -#include "../Callbacks.hpp" - -namespace AsyncMqttClientInternals { -class ConnAckPacket : public Packet { - public: - explicit ConnAckPacket(ParsingInformation* parsingInformation, OnConnAckInternalCallback callback); - ~ConnAckPacket(); - - void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); - void parsePayload(char* data, size_t len, size_t* currentBytePosition); - - private: - ParsingInformation* _parsingInformation; - OnConnAckInternalCallback _callback; - - uint8_t _bytePosition; - bool _sessionPresent; - uint8_t _connectReturnCode; -}; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/Packet.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/Packet.hpp deleted file mode 100644 index 9552cf06a9..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/Packet.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -namespace AsyncMqttClientInternals { -class Packet { - public: - virtual ~Packet() {} - - virtual void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) = 0; - virtual void parsePayload(char* data, size_t len, size_t* currentBytePosition) = 0; -}; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PingRespPacket.cpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PingRespPacket.cpp deleted file mode 100644 index 2a939aac96..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PingRespPacket.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "PingRespPacket.hpp" - -using AsyncMqttClientInternals::PingRespPacket; - -PingRespPacket::PingRespPacket(ParsingInformation* parsingInformation, OnPingRespInternalCallback callback) -: _parsingInformation(parsingInformation) -, _callback(callback) { -} - -PingRespPacket::~PingRespPacket() { -} - -void PingRespPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { - (void)data; - (void)currentBytePosition; -} - -void PingRespPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { - (void)data; - (void)currentBytePosition; -} diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PingRespPacket.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PingRespPacket.hpp deleted file mode 100644 index 043a730323..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PingRespPacket.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include "Arduino.h" -#include "Packet.hpp" -#include "../ParsingInformation.hpp" -#include "../Callbacks.hpp" - -namespace AsyncMqttClientInternals { -class PingRespPacket : public Packet { - public: - explicit PingRespPacket(ParsingInformation* parsingInformation, OnPingRespInternalCallback callback); - ~PingRespPacket(); - - void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); - void parsePayload(char* data, size_t len, size_t* currentBytePosition); - - private: - ParsingInformation* _parsingInformation; - OnPingRespInternalCallback _callback; -}; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubAckPacket.cpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubAckPacket.cpp deleted file mode 100644 index efa5fa4102..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubAckPacket.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "PubAckPacket.hpp" - -using AsyncMqttClientInternals::PubAckPacket; - -PubAckPacket::PubAckPacket(ParsingInformation* parsingInformation, OnPubAckInternalCallback callback) -: _parsingInformation(parsingInformation) -, _callback(callback) -, _bytePosition(0) -, _packetIdMsb(0) -, _packetId(0) { -} - -PubAckPacket::~PubAckPacket() { -} - -void PubAckPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { - char currentByte = data[(*currentBytePosition)++]; - if (_bytePosition++ == 0) { - _packetIdMsb = currentByte; - } else { - _packetId = currentByte | _packetIdMsb << 8; - _parsingInformation->bufferState = BufferState::NONE; - _callback(_packetId); - } -} - -void PubAckPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { - (void)data; - (void)currentBytePosition; -} diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubAckPacket.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubAckPacket.hpp deleted file mode 100644 index bd00142d0f..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubAckPacket.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "Arduino.h" -#include "Packet.hpp" -#include "../ParsingInformation.hpp" -#include "../Callbacks.hpp" - -namespace AsyncMqttClientInternals { -class PubAckPacket : public Packet { - public: - explicit PubAckPacket(ParsingInformation* parsingInformation, OnPubAckInternalCallback callback); - ~PubAckPacket(); - - void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); - void parsePayload(char* data, size_t len, size_t* currentBytePosition); - - private: - ParsingInformation* _parsingInformation; - OnPubAckInternalCallback _callback; - - uint8_t _bytePosition; - char _packetIdMsb; - uint16_t _packetId; -}; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubCompPacket.cpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubCompPacket.cpp deleted file mode 100644 index 2b3e00ded1..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubCompPacket.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "PubCompPacket.hpp" - -using AsyncMqttClientInternals::PubCompPacket; - -PubCompPacket::PubCompPacket(ParsingInformation* parsingInformation, OnPubCompInternalCallback callback) -: _parsingInformation(parsingInformation) -, _callback(callback) -, _bytePosition(0) -, _packetIdMsb(0) -, _packetId(0) { -} - -PubCompPacket::~PubCompPacket() { -} - -void PubCompPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { - char currentByte = data[(*currentBytePosition)++]; - if (_bytePosition++ == 0) { - _packetIdMsb = currentByte; - } else { - _packetId = currentByte | _packetIdMsb << 8; - _parsingInformation->bufferState = BufferState::NONE; - _callback(_packetId); - } -} - -void PubCompPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { - (void)data; - (void)currentBytePosition; -} diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubCompPacket.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubCompPacket.hpp deleted file mode 100644 index 17c1db4888..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubCompPacket.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "Arduino.h" -#include "Packet.hpp" -#include "../ParsingInformation.hpp" -#include "../Callbacks.hpp" - -namespace AsyncMqttClientInternals { -class PubCompPacket : public Packet { - public: - explicit PubCompPacket(ParsingInformation* parsingInformation, OnPubCompInternalCallback callback); - ~PubCompPacket(); - - void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); - void parsePayload(char* data, size_t len, size_t* currentBytePosition); - - private: - ParsingInformation* _parsingInformation; - OnPubCompInternalCallback _callback; - - uint8_t _bytePosition; - char _packetIdMsb; - uint16_t _packetId; -}; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRecPacket.cpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRecPacket.cpp deleted file mode 100644 index ec535c613f..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRecPacket.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "PubRecPacket.hpp" - -using AsyncMqttClientInternals::PubRecPacket; - -PubRecPacket::PubRecPacket(ParsingInformation* parsingInformation, OnPubRecInternalCallback callback) -: _parsingInformation(parsingInformation) -, _callback(callback) -, _bytePosition(0) -, _packetIdMsb(0) -, _packetId(0) { -} - -PubRecPacket::~PubRecPacket() { -} - -void PubRecPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { - char currentByte = data[(*currentBytePosition)++]; - if (_bytePosition++ == 0) { - _packetIdMsb = currentByte; - } else { - _packetId = currentByte | _packetIdMsb << 8; - _parsingInformation->bufferState = BufferState::NONE; - _callback(_packetId); - } -} - -void PubRecPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { - (void)data; - (void)currentBytePosition; -} diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRecPacket.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRecPacket.hpp deleted file mode 100644 index 910130a2b5..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRecPacket.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "Arduino.h" -#include "Packet.hpp" -#include "../ParsingInformation.hpp" -#include "../Callbacks.hpp" - -namespace AsyncMqttClientInternals { -class PubRecPacket : public Packet { - public: - explicit PubRecPacket(ParsingInformation* parsingInformation, OnPubRecInternalCallback callback); - ~PubRecPacket(); - - void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); - void parsePayload(char* data, size_t len, size_t* currentBytePosition); - - private: - ParsingInformation* _parsingInformation; - OnPubRecInternalCallback _callback; - - uint8_t _bytePosition; - char _packetIdMsb; - uint16_t _packetId; -}; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRelPacket.cpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRelPacket.cpp deleted file mode 100644 index 2d5abde0e8..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRelPacket.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "PubRelPacket.hpp" - -using AsyncMqttClientInternals::PubRelPacket; - -PubRelPacket::PubRelPacket(ParsingInformation* parsingInformation, OnPubRelInternalCallback callback) -: _parsingInformation(parsingInformation) -, _callback(callback) -, _bytePosition(0) -, _packetIdMsb(0) -, _packetId(0) { -} - -PubRelPacket::~PubRelPacket() { -} - -void PubRelPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { - char currentByte = data[(*currentBytePosition)++]; - if (_bytePosition++ == 0) { - _packetIdMsb = currentByte; - } else { - _packetId = currentByte | _packetIdMsb << 8; - _parsingInformation->bufferState = BufferState::NONE; - _callback(_packetId); - } -} - -void PubRelPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { - (void)data; - (void)currentBytePosition; -} diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRelPacket.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRelPacket.hpp deleted file mode 100644 index edea3d53b1..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PubRelPacket.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "Arduino.h" -#include "Packet.hpp" -#include "../ParsingInformation.hpp" -#include "../Callbacks.hpp" - -namespace AsyncMqttClientInternals { -class PubRelPacket : public Packet { - public: - explicit PubRelPacket(ParsingInformation* parsingInformation, OnPubRelInternalCallback callback); - ~PubRelPacket(); - - void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); - void parsePayload(char* data, size_t len, size_t* currentBytePosition); - - private: - ParsingInformation* _parsingInformation; - OnPubRelInternalCallback _callback; - - uint8_t _bytePosition; - char _packetIdMsb; - uint16_t _packetId; -}; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PublishPacket.cpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PublishPacket.cpp deleted file mode 100644 index dab30a1542..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PublishPacket.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include "PublishPacket.hpp" - -using AsyncMqttClientInternals::PublishPacket; - -PublishPacket::PublishPacket(ParsingInformation* parsingInformation, OnMessageInternalCallback dataCallback, OnPublishInternalCallback completeCallback) -: _parsingInformation(parsingInformation) -, _dataCallback(dataCallback) -, _completeCallback(completeCallback) -, _dup(false) -, _qos(0) -, _retain(0) -, _bytePosition(0) -, _topicLengthMsb(0) -, _topicLength(0) -, _ignore(false) -, _packetIdMsb(0) -, _packetId(0) -, _payloadLength(0) -, _payloadBytesRead(0) { - _dup = _parsingInformation->packetFlags & HeaderFlag.PUBLISH_DUP; - _retain = _parsingInformation->packetFlags & HeaderFlag.PUBLISH_RETAIN; - char qosMasked = _parsingInformation->packetFlags & 0x06; - switch (qosMasked) { - case HeaderFlag.PUBLISH_QOS0: - _qos = 0; - break; - case HeaderFlag.PUBLISH_QOS1: - _qos = 1; - break; - case HeaderFlag.PUBLISH_QOS2: - _qos = 2; - break; - } -} - -PublishPacket::~PublishPacket() { -} - -void PublishPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { - char currentByte = data[(*currentBytePosition)++]; - if (_bytePosition == 0) { - _topicLengthMsb = currentByte; - } else if (_bytePosition == 1) { - _topicLength = currentByte | _topicLengthMsb << 8; - if (_topicLength > _parsingInformation->maxTopicLength) { - _ignore = true; - } else { - _parsingInformation->topicBuffer[_topicLength] = '\0'; - } - } else if (_bytePosition >= 2 && _bytePosition < 2 + _topicLength) { - // Starting from here, _ignore might be true - if (!_ignore) _parsingInformation->topicBuffer[_bytePosition - 2] = currentByte; - if (_bytePosition == 2 + _topicLength - 1 && _qos == 0) { - _preparePayloadHandling(_parsingInformation->remainingLength - (_bytePosition + 1)); - return; - } - } else if (_bytePosition == 2 + _topicLength) { - _packetIdMsb = currentByte; - } else { - _packetId = currentByte | _packetIdMsb << 8; - _preparePayloadHandling(_parsingInformation->remainingLength - (_bytePosition + 1)); - } - _bytePosition++; -} - -void PublishPacket::_preparePayloadHandling(uint32_t payloadLength) { - _payloadLength = payloadLength; - if (payloadLength == 0) { - _parsingInformation->bufferState = BufferState::NONE; - if (!_ignore) { - _dataCallback(_parsingInformation->topicBuffer, nullptr, _qos, _dup, _retain, 0, 0, 0, _packetId); - _completeCallback(_packetId, _qos); - } - } else { - _parsingInformation->bufferState = BufferState::PAYLOAD; - } -} - -void PublishPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { - size_t remainToRead = len - (*currentBytePosition); - if (_payloadBytesRead + remainToRead > _payloadLength) remainToRead = _payloadLength - _payloadBytesRead; - - if (!_ignore) _dataCallback(_parsingInformation->topicBuffer, data + (*currentBytePosition), _qos, _dup, _retain, remainToRead, _payloadBytesRead, _payloadLength, _packetId); - _payloadBytesRead += remainToRead; - (*currentBytePosition) += remainToRead; - - if (_payloadBytesRead == _payloadLength) { - _parsingInformation->bufferState = BufferState::NONE; - if (!_ignore) _completeCallback(_packetId, _qos); - } -} diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PublishPacket.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PublishPacket.hpp deleted file mode 100644 index 9dc19f0aa2..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/PublishPacket.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include "Arduino.h" -#include "Packet.hpp" -#include "../Flags.hpp" -#include "../ParsingInformation.hpp" -#include "../Callbacks.hpp" - -namespace AsyncMqttClientInternals { -class PublishPacket : public Packet { - public: - explicit PublishPacket(ParsingInformation* parsingInformation, OnMessageInternalCallback dataCallback, OnPublishInternalCallback completeCallback); - ~PublishPacket(); - - void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); - void parsePayload(char* data, size_t len, size_t* currentBytePosition); - - private: - ParsingInformation* _parsingInformation; - OnMessageInternalCallback _dataCallback; - OnPublishInternalCallback _completeCallback; - - void _preparePayloadHandling(uint32_t payloadLength); - - bool _dup; - uint8_t _qos; - bool _retain; - - uint8_t _bytePosition; - char _topicLengthMsb; - uint16_t _topicLength; - bool _ignore; - char _packetIdMsb; - uint16_t _packetId; - uint32_t _payloadLength; - uint32_t _payloadBytesRead; -}; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/SubAckPacket.cpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/SubAckPacket.cpp deleted file mode 100644 index ab89965506..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/SubAckPacket.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "SubAckPacket.hpp" - -using AsyncMqttClientInternals::SubAckPacket; - -SubAckPacket::SubAckPacket(ParsingInformation* parsingInformation, OnSubAckInternalCallback callback) -: _parsingInformation(parsingInformation) -, _callback(callback) -, _bytePosition(0) -, _packetIdMsb(0) -, _packetId(0) { -} - -SubAckPacket::~SubAckPacket() { -} - -void SubAckPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { - char currentByte = data[(*currentBytePosition)++]; - if (_bytePosition++ == 0) { - _packetIdMsb = currentByte; - } else { - _packetId = currentByte | _packetIdMsb << 8; - _parsingInformation->bufferState = BufferState::PAYLOAD; - } -} - -void SubAckPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { - char status = data[(*currentBytePosition)++]; - - /* switch (status) { - case 0: - Serial.println("Success QoS 0"); - break; - case 1: - Serial.println("Success QoS 1"); - break; - case 2: - Serial.println("Success QoS 2"); - break; - case 0x80: - Serial.println("Failure"); - break; - } */ - - _parsingInformation->bufferState = BufferState::NONE; - _callback(_packetId, status); -} diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/SubAckPacket.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/SubAckPacket.hpp deleted file mode 100644 index 011b800a04..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/SubAckPacket.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "Arduino.h" -#include "Packet.hpp" -#include "../ParsingInformation.hpp" -#include "../Callbacks.hpp" - -namespace AsyncMqttClientInternals { -class SubAckPacket : public Packet { - public: - explicit SubAckPacket(ParsingInformation* parsingInformation, OnSubAckInternalCallback callback); - ~SubAckPacket(); - - void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); - void parsePayload(char* data, size_t len, size_t* currentBytePosition); - - private: - ParsingInformation* _parsingInformation; - OnSubAckInternalCallback _callback; - - uint8_t _bytePosition; - char _packetIdMsb; - uint16_t _packetId; -}; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/UnsubAckPacket.cpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/UnsubAckPacket.cpp deleted file mode 100644 index a44943d171..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/UnsubAckPacket.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "UnsubAckPacket.hpp" - -using AsyncMqttClientInternals::UnsubAckPacket; - -UnsubAckPacket::UnsubAckPacket(ParsingInformation* parsingInformation, OnUnsubAckInternalCallback callback) -: _parsingInformation(parsingInformation) -, _callback(callback) -, _bytePosition(0) -, _packetIdMsb(0) -, _packetId(0) { -} - -UnsubAckPacket::~UnsubAckPacket() { -} - -void UnsubAckPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { - char currentByte = data[(*currentBytePosition)++]; - if (_bytePosition++ == 0) { - _packetIdMsb = currentByte; - } else { - _packetId = currentByte | _packetIdMsb << 8; - _parsingInformation->bufferState = BufferState::NONE; - _callback(_packetId); - } -} - -void UnsubAckPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { - (void)data; - (void)currentBytePosition; -} diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/UnsubAckPacket.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/UnsubAckPacket.hpp deleted file mode 100644 index ab5b9c5cb3..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Packets/UnsubAckPacket.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "Arduino.h" -#include "Packet.hpp" -#include "../ParsingInformation.hpp" -#include "../Callbacks.hpp" - -namespace AsyncMqttClientInternals { -class UnsubAckPacket : public Packet { - public: - explicit UnsubAckPacket(ParsingInformation* parsingInformation, OnUnsubAckInternalCallback callback); - ~UnsubAckPacket(); - - void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); - void parsePayload(char* data, size_t len, size_t* currentBytePosition); - - private: - ParsingInformation* _parsingInformation; - OnUnsubAckInternalCallback _callback; - - uint8_t _bytePosition; - char _packetIdMsb; - uint16_t _packetId; -}; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/ParsingInformation.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/ParsingInformation.hpp deleted file mode 100644 index 2d46f27f89..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/ParsingInformation.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -namespace AsyncMqttClientInternals { -enum class BufferState : uint8_t { - NONE = 0, - REMAINING_LENGTH = 2, - VARIABLE_HEADER = 3, - PAYLOAD = 4 -}; - -struct ParsingInformation { - BufferState bufferState; - - uint16_t maxTopicLength; - char* topicBuffer; - - uint8_t packetType; - uint16_t packetFlags; - uint32_t remainingLength; -}; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Storage.hpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Storage.hpp deleted file mode 100644 index 725307b7f2..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/Storage.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -namespace AsyncMqttClientInternals { -struct PendingPubRel { - uint16_t packetId; -}; - -struct PendingAck { - uint8_t packetType; - uint8_t headerFlag; - uint16_t packetId; -}; -} // namespace AsyncMqttClientInternals diff --git a/wled00/src/dependencies/async-mqtt-client/LICENSE b/wled00/src/dependencies/async-mqtt-client/LICENSE deleted file mode 100644 index a6183c687c..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Marvin Roger - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/wled00/src/dependencies/async-mqtt-client/README.md b/wled00/src/dependencies/async-mqtt-client/README.md deleted file mode 100644 index 7ea6db1a7e..0000000000 --- a/wled00/src/dependencies/async-mqtt-client/README.md +++ /dev/null @@ -1,18 +0,0 @@ -Async MQTT client for ESP8266 and ESP32 (Github: https://github.com/marvinroger/async-mqtt-client) -============================= - -[![Build Status](https://img.shields.io/travis/marvinroger/async-mqtt-client/master.svg?style=flat-square)](https://travis-ci.org/marvinroger/async-mqtt-client) - -An Arduino for ESP8266 and ESP32 asynchronous [MQTT](http://mqtt.org/) client implementation, built on [me-no-dev/ESPAsyncTCP (ESP8266)](https://github.com/me-no-dev/ESPAsyncTCP) | [me-no-dev/AsyncTCP (ESP32)](https://github.com/me-no-dev/AsyncTCP) . -## Features - -* Compliant with the 3.1.1 version of the protocol -* Fully asynchronous -* Subscribe at QoS 0, 1 and 2 -* Publish at QoS 0, 1 and 2 -* SSL/TLS support -* Available in the [PlatformIO registry](http://platformio.org/lib/show/346/AsyncMqttClient) - -## Requirements, installation and usage - -The project is documented in the [/docs folder](docs). From 2c0259f21441781390d920959126eb8663de0e1c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 16 Aug 2025 11:57:50 +0100 Subject: [PATCH 05/45] Rename Network to WLEDNetwork to prevent clash --- usermods/ST7789_display/ST7789_display.cpp | 2 +- usermods/quinled-an-penta/quinled-an-penta.cpp | 6 +++--- .../usermod_v2_four_line_display_ALT.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/usermods/ST7789_display/ST7789_display.cpp b/usermods/ST7789_display/ST7789_display.cpp index c596baecce..486dacb62b 100644 --- a/usermods/ST7789_display/ST7789_display.cpp +++ b/usermods/ST7789_display/ST7789_display.cpp @@ -196,7 +196,7 @@ class St7789DisplayUsermod : public Usermod { // Check if values which are shown on display changed from the last time. if ((((apActive) ? String(apSSID) : WiFi.SSID()) != knownSsid) || - (knownIp != (apActive ? IPAddress(4, 3, 2, 1) : Network.localIP())) || + (knownIp != (apActive ? IPAddress(4, 3, 2, 1) : WLEDNetwork.localIP())) || (knownBrightness != bri) || (knownEffectSpeed != strip.getMainSegment().speed) || (knownEffectIntensity != strip.getMainSegment().intensity) || diff --git a/usermods/quinled-an-penta/quinled-an-penta.cpp b/usermods/quinled-an-penta/quinled-an-penta.cpp index a3b452bf18..b90a9f9419 100644 --- a/usermods/quinled-an-penta/quinled-an-penta.cpp +++ b/usermods/quinled-an-penta/quinled-an-penta.cpp @@ -234,11 +234,11 @@ class QuinLEDAnPentaUsermod : public Usermod bool oledCheckForNetworkChanges() { - if (lastKnownNetworkConnected != Network.isConnected() || lastKnownIp != Network.localIP() + if (lastKnownNetworkConnected != WLEDNetwork.isConnected() || lastKnownIp != WLEDNetwork.localIP() || lastKnownWiFiConnected != WiFi.isConnected() || lastKnownSsid != WiFi.SSID() || lastKnownApActive != apActive || lastKnownApSsid != apSSID || lastKnownApPass != apPass || lastKnownApChannel != apChannel) { - lastKnownNetworkConnected = Network.isConnected(); - lastKnownIp = Network.localIP(); + lastKnownNetworkConnected = WLEDNetwork.isConnected(); + lastKnownIp = WLEDNetwork.localIP(); lastKnownWiFiConnected = WiFi.isConnected(); lastKnownSsid = WiFi.SSID(); lastKnownApActive = apActive; diff --git a/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp b/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp index 36a8b029f1..8e3bc0e0a8 100644 --- a/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp +++ b/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp @@ -264,7 +264,7 @@ void FourLineDisplayUsermod::setup() { // interfaces here void FourLineDisplayUsermod::connected() { knownSsid = WiFi.SSID(); //apActive ? apSSID : WiFi.SSID(); //apActive ? WiFi.softAPSSID() : - knownIp = Network.localIP(); //apActive ? IPAddress(4, 3, 2, 1) : Network.localIP(); + knownIp = WLEDNetwork.localIP(); //apActive ? IPAddress(4, 3, 2, 1) : WLEDNetwork.localIP(); networkOverlay(PSTR("NETWORK INFO"),7000); } From 03a9d9e56f7bae4251b15c139f4b7a4411ea52fa Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 16 Aug 2025 12:05:41 +0100 Subject: [PATCH 06/45] ledc changes for versions 2.X (based on ESP-IDF 4.4) to version 3.0 (based on ESP-IDF 5.1) - https://docs.espressif.com/projects/arduino-esp32/en/latest/migration_guides/2.x_to_3.0.html --- wled00/bus_manager.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index ab662ce1ed..3d003e16cf 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -12,7 +12,7 @@ #if !(defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)) #define LEDC_MUTEX_LOCK() do {} while (xSemaphoreTake(_ledc_sys_lock, portMAX_DELAY) != pdPASS) #define LEDC_MUTEX_UNLOCK() xSemaphoreGive(_ledc_sys_lock) - extern xSemaphoreHandle _ledc_sys_lock; + extern SemaphoreHandle_t _ledc_sys_lock; #else #define LEDC_MUTEX_LOCK() #define LEDC_MUTEX_UNLOCK() @@ -450,8 +450,7 @@ BusPwm::BusPwm(const BusConfig &bc) pinMode(_pins[i], OUTPUT); #else unsigned channel = _ledcStart + i; - ledcSetup(channel, _frequency, _depth - (dithering*4)); // with dithering _frequency doesn't really matter as resolution is 8 bit - ledcAttachPin(_pins[i], channel); + ledcAttach(_pins[i], _frequency, _depth - (dithering*4)); // LEDC timer reset credit @dedehai uint8_t group = (channel / 8), timer = ((channel / 2) % 4); // same fromula as in ledcSetup() ledc_timer_rst((ledc_mode_t)group, (ledc_timer_t)timer); // reset timer so all timers are almost in sync (for phase shift) @@ -618,7 +617,7 @@ void BusPwm::deallocatePins() { #ifdef ESP8266 digitalWrite(_pins[i], LOW); //turn off PWM interrupt #else - if (_ledcStart < WLED_MAX_ANALOG_CHANNELS) ledcDetachPin(_pins[i]); + if (_ledcStart < WLED_MAX_ANALOG_CHANNELS) ledcDetach(_pins[i]); #endif } #ifdef ARDUINO_ARCH_ESP32 From bc19133e73d33dd9d51f1e0a7a95d40372c73c44 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 16 Aug 2025 12:33:25 +0100 Subject: [PATCH 07/45] Update PlatformIO --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index fd9806ac23..961034b7ba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,7 +32,7 @@ marshmallow==3.26.1 # via platformio packaging==24.2 # via marshmallow -platformio==6.1.17 +platformio==6.1.18 # via -r requirements.in pyelftools==0.32 # via platformio From e4815d1ff5f8fcd1df2f71de0cccf0aabba8f54f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 16 Aug 2025 12:36:41 +0100 Subject: [PATCH 08/45] Update PlatformIO --- requirements.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/requirements.txt b/requirements.txt index 961034b7ba..c3aa2a87b1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,15 +6,15 @@ # ajsonrpc==1.2.0 # via platformio -anyio==4.8.0 +anyio==4.10.0 # via starlette -bottle==0.13.2 +bottle==0.13.4 # via platformio -certifi==2025.1.31 +certifi==2025.8.3 # via requests -charset-normalizer==3.4.1 +charset-normalizer==3.4.3 # via requests -click==8.1.8 +click==8.2.2 # via # platformio # uvicorn @@ -28,9 +28,9 @@ idna==3.10 # via # anyio # requests -marshmallow==3.26.1 +marshmallow==4.0.0 # via platformio -packaging==24.2 +packaging==25.0 # via marshmallow platformio==6.1.18 # via -r requirements.in @@ -44,15 +44,15 @@ semantic-version==2.10.0 # via platformio sniffio==1.3.1 # via anyio -starlette==0.45.3 +starlette==0.47.2 # via platformio tabulate==0.9.0 # via platformio -typing-extensions==4.12.2 +typing-extensions==4.14.1 # via anyio urllib3==2.5.0 # via requests -uvicorn==0.34.0 +uvicorn==0.35.0 # via platformio wsproto==1.2.0 # via platformio From 81c92257dac335612b0063a80df933e7d427ef43 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 16 Aug 2025 12:45:36 +0100 Subject: [PATCH 09/45] Update PlatformIO --- requirements.txt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/requirements.txt b/requirements.txt index c3aa2a87b1..6b5a61b4ce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.13 # by the following command: # -# pip-compile requirements.in +# pip-compile # ajsonrpc==1.2.0 # via platformio @@ -14,7 +14,7 @@ certifi==2025.8.3 # via requests charset-normalizer==3.4.3 # via requests -click==8.2.2 +click==8.1.7 # via # platformio # uvicorn @@ -28,7 +28,7 @@ idna==3.10 # via # anyio # requests -marshmallow==4.0.0 +marshmallow==3.26.1 # via platformio packaging==25.0 # via marshmallow @@ -44,15 +44,13 @@ semantic-version==2.10.0 # via platformio sniffio==1.3.1 # via anyio -starlette==0.47.2 +starlette==0.46.2 # via platformio tabulate==0.9.0 # via platformio -typing-extensions==4.14.1 - # via anyio urllib3==2.5.0 # via requests -uvicorn==0.35.0 +uvicorn==0.34.3 # via platformio wsproto==1.2.0 # via platformio From ec22c508137cd679bb8706ea4139d06e74967681 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 09:58:13 +0000 Subject: [PATCH 10/45] Update DMX Input for latest esp_dmx --- platformio.ini | 4 +- wled00/dmx_input.cpp | 106 ++++++++++++++++++++++++------------------- wled00/dmx_input.h | 8 ++-- 3 files changed, 66 insertions(+), 52 deletions(-) diff --git a/platformio.ini b/platformio.ini index 914834ed60..d4983118be 100644 --- a/platformio.ini +++ b/platformio.ini @@ -274,10 +274,10 @@ build_flags = -g ${esp32_all_variants.build_flags} -D WLED_DISABLE_INFRARED ;; TODO: remove once we have updated library for V5 -D WLED_DISABLE_MQTT ;; TODO: remove once we have updated library for V5 -; -D WLED_ENABLE_DMX_INPUT + -D WLED_ENABLE_DMX_INPUT lib_deps = ${esp32_all_variants.lib_deps} -; https://github.com/someweisguy/esp_dmx.git#47db25d + https://github.com/netmindz/esp_dmx/#esp-idf-v5-fixes ${env.lib_deps} [esp32s2] diff --git a/wled00/dmx_input.cpp b/wled00/dmx_input.cpp index 59467590c4..45d385fdcb 100644 --- a/wled00/dmx_input.cpp +++ b/wled00/dmx_input.cpp @@ -1,6 +1,7 @@ #include "wled.h" #ifdef WLED_ENABLE_DMX_INPUT +#pragma message "DMX physical input driver enabled" #ifdef ESP8266 #error DMX input is only supported on ESP32 @@ -9,8 +10,8 @@ #include "dmx_input.h" #include -void rdmPersonalityChangedCb(dmx_port_t dmxPort, const rdm_header_t *header, - void *context) +void rdmPersonalityChangedCb(dmx_port_t dmxPort, rdm_header_t *request_header, + rdm_header_t *response_header, void *context) { DMXInput *dmx = static_cast(context); @@ -19,7 +20,7 @@ void rdmPersonalityChangedCb(dmx_port_t dmxPort, const rdm_header_t *header, return; } - if (header->cc == RDM_CC_SET_COMMAND_RESPONSE) { + if (response_header->cc == RDM_CC_SET_COMMAND_RESPONSE) { const uint8_t personality = dmx_get_current_personality(dmx->inputPortNum); DMXMode = std::min(DMX_MODE_PRESET, std::max(DMX_MODE_SINGLE_RGB, int(personality))); configNeedsWrite = true; @@ -27,8 +28,8 @@ void rdmPersonalityChangedCb(dmx_port_t dmxPort, const rdm_header_t *header, } } -void rdmAddressChangedCb(dmx_port_t dmxPort, const rdm_header_t *header, - void *context) +void rdmAddressChangedCb(dmx_port_t dmxPort, rdm_header_t *request_header, + rdm_header_t *response_header, void *context) { DMXInput *dmx = static_cast(context); @@ -37,7 +38,7 @@ void rdmAddressChangedCb(dmx_port_t dmxPort, const rdm_header_t *header, return; } - if (header->cc == RDM_CC_SET_COMMAND_RESPONSE) { + if (response_header->cc == RDM_CC_SET_COMMAND_RESPONSE) { const uint16_t addr = dmx_get_start_address(dmx->inputPortNum); DMXAddress = std::min(512, int(addr)); configNeedsWrite = true; @@ -47,46 +48,53 @@ void rdmAddressChangedCb(dmx_port_t dmxPort, const rdm_header_t *header, static dmx_config_t createConfig() { - dmx_config_t config; - config.pd_size = 255; - config.dmx_start_address = DMXAddress; + dmx_config_t config = DMX_CONFIG_DEFAULT; config.model_id = 0; config.product_category = RDM_PRODUCT_CATEGORY_FIXTURE; config.software_version_id = VERSION; - strcpy(config.device_label, "WLED_MM"); const std::string versionString = "WLED_V" + std::to_string(VERSION); - strncpy(config.software_version_label, versionString.c_str(), 32); - config.software_version_label[32] = '\0'; // zero termination in case versionString string was longer than 32 chars - - config.personalities[0].description = "SINGLE_RGB"; - config.personalities[0].footprint = 3; - config.personalities[1].description = "SINGLE_DRGB"; - config.personalities[1].footprint = 4; - config.personalities[2].description = "EFFECT"; - config.personalities[2].footprint = 15; - config.personalities[3].description = "MULTIPLE_RGB"; - config.personalities[3].footprint = std::min(512, int(strip.getLengthTotal()) * 3); - config.personalities[4].description = "MULTIPLE_DRGB"; - config.personalities[4].footprint = std::min(512, int(strip.getLengthTotal()) * 3 + 1); - config.personalities[5].description = "MULTIPLE_RGBW"; - config.personalities[5].footprint = std::min(512, int(strip.getLengthTotal()) * 4); - config.personalities[6].description = "EFFECT_W"; - config.personalities[6].footprint = 18; - config.personalities[7].description = "EFFECT_SEGMENT"; - config.personalities[7].footprint = std::min(512, strip.getSegmentsNum() * 15); - config.personalities[8].description = "EFFECT_SEGMENT_W"; - config.personalities[8].footprint = std::min(512, strip.getSegmentsNum() * 18); - config.personalities[9].description = "PRESET"; - config.personalities[9].footprint = 1; - - config.personality_count = 10; - // rdm personalities are numbered from 1, thus we can just set the DMXMode directly. - config.current_personality = DMXMode; + config.software_version_label = versionString.c_str(); return config; } +static dmx_personality_t personalities[10]; + +static void createPersonalities() +{ + // Initialize personalities array + strncpy(personalities[0].description, "SINGLE_RGB", 32); + personalities[0].footprint = 3; + + strncpy(personalities[1].description, "SINGLE_DRGB", 32); + personalities[1].footprint = 4; + + strncpy(personalities[2].description, "EFFECT", 32); + personalities[2].footprint = 15; + + strncpy(personalities[3].description, "MULTIPLE_RGB", 32); + personalities[3].footprint = std::min(512, int(strip.getLengthTotal()) * 3); + + strncpy(personalities[4].description, "MULTIPLE_DRGB", 32); + personalities[4].footprint = std::min(512, int(strip.getLengthTotal()) * 3 + 1); + + strncpy(personalities[5].description, "MULTIPLE_RGBW", 32); + personalities[5].footprint = std::min(512, int(strip.getLengthTotal()) * 4); + + strncpy(personalities[6].description, "EFFECT_W", 32); + personalities[6].footprint = 18; + + strncpy(personalities[7].description, "EFFECT_SEGMENT", 32); + personalities[7].footprint = std::min(512, strip.getSegmentsNum() * 15); + + strncpy(personalities[8].description, "EFFECT_SEGMENT_W", 32); + personalities[8].footprint = std::min(512, strip.getSegmentsNum() * 18); + + strncpy(personalities[9].description, "PRESET", 32); + personalities[9].footprint = 1; +} + void dmxReceiverTask(void *context) { DMXInput *instance = static_cast(context); @@ -103,10 +111,11 @@ void dmxReceiverTask(void *context) bool DMXInput::installDriver() { - const auto config = createConfig(); + createPersonalities(); + DEBUG_PRINTF("DMX port: %u\n", inputPortNum); - if (!dmx_driver_install(inputPortNum, &config, DMX_INTR_FLAGS_DEFAULT)) { + if (!dmx_driver_install(inputPortNum, &config, personalities, 10)) { DEBUG_PRINTF("Error: Failed to install dmx driver\n"); return false; } @@ -116,8 +125,14 @@ bool DMXInput::installDriver() DEBUG_PRINTF("DMX enable pin is: %u\n", enPin); dmx_set_pin(inputPortNum, txPin, rxPin, enPin); + // Set initial DMX start address and personality + dmx_set_start_address(inputPortNum, DMXAddress); + dmx_set_current_personality(inputPortNum, DMXMode); + + // Register RDM callbacks for start address and personality changes rdm_register_dmx_start_address(inputPortNum, rdmAddressChangedCb, this); - rdm_register_dmx_personality(inputPortNum, rdmPersonalityChangedCb, this); + rdm_register_dmx_personality(inputPortNum, 10, rdmPersonalityChangedCb, this); + initialized = true; return true; } @@ -151,9 +166,9 @@ void DMXInput::init(uint8_t rxPin, uint8_t txPin, uint8_t enPin, uint8_t inputPo const bool pinsAllocated = PinManager::allocateMultiplePins(pins, 3, PinOwner::DMX_INPUT); if (!pinsAllocated) { DEBUG_PRINTF("DMXInput: Error: Failed to allocate pins for DMX_INPUT. Pins already in use:\n"); - DEBUG_PRINTF("rx in use by: %s\n", PinManager::getPinOwner(rxPin)); - DEBUG_PRINTF("tx in use by: %s\n", PinManager::getPinOwner(txPin)); - DEBUG_PRINTF("en in use by: %s\n", PinManager::getPinOwner(enPin)); + DEBUG_PRINTF("rx in use by: %s\n", pinManager.getPinOwnerText(rxPin).c_str()); + DEBUG_PRINTF("tx in use by: %s\n", pinManager.getPinOwnerText(txPin).c_str()); + DEBUG_PRINTF("en in use by: %s\n", pinManager.getPinOwnerText(enPin).c_str()); return; } @@ -247,12 +262,11 @@ void DMXInput::enable() bool DMXInput::isIdentifyOn() const { - - uint8_t identify = 0; + bool identify = false; const bool gotIdentify = rdm_get_identify_device(inputPortNum, &identify); // gotIdentify should never be false because it is a default parameter in rdm // but just in case we check for it anyway - return bool(identify) && gotIdentify; + return identify && gotIdentify; } void DMXInput::checkAndUpdateConfig() diff --git a/wled00/dmx_input.h b/wled00/dmx_input.h index 29f015bdc8..97056d64c9 100644 --- a/wled00/dmx_input.h +++ b/wled00/dmx_input.h @@ -42,12 +42,12 @@ class DMXInput void updateInternal(); // is invoked whenver the dmx start address is changed via rdm - friend void rdmAddressChangedCb(dmx_port_t dmxPort, const rdm_header_t *header, - void *context); + friend void rdmAddressChangedCb(dmx_port_t dmxPort, rdm_header_t *request_header, + rdm_header_t *response_header, void *context); // is invoked whenever the personality is changed via rdm - friend void rdmPersonalityChangedCb(dmx_port_t dmxPort, const rdm_header_t *header, - void *context); + friend void rdmPersonalityChangedCb(dmx_port_t dmxPort, rdm_header_t *request_header, + rdm_header_t *response_header, void *context); /// The internal dmx task. /// This is the main loop of the dmx receiver. It never returns. From 68dff2d392f20ddee370d4562ff32b33a01d00d3 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 10:53:41 +0000 Subject: [PATCH 11/45] mbedtls_sha1 workaround --- wled00/mbedtls_sha1_shim.cpp | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 wled00/mbedtls_sha1_shim.cpp diff --git a/wled00/mbedtls_sha1_shim.cpp b/wled00/mbedtls_sha1_shim.cpp new file mode 100644 index 0000000000..585a1ea946 --- /dev/null +++ b/wled00/mbedtls_sha1_shim.cpp @@ -0,0 +1,44 @@ +#include "mbedtls/sha1.h" +#include "SHA1Builder.h" + +// Wrapper functions to map mbedtls SHA1 calls to Arduino SHA1Builder +// This is needed because ESP-IDF 5.x disables SHA1 in mbedtls by default + +struct mbedtls_sha1_context_wrapper { + SHA1Builder builder; +}; + +extern "C" { + +void mbedtls_sha1_init(mbedtls_sha1_context *ctx) { + // Allocate wrapper + auto* wrapper = new mbedtls_sha1_context_wrapper(); + *(void**)ctx = wrapper; +} + +int mbedtls_sha1_starts(mbedtls_sha1_context *ctx) { + auto* wrapper = *(mbedtls_sha1_context_wrapper**)ctx; + wrapper->builder.begin(); + return 0; +} + +int mbedtls_sha1_update(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen) { + auto* wrapper = *(mbedtls_sha1_context_wrapper**)ctx; + wrapper->builder.add((const uint8_t*)input, ilen); + return 0; +} + +int mbedtls_sha1_finish(mbedtls_sha1_context *ctx, unsigned char output[20]) { + auto* wrapper = *(mbedtls_sha1_context_wrapper**)ctx; + wrapper->builder.calculate(); + wrapper->builder.getBytes(output); + return 0; +} + +void mbedtls_sha1_free(mbedtls_sha1_context *ctx) { + auto* wrapper = *(mbedtls_sha1_context_wrapper**)ctx; + delete wrapper; +} + +} // extern "C" + From 7daada1f3eb23e134c434c531f0fa6b2953cd25d Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 11:18:25 +0000 Subject: [PATCH 12/45] fix for esp32_eth --- platformio.ini | 4 ++-- wled00/network.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/platformio.ini b/platformio.ini index d4983118be..eb23c3da7c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -470,9 +470,9 @@ platform = ${esp32_idf_V5.platform} upload_speed = 921600 custom_usermods = ${common.default_usermods} build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\"ESP32_Ethernet\" -D RLYPIN=-1 -D WLED_USE_ETHERNET -D BTNPIN=-1 +build_flags = ${common.build_flags} ${esp32_idf_V5.build_flags} -D WLED_RELEASE_NAME=\"ESP32_Ethernet\" -D RLYPIN=-1 -D WLED_USE_ETHERNET -D BTNPIN=-1 ; -D WLED_DISABLE_ESPNOW ;; ESP-NOW requires wifi, may crash with ethernet only -lib_deps = ${esp32.lib_deps} +lib_deps = ${esp32_idf_V5.lib_deps} board_build.partitions = ${esp32.default_partitions} board_build.flash_mode = dio diff --git a/wled00/network.cpp b/wled00/network.cpp index de326bbee6..174df1c631 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -222,11 +222,11 @@ bool initEthernet() #endif if (!ETH.begin( - (uint8_t) es.eth_address, - (int) es.eth_power, + (eth_phy_type_t) es.eth_type, + (int32_t) es.eth_address, (int) es.eth_mdc, (int) es.eth_mdio, - (eth_phy_type_t) es.eth_type, + (int) es.eth_power, (eth_clock_mode_t) es.eth_clk_mode )) { DEBUG_PRINTLN(F("initC: ETH.begin() failed")); @@ -396,7 +396,7 @@ void WiFiEvent(WiFiEvent_t event) if (!apActive) { WiFi.disconnect(true); // disable WiFi entirely } - if (multiWiFi[0].staticIP != (uint32_t)0x00000000 && multiWiFi[0].staticGW != (uint32_t)0x00000000) { + if (multiWiFi[0].staticIP != IPAddress(0,0,0,0) && multiWiFi[0].staticGW != IPAddress(0,0,0,0)) { ETH.config(multiWiFi[0].staticIP, multiWiFi[0].staticGW, multiWiFi[0].staticSN, dnsAddress); } else { ETH.config(INADDR_NONE, INADDR_NONE, INADDR_NONE); From 446c04380ee861b51fa7bc47fa5f173ce159e01c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 11:20:03 +0000 Subject: [PATCH 13/45] fix for esp32_eth --- wled00/xml.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/xml.cpp b/wled00/xml.cpp index e4f165732a..bb0056e4cf 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -240,7 +240,7 @@ void getSettingsJS(byte subPage, Print& settingsScript) sprintf(s, "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]); #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) - if (Network.isEthernet()) strcat_P(s ,PSTR(" (Ethernet)")); + if (WLEDNetwork.isEthernet()) strcat_P(s ,PSTR(" (Ethernet)")); #endif printSetClassElementHTML(settingsScript,PSTR("sip"),0,s); } else From d4bafec0f3ad5b1c7c482d162931c19895550777 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 11:27:33 +0000 Subject: [PATCH 14/45] WLED_DISABLE_MQTT for 8266 --- platformio.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platformio.ini b/platformio.ini index eb23c3da7c..e57c27bed5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -195,6 +195,7 @@ build_flags = -D PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48 ;; in case of linker errors like "section `.text1' will not fit in region `iram1_0_seg'" ; -D PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED ;; (experimental) adds some extra heap, but may cause slowdown -D NON32XFER_HANDLER ;; ask forgiveness for PROGMEM misuse + -D WLED_DISABLE_MQTT ;; TODO: remove once we have updated library for V5 lib_deps = #https://github.com/lorol/LITTLEFS.git @@ -215,6 +216,7 @@ build_flags_compat = -DVTABLES_IN_FLASH -DMIMETYPE_MINIMAL -DWLED_SAVE_IRAM ;; needed to prevent linker error + -D WLED_DISABLE_MQTT ;; TODO: remove once we have updated library for V5 ;; this platform version was used for WLED 0.14.0 platform_compat = espressif8266@4.2.0 From 2f8882ee569a81ccbf250b5b9c61742cf298260b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 11:39:02 +0000 Subject: [PATCH 15/45] WLED_DISABLE_INFRARED for 8266 --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index e57c27bed5..a5bc6f4a66 100644 --- a/platformio.ini +++ b/platformio.ini @@ -196,7 +196,7 @@ build_flags = ; -D PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED ;; (experimental) adds some extra heap, but may cause slowdown -D NON32XFER_HANDLER ;; ask forgiveness for PROGMEM misuse -D WLED_DISABLE_MQTT ;; TODO: remove once we have updated library for V5 - + -D WLED_DISABLE_INFRARED ;; TODO: remove once we have updated for V5 lib_deps = #https://github.com/lorol/LITTLEFS.git ESPAsyncTCP @ 1.2.2 From 52051109602cc0b6b9f3628749d9e774477f2139 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 11:40:00 +0000 Subject: [PATCH 16/45] mbedtls_sha1_shim.cpp not required for 8266 --- wled00/mbedtls_sha1_shim.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wled00/mbedtls_sha1_shim.cpp b/wled00/mbedtls_sha1_shim.cpp index 585a1ea946..8561afcfc3 100644 --- a/wled00/mbedtls_sha1_shim.cpp +++ b/wled00/mbedtls_sha1_shim.cpp @@ -1,3 +1,6 @@ +#include "wled.h" +#ifdef ESP32 +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0) #include "mbedtls/sha1.h" #include "SHA1Builder.h" @@ -42,3 +45,6 @@ void mbedtls_sha1_free(mbedtls_sha1_context *ctx) { } // extern "C" +#endif + +#endif From 906d4560a72a4d7bf53347c25966a2c4cca88ea2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 11:43:38 +0000 Subject: [PATCH 17/45] fix for pin usage logger --- wled00/dmx_input.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wled00/dmx_input.cpp b/wled00/dmx_input.cpp index 45d385fdcb..96a5221933 100644 --- a/wled00/dmx_input.cpp +++ b/wled00/dmx_input.cpp @@ -166,9 +166,9 @@ void DMXInput::init(uint8_t rxPin, uint8_t txPin, uint8_t enPin, uint8_t inputPo const bool pinsAllocated = PinManager::allocateMultiplePins(pins, 3, PinOwner::DMX_INPUT); if (!pinsAllocated) { DEBUG_PRINTF("DMXInput: Error: Failed to allocate pins for DMX_INPUT. Pins already in use:\n"); - DEBUG_PRINTF("rx in use by: %s\n", pinManager.getPinOwnerText(rxPin).c_str()); - DEBUG_PRINTF("tx in use by: %s\n", pinManager.getPinOwnerText(txPin).c_str()); - DEBUG_PRINTF("en in use by: %s\n", pinManager.getPinOwnerText(enPin).c_str()); + DEBUG_PRINTF("rx in use by: %hhd\n", PinManager::getPinOwner(rxPin)); + DEBUG_PRINTF("tx in use by: %hhd\n", PinManager::getPinOwner(txPin)); + DEBUG_PRINTF("en in use by: %hhd\n", PinManager::getPinOwner(enPin)); return; } From 41878f01f94f2a87dddb79b1ec99ef0592a34562 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 11:51:08 +0000 Subject: [PATCH 18/45] WLED_DISABLE_INFRARED for 8266 --- platformio.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platformio.ini b/platformio.ini index a5bc6f4a66..cd4e6b215e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -359,6 +359,8 @@ platform = ${esp8266.platform_compat} platform_packages = ${esp8266.platform_packages_compat} build_flags = ${common.build_flags} ${esp8266.build_flags_compat} -D WLED_RELEASE_NAME=\"ESP8266_compat\" #-DWLED_DISABLE_2D -D WLED_DISABLE_PARTICLESYSTEM2D + -D WLED_DISABLE_INFRARED ;; TODO: remove once we have updated for V5 + ;; lib_deps = ${esp8266.lib_deps_compat} ;; experimental - use older NeoPixelBus 2.7.9 [env:nodemcuv2_160] @@ -387,6 +389,8 @@ platform_packages = ${esp8266.platform_packages_compat} build_flags = ${common.build_flags} ${esp8266.build_flags_compat} -D WLED_RELEASE_NAME=\"ESP02_compat\" #-DWLED_DISABLE_2D -D WLED_DISABLE_PARTICLESYSTEM1D -D WLED_DISABLE_PARTICLESYSTEM2D + -D WLED_DISABLE_INFRARED ;; TODO: remove once we have updated for V5 + [env:esp8266_2m_160] extends = env:esp8266_2m From 44a483f45400518d101c47fe90a8e5dae37c516e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 11:55:01 +0000 Subject: [PATCH 19/45] WLED_DISABLE_INFRARED for 8266 --- platformio.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platformio.ini b/platformio.ini index cd4e6b215e..12622bdc18 100644 --- a/platformio.ini +++ b/platformio.ini @@ -410,6 +410,8 @@ build_flags = ${common.build_flags} ${esp8266.build_flags} -D WLED_RELEASE_NAME= ; -D WLED_USE_REAL_MATH ;; may fix wrong sunset/sunrise times, at the cost of 7064 bytes FLASH and 975 bytes RAM -D WLED_DISABLE_PARTICLESYSTEM1D -D WLED_DISABLE_PARTICLESYSTEM2D + -D WLED_DISABLE_INFRARED ;; TODO: remove once we have updated for V5 + lib_deps = ${esp8266.lib_deps} [env:esp01_1m_full_compat] From 7a0325f88f89dd51fdff4f2d48cc63746b2b8c2e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 12:02:25 +0000 Subject: [PATCH 20/45] WLED_DISABLE_INFRARED for 8266 --- platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio.ini b/platformio.ini index 12622bdc18..424d5a9b7d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -422,6 +422,7 @@ platform_packages = ${esp8266.platform_packages_compat} build_flags = ${common.build_flags} ${esp8266.build_flags_compat} -D WLED_RELEASE_NAME=\"ESP01_compat\" -D WLED_DISABLE_OTA #-DWLED_DISABLE_2D -D WLED_DISABLE_PARTICLESYSTEM1D -D WLED_DISABLE_PARTICLESYSTEM2D + -D WLED_DISABLE_INFRARED ;; TODO: remove once we have updated for V5 [env:esp01_1m_full_160] extends = env:esp01_1m_full From 86679edd1fe5d90bee2e5029ad12775a1f85a4f3 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 12:07:49 +0000 Subject: [PATCH 21/45] ESP-IDF fix for PWM_fan.cpp --- usermods/PWM_fan/PWM_fan.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usermods/PWM_fan/PWM_fan.cpp b/usermods/PWM_fan/PWM_fan.cpp index a0939f0854..079cbc7f1c 100644 --- a/usermods/PWM_fan/PWM_fan.cpp +++ b/usermods/PWM_fan/PWM_fan.cpp @@ -129,11 +129,14 @@ class PWMFanUsermod : public Usermod { if (pwmChannel == 255) { //no more free LEDC channels deinitPWMfan(); return; } - // configure LED PWM functionalitites + // configure LED PWM functionalitites - ESP-IDF 5.x API + #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) + ledcAttach(pwmPin, 25000, 8); // New API: ledcAttach(pin, freq, resolution) + #else ledcSetup(pwmChannel, 25000, 8); - // attach the channel to the GPIO to be controlled ledcAttachPin(pwmPin, pwmChannel); #endif + #endif DEBUG_PRINTLN(F("Fan PWM sucessfully initialized.")); } From c5e2ec72bd693e2e91d34c919f46170b41f2e474 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 12:08:50 +0000 Subject: [PATCH 22/45] WLED_DISABLE_INFRARED for 8266 --- platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio.ini b/platformio.ini index 424d5a9b7d..da684434be 100644 --- a/platformio.ini +++ b/platformio.ini @@ -423,6 +423,7 @@ build_flags = ${common.build_flags} ${esp8266.build_flags_compat} -D WLED_RELEAS -D WLED_DISABLE_PARTICLESYSTEM1D -D WLED_DISABLE_PARTICLESYSTEM2D -D WLED_DISABLE_INFRARED ;; TODO: remove once we have updated for V5 + -D WLED_DISABLE_INFRARED ;; TODO: remove once we have updated for V5 [env:esp01_1m_full_160] extends = env:esp01_1m_full From 93821efb9065051a2c0db2d3bcefa10c53808c1f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 12:11:48 +0000 Subject: [PATCH 23/45] disable usermods build for now --- platformio.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index da684434be..60878bb3c3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,7 +10,8 @@ # ------------------------------------------------------------------------------ # CI/release binaries -default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, nodemcuv2_160, esp8266_2m_160, esp01_1m_full_160, nodemcuv2_compat, esp8266_2m_compat, esp01_1m_full_compat, esp32dev, esp32_eth, lolin_s2_mini, esp32c3dev, esp32s3dev_16MB_opi, esp32s3dev_8MB_opi, esp32s3_4M_qspi, esp32_wrover, usermods +default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, nodemcuv2_160, esp8266_2m_160, esp01_1m_full_160, nodemcuv2_compat, esp8266_2m_compat, esp01_1m_full_compat, esp32dev, esp32_eth, lolin_s2_mini, esp32c3dev, esp32s3dev_16MB_opi, esp32s3dev_8MB_opi, esp32s3_4M_qspi, esp32_wrover +# usermods src_dir = ./wled00 data_dir = ./wled00/data From ce84a57a0d0839a9dcda681bdf4eed8ebddf442e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 12:44:26 +0000 Subject: [PATCH 24/45] NeoEsp32RmtHI does not support V5 --- platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio.ini b/platformio.ini index afa57dc7b5..cb09567684 100644 --- a/platformio.ini +++ b/platformio.ini @@ -296,6 +296,7 @@ build_flags = -g -D WLED_DISABLE_INFRARED ;; TODO: remove once we have updated library for V5 -D WLED_DISABLE_MQTT ;; TODO: remove once we have updated library for V5 -D WLED_ENABLE_DMX_INPUT + -D WLED_USE_SHARED_RMT ;; Use standard RMT method instead of incompatible NeoEsp32RmtHI - until updated for V5 lib_deps = ${esp32_all_variants.lib_deps} https://github.com/netmindz/esp_dmx/#esp-idf-v5-fixes From 2af23fc0cd48fd99f43c5e490bd5c743f1fc2eea Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 12:49:27 +0000 Subject: [PATCH 25/45] AsyncTCP 3.4.7 does not support V5 --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index cb09567684..195053aa49 100644 --- a/platformio.ini +++ b/platformio.ini @@ -257,7 +257,7 @@ lib_deps_compat = [esp32_all_variants] lib_deps = - esp32async/AsyncTCP @ 3.4.7 + esp32async/AsyncTCP @ 3.4.6 bitbank2/AnimatedGIF@^1.4.7 https://github.com/Aircoookie/GifDecoder#bc3af18 build_flags = From 51e1f4fc04239ab91942b8f19fe04b5f3afb431e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 12:49:52 +0000 Subject: [PATCH 26/45] NeoEsp32RmtHI does not support V5 --- platformio.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platformio.ini b/platformio.ini index 195053aa49..53284eaae0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -301,6 +301,9 @@ lib_deps = ${esp32_all_variants.lib_deps} https://github.com/netmindz/esp_dmx/#esp-idf-v5-fixes ${env.lib_deps} +lib_ignore = + NeoESP32RmtHI +lib_ldf_mode = chain+ ; Ensure proper dependency scanning [esp32s2] ;; generic definitions for all ESP32-S2 boards From 065385490413400cfdc1a6bb66a6061b1b218b1d Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 13:03:55 +0000 Subject: [PATCH 27/45] NeoEsp32RmtHI does not support V5 --- lib/NeoESP32RmtHI/include/NeoEsp32RmtHIMethod.h | 3 +++ lib/NeoESP32RmtHI/src/NeoEsp32RmtHIMethod.cpp | 6 +++++- platformio.ini | 1 - 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/NeoESP32RmtHI/include/NeoEsp32RmtHIMethod.h b/lib/NeoESP32RmtHI/include/NeoEsp32RmtHIMethod.h index 02e066f741..5b172989c9 100644 --- a/lib/NeoESP32RmtHI/include/NeoEsp32RmtHIMethod.h +++ b/lib/NeoESP32RmtHI/include/NeoEsp32RmtHIMethod.h @@ -1,3 +1,4 @@ +#if false /*------------------------------------------------------------------------- NeoPixel driver for ESP32 RMTs using High-priority Interrupt @@ -467,3 +468,5 @@ typedef NeoEsp32RmtHI7Ws2805InvertedMethod NeoEsp32RmtHI7Ws2814InvertedMethod; #endif // !defined(CONFIG_IDF_TARGET_ESP32C3) #endif + +#endif // NEOE_SP32_RMT_HI_METHODS_H \ No newline at end of file diff --git a/lib/NeoESP32RmtHI/src/NeoEsp32RmtHIMethod.cpp b/lib/NeoESP32RmtHI/src/NeoEsp32RmtHIMethod.cpp index 8353201f08..20a7955ed5 100644 --- a/lib/NeoESP32RmtHI/src/NeoEsp32RmtHIMethod.cpp +++ b/lib/NeoESP32RmtHI/src/NeoEsp32RmtHIMethod.cpp @@ -1,3 +1,5 @@ +#if false + /*------------------------------------------------------------------------- NeoPixel library helper functions for Esp32. @@ -504,4 +506,6 @@ esp_err_t NeoEsp32RmtHiMethodDriver::WaitForTxDone(rmt_channel_t channel, TickTy return rv; } -#endif \ No newline at end of file +#endif + +#endif // ARDUINO_ARCH_ESP32 \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 53284eaae0..9d1e4f22f1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -303,7 +303,6 @@ lib_deps = ${env.lib_deps} lib_ignore = NeoESP32RmtHI -lib_ldf_mode = chain+ ; Ensure proper dependency scanning [esp32s2] ;; generic definitions for all ESP32-S2 boards From 36eaca6cb2925cd4cd806605c81ee664464b5f70 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 13:24:39 +0000 Subject: [PATCH 28/45] NeoEsp32RmtHI does not support V5 --- platformio.ini | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index 9d1e4f22f1..90a6f2a0d3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -23,11 +23,11 @@ default_envs = nodemcuv2 esp32dev_debug esp32_eth esp32_wrover - lolin_s2_mini + ; lolin_s2_mini ;; TODO: disabled NeoEsp32RmtMethodIsr esp32c3dev - esp32s3dev_16MB_opi - esp32s3dev_8MB_opi - esp32s3_4M_qspi + ; esp32s3dev_16MB_opi ;; TODO: disabled NeoEsp32RmtMethodIsr + ; esp32s3dev_8MB_opi ;; TODO: disabled NeoEsp32RmtMethodIsr + ;esp32s3_4M_qspi ;; TODO: disabled NeoEsp32RmtMethodIsr ; usermods src_dir = ./wled00 @@ -118,6 +118,7 @@ build_flags = -D DECODE_SAMSUNG=true -D DECODE_LG=true -DWLED_USE_MY_CONFIG + -D WLED_USE_SHARED_RMT ;; Use standard RMT method instead of incompatible NeoEsp32RmtHI - until updated for V5 build_unflags = From 7c8b8fd0f3b558d237735c64cfbdd8fb5269e006 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 15:02:09 +0000 Subject: [PATCH 29/45] NeoPixelBus CORE3 --- platformio.ini | 2 +- wled00/bus_wrapper.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 90a6f2a0d3..2aca5bef37 100644 --- a/platformio.ini +++ b/platformio.ini @@ -162,7 +162,7 @@ lib_compat_mode = strict lib_deps = fastled/FastLED @ 3.10.1 ; IRremoteESP8266 @ 2.8.2 - makuna/NeoPixelBus @ 2.8.3 + https://github.com/netmindz/NeoPixelBus.git#2f05279a4a9f56875fb85482e6ec4e17078accc3 ;; CORE3 with log fix https://github.com/Aircoookie/ESPAsyncWebServer.git#v2.4.2 marvinroger/AsyncMqttClient @ 0.9.0 # for I2C interface diff --git a/wled00/bus_wrapper.h b/wled00/bus_wrapper.h index b2ff947418..0bc3cc4ec5 100644 --- a/wled00/bus_wrapper.h +++ b/wled00/bus_wrapper.h @@ -5,6 +5,20 @@ //#define NPB_CONF_4STEP_CADENCE #include "NeoPixelBus.h" +// --- temporary shim for NeoPixelBus CORE3 / RMT driver_v2 ------------------ +#if __has_include() + #define NeoEsp32RmtNWs2812xMethod NeoEsp32RmtXWs2812xMethod + #define NeoEsp32RmtNSk6812Method NeoEsp32RmtXSk6812Method + #define NeoEsp32RmtN800KbpsMethod NeoEsp32RmtX800KbpsMethod + #define NeoEsp32RmtN400KbpsMethod NeoEsp32RmtX400KbpsMethod + #define NeoEsp32RmtNTm1814Method NeoEsp32RmtXTm1814Method + #define NeoEsp32RmtNTm1829Method NeoEsp32RmtXTm1829Method + #define NeoEsp32RmtNTm1914Method NeoEsp32RmtXTm1914Method + #define NeoEsp32RmtNApa106Method NeoEsp32RmtXApa106Method + #define NeoEsp32RmtNWs2805Method NeoEsp32RmtXWs2805Method +#endif +// --------------------------------------------------------------------------- + //Hardware SPI Pins #define P_8266_HS_MOSI 13 #define P_8266_HS_CLK 14 From d632cf8e8ce46ad1cdb0b4e71a12746d0e9ee9a7 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 15:02:33 +0000 Subject: [PATCH 30/45] improve esp32_dev env --- platformio.ini | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 2aca5bef37..25a7fc5fc3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -471,7 +471,10 @@ board_build.flash_mode = dio [env:esp32dev_debug] extends = env:esp32dev -build_unflags = -D WLED_RELEASE_NAME=\"ESP32_V4\" +build_type = debug +monitor_filters = esp32_exception_decoder +upload_speed = 921600 +build_unflags = -D WLED_RELEASE_NAME=\"ESP32\" build_flags = ${env:esp32dev.build_flags} -D WLED_DEBUG -D WLED_RELEASE_NAME=\"ESP32_DEBUG\" From b51e80f5ddf5eb0ec9141607bbcd360a3fdf3c4a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 16:28:19 +0000 Subject: [PATCH 31/45] Safety check: ensure multiWiFi is never empty to prevent crashes during serialization --- wled00/wled.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wled00/wled.cpp b/wled00/wled.cpp index bbf11f9909..e51101995d 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -658,11 +658,17 @@ void WLED::initConnection() WiFi.setPhyMode(force802_3g ? WIFI_PHY_MODE_11G : WIFI_PHY_MODE_11N); #endif - if (multiWiFi[selectedWiFi].staticIP != 0U && multiWiFi[selectedWiFi].staticGW != 0U) { +if (multiWiFi.empty()) { // guard: handle empty WiFi list safely + WiFi.config(IPAddress((uint32_t)0), IPAddress((uint32_t)0), IPAddress((uint32_t)0)); + } else { + if (selectedWiFi >= multiWiFi.size()) selectedWiFi = 0; // guard: ensure valid index + if (multiWiFi[selectedWiFi].staticIP != IPAddress((uint32_t)0) && + multiWiFi[selectedWiFi].staticGW != IPAddress((uint32_t)0)) { // guard: compare as IPAddress to avoid pointer overload WiFi.config(multiWiFi[selectedWiFi].staticIP, multiWiFi[selectedWiFi].staticGW, multiWiFi[selectedWiFi].staticSN, dnsAddress); } else { WiFi.config(IPAddress((uint32_t)0), IPAddress((uint32_t)0), IPAddress((uint32_t)0)); } + } lastReconnectAttempt = millis(); From 9f3e53a5167808b8ad43ceb7bb626e83b55f803a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Nov 2025 16:39:31 +0000 Subject: [PATCH 32/45] disable 8266 builds for now --- platformio.ini | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/platformio.ini b/platformio.ini index 25a7fc5fc3..aeb5ad88bf 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,15 +10,16 @@ # ------------------------------------------------------------------------------ # CI/release binaries -default_envs = nodemcuv2 - esp8266_2m - esp01_1m_full - nodemcuv2_160 - esp8266_2m_160 - esp01_1m_full_160 - nodemcuv2_compat - esp8266_2m_compat - esp01_1m_full_compat +default_envs = +; nodemcuv2 +; esp8266_2m +; esp01_1m_full +; nodemcuv2_160 +; esp8266_2m_160 +; esp01_1m_full_160 +; nodemcuv2_compat +; esp8266_2m_compat +; esp01_1m_full_compat esp32dev esp32dev_debug esp32_eth From 9743775fb5901b1d9e855abfbc07714f532d91c3 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 1 Dec 2025 00:19:59 +0100 Subject: [PATCH 33/45] bring back lost esp_idf_v4 section (from main) for back-to-back testing, and for compatibility with user-specific platformio_override.ini --- platformio.ini | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/platformio.ini b/platformio.ini index aeb5ad88bf..43864ed7f3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -287,6 +287,28 @@ AR_build_flags = ;; -fsingle-precision-constant ;; forces ArduinoFFT to use floa AR_lib_deps = ;; for pre-usermod-library platformio_override compatibility +[esp32_idf_V4] +;; build environment for ESP32 using ESP-IDF 4.4.x / arduino-esp32 v2.0.5 +;; *** important: build flags from esp32_idf_V4 are inherited by _all_ esp32-based MCUs: esp32, esp32s2, esp32s3, esp32c3 +;; +;; please note that you can NOT update existing ESP32 installs with a "V4" build. Also updating by OTA will not work properly. +;; You need to completely erase your device (esptool erase_flash) first, then install the "V4" build from VSCode+platformio. + +;; select arduino-esp32 v2.0.9 (arduino-esp32 2.0.10 thru 2.0.14 are buggy so avoid them) +platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.06.02/platform-espressif32.zip ;; Tasmota Arduino Core 2.0.9 with IPv6 support, based on IDF 4.4.4 +platform_packages = +build_unflags = ${common.build_unflags} +build_flags = -g + -Wshadow=compatible-local ;; emit warning in case a local variable "shadows" another local one + -DARDUINO_ARCH_ESP32 -DESP32 + ${esp32_all_variants.build_flags} + -D WLED_ENABLE_DMX_INPUT +lib_deps = + ${esp32_all_variants.lib_deps} + https://github.com/someweisguy/esp_dmx.git#47db25d + ${env.lib_deps} + + [esp32_idf_V5] ;; build environment for ESP32 using ESP-IDF 5.3.3 / arduino-esp32 v3.1.3 platform = https://github.com/tasmota/platform-espressif32/releases/download/2025.08.30/platform-espressif32-2025.08.30.zip ;; Platform 2025.08.30 Tasmota Arduino Core 3.1.3.250808 based on IDF 5.3.3.250801 From 79e2128e71863db6146b05e1bdba2868790585ea Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 1 Dec 2025 00:21:14 +0100 Subject: [PATCH 34/45] add flag to disable the new arduino-esp32 RMT leds driver causes conflicts with NeoPixelBus --- platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio.ini b/platformio.ini index 43864ed7f3..1df43c2b89 100644 --- a/platformio.ini +++ b/platformio.ini @@ -321,6 +321,7 @@ build_flags = -g -D WLED_DISABLE_MQTT ;; TODO: remove once we have updated library for V5 -D WLED_ENABLE_DMX_INPUT -D WLED_USE_SHARED_RMT ;; Use standard RMT method instead of incompatible NeoEsp32RmtHI - until updated for V5 + -D ESP32_ARDUINO_NO_RGB_BUILTIN ;; avoids RMT driver abort on startup "E (98) rmt(legacy): CONFLICT! driver_ng is not allowed to be used with the legacy driver" lib_deps = ${esp32_all_variants.lib_deps} https://github.com/netmindz/esp_dmx/#esp-idf-v5-fixes From ecfcd0da19022a822fb514bbafac15e6cfd5e860 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 1 Dec 2025 00:41:29 +0100 Subject: [PATCH 35/45] fix compiler warning "ESP32 redefined", add buildenv sanity check * fix for warning: "ESP32" redefined * wled.h: add sanity check to catch conflicting / missing defines --- platformio.ini | 5 +++-- wled00/wled.h | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 1df43c2b89..280c62fdb4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -315,7 +315,8 @@ platform = https://github.com/tasmota/platform-espressif32/releases/download/202 build_unflags = ${common.build_unflags} build_flags = -g -Wshadow=compatible-local ;; emit warning in case a local variable "shadows" another local one - -DARDUINO_ARCH_ESP32 -DESP32 + -DARDUINO_ARCH_ESP32 + ; -DESP32=ESP32 ;; disabled to avoid compiler warning: "ESP32" redefined ${esp32_all_variants.build_flags} -D WLED_DISABLE_INFRARED ;; TODO: remove once we have updated library for V5 -D WLED_DISABLE_MQTT ;; TODO: remove once we have updated library for V5 @@ -370,7 +371,7 @@ board_build.flash_mode = qio platform = ${esp32_idf_V5.platform} build_unflags = ${common.build_unflags} build_flags = -g - -DESP32 + ;; -DESP32 ;; disabled to avoid compiler warning: "ESP32" redefined -DARDUINO_ARCH_ESP32 -DARDUINO_ARCH_ESP32S3 -DCONFIG_IDF_TARGET_ESP32S3=1 diff --git a/wled00/wled.h b/wled00/wled.h index b480c1a30a..36c1e38d6e 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -75,6 +75,18 @@ // Library inclusions. #include + +// buildenv sanity check +#if !defined(ESP32) && !defined(ESP8266) +#error neither ESP32 nor ESP8266 defined. Please fix your build environment. +#endif +#if defined(ESP8266) && (defined(ARDUINO_ARCH_ESP32) || defined(ESP32)) +#error both ESP8266 and ESP32/ARDUINO_ARCH_ESP32 defined. Please fix your build environment. +#endif +#if (defined(ARDUINO_ARCH_ESP32) && !defined(ESP32)) || (defined(ESP32) && !defined(ARDUINO_ARCH_ESP32)) +#error either ESP32 or ARDUINO_ARCH_ESP32 not defined. Please fix your build environment. +#endif + #ifdef ESP8266 #include #include From a55209415c7302a8124341a1d5e1357f99450d56 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 1 Dec 2025 14:02:24 +0100 Subject: [PATCH 36/45] Refactor software version label handling in DMX input revert changes imported from main branch --- wled00/dmx_input.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wled00/dmx_input.cpp b/wled00/dmx_input.cpp index 5ccd5e8f5e..854e713d4f 100644 --- a/wled00/dmx_input.cpp +++ b/wled00/dmx_input.cpp @@ -53,6 +53,8 @@ static dmx_config_t createConfig() config.product_category = RDM_PRODUCT_CATEGORY_FIXTURE; config.software_version_id = VERSION; +#if 0 + // softhack007: ToDO: current code from main does not work in V5 yet const std::string dmxWledVersionString = "WLED_V" + std::to_string(VERSION); strncpy(config.software_version_label, dmxWledVersionString.c_str(), 32); config.software_version_label[32] = '\0'; // zero termination in case versionString string was longer than 32 chars @@ -81,6 +83,11 @@ static dmx_config_t createConfig() config.personality_count = 10; // rdm personalities are numbered from 1, thus we can just set the DMXMode directly. config.current_personality = DMXMode; + #else + // fallback code + const std::string versionString = "WLED_V" + std::to_string(VERSION); + config.software_version_label = versionString.c_str(); + #endif return config; } @@ -317,4 +324,4 @@ void DMXInput::checkAndUpdateConfig() } } -#endif \ No newline at end of file +#endif From 2c7923e17d078d9e02dc0f052df23d4594c5b99a Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 1 Dec 2025 14:43:33 +0100 Subject: [PATCH 37/45] fix name clash in dmx_input.cpp versionString was clashing with a structure defined in wled.h => build errors. --- wled00/dmx_input.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/dmx_input.cpp b/wled00/dmx_input.cpp index 854e713d4f..24d017ea95 100644 --- a/wled00/dmx_input.cpp +++ b/wled00/dmx_input.cpp @@ -85,8 +85,8 @@ static dmx_config_t createConfig() config.current_personality = DMXMode; #else // fallback code - const std::string versionString = "WLED_V" + std::to_string(VERSION); - config.software_version_label = versionString.c_str(); + const std::string DmxVersionString = "WLED_V" + std::to_string(VERSION); + config.software_version_label = DmxVersionString.c_str(); #endif return config; From 83b541e1baee90d8807299e2cf2b4fd5ab096bf4 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 1 Dec 2025 14:58:51 +0100 Subject: [PATCH 38/45] fix broken indentation in platformio.ini, disable usermod builds hoping that this will finally solve errors in the standard builds --- platformio.ini | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/platformio.ini b/platformio.ini index eb77d23154..c5d38b73fd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,27 +11,27 @@ # CI/release binaries default_envs = -; nodemcuv2 -; esp8266_2m -; esp01_1m_full -; nodemcuv2_160 -; esp8266_2m_160 -; esp01_1m_full_160 -; nodemcuv2_compat -; esp8266_2m_compat -; esp01_1m_full_compat + ; nodemcuv2 + ; esp8266_2m + ; esp01_1m_full + ; nodemcuv2_160 + ; esp8266_2m_160 + ; esp01_1m_full_160 + ; nodemcuv2_compat + ; esp8266_2m_compat + ; esp01_1m_full_compat esp32dev esp32dev_debug esp32_eth esp32_wrover - ; lolin_s2_mini ;; TODO: disabled NeoEsp32RmtMethodIsr + ; lolin_s2_mini ;; TODO: disabled NeoEsp32RmtMethodIsr esp32c3dev ; esp32s3dev_16MB_opi ;; TODO: disabled NeoEsp32RmtMethodIsr - ; esp32s3dev_8MB_opi ;; TODO: disabled NeoEsp32RmtMethodIsr - ;esp32s3_4M_qspi ;; TODO: disabled NeoEsp32RmtMethodIsr + ; esp32s3dev_8MB_opi ;; TODO: disabled NeoEsp32RmtMethodIsr + ; esp32s3_4M_qspi ;; TODO: disabled NeoEsp32RmtMethodIsr esp32c3dev_qio - ; esp32S3_wroom2 -; usermods + ; esp32S3_wroom2 + ; usermods src_dir = ./wled00 data_dir = ./wled00/data @@ -732,5 +732,6 @@ build_flags = ${common.build_flags} ${esp32_idf_V5.build_flags} -D WLED_RELEASE_ lib_deps = ${esp32_idf_V5.lib_deps} monitor_filters = esp32_exception_decoder board_build.flash_mode = dio -custom_usermods = * ; Expands to all usermods in usermods folder +;custom_usermods = * ; Expands to all usermods in usermods folder +custom_usermods = ; ToDO: fix usermods build once the main V5 build works without errors and warnings board_build.partitions = ${esp32.extreme_partitions} ; We're gonna need a bigger boat From 71920659e137e64eb6d17d7d424393663be20d56 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 1 Dec 2025 15:18:56 +0100 Subject: [PATCH 39/45] temporarily disable getDeviceId() feature for V5 builds lots of deprecated functions and esp-idf structures ... Disabled until we find a way to make this work in V5 --- wled00/fcn_declare.h | 4 ++++ wled00/json.cpp | 2 ++ wled00/util.cpp | 3 +++ 3 files changed, 9 insertions(+) diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index 2346ee450b..d950b16655 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -401,8 +401,12 @@ uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxL int16_t extractModeDefaults(uint8_t mode, const char *segVar); void checkSettingsPIN(const char *pin); uint16_t crc16(const unsigned char* data_p, size_t length); + +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)// ToDO: find a solution to make this work in V5 String computeSHA1(const String& input); String getDeviceId(); +#endif + uint16_t beatsin88_t(accum88 beats_per_minute_88, uint16_t lowest = 0, uint16_t highest = 65535, uint32_t timebase = 0, uint16_t phase_offset = 0); uint16_t beatsin16_t(accum88 beats_per_minute, uint16_t lowest = 0, uint16_t highest = 65535, uint32_t timebase = 0, uint16_t phase_offset = 0); uint8_t beatsin8_t(accum88 beats_per_minute, uint8_t lowest = 0, uint8_t highest = 255, uint32_t timebase = 0, uint8_t phase_offset = 0); diff --git a/wled00/json.cpp b/wled00/json.cpp index 8dff8f0ad4..35fde73c69 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -699,7 +699,9 @@ void serializeInfo(JsonObject root) root[F("cn")] = F(WLED_CODENAME); root[F("release")] = releaseString; root[F("repo")] = repoString; +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)// ToDO: find a solution to make this work in V5 root[F("deviceId")] = getDeviceId(); +#endif JsonObject leds = root.createNestedObject(F("leds")); leds[F("count")] = strip.getLengthTotal(); diff --git a/wled00/util.cpp b/wled00/util.cpp index d135cc4f87..391e2873fb 100644 --- a/wled00/util.cpp +++ b/wled00/util.cpp @@ -1132,6 +1132,8 @@ uint8_t perlin8(uint16_t x, uint16_t y, uint16_t z) { return (((perlin3D_raw((uint32_t)x << 8, (uint32_t)y << 8, (uint32_t)z << 8, true) * 2015) >> 10) + 33168) >> 8; //scale to 16 bit, offset, then scale to 8bit } +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) // ToDO: find a solution to make this work in V5 + // Platform-agnostic SHA1 computation from String input String computeSHA1(const String& input) { #ifdef ESP8266 @@ -1224,4 +1226,5 @@ String getDeviceId() { return cachedDeviceId; } +#endif // V5 workaround From 2245e0e0df15e2fc1332ec2dd4aa9a7916c01144 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 1 Dec 2025 20:53:08 +0100 Subject: [PATCH 40/45] optional: newer tasmota core --- platformio.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platformio.ini b/platformio.ini index 8741022048..eb2fbde1b7 100644 --- a/platformio.ini +++ b/platformio.ini @@ -314,6 +314,8 @@ lib_deps = [esp32_idf_V5] ;; build environment for ESP32 using ESP-IDF 5.3.3 / arduino-esp32 v3.1.3 platform = https://github.com/tasmota/platform-espressif32/releases/download/2025.08.30/platform-espressif32-2025.08.30.zip ;; Platform 2025.08.30 Tasmota Arduino Core 3.1.3.250808 based on IDF 5.3.3.250801 +;; (optiona) latest tasmota core for ESP32 family, based on ESP-IDF 5.3.4.251110 and Arduino core 3.3.4 +;; platform = https://github.com/tasmota/platform-espressif32/releases/download/2025.11.31/platform-espressif32.zip platform_packages = build_unflags = ${common.build_unflags} build_flags = -g From 5ef41e7d3bb2bb1017e90e868058a9cbc6658892 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 1 Dec 2025 16:29:07 +0000 Subject: [PATCH 41/45] Fix usermods.yml to only run for external fork PRs Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com> --- .github/workflows/usermods.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/usermods.yml b/.github/workflows/usermods.yml index 9b60e40062..3452ed46b9 100644 --- a/.github/workflows/usermods.yml +++ b/.github/workflows/usermods.yml @@ -12,6 +12,8 @@ on: jobs: get_usermod_envs: + # Run on push events, or on pull_request events only from forks (not from branches within wled/WLED) + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository name: Gather Usermods runs-on: ubuntu-latest steps: @@ -31,6 +33,8 @@ jobs: build: + # Run on push events, or on pull_request events only from forks (not from branches within wled/WLED) + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository name: Build Enviornments runs-on: ubuntu-latest needs: get_usermod_envs From 8ea41cf2d2606477af573134fbc19c85000f67b9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 1 Dec 2025 16:46:13 +0000 Subject: [PATCH 42/45] Remove push trigger, only run usermods CI for external fork PRs Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com> --- .github/workflows/usermods.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/usermods.yml b/.github/workflows/usermods.yml index 3452ed46b9..e8ab65066d 100644 --- a/.github/workflows/usermods.yml +++ b/.github/workflows/usermods.yml @@ -1,10 +1,6 @@ name: Usermod CI on: - push: - paths: - - usermods/** - - .github/workflows/usermods.yml pull_request: paths: - usermods/** @@ -12,8 +8,8 @@ on: jobs: get_usermod_envs: - # Run on push events, or on pull_request events only from forks (not from branches within wled/WLED) - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository + # Only run for pull requests from forks (not from branches within wled/WLED) + if: github.event.pull_request.head.repo.full_name != github.repository name: Gather Usermods runs-on: ubuntu-latest steps: @@ -33,8 +29,8 @@ jobs: build: - # Run on push events, or on pull_request events only from forks (not from branches within wled/WLED) - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository + # Only run for pull requests from forks (not from branches within wled/WLED) + if: github.event.pull_request.head.repo.full_name != github.repository name: Build Enviornments runs-on: ubuntu-latest needs: get_usermod_envs From 0b27bc37bd94c5cda2223fa5858328262d32fe3b Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 1 Dec 2025 23:41:12 +0100 Subject: [PATCH 43/45] fix compiler warning for WLED_MAX_ANALOG_CHANNELS in V5, LEDC_CHANNEL_MAX and LEDC_SPEED_MODE_MAX are enum constants, and the compiler does not allow a macro where enums are implicitly treated as int. Solution: change into constexpr with static type cast => still computed by the compiler and does not create any local variable. --- wled00/const.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wled00/const.h b/wled00/const.h index ac48838435..3daefe8e93 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -61,7 +61,10 @@ constexpr size_t FIXED_PALETTE_COUNT = DYNAMIC_PALETTE_COUNT + FASTLED_PALETTE_C #if !defined(LEDC_CHANNEL_MAX) || !defined(LEDC_SPEED_MODE_MAX) #include "driver/ledc.h" // needed for analog/LEDC channel counts #endif - #define WLED_MAX_ANALOG_CHANNELS (LEDC_CHANNEL_MAX*LEDC_SPEED_MODE_MAX) + + // define -> constexpr to avoid preprocessor errors and enum arithmetic warnings from newer compilers + constexpr size_t WLED_MAX_ANALOG_CHANNELS = static_cast(LEDC_CHANNEL_MAX) * static_cast(LEDC_SPEED_MODE_MAX); + #if defined(CONFIG_IDF_TARGET_ESP32C3) // 2 RMT, 6 LEDC, only has 1 I2S but NPB does not support it ATM #define WLED_MAX_DIGITAL_CHANNELS 2 //#define WLED_MAX_ANALOG_CHANNELS 6 From 5d54597ffcf6d61871ef6eed066722f2d71ac544 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 1 Dec 2025 23:47:37 +0100 Subject: [PATCH 44/45] change dependancy logic for proper inheritance of build_unflags and lib_ignore * esp32_idf_V5 has the main build_unflags and lib_ignore * next level (esp32, esp32s3, esp32s2, esp32c3) inherits from esp32_idf_V5 * user buildenvs _only_ inherit from (esp32, esp32s3, esp32s2, esp32c3) --- platformio.ini | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index eb2fbde1b7..f5a7fa9524 100644 --- a/platformio.ini +++ b/platformio.ini @@ -272,9 +272,10 @@ build_flags = [esp32] platform = ${esp32_idf_V5.platform} platform_packages = -build_unflags = ${common.build_unflags} +build_unflags = ${esp32_idf_V5.build_flags} build_flags = ${esp32_idf_V5.build_flags} lib_deps = ${esp32_idf_V5.lib_deps} +lib_ignore = ${esp32_idf_V5.lib_ignore} tiny_partitions = tools/WLED_ESP32_2MB_noOTA.csv default_partitions = tools/WLED_ESP32_4MB_1MB_FS.csv @@ -339,7 +340,7 @@ lib_ignore = ;; generic definitions for all ESP32-S2 boards platform = ${esp32_idf_V5.platform} platform_packages = ${esp32_idf_V5.platform_packages} -build_unflags = ${common.build_unflags} +build_unflags = ${esp32_idf_V5.build_unflags} build_flags = -g -DARDUINO_ARCH_ESP32 -DARDUINO_ARCH_ESP32S2 @@ -352,13 +353,14 @@ build_flags = -g ${esp32_idf_V5.build_flags} lib_deps = ${esp32_idf_V5.lib_deps} +lib_ignore = ${esp32_idf_V5.lib_ignore} board_build.partitions = ${esp32.default_partitions} ;; default partioning for 4MB Flash - can be overridden in build envs [esp32c3] ;; generic definitions for all ESP32-C3 boards platform = ${esp32_idf_V5.platform} platform_packages = ${esp32_idf_V5.platform_packages} -build_unflags = ${common.build_unflags} +build_unflags = ${esp32_idf_V5.build_unflags} build_flags = -g -DARDUINO_ARCH_ESP32 -DARDUINO_ARCH_ESP32C3 @@ -370,6 +372,7 @@ build_flags = -g ${esp32_idf_V5.build_flags} lib_deps = ${esp32_idf_V5.lib_deps} +lib_ignore = ${esp32_idf_V5.lib_ignore} board_build.partitions = ${esp32.default_partitions} ;; default partioning for 4MB Flash - can be overridden in build envs board_build.flash_mode = qio From 29c7b5072732023108292a5593673b03376a454d Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 1 Dec 2025 23:48:15 +0100 Subject: [PATCH 45/45] fix stupid warning for c files --- platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio.ini b/platformio.ini index f5a7fa9524..30bd07554a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -319,6 +319,7 @@ platform = https://github.com/tasmota/platform-espressif32/releases/download/202 ;; platform = https://github.com/tasmota/platform-espressif32/releases/download/2025.11.31/platform-espressif32.zip platform_packages = build_unflags = ${common.build_unflags} + -Wno-volatile ;; avoid warning on .c files: "-Wno-volatile only applies to c++ files" build_flags = -g -Wshadow=compatible-local ;; emit warning in case a local variable "shadows" another local one -DARDUINO_ARCH_ESP32