mirror of
https://github.com/jwetzell/acn-js.git
synced 2026-08-13 10:43:38 +00:00
add sdt NAK data decoding
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user