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_ACCEPT
- [x] LEAVING
- [ ] NAK
- [x] NAK
- [x] REL_WRAP
- [x] UNREL_WRAP
- [x] GET_SESSIONS
+19 -1
View File
@@ -111,6 +111,15 @@ export type SDTAckData = {
reliableSequenceNumber: number;
};
export type SDTNakData = {
leaderComponenetID: string;
channelNumber: number;
memberID: number;
reliableSequenceNumber: number;
firstMissedSequence: number;
lastMissedSequence: number;
};
export type SDTGetSessionsData = {
componentID: string;
};
@@ -118,7 +127,16 @@ export type SDTGetSessionsData = {
export type SessionDataTransportPDU = {
vector: SessionDataTransportVectors;
// 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 = {
+23 -3
View File
@@ -6,6 +6,7 @@ import {
SDTJoinData,
SDTJoinRefuseData,
SDTLeavingData,
SDTNakData,
SDTWrapperData,
SessionDataTransportPDU,
SessionDataTransportVectors,
@@ -125,7 +126,16 @@ function decodeClientBlock(bytes: Uint8Array) {
function decodeData(
vector: SessionDataTransportVectors,
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);
switch (vector) {
case SessionDataTransportVectors.JOIN: {
@@ -212,8 +222,18 @@ function decodeData(
}
case SessionDataTransportVectors.GET_SESSIONS: {
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:
console.error(`unhandled SDT vector: ${vector}`);