From bd31dd2508789d55ff8534d4da541f290204d105 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Thu, 16 Jan 2025 14:48:54 +0100 Subject: [PATCH] increase E131 max universes from 12 to 112 (esp32 boards only) * use a more meaningful max universes limit of 112 (safe up to 128x128 pixels) * accept more universes, but only track sequences for the configures max universes * made e131LastSequenceNumber[] local (its only used in e131.cpp) --- wled00/const.h | 6 +++++- wled00/e131.cpp | 8 +++++--- wled00/wled.h | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/wled00/const.h b/wled00/const.h index 2c6ac1a71b..f224751212 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -446,7 +446,11 @@ #ifdef ESP8266 #define E131_MAX_UNIVERSE_COUNT 9 #else - #define E131_MAX_UNIVERSE_COUNT 12 + #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C6) + #define E131_MAX_UNIVERSE_COUNT 112 // WLEDMM enough universes for 128 x 128 pixels, for boards that can handle it + #else + #define E131_MAX_UNIVERSE_COUNT 12 // WLEDMM use upstream default for S2 and C3 + #endif #endif #endif #endif diff --git a/wled00/e131.cpp b/wled00/e131.cpp index f83e17228c..a6123e7a50 100644 --- a/wled00/e131.cpp +++ b/wled00/e131.cpp @@ -7,6 +7,7 @@ /* * E1.31 handler */ +static byte e131LastSequenceNumber[E131_MAX_UNIVERSE_COUNT] = {0}; // to detect packet loss // WLEDMM moved from wled.h into e131.cpp //DDP protocol support, called by handleE131Packet //handles RGB data only @@ -94,11 +95,12 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){ } // only listen for universes we're handling & allocated memory - if (uni < e131Universe || uni >= (e131Universe + E131_MAX_UNIVERSE_COUNT)) return; + //if (uni < e131Universe || uni >= (e131Universe + E131_MAX_UNIVERSE_COUNT)) return; + if (uni < e131Universe || uni >= e131Universe + 256) return; // WLEDMM just prevent overflow uint8_t previousUniverses = uni - e131Universe; - if (e131SkipOutOfSequence) + if (e131SkipOutOfSequence && (previousUniverses < E131_MAX_UNIVERSE_COUNT)) // WLEDMM if (seq < e131LastSequenceNumber[previousUniverses] && seq > 20 && e131LastSequenceNumber[previousUniverses] < 250){ DEBUG_PRINT(F("skipping E1.31 frame (last seq=")); DEBUG_PRINT(e131LastSequenceNumber[previousUniverses]); @@ -109,7 +111,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){ DEBUG_PRINTLN(")"); return; } - e131LastSequenceNumber[previousUniverses] = seq; + if (previousUniverses < E131_MAX_UNIVERSE_COUNT) e131LastSequenceNumber[previousUniverses] = seq; // WLEDMM prevent array bounds violation // update status info realtimeIP = clientIP; diff --git a/wled00/wled.h b/wled00/wled.h index aa0687b1dc..7d29c740de 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -7,7 +7,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2501160 +#define VERSION 2501161 // WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED. #define _MoonModules_WLED_ @@ -471,7 +471,7 @@ WLED_GLOBAL E131Priority highPriority _INIT(3); // E1.31 highe WLED_GLOBAL byte DMXMode _INIT(DMX_MODE_MULTIPLE_RGB); // DMX mode (s.a.) WLED_GLOBAL uint16_t DMXAddress _INIT(1); // DMX start address of fixture, a.k.a. first Channel [for E1.31 (sACN) protocol] WLED_GLOBAL uint16_t DMXSegmentSpacing _INIT(0); // Number of void/unused channels between each segments DMX channels -WLED_GLOBAL byte e131LastSequenceNumber[E131_MAX_UNIVERSE_COUNT]; // to detect packet loss +//WLED_GLOBAL byte e131LastSequenceNumber[E131_MAX_UNIVERSE_COUNT]; // to detect packet loss // WLEDMM move into e131.cpp - array is not used anywhere else WLED_GLOBAL bool e131Multicast _INIT(false); // multicast or unicast WLED_GLOBAL bool e131SkipOutOfSequence _INIT(false); // freeze instead of flickering WLED_GLOBAL uint16_t pollReplyCount _INIT(0); // count number of replies for ArtPoll node report