Skip to content

Commit

Permalink
Add support for NACK reply to "GetValueById" cmd.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielwippermann committed Jul 23, 2020
1 parent 066c0bd commit d31f8aa
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,14 @@ const Connection = extend(Duplex, /** @lends Connection# */ {

const subIndex = (valueId >> 16) & 0x7F;
valueId = valueId & 0xFFFF;
const reqCommand = 0x0300 | subIndex;
const ackCommand = 0x0100 | subIndex;
const nackCommand = 0x4300 | subIndex;

const txDatagram = new Datagram({
destinationAddress: address,
sourceAddress: this.selfAddress,
command: 0x0300 | subIndex,
command: reqCommand,
valueId,
value: 0
}).toLiveBuffer();
Expand All @@ -507,12 +510,18 @@ const Connection = extend(Duplex, /** @lends Connection# */ {
// nop
} else if (rxDatagram.sourceAddress !== address) {
// nop
} else if (rxDatagram.command !== (0x0100 | subIndex)) {
// nop
} else if (rxDatagram.valueId !== valueId) {
// nop
} else {
done(null, rxDatagram);
} else if (rxDatagram.command === ackCommand) {
if (rxDatagram.valueId !== valueId) {
// nop
} else {
done(null, rxDatagram);
}
} else if (rxDatagram.command !== nackCommand) {
if (rxDatagram.valueId !== valueId) {
// nop
} else {
done(null, rxDatagram);
}
}
};

Expand Down

0 comments on commit d31f8aa

Please sign in to comment.