knxultimate
Advanced tools
Comparing version
@@ -10,4 +10,10 @@  | ||
<p> | ||
<b>Version 1.0.19</b> - April 2022<br/> | ||
- Protected some functions to avoid issues in case of misuse.<br/> | ||
- The ACK of received telegrams is now called befor the "indication" event is emitted to the client.<br/> | ||
- Fixed some issues in the disconnection mechanism.<br/> | ||
</p> | ||
<p> | ||
<b>Version 1.0.18</b> - April 2022<br/> | ||
- NEW: new event has been added. The ackReceived event is triggered every time a telegram is sent over TunnelUDP ot TunnelTCP, after it has been acknowledge or not acknowledge<br/> | ||
- NEW: new event has been added. The ackReceived event is triggered every time a telegram is sent over TunnelUDP or TunnelTCP, after it has been acknowledged or not acknowledged. Please see the full featured sample.js file.<br/> | ||
</p> | ||
@@ -14,0 +20,0 @@ <p> |
{ | ||
"name": "knxultimate", | ||
"description": "KNX IP protocol implementation for Node. This is the ENGINE of Node-Red KNX-Ultimate node.", | ||
"version": "1.0.18", | ||
"version": "1.0.19", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">=14" |
@@ -87,2 +87,3 @@ const knx = require("./index.js"); | ||
// Let's go | ||
@@ -89,0 +90,0 @@ var knxUltimateClient = new knx.KNXClient(knxUltimateClientProperties); |
@@ -59,3 +59,3 @@ const knx = require("./index.js"); | ||
// WARNING, THIS WILL WRITE ON YOUR KNX BUS! | ||
knxUltimateClient.write("0/1/1", false, "1.001"); | ||
knxUltimateClient.write("0/1/1", false, "1.001"); | ||
}); | ||
@@ -62,0 +62,0 @@ |
@@ -598,4 +598,7 @@ // Made with love by Supergiovane | ||
this._clientTunnelSeqNumber = -1; | ||
this._sendConnectRequestMessage(new TunnelCRI.TunnelCRI(knxLayer)); | ||
try { | ||
this._sendConnectRequestMessage(new TunnelCRI.TunnelCRI(knxLayer)); | ||
} catch (error) { } | ||
} else if (this._options.hostProtocol === "TunnelTCP") { | ||
@@ -625,3 +628,3 @@ | ||
this._clearToSend = true; // 26/12/2021 allow to send | ||
this._clientTunnelSeqNumber = -1; | ||
@@ -661,12 +664,22 @@ try { | ||
this._awaitingResponseType = KNXConstants.KNX_CONSTANTS.CONNECTIONSTATE_RESPONSE; | ||
this._sendConnectionStateRequestMessage(this._channelID); | ||
try { | ||
this._sendConnectionStateRequestMessage(this._channelID); | ||
} catch (error) { } | ||
} | ||
Disconnect() { | ||
if (this._clientSocket == null) { | ||
if (this._clientSocket === null) { | ||
throw new Error('No client socket defined'); | ||
} | ||
// 20/04/2022 this._channelID === null can happen when the KNX Gateway is already disconnected | ||
if (this._channelID === null) { | ||
throw new Error('KNX Socket is already disconnected'); | ||
} | ||
this.stopHeartBeat(); | ||
this._connectionState = STATE.DISCONNECTING; | ||
this._awaitingResponseType = KNXConstants.KNX_CONSTANTS.DISCONNECT_RESPONSE; | ||
this._sendDisconnectRequestMessage(this._channelID); | ||
try { | ||
this._sendDisconnectRequestMessage(this._channelID); | ||
} catch (error) { | ||
} | ||
// 12/03/2021 Set disconnected if not already set by DISCONNECT_RESPONSE sent from the IP Interface | ||
@@ -746,2 +759,3 @@ let t = setTimeout(() => { // 21/03/2022 fixed possible memory leak. Previously was setTimeout without "let t = ". | ||
this.emit(KNXClientEvents.error, timeoutErr); | ||
if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.error("KNXClient: _setTimerWaitingForACK: " + (timeoutErr.message || "Undef error") + " no ACK received. ABORT sending datagram with seqNumber " + this._getSeqNumber() + " from " + knxTunnelingRequest.cEMIMessage.srcAddress.toString() + " to " + knxTunnelingRequest.cEMIMessage.dstAddress.toString()); | ||
} else { | ||
@@ -751,3 +765,3 @@ // 26/12/2021 // If no ACK received, resend the datagram once with the same sequence number | ||
this.send(knxTunnelingRequest); | ||
if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.error("KNXClient: _setTimerWaitingForACK: " + (timeoutErr.message || "Undef error") + " no ACK received. Retransmit datagram with seqNumber " + this._getSeqNumber()); | ||
if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.error("KNXClient: _setTimerWaitingForACK: " + (timeoutErr.message || "Undef error") + " no ACK received. Retransmit datagram with seqNumber " + this._getSeqNumber() + " from " + knxTunnelingRequest.cEMIMessage.srcAddress.toString() + " to " + knxTunnelingRequest.cEMIMessage.dstAddress.toString()); | ||
} | ||
@@ -783,4 +797,4 @@ } catch (error) { } | ||
//this._setDisconnected("Routing Lost Message"); // 31/03/2022 Commented, because it doesn't matter. Non need to disconnect. | ||
return; | ||
} catch (error) { } | ||
return; | ||
} else if (knxHeader.service_type === KNXConstants.KNX_CONSTANTS.ROUTING_BUSY) { | ||
@@ -790,4 +804,4 @@ try { | ||
//this._setDisconnected("Routing Busy"); // 31/03/2022 Commented, because it doesn't matter. Non need to disconnect. | ||
return; | ||
} catch (error) { } | ||
return; | ||
} | ||
@@ -862,3 +876,6 @@ | ||
this._connectionState = STATE.DISCONNECTING; | ||
this._sendDisconnectResponseMessage(knxDisconnectRequest.channelID); | ||
try { | ||
this._sendDisconnectResponseMessage(knxDisconnectRequest.channelID); | ||
} catch (error) { } | ||
// 12/03/2021 Added 1 sec delay. | ||
@@ -875,2 +892,8 @@ let t = setTimeout(() => { // 21/03/2022 fixed possible memory leak. Previously was setTimeout without "let t = ". | ||
} | ||
// 26/12/2021 send the ACK if the server requestet that | ||
// Then REMOVED, because some interfaces sets the "ack request" always to 0 even if it needs ack. | ||
//if (knxMessage.cEMIMessage.control.ack){ | ||
let knxTunnelAck = KNXProtocol.KNXProtocol.newKNXTunnelingACK(knxTunnelingRequest.channelID, knxTunnelingRequest.seqCounter, KNXConstants.KNX_CONSTANTS.E_NO_ERROR); | ||
this.send(knxTunnelAck); | ||
//} | ||
@@ -904,11 +927,4 @@ if (knxTunnelingRequest.cEMIMessage.msgCode === CEMIConstants.CEMIConstants.L_DATA_IND) { | ||
// 26/12/2021 send the ACK if the server requestet that | ||
// Then REMOVED, because some interfaces sets the "ack request" always to 0 even if it needs ack. | ||
//if (knxMessage.cEMIMessage.control.ack){ | ||
const knxTunnelAck = KNXProtocol.KNXProtocol.newKNXTunnelingACK(knxTunnelingRequest.channelID, knxTunnelingRequest.seqCounter, KNXConstants.KNX_CONSTANTS.E_NO_ERROR); | ||
this.send(knxTunnelAck); | ||
//} | ||
} else if (knxHeader.service_type === KNXConstants.KNX_CONSTANTS.TUNNELING_ACK) { | ||
} else if (knxHeader.service_type === KNXConstants.KNX_CONSTANTS.TUNNELING_ACK) { | ||
//const knxTunnelingAck = lodash.cloneDeep(knxMessage); | ||
const knxTunnelingAck = knxMessage; | ||
@@ -925,2 +941,3 @@ if (knxTunnelingAck.channelID !== this._channelID) { | ||
if (!this._options.suppress_ack_ldatareq) { | ||
if (knxTunnelingAck.seqCounter === this._getSeqNumber()) { | ||
@@ -979,5 +996,2 @@ if (this._timerWaitingForACK !== null) clearTimeout(this._timerWaitingForACK); | ||
} else if (knxHeader.service_type === KNXConstants.KNX_CONSTANTS.ROUTING_LOST_MESSAGE) { | ||
// Multicast, ho perso il mondo dei messaggi | ||
} else { | ||
@@ -984,0 +998,0 @@ if (knxHeader.service_type === this._awaitingResponseType) { |
950001
0.11%9232
0.14%