knxultimate
Advanced tools
Comparing version 1.0.39 to 1.0.41
@@ -10,2 +10,6 @@ ![Sample Node](img/logo.png) | ||
<p> | ||
<b>Version 1.0.41</b> - July 2023<br/> | ||
- Enabled compatibility with KNX Virtual software (BETA).<br/> | ||
</p> | ||
<p> | ||
<b>Version 1.0.39</b> - June 2023<br/> | ||
@@ -15,4 +19,4 @@ - Bump dependencies versions.<br/> | ||
- Set max hop count in tunneling/broadcast, from 6 to 7.<br/> | ||
</p> | ||
<p> | ||
<p> | ||
<b>Version 1.0.37</b> - June 2023<br/> | ||
@@ -19,0 +23,0 @@ - Dependencies versions bump.<br/> |
{ | ||
"name": "knxultimate", | ||
"description": "KNX IP protocol implementation for Node. This is the ENGINE of Node-Red KNX-Ultimate node.", | ||
"version": "1.0.39", | ||
"version": "1.0.41", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">=14" |
@@ -93,2 +93,9 @@ // Made with love by Supergiovane | ||
super() | ||
//this._clientTunnelSeqNumber = -1 | ||
this._channelID = null | ||
this._connectionState = STATE.DISCONNECTED | ||
this._timerWaitingForACK = null | ||
this._numFailedTelegramACK = 0 // 25/12/2021 Keep count of the failed tunnelig ACK telegrams | ||
this._clientTunnelSeqNumber = -1 | ||
@@ -100,2 +107,3 @@ this._options = options// Object.assign(optionsDefaults, options); | ||
this._peerPort = this._options.ipPort | ||
this._options.localSocketAddress = options.localSocketAddress | ||
this._connectionTimeoutTimer = null | ||
@@ -130,11 +138,9 @@ this._heartbeatFailures = 0 | ||
if (this._options.hostProtocol === 'TunnelUDP') { | ||
let conn = this | ||
this._clientSocket = dgram.createSocket({ type: 'udp4', reuseAddr: false }) | ||
this._clientSocket.removeAllListeners() // 12/03/2022 Remove all listeners | ||
this._clientSocket.on(SocketEvents.message, this._processInboundMessage) | ||
this._clientSocket.on(SocketEvents.error, error => this.emit(KNXClientEvents.error, error)) | ||
this._clientSocket.on(SocketEvents.close, info => this.emit(KNXClientEvents.close, info)) | ||
let conn = this | ||
this._clientSocket.bind({ address: this._options.localIPAddress, port: this._options._peerPort }, function () { | ||
this._clientSocket.bind({ port: null, address: this._options.localIPAddress }, function () { | ||
try { | ||
conn._clientSocket.setTTL(250) | ||
if (conn._options.localSocketAddress === undefined) conn._options.localSocketAddress = conn._clientSocket.address() | ||
} catch (error) { | ||
@@ -145,2 +151,5 @@ if (conn.sysLogger !== undefined && conn.sysLogger !== null) conn.sysLogger.error('UDP: Error setting SetTTL ' + error.message || '') | ||
}) | ||
this._clientSocket.on(SocketEvents.message, this._processInboundMessage) | ||
this._clientSocket.on(SocketEvents.error, error => this.emit(KNXClientEvents.error, error)) | ||
this._clientSocket.on(SocketEvents.close, info => this.emit(KNXClientEvents.close, info)) | ||
} else if (this._options.hostProtocol === 'TunnelTCP') { | ||
@@ -184,11 +193,6 @@ // TCP | ||
conn = null | ||
// this._localPort = this._clientSocket.address().port;// 07/12/2021 Get the local port used bu the socket | ||
}) | ||
} | ||
this._clientTunnelSeqNumber = -1 | ||
this._channelID = null | ||
this._connectionState = STATE.DISCONNECTED | ||
this._timerWaitingForACK = null | ||
this._numFailedTelegramACK = 0 // 25/12/2021 Keep count of the failed tunnelig ACK telegrams | ||
} | ||
@@ -246,17 +250,2 @@ | ||
// bindSocketPortAsync(port = KNXConstants.KNX_CONSTANTS.KNX_PORT, host = '0.0.0.0') { | ||
// return new Promise((resolve, reject) => { | ||
// try { | ||
// this._clientSocket.bind(port, host, () => { | ||
// this._clientSocket.setMulticastInterface(host); | ||
// this._clientSocket.setMulticastTTL(128); | ||
// this._options.localIPAddress = host; | ||
// resolve(); | ||
// }); | ||
// } | ||
// catch (err) { | ||
// reject(err); | ||
// } | ||
// }); | ||
// } | ||
send(knxPacket) { | ||
@@ -588,3 +577,7 @@ // Logging | ||
try { | ||
this._sendConnectRequestMessage(new TunnelCRI.TunnelCRI(knxLayer)) | ||
// 27/06/2023, leave some time to the dgram, do do the bind and read local ip and local port | ||
const t = setTimeout(() => { | ||
this._sendConnectRequestMessage(new TunnelCRI.TunnelCRI(knxLayer)) | ||
}, 2000); | ||
} catch (error) { } | ||
@@ -821,7 +814,8 @@ } else if (this._options.hostProtocol === 'TunnelTCP') { | ||
if (this._timerWaitingForACK !== null) clearTimeout(this._timerWaitingForACK) | ||
this._channelID = knxConnectResponse.channelID | ||
this._connectionState = STATE.CONNECTED | ||
this._numFailedTelegramACK = 0 // 16/03/2022 Reset the failed ACK counter | ||
this._clearToSend = true // 16/03/2022 allow to send | ||
this._connectionState = STATE.CONNECTED | ||
this._channelID = knxConnectResponse.channelID | ||
try { | ||
@@ -1018,11 +1012,29 @@ if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.debug('Received KNX packet: CONNECT_RESPONSE, ChannelID:' + this._channelID + ' Host:' + this._options.ipAddr + ':' + this._options.ipPort) | ||
_sendConnectRequestMessage(cri) { | ||
this.send(KNXProtocol.KNXProtocol.newKNXConnectRequest(cri)) | ||
try { | ||
const oHPAI = new HPAI.HPAI(this._options.localSocketAddress.address, this._options.localSocketAddress.port, this._options.hostProtocol === 'TunnelTCP' ? KNXConstants.KNX_CONSTANTS.IPV4_TCP : KNXConstants.KNX_CONSTANTS.IPV4_UDP) | ||
this.send(KNXProtocol.KNXProtocol.newKNXConnectRequest(cri, oHPAI, oHPAI)) | ||
} catch (error) { | ||
this.send(KNXProtocol.KNXProtocol.newKNXConnectRequest(cri)) | ||
} | ||
// this.send(KNXProtocol.KNXProtocol.newKNXConnectRequest(cri)) | ||
} | ||
_sendConnectionStateRequestMessage(channelID) { | ||
this.send(KNXProtocol.KNXProtocol.newKNXConnectionStateRequest(channelID)) | ||
try { | ||
const oHPAI = new HPAI.HPAI(this._options.localSocketAddress.address, this._options.localSocketAddress.port, this._options.hostProtocol === 'TunnelTCP' ? KNXConstants.KNX_CONSTANTS.IPV4_TCP : KNXConstants.KNX_CONSTANTS.IPV4_UDP) | ||
this.send(KNXProtocol.KNXProtocol.newKNXConnectionStateRequest(channelID, oHPAI)) | ||
} catch (error) { | ||
this.send(KNXProtocol.KNXProtocol.newKNXConnectionStateRequest(channelID)) | ||
} | ||
//this.send(KNXProtocol.KNXProtocol.newKNXConnectionStateRequest(channelID)) | ||
} | ||
_sendDisconnectRequestMessage(channelID) { | ||
this.send(KNXProtocol.KNXProtocol.newKNXDisconnectRequest(channelID)) | ||
try { | ||
const oHPAI = new HPAI.HPAI(this._options.localSocketAddress.address, this._options.localSocketAddress.port, this._options.hostProtocol === 'TunnelTCP' ? KNXConstants.KNX_CONSTANTS.IPV4_TCP : KNXConstants.KNX_CONSTANTS.IPV4_UDP) | ||
this.send(KNXProtocol.KNXProtocol.newKNXDisconnectRequest(channelID, oHPAI)) | ||
} catch (error) { | ||
this.send(KNXProtocol.KNXProtocol.newKNXDisconnectRequest(channelID)) | ||
} | ||
//this.send(KNXProtocol.KNXProtocol.newKNXDisconnectRequest(channelID)) | ||
} | ||
@@ -1029,0 +1041,0 @@ |
1492473
9616