From af67fe3cfec5fc4aa2dba8bb23e7c61ce24a827e Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Sat, 7 Dec 2024 11:36:11 -0600 Subject: [PATCH] add sdt get sessions data decoding --- README.md | 16 ++++++++-------- packages/acn/src/models.ts | 6 +++++- packages/acn/src/pdu/sdt.ts | 8 +++++++- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2b05d92..fa46500 100644 --- a/README.md +++ b/README.md @@ -5,22 +5,22 @@ not sure how far I will take this but messing around with E1.17 ACN protocol - rlp - sdt - vectors - - [x] REL_WRAP - - [x] UNREL_WRAP - - [ ] CHANNEL_PARAMS - [x] JOIN - [x] JOIN_REFUSE - [x] JOIN_ACCEPT - - [ ] LEAVE - [x] LEAVING + - [ ] NAK + - [x] REL_WRAP + - [x] UNREL_WRAP + - [x] GET_SESSIONS + - [ ] SESSIONS + - [x] ACK + - [ ] CHANNEL_PARAMS + - [ ] LEAVE - [ ] CONNECT - [ ] CONNECT_ACCEPT - [ ] CONNECT_REFUSE - [ ] DISCONNECT - [ ] DISCONNECTING - - [x] ACK - - [ ] NAK - - [ ] GET_SESSIONS - - [ ] SESSIONS - dmp - ddl diff --git a/packages/acn/src/models.ts b/packages/acn/src/models.ts index 80fd115..addb466 100644 --- a/packages/acn/src/models.ts +++ b/packages/acn/src/models.ts @@ -111,10 +111,14 @@ export type SDTAckData = { reliableSequenceNumber: number; }; +export type SDTGetSessionsData = { + componentID: string; +}; + export type SessionDataTransportPDU = { vector: SessionDataTransportVectors; // TODO(jwetzell): cleanup these types - data: SDTJoinData | SDTJoinAcceptData | SDTJoinRefuseData | SDTWrapperData | SDTAckData | SDTLeavingData | Uint8Array; + data: SDTJoinData | SDTJoinAcceptData | SDTJoinRefuseData | SDTWrapperData | SDTAckData | SDTLeavingData | SDTGetSessionsData | Uint8Array; }; export type SDTClientBlock = { diff --git a/packages/acn/src/pdu/sdt.ts b/packages/acn/src/pdu/sdt.ts index 32c6a9b..02e2a34 100644 --- a/packages/acn/src/pdu/sdt.ts +++ b/packages/acn/src/pdu/sdt.ts @@ -1,6 +1,7 @@ import { Protocols, SDTAckData, + SDTGetSessionsData, SDTJoinAcceptData, SDTJoinData, SDTJoinRefuseData, @@ -124,7 +125,7 @@ function decodeClientBlock(bytes: Uint8Array) { function decodeData( vector: SessionDataTransportVectors, bytes: Uint8Array -): SDTJoinData | SDTJoinAcceptData | SDTJoinRefuseData | SDTWrapperData | SDTAckData | SDTLeavingData | Uint8Array { +): SDTJoinData | SDTJoinAcceptData | SDTJoinRefuseData | SDTWrapperData | SDTAckData | SDTLeavingData | SDTGetSessionsData | Uint8Array { const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); switch (vector) { case SessionDataTransportVectors.JOIN: { @@ -209,6 +210,11 @@ function decodeData( reasonCode: view.getUint8(24), }; } + case SessionDataTransportVectors.GET_SESSIONS: { + return { + componentID: toHex(bytes.subarray(0, 16)) + } + } default: console.error(`unhandled SDT vector: ${vector}`); return bytes;