Skip to content

Commit bd31dd2

Browse files
committed
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)
1 parent 63db2c9 commit bd31dd2

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

wled00/const.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,11 @@
446446
#ifdef ESP8266
447447
#define E131_MAX_UNIVERSE_COUNT 9
448448
#else
449-
#define E131_MAX_UNIVERSE_COUNT 12
449+
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C6)
450+
#define E131_MAX_UNIVERSE_COUNT 112 // WLEDMM enough universes for 128 x 128 pixels, for boards that can handle it
451+
#else
452+
#define E131_MAX_UNIVERSE_COUNT 12 // WLEDMM use upstream default for S2 and C3
453+
#endif
450454
#endif
451455
#endif
452456
#endif

wled00/e131.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/*
88
* E1.31 handler
99
*/
10+
static byte e131LastSequenceNumber[E131_MAX_UNIVERSE_COUNT] = {0}; // to detect packet loss // WLEDMM moved from wled.h into e131.cpp
1011

1112
//DDP protocol support, called by handleE131Packet
1213
//handles RGB data only
@@ -94,11 +95,12 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
9495
}
9596

9697
// only listen for universes we're handling & allocated memory
97-
if (uni < e131Universe || uni >= (e131Universe + E131_MAX_UNIVERSE_COUNT)) return;
98+
//if (uni < e131Universe || uni >= (e131Universe + E131_MAX_UNIVERSE_COUNT)) return;
99+
if (uni < e131Universe || uni >= e131Universe + 256) return; // WLEDMM just prevent overflow
98100

99101
uint8_t previousUniverses = uni - e131Universe;
100102

101-
if (e131SkipOutOfSequence)
103+
if (e131SkipOutOfSequence && (previousUniverses < E131_MAX_UNIVERSE_COUNT)) // WLEDMM
102104
if (seq < e131LastSequenceNumber[previousUniverses] && seq > 20 && e131LastSequenceNumber[previousUniverses] < 250){
103105
DEBUG_PRINT(F("skipping E1.31 frame (last seq="));
104106
DEBUG_PRINT(e131LastSequenceNumber[previousUniverses]);
@@ -109,7 +111,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
109111
DEBUG_PRINTLN(")");
110112
return;
111113
}
112-
e131LastSequenceNumber[previousUniverses] = seq;
114+
if (previousUniverses < E131_MAX_UNIVERSE_COUNT) e131LastSequenceNumber[previousUniverses] = seq; // WLEDMM prevent array bounds violation
113115

114116
// update status info
115117
realtimeIP = clientIP;

wled00/wled.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
// version code in format yymmddb (b = daily build)
10-
#define VERSION 2501160
10+
#define VERSION 2501161
1111

1212
// 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.
1313
#define _MoonModules_WLED_
@@ -471,7 +471,7 @@ WLED_GLOBAL E131Priority highPriority _INIT(3); // E1.31 highe
471471
WLED_GLOBAL byte DMXMode _INIT(DMX_MODE_MULTIPLE_RGB); // DMX mode (s.a.)
472472
WLED_GLOBAL uint16_t DMXAddress _INIT(1); // DMX start address of fixture, a.k.a. first Channel [for E1.31 (sACN) protocol]
473473
WLED_GLOBAL uint16_t DMXSegmentSpacing _INIT(0); // Number of void/unused channels between each segments DMX channels
474-
WLED_GLOBAL byte e131LastSequenceNumber[E131_MAX_UNIVERSE_COUNT]; // to detect packet loss
474+
//WLED_GLOBAL byte e131LastSequenceNumber[E131_MAX_UNIVERSE_COUNT]; // to detect packet loss // WLEDMM move into e131.cpp - array is not used anywhere else
475475
WLED_GLOBAL bool e131Multicast _INIT(false); // multicast or unicast
476476
WLED_GLOBAL bool e131SkipOutOfSequence _INIT(false); // freeze instead of flickering
477477
WLED_GLOBAL uint16_t pollReplyCount _INIT(0); // count number of replies for ArtPoll node report

0 commit comments

Comments
 (0)