Sync groups (#2150)
* Added UDP sync groups. * Shortened string. * Changed sync default to group 1 only. * Make packets with version < 9 group 1 * Send sync group options as bytes, parse in JS Co-authored-by: cschwinne <dev.aircoookie@gmail.com>
This commit is contained in:
@@ -4,13 +4,14 @@
|
||||
* UDP sync notifier / Realtime / Hyperion / TPM2.NET
|
||||
*/
|
||||
|
||||
#define WLEDPACKETSIZE 36
|
||||
#define WLEDPACKETSIZE 37
|
||||
#define UDP_IN_MAXSIZE 1472
|
||||
#define PRESUMED_NETWORK_DELAY 3 //how many ms could it take on avg to reach the receiver? This will be added to transmitted times
|
||||
|
||||
void notify(byte callMode, bool followUp)
|
||||
{
|
||||
if (!udpConnected) return;
|
||||
if (!syncGroups) return;
|
||||
switch (callMode)
|
||||
{
|
||||
case CALL_MODE_INIT: return;
|
||||
@@ -39,7 +40,8 @@ void notify(byte callMode, bool followUp)
|
||||
//0: old 1: supports white 2: supports secondary color
|
||||
//3: supports FX intensity, 24 byte packet 4: supports transitionDelay 5: sup palette
|
||||
//6: supports timebase syncing, 29 byte packet 7: supports tertiary color 8: supports sys time sync, 36 byte packet
|
||||
udpOut[11] = 8;
|
||||
//9: supports sync groups, 37 byte packet
|
||||
udpOut[11] = 9;
|
||||
udpOut[12] = colSec[0];
|
||||
udpOut[13] = colSec[1];
|
||||
udpOut[14] = colSec[2];
|
||||
@@ -72,6 +74,9 @@ void notify(byte callMode, bool followUp)
|
||||
uint16_t ms = tm.ms;
|
||||
udpOut[34] = (ms >> 8) & 0xFF;
|
||||
udpOut[35] = (ms >> 0) & 0xFF;
|
||||
|
||||
//sync groups
|
||||
udpOut[36] = syncGroups;
|
||||
|
||||
IPAddress broadcastIp;
|
||||
broadcastIp = ~uint32_t(Network.subnetMask()) | uint32_t(Network.gatewayIP());
|
||||
@@ -219,6 +224,12 @@ void handleNotifications()
|
||||
|
||||
//compatibilityVersionByte:
|
||||
byte version = udpIn[11];
|
||||
|
||||
// if we are not part of any sync group ignore message
|
||||
if (version < 9 || version > 199) {
|
||||
// legacy senders are treated as if sending in sync group 1 only
|
||||
if (!(receiveGroups & 0x01)) return;
|
||||
} else if (!(receiveGroups & udpIn[36])) return;
|
||||
|
||||
bool someSel = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
|
||||
//apply colors from notification
|
||||
@@ -263,7 +274,7 @@ void handleNotifications()
|
||||
}
|
||||
|
||||
//adjust system time, but only if sender is more accurate than self
|
||||
if (version > 7)
|
||||
if (version > 7 && version < 200)
|
||||
{
|
||||
Toki::Time tm;
|
||||
tm.sec = (udpIn[30] << 24) | (udpIn[31] << 16) | (udpIn[32] << 8) | (udpIn[33]);
|
||||
|
||||
Reference in New Issue
Block a user