applied suggestions from review
This commit is contained in:
parent
550b4d9dea
commit
4b5c3a396d
@ -46,13 +46,8 @@ class UdpNameSync : public Usermod {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char checksumSegName = 0;
|
const char* curName = mainseg.name ? mainseg.name : "";
|
||||||
char checksumCurName = 0;
|
if (strncmp(curName, segmentName, sizeof(segmentName)) == 0) return; // same name, do nothing
|
||||||
for(int i=0; i++; mainseg.name[i]==0 || segmentName[i]==0) {
|
|
||||||
checksumSegName+=segmentName[i];
|
|
||||||
checksumCurName+=mainseg.name[i];
|
|
||||||
}
|
|
||||||
if (checksumCurName == checksumSegName) return; // same name, do nothing
|
|
||||||
|
|
||||||
notifierUdp.beginPacket(broadcastIp, udpPort);
|
notifierUdp.beginPacket(broadcastIp, udpPort);
|
||||||
DEBUG_PRINT(F("UdpNameSync: saving segment name "));
|
DEBUG_PRINT(F("UdpNameSync: saving segment name "));
|
||||||
|
|||||||
@ -557,9 +557,6 @@ void handleNotifications()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// usermods hook can override processing
|
|
||||||
if (UsermodManager::onUdpPacket(udpIn, packetSize)) return;
|
|
||||||
|
|
||||||
//wled notifier, ignore if realtime packets active
|
//wled notifier, ignore if realtime packets active
|
||||||
if (udpIn[0] == 0 && !realtimeMode && receiveGroups)
|
if (udpIn[0] == 0 && !realtimeMode && receiveGroups)
|
||||||
{
|
{
|
||||||
@ -568,11 +565,9 @@ void handleNotifications()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!receiveDirect) return;
|
if (receiveDirect) {
|
||||||
|
|
||||||
//TPM2.NET
|
//TPM2.NET
|
||||||
if (udpIn[0] == 0x9c)
|
if (udpIn[0] == 0x9c) {
|
||||||
{
|
|
||||||
//WARNING: this code assumes that the final TMP2.NET payload is evenly distributed if using multiple packets (ie. frame size is constant)
|
//WARNING: this code assumes that the final TMP2.NET payload is evenly distributed if using multiple packets (ie. frame size is constant)
|
||||||
//if the number of LEDs in your installation doesn't allow that, please include padding bytes at the end of the last packet
|
//if the number of LEDs in your installation doesn't allow that, please include padding bytes at the end of the last packet
|
||||||
byte tpmType = udpIn[1];
|
byte tpmType = udpIn[1];
|
||||||
@ -604,8 +599,7 @@ void handleNotifications()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//UDP realtime: 1 warls 2 drgb 3 drgbw 4 dnrgb 5 dnrgbw
|
//UDP realtime: 1 warls 2 drgb 3 drgbw 4 dnrgb 5 dnrgbw
|
||||||
if (udpIn[0] > 0 && udpIn[0] < 6)
|
if (udpIn[0] > 0 && udpIn[0] < 6) {
|
||||||
{
|
|
||||||
realtimeIP = (isSupp) ? notifier2Udp.remoteIP() : notifierUdp.remoteIP();
|
realtimeIP = (isSupp) ? notifier2Udp.remoteIP() : notifierUdp.remoteIP();
|
||||||
DEBUG_PRINTLN(realtimeIP);
|
DEBUG_PRINTLN(realtimeIP);
|
||||||
if (packetSize < 2) return;
|
if (packetSize < 2) return;
|
||||||
@ -619,36 +613,27 @@ void handleNotifications()
|
|||||||
if (realtimeOverride) return;
|
if (realtimeOverride) return;
|
||||||
|
|
||||||
unsigned totalLen = strip.getLengthTotal();
|
unsigned totalLen = strip.getLengthTotal();
|
||||||
if (udpIn[0] == 1 && packetSize > 5) //warls
|
if (udpIn[0] == 1 && packetSize > 5) { //warls
|
||||||
{
|
for (size_t i = 2; i < packetSize -3; i += 4) {
|
||||||
for (size_t i = 2; i < packetSize -3; i += 4)
|
|
||||||
{
|
|
||||||
setRealtimePixel(udpIn[i], udpIn[i+1], udpIn[i+2], udpIn[i+3], 0);
|
setRealtimePixel(udpIn[i], udpIn[i+1], udpIn[i+2], udpIn[i+3], 0);
|
||||||
}
|
}
|
||||||
} else if (udpIn[0] == 2 && packetSize > 4) //drgb
|
} else if (udpIn[0] == 2 && packetSize > 4) { //drgb
|
||||||
{
|
|
||||||
for (size_t i = 2, id = 0; i < packetSize -2 && id < totalLen; i += 3, id++)
|
for (size_t i = 2, id = 0; i < packetSize -2 && id < totalLen; i += 3, id++)
|
||||||
{
|
{
|
||||||
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], 0);
|
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], 0);
|
||||||
}
|
}
|
||||||
} else if (udpIn[0] == 3 && packetSize > 6) //drgbw
|
} else if (udpIn[0] == 3 && packetSize > 6) { //drgbw
|
||||||
{
|
for (size_t i = 2, id = 0; i < packetSize -3 && id < totalLen; i += 4, id++) {
|
||||||
for (size_t i = 2, id = 0; i < packetSize -3 && id < totalLen; i += 4, id++)
|
|
||||||
{
|
|
||||||
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], udpIn[i+3]);
|
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], udpIn[i+3]);
|
||||||
}
|
}
|
||||||
} else if (udpIn[0] == 4 && packetSize > 7) //dnrgb
|
} else if (udpIn[0] == 4 && packetSize > 7) { //dnrgb
|
||||||
{
|
|
||||||
unsigned id = ((udpIn[3] << 0) & 0xFF) + ((udpIn[2] << 8) & 0xFF00);
|
unsigned id = ((udpIn[3] << 0) & 0xFF) + ((udpIn[2] << 8) & 0xFF00);
|
||||||
for (size_t i = 4; i < packetSize -2 && id < totalLen; i += 3, id++)
|
for (size_t i = 4; i < packetSize -2 && id < totalLen; i += 3, id++) {
|
||||||
{
|
|
||||||
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], 0);
|
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], 0);
|
||||||
}
|
}
|
||||||
} else if (udpIn[0] == 5 && packetSize > 8) //dnrgbw
|
} else if (udpIn[0] == 5 && packetSize > 8) { //dnrgbw
|
||||||
{
|
|
||||||
unsigned id = ((udpIn[3] << 0) & 0xFF) + ((udpIn[2] << 8) & 0xFF00);
|
unsigned id = ((udpIn[3] << 0) & 0xFF) + ((udpIn[2] << 8) & 0xFF00);
|
||||||
for (size_t i = 4; i < packetSize -2 && id < totalLen; i += 4, id++)
|
for (size_t i = 4; i < packetSize -2 && id < totalLen; i += 4, id++) {
|
||||||
{
|
|
||||||
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], udpIn[i+3]);
|
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], udpIn[i+3]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -656,6 +641,7 @@ void handleNotifications()
|
|||||||
else strip.show();
|
else strip.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// API over UDP
|
// API over UDP
|
||||||
udpIn[packetSize] = '\0';
|
udpIn[packetSize] = '\0';
|
||||||
@ -672,6 +658,8 @@ void handleNotifications()
|
|||||||
}
|
}
|
||||||
releaseJSONBufferLock();
|
releaseJSONBufferLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UsermodManager::onUdpPacket(udpIn, packetSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user