diff --git a/lib/client.js b/lib/client.js index ebf4c6bd..553a7b98 100644 --- a/lib/client.js +++ b/lib/client.js @@ -478,6 +478,12 @@ class Client extends EventEmitter { } header.apduType = baApdu.getDecodedType(buffer, offset); header.expectingReply = !!(result.funct & baEnum.NpduControlBit.EXPECTING_REPLY); + if (result.source) { + // SNET of the host. Integer. + header.sender.net = result.source.net; + // SADR of the host. Integer[]. + header.sender.adr = result.source.adr; + } this._handlePdu(buffer, offset, msgLength, header); } diff --git a/lib/npdu.js b/lib/npdu.js index 6878ba83..abeddcf4 100644 --- a/lib/npdu.js +++ b/lib/npdu.js @@ -52,7 +52,10 @@ module.exports.decodeFunction = (buffer, offset) => { module.exports.decode = (buffer, offset) => { let adrLen; const orgOffset = offset; - offset++; + const protocolVersion = buffer[offset++]; + if (protocolVersion !== BACNET_PROTOCOL_VERSION) { + return undefined; + } const funct = buffer[offset++]; let destination; if (funct & baEnum.NpduControlBit.DESTINATION_SPECIFIED) { @@ -80,9 +83,6 @@ module.exports.decode = (buffer, offset) => { offset += 2; } } - if (buffer[orgOffset + 0] !== BACNET_PROTOCOL_VERSION) { - return undefined; - } return { len: offset - orgOffset, funct, diff --git a/package.json b/package.json index 63f82d72..aaaf97bb 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,9 @@ { "name": "Ingo Fischer", "email": "iobroker@fischer-ka.de" + }, + { + "name": "Colin Kuebler (kueblc)" } ], "engines": {