add encoder for RTTrPL packet

This commit is contained in:
2025-03-15 13:20:41 -05:00
parent bd427c2de3
commit 96e4e12ca3
3 changed files with 44 additions and 0 deletions
+2
View File
@@ -1,5 +1,6 @@
import ChannelBlock from './lighting/channel-block';
import LightingOutput from './lighting/lighting-output';
import RTTrPL from './lighting/rttrpl';
import Spot from './lighting/spot';
import Universe from './lighting/universe';
import CentroidAccelVelocity from './motion/centroid-accel-velocity';
@@ -17,6 +18,7 @@ import RTTrPHeader from './rttrp-header';
export const Encoders = {
RTTrPHeader,
RTTrPM,
RTTrPL,
Trackable,
CentroidPosition,
OrientationQuaternion,
+27
View File
@@ -0,0 +1,27 @@
import RTTrPHeader from '../rttrp-header';
export default (
packetId: number,
context: number,
lightingOutputs: Uint8Array[],
isLittleEndian: boolean = false
): Uint8Array => {
let totalPacketSize = 18; //header size
lightingOutputs.forEach((lightingOutput) => {
totalPacketSize += lightingOutput.length;
});
const bytes = new Uint8Array(totalPacketSize);
let dataOffset = 0;
const headerBytes = RTTrPHeader(0x4434, 0x02, packetId, 0x00, context, lightingOutputs, isLittleEndian);
bytes.set(headerBytes, dataOffset);
dataOffset += headerBytes.length;
lightingOutputs.forEach((lightingOutput) => {
bytes.set(lightingOutput, dataOffset);
dataOffset += lightingOutput.length;
});
return bytes;
};