add sdt NAK data decoding

This commit is contained in:
2024-12-07 11:41:03 -06:00
parent af67fe3cfe
commit 759ae56bdc
3 changed files with 43 additions and 5 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ not sure how far I will take this but messing around with E1.17 ACN protocol
- [x] JOIN_REFUSE - [x] JOIN_REFUSE
- [x] JOIN_ACCEPT - [x] JOIN_ACCEPT
- [x] LEAVING - [x] LEAVING
- [ ] NAK - [x] NAK
- [x] REL_WRAP - [x] REL_WRAP
- [x] UNREL_WRAP - [x] UNREL_WRAP
- [x] GET_SESSIONS - [x] GET_SESSIONS
+19 -1
View File
@@ -111,6 +111,15 @@ export type SDTAckData = {
reliableSequenceNumber: number; reliableSequenceNumber: number;
}; };
export type SDTNakData = {
leaderComponenetID: string;
channelNumber: number;
memberID: number;
reliableSequenceNumber: number;
firstMissedSequence: number;
lastMissedSequence: number;
};
export type SDTGetSessionsData = { export type SDTGetSessionsData = {
componentID: string; componentID: string;
}; };
@@ -118,7 +127,16 @@ export type SDTGetSessionsData = {
export type SessionDataTransportPDU = { export type SessionDataTransportPDU = {
vector: SessionDataTransportVectors; vector: SessionDataTransportVectors;
// TODO(jwetzell): cleanup these types // TODO(jwetzell): cleanup these types
data: SDTJoinData | SDTJoinAcceptData | SDTJoinRefuseData | SDTWrapperData | SDTAckData | SDTLeavingData | SDTGetSessionsData | Uint8Array; data:
| SDTJoinData
| SDTJoinAcceptData
| SDTJoinRefuseData
| SDTWrapperData
| SDTAckData
| SDTLeavingData
| SDTGetSessionsData
| SDTNakData
| Uint8Array;
}; };
export type SDTClientBlock = { export type SDTClientBlock = {
+22 -2
View File
@@ -6,6 +6,7 @@ import {
SDTJoinData, SDTJoinData,
SDTJoinRefuseData, SDTJoinRefuseData,
SDTLeavingData, SDTLeavingData,
SDTNakData,
SDTWrapperData, SDTWrapperData,
SessionDataTransportPDU, SessionDataTransportPDU,
SessionDataTransportVectors, SessionDataTransportVectors,
@@ -125,7 +126,16 @@ function decodeClientBlock(bytes: Uint8Array) {
function decodeData( function decodeData(
vector: SessionDataTransportVectors, vector: SessionDataTransportVectors,
bytes: Uint8Array bytes: Uint8Array
): SDTJoinData | SDTJoinAcceptData | SDTJoinRefuseData | SDTWrapperData | SDTAckData | SDTLeavingData | SDTGetSessionsData | Uint8Array { ):
| SDTJoinData
| SDTJoinAcceptData
| SDTJoinRefuseData
| SDTWrapperData
| SDTAckData
| SDTLeavingData
| SDTGetSessionsData
| SDTNakData
| Uint8Array {
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
switch (vector) { switch (vector) {
case SessionDataTransportVectors.JOIN: { case SessionDataTransportVectors.JOIN: {
@@ -212,8 +222,18 @@ function decodeData(
} }
case SessionDataTransportVectors.GET_SESSIONS: { case SessionDataTransportVectors.GET_SESSIONS: {
return { return {
componentID: toHex(bytes.subarray(0, 16)) componentID: toHex(bytes.subarray(0, 16)),
};
} }
case SessionDataTransportVectors.NAK: {
return {
leaderComponentID: toHex(bytes.subarray(0, 16)),
channelNumber: view.getUint16(16),
memberID: view.getUint16(18),
reliableSequenceNumber: view.getUint32(20),
firstMissedSequence: view.getUint32(24),
lastMissedSequence: view.getUint32(28),
};
} }
default: default:
console.error(`unhandled SDT vector: ${vector}`); console.error(`unhandled SDT vector: ${vector}`);