From aa9d5431f85c1c7a1bb6c03176d9c872dbb8e6a5 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Wed, 24 Nov 2021 20:44:04 +0100 Subject: [PATCH] Changed payloadSize to payloadData with payloadSize getter --- src/dto/Packet.js | 5 ++++- src/streamHandler/PacketStreamFactory.js | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dto/Packet.js b/src/dto/Packet.js index 66b7f80..2162779 100644 --- a/src/dto/Packet.js +++ b/src/dto/Packet.js @@ -24,7 +24,10 @@ class Packet{ frequency; dataRate; - payloadSize; + payloadData; + get payloadSize(){ + return payloadData.length/2; + } packetType; } diff --git a/src/streamHandler/PacketStreamFactory.js b/src/streamHandler/PacketStreamFactory.js index 668683d..3770075 100644 --- a/src/streamHandler/PacketStreamFactory.js +++ b/src/streamHandler/PacketStreamFactory.js @@ -76,8 +76,7 @@ class PacketStreamFactory extends Transform{ _handlePayload(packet, data){ // Get payload-Hex-Data. If there is no data: empty - let payloadData = data.join('').match(/(?<=\s)([A-F0-9]{1,4}(?!(\.|x)))/igm)?.join('') ?? ''; - packet.payloadSize = payloadData.length/2; // 2 hex-chars = 1 byte + packet.payloadData = data.join('').match(/(?<=\s)([A-F0-9]{1,4}(?!(\.|x)))/igm)?.join('') ?? ''; } }