add E1.31 packet out-of-sequence config option, wrt #742

This commit is contained in:
pille 2020-03-10 18:21:16 +01:00
parent bffe2d7bd0
commit 62510ac6a3
7 changed files with 25 additions and 12 deletions

View File

@ -85,6 +85,7 @@
<h3>Realtime</h3>
Receive UDP realtime: <input type="checkbox" name="RD"><br><br>
E1.31 (sACN)<br>
Skip out-of-sequence packets (freeze instead of flicker): <input type="checkbox" name="ES"><br>
Multicast mode: <input type="checkbox" name="EM"><br>
E1.31 start universe: <input name="EU" type="number" min="1" max="63999" required><br>
<i>Reboot required.</i> Check out <a href="https://github.com/ahodges9/LedFx" target="_blank">LedFx</a>!<br><br>

View File

@ -284,6 +284,7 @@ Send notifications twice: <input type="checkbox" name="S2">
<h3>Realtime</h3>
Receive UDP realtime: <input type="checkbox" name="RD"><br><br>
<i>E1.31 (sACN)</i><br>
Skip out-of-sequence packets (freeze instead of flicker): <input type="checkbox" name="ES"><br>
Use E1.31 multicast: <input type="checkbox" name="EM"><br>
E1.31 start universe: <input name="EU" type="number" min="1" max="63999" required><br>
<i>Reboot required.</i> Check out <a href="https://github.com/ahodges9/LedFx" target="_blank">LedFx</a>!<br>

View File

@ -213,6 +213,7 @@ uint16_t DMXAddress = 1; //DMX start address of fixture, a.
uint8_t DMXOldDimmer = 0; //only update brightness on change
uint8_t e131LastSequenceNumber[E131_MAX_UNIVERSE_COUNT]; //to detect packet loss
bool e131Multicast = false; //multicast or unicast
bool e131SkipOutOfSequence = false; //freeze instead of flickering
bool mqttEnabled = false;
char mqttDeviceTopic[33] = ""; //main MQTT topic (individual per device, default is wled/mac)

View File

@ -6,7 +6,7 @@
#define EEPSIZE 2560 //Maximum is 4096
//eeprom Version code, enables default settings instead of 0 init on update
#define EEPVER 17
#define EEPVER 18
//0 -> old version, default
//1 -> 0.4p 1711272 and up
//2 -> 0.4p 1711302 and up
@ -25,6 +25,7 @@
//15-> 0.9.0-b3
//16-> 0.9.1
//17-> 0.9.1-dmx
//18-> 0.9.1-e131
void commit()
{
@ -208,6 +209,7 @@ void saveSettingsToEEPROM()
EEPROM.write(2181, macroNl);
EEPROM.write(2182, macroDoublePress);
EEPROM.write(2189, e131SkipOutOfSequence);
EEPROM.write(2190, e131Universe & 0xFF);
EEPROM.write(2191, (e131Universe >> 8) & 0xFF);
EEPROM.write(2192, e131Multicast);
@ -505,6 +507,12 @@ void loadSettingsFromEEPROM(bool first)
noWifiSleep = EEPROM.read(370);
//}
if (lastEEPROMversion > 17)
{
e131SkipOutOfSequence = EEPROM.read(2189);
} else {
e131SkipOutOfSequence = true;
}
receiveDirect = !EEPROM.read(2200);
notifyMacro = EEPROM.read(2201);

View File

@ -324,6 +324,7 @@ void getSettingsJS(byte subPage, char* dest)
sappend('c',"SM",notifyMacro);
sappend('c',"S2",notifyTwice);
sappend('c',"RD",receiveDirect);
sappend('c',"ES",e131SkipOutOfSequence);
sappend('c',"EM",e131Multicast);
sappend('v',"EU",e131Universe);
sappend('v',"DA",DMXAddress);

View File

@ -138,6 +138,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
notifyTwice = request->hasArg("S2");
receiveDirect = request->hasArg("RD");
e131SkipOutOfSequence = request->hasArg("ES");
e131Multicast = request->hasArg("EM");
t = request->arg("EU").toInt();
if (t > 0 && t <= 63999) e131Universe = t;

View File

@ -97,17 +97,17 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP){
// only listen for universes we're handling & allocated memory
if (uni >= (e131Universe + E131_MAX_UNIVERSE_COUNT)) return;
// skip out-of-sequence packets
if (p->sequence_number < e131LastSequenceNumber[uni-e131Universe] && p->sequence_number > 20 && e131LastSequenceNumber[uni-e131Universe] < 250){
DEBUG_PRINT("skipping E1.31 frame (last seq=");
DEBUG_PRINT(e131LastSequenceNumber[uni-e131Universe]);
DEBUG_PRINT(", current seq=");
DEBUG_PRINT(p->sequence_number);
DEBUG_PRINT(", universe=");
DEBUG_PRINT(uni);
DEBUG_PRINTLN(")");
return;
}
if (e131SkipOutOfSequence)
if (p->sequence_number < e131LastSequenceNumber[uni-e131Universe] && p->sequence_number > 20 && e131LastSequenceNumber[uni-e131Universe] < 250){
DEBUG_PRINT("skipping E1.31 frame (last seq=");
DEBUG_PRINT(e131LastSequenceNumber[uni-e131Universe]);
DEBUG_PRINT(", current seq=");
DEBUG_PRINT(p->sequence_number);
DEBUG_PRINT(", universe=");
DEBUG_PRINT(uni);
DEBUG_PRINTLN(")");
return;
}
e131LastSequenceNumber[uni-e131Universe] = p->sequence_number;
// update status info