From a47205ed9cc0585aa30805c78d3877c17398bfab Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Sat, 7 Dec 2024 12:06:03 -0600 Subject: [PATCH] add sdt connect, connect accept, connect refuse data decoding --- README.md | 6 +++--- packages/acn/src/models.ts | 13 +++++++++++++ packages/acn/src/pdu/sdt.ts | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1293b2d..4c10d6c 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,9 @@ not sure how far I will take this but messing around with E1.17 ACN protocol - [x] ACK - [ ] CHANNEL_PARAMS - [ ] LEAVE - - [ ] CONNECT - - [ ] CONNECT_ACCEPT - - [ ] CONNECT_REFUSE + - [x] CONNECT + - [x] CONNECT_ACCEPT + - [x] CONNECT_REFUSE - [ ] DISCONNECT - [ ] DISCONNECTING - dmp diff --git a/packages/acn/src/models.ts b/packages/acn/src/models.ts index e9a49e3..64432e8 100644 --- a/packages/acn/src/models.ts +++ b/packages/acn/src/models.ts @@ -120,6 +120,16 @@ export type SDTNakData = { lastMissedSequence: number; }; +export type SDTConnectData = { + protocolID: number; +}; + +export type SDTConnectAcceptData = SDTConnectData; +export type SDTConnectRefuseData = { + protocolID: number; + refuseCode: number; +}; + export type SDTGetSessionsData = { componentID: string; }; @@ -136,6 +146,9 @@ export type SessionDataTransportPDU = { | SDTLeavingData | SDTGetSessionsData | SDTNakData + | SDTConnectData + | SDTConnectAcceptData + | SDTConnectRefuseData | Uint8Array; }; diff --git a/packages/acn/src/pdu/sdt.ts b/packages/acn/src/pdu/sdt.ts index a5e593d..661c507 100644 --- a/packages/acn/src/pdu/sdt.ts +++ b/packages/acn/src/pdu/sdt.ts @@ -1,6 +1,9 @@ import { Protocols, SDTAckData, + SDTConnectAcceptData, + SDTConnectData, + SDTConnectRefuseData, SDTGetSessionsData, SDTJoinAcceptData, SDTJoinData, @@ -135,6 +138,9 @@ function decodeData( | SDTLeavingData | SDTGetSessionsData | SDTNakData + | SDTConnectData + | SDTConnectAcceptData + | SDTConnectRefuseData | Uint8Array { const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); switch (vector) { @@ -235,6 +241,18 @@ function decodeData( lastMissedSequence: view.getUint32(28), }; } + case SessionDataTransportVectors.CONNECT: + case SessionDataTransportVectors.CONNECT_ACCEPT: { + return { + protocolID: view.getUint32(0), + }; + } + case SessionDataTransportVectors.CONNECT_REFUSE: { + return { + protocolID: view.getUint32(0), + refuseCode: view.getUint8(4), + }; + } default: console.error(`unhandled SDT vector: ${vector}`); return bytes;