knxultimate
Advanced tools
Comparing version 1.0.12 to 1.0.13
@@ -10,2 +10,6 @@ ![Sample Node](img/logo.png) | ||
<p> | ||
<b>Version 1.0.13</b> - March 2022<br/> | ||
- Updated samples and fixed disconnection issues is some circumstaces, where the KNX IP Interface doesn't send the DISCONNECT_RESPONSE datagram to confirm the disconnection.<br/> | ||
</p> | ||
<p> | ||
<b>Version 1.0.12</b> - February 2022<br/> | ||
@@ -12,0 +16,0 @@ - FIX Datapoint 16.001: fixed an issue with the ISO8859-1 encoding.<br/> |
{ | ||
"name": "knxultimate", | ||
"description": "KNX IP protocol implementation for Node. This is the ENGINE of Node-Red KNX-Ultimate node.", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">=14" |
@@ -115,3 +115,2 @@ ![Logo](img/logo-big.png) | ||
// Instantiate the client | ||
@@ -146,3 +145,2 @@ const knxUltimateClient = new knx.KNXClient(knxUltimateClientProperties); | ||
```javascript | ||
const knx = require("./index.js"); | ||
@@ -192,3 +190,3 @@ const dptlib = require('./src/dptlib'); | ||
}; | ||
return(jRet); | ||
return (jRet); | ||
} | ||
@@ -219,9 +217,3 @@ jRet = { "help": "No sample currently avaiable", "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-ultimate/wiki/-SamplesHome" }; | ||
// Let's connect and turn on your appliance. | ||
// Set the properties | ||
@@ -242,5 +234,4 @@ let knxUltimateClientProperties = { | ||
// Let's go | ||
const knxUltimateClient = new knx.KNXClient(knxUltimateClientProperties); | ||
var knxUltimateClient = new knx.KNXClient(knxUltimateClientProperties); | ||
@@ -255,7 +246,7 @@ // Setting handlers | ||
knxUltimateClient.on(knx.KNXClient.KNXClientEvents.disconnected, info => { | ||
// The client is cisconnected | ||
// The client is disconnected. Here you can handle the reconnection | ||
console.log("Disconnected", info) | ||
}); | ||
knxUltimateClient.on(knx.KNXClient.KNXClientEvents.close, info => { | ||
// The client connection has been closed | ||
// The client physical net socket has been closed | ||
console.log("Closed", info) | ||
@@ -267,3 +258,2 @@ | ||
console.log("Connected. On Duty", info) | ||
}); | ||
@@ -291,8 +281,3 @@ knxUltimateClient.on(knx.KNXClient.KNXClientEvents.connecting, info => { | ||
console.log("WARNING: I'm about to write to your BUS in 10 seconds! Press Control+C to abort!") | ||
console.log("WARNING: I'm about to write to your BUS in 10 seconds! Press Control+C to abort!") | ||
console.log("WARNING: I'm about to write to your BUS in 10 seconds! Press Control+C to abort!") | ||
console.log("WARNING: I'm about to write to your BUS in 10 seconds! Press Control+C to abort!") | ||
console.log("WARNING: I'm about to write to your BUS in 10 seconds! Press Control+C to abort!") | ||
@@ -303,2 +288,9 @@ // WRITE SOMETHING | ||
// WARNING, THIS WILL WRITE ON YOUR KNX BUS! | ||
if (!knxUltimateClient.isConnected()) { | ||
console.log("I'm not connected"); | ||
return; | ||
} | ||
// Check wether knxUltimateClient is clear to send the next telegram. | ||
@@ -326,3 +318,9 @@ // This should be called bevore any .write, .response, and .read request. | ||
}, 10000); | ||
}, 5000); | ||
// Disconnect after 20 secs. | ||
setTimeout(() => { | ||
knxUltimateClient.Disconnect(); | ||
}, 20000); | ||
``` | ||
@@ -340,3 +338,2 @@ <br/> | ||
```javascript | ||
const knx = require("./index.js"); | ||
@@ -400,4 +397,4 @@ const KNXsecureKeyring = require("./src/KNXsecureKeyring.js"); | ||
// Instantiate the client | ||
const knxUltimateClient = new knx.KNXClient(knxUltimateClientProperties); | ||
var knxUltimateClient = new knx.KNXClient(knxUltimateClientProperties); | ||
// This contains the decrypted keyring file, accessible to all .js files referencing the "index.js" module. | ||
@@ -418,5 +415,4 @@ console.log(knx.getDecodedKeyring()); | ||
knxUltimateClient.on(knx.KNXClient.KNXClientEvents.close, info => { | ||
// The client connection has been closed | ||
// The client physical net socket has been closed | ||
console.log("Closed", info) | ||
}); | ||
@@ -452,8 +448,7 @@ knxUltimateClient.on(knx.KNXClient.KNXClientEvents.connected, info => { | ||
// WARNING, THIS WILL WRITE ON YOUR KNX BUS! | ||
if (knxUltimateClient.isConnected()) knxUltimateClient.write("0/1/1", false, "1.001"); | ||
// WARNING, THIS WILL WRITE ON YOUR KNX BUS! | ||
knxUltimateClient.write("0/1/1", false, "1.001"); | ||
} | ||
// Gona fishing. | ||
go(); | ||
@@ -460,0 +455,0 @@ |
@@ -1,2 +0,1 @@ | ||
const knx = require("./index.js"); | ||
@@ -46,3 +45,3 @@ const dptlib = require('./src/dptlib'); | ||
}; | ||
return(jRet); | ||
return (jRet); | ||
} | ||
@@ -73,9 +72,3 @@ jRet = { "help": "No sample currently avaiable", "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-ultimate/wiki/-SamplesHome" }; | ||
// Let's connect and turn on your appliance. | ||
// Set the properties | ||
@@ -96,5 +89,4 @@ let knxUltimateClientProperties = { | ||
// Let's go | ||
const knxUltimateClient = new knx.KNXClient(knxUltimateClientProperties); | ||
var knxUltimateClient = new knx.KNXClient(knxUltimateClientProperties); | ||
@@ -109,7 +101,7 @@ // Setting handlers | ||
knxUltimateClient.on(knx.KNXClient.KNXClientEvents.disconnected, info => { | ||
// The client is cisconnected | ||
// The client is disconnected. Here you can handle the reconnection | ||
console.log("Disconnected", info) | ||
}); | ||
knxUltimateClient.on(knx.KNXClient.KNXClientEvents.close, info => { | ||
// The client connection has been closed | ||
// The client physical net socket has been closed | ||
console.log("Closed", info) | ||
@@ -121,3 +113,2 @@ | ||
console.log("Connected. On Duty", info) | ||
}); | ||
@@ -145,8 +136,3 @@ knxUltimateClient.on(knx.KNXClient.KNXClientEvents.connecting, info => { | ||
console.log("WARNING: I'm about to write to your BUS in 10 seconds! Press Control+C to abort!") | ||
console.log("WARNING: I'm about to write to your BUS in 10 seconds! Press Control+C to abort!") | ||
console.log("WARNING: I'm about to write to your BUS in 10 seconds! Press Control+C to abort!") | ||
console.log("WARNING: I'm about to write to your BUS in 10 seconds! Press Control+C to abort!") | ||
console.log("WARNING: I'm about to write to your BUS in 10 seconds! Press Control+C to abort!") | ||
@@ -157,2 +143,9 @@ // WRITE SOMETHING | ||
// WARNING, THIS WILL WRITE ON YOUR KNX BUS! | ||
if (!knxUltimateClient.isConnected()) { | ||
console.log("I'm not connected"); | ||
return; | ||
} | ||
// Check wether knxUltimateClient is clear to send the next telegram. | ||
@@ -180,6 +173,7 @@ // This should be called bevore any .write, .response, and .read request. | ||
}, 5000); | ||
}, 10000); | ||
// Disconnect after 20 secs. | ||
setTimeout(() => { | ||
knxUltimateClient.Disconnect(); | ||
}, 20000); |
@@ -60,4 +60,4 @@ | ||
// Instantiate the client | ||
const knxUltimateClient = new knx.KNXClient(knxUltimateClientProperties); | ||
var knxUltimateClient = new knx.KNXClient(knxUltimateClientProperties); | ||
// This contains the decrypted keyring file, accessible to all .js files referencing the "index.js" module. | ||
@@ -78,5 +78,4 @@ console.log(knx.getDecodedKeyring()); | ||
knxUltimateClient.on(knx.KNXClient.KNXClientEvents.close, info => { | ||
// The client connection has been closed | ||
// The client physical net socket has been closed | ||
console.log("Closed", info) | ||
}); | ||
@@ -112,8 +111,7 @@ knxUltimateClient.on(knx.KNXClient.KNXClientEvents.connected, info => { | ||
// WARNING, THIS WILL WRITE ON YOUR KNX BUS! | ||
if (knxUltimateClient.isConnected()) knxUltimateClient.write("0/1/1", false, "1.001"); | ||
// WARNING, THIS WILL WRITE ON YOUR KNX BUS! | ||
knxUltimateClient.write("0/1/1", false, "1.001"); | ||
} | ||
go(); | ||
@@ -120,0 +118,0 @@ |
@@ -1,2 +0,1 @@ | ||
const knx = require("./index.js"); | ||
@@ -19,3 +18,2 @@ | ||
// Instantiate the client | ||
@@ -41,3 +39,1 @@ const knxUltimateClient = new knx.KNXClient(knxUltimateClientProperties); | ||
knxUltimateClient.write("0/1/1", false, "1.001"); | ||
@@ -126,2 +126,4 @@ // Made with love by Supergiovane | ||
// 12/03/2022 Remove all listeners | ||
this.removeAllListeners(); | ||
@@ -132,2 +134,3 @@ 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); | ||
@@ -147,2 +150,3 @@ this._clientSocket.on(SocketEvents.error, error => this.emit(KNXClientEvents.error, error)); | ||
this._clientSocket = new net.Socket(); | ||
this._clientSocket.removeAllListeners(); // 12/03/2022 Remove all listeners | ||
//this._clientSocket.on(SocketEvents.data, this._processInboundMessage); | ||
@@ -158,2 +162,3 @@ this._clientSocket.on(SocketEvents.data, function (msg, rinfo, callback) { | ||
this._clientSocket = dgram.createSocket({ type: 'udp4', reuseAddr: true }); | ||
this._clientSocket.removeAllListeners(); // 12/03/2022 Remove all listeners | ||
this._clientSocket.on(SocketEvents.listening, function () { | ||
@@ -355,4 +360,3 @@ try { | ||
cEMIMessage.control.hopCount = 6; | ||
this._incSeqNumber(); // 26/12/2021 | ||
const seqNum = this._getSeqNumber(); | ||
const seqNum = this._incSeqNumber(); // 26/12/2021 | ||
const knxPacketRequest = KNXProtocol.KNXProtocol.newKNXTunnelingRequest(this._channelID, seqNum, cEMIMessage); | ||
@@ -402,4 +406,3 @@ if (!this._options.suppress_ack_ldatareq) this._setTimerWaitingForACK(knxPacketRequest); | ||
cEMIMessage.control.hopCount = 6; | ||
this._incSeqNumber(); // 26/12/2021 | ||
const seqNum = this._getSeqNumber(); | ||
const seqNum = this._incSeqNumber(); // 26/12/2021 | ||
const knxPacketRequest = KNXProtocol.KNXProtocol.newKNXTunnelingRequest(this._channelID, seqNum, cEMIMessage); | ||
@@ -445,4 +448,3 @@ if (!this._options.suppress_ack_ldatareq) this._setTimerWaitingForACK(knxPacketRequest); | ||
cEMIMessage.control.hopCount = 6; | ||
this._incSeqNumber(); // 26/12/2021 | ||
const seqNum = this._getSeqNumber(); | ||
const seqNum = this._incSeqNumber(); // 26/12/2021 | ||
const knxPacketRequest = KNXProtocol.KNXProtocol.newKNXTunnelingRequest(this._channelID, seqNum, cEMIMessage); | ||
@@ -460,52 +462,3 @@ if (!this._options.suppress_ack_ldatareq) this._setTimerWaitingForACK(knxPacketRequest); | ||
} | ||
// writeRaw(dstAddress, _rawDataBuffer, bitlength) { | ||
// // bitlength is unused and only for backward compatibility | ||
// if (this._connectionState !== STATE.CONNECTED) throw new Error("The socket is not connected. Unable to access the KNX BUS"); | ||
// if (!Buffer.isBuffer(_rawDataBuffer)) { | ||
// if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.error('KNXClient: writeRaw: Value must be a buffer! '); | ||
// return | ||
// } | ||
// // Transform the "data" into a KNDDataBuffer | ||
// let data = new KNXDataBuffer(_rawDataBuffer); | ||
// if (typeof dstAddress === "string") dstAddress = KNXAddress.createFromString(dstAddress, KNXAddress.TYPE_GROUP); | ||
// let srcAddress = this._options.physAddr; | ||
// if (this._options.hostProtocol === "Multicast") { | ||
// // Multicast | ||
// const cEMIMessage = CEMIFactory.CEMIFactory.newLDataIndicationMessage("write", srcAddress, dstAddress, data); | ||
// cEMIMessage.control.ack = 0; | ||
// cEMIMessage.control.broadcast = 1; | ||
// cEMIMessage.control.priority = 3; | ||
// cEMIMessage.control.addressType = 1; | ||
// cEMIMessage.control.hopCount = 6; | ||
// const knxPacketRequest = KNXProtocol.KNXProtocol.newKNXRoutingIndication(cEMIMessage); | ||
// this.send(knxPacketRequest); | ||
// // 06/12/2021 Multivast automaticalli echoes telegrams | ||
// } else { | ||
// // Tunneling | ||
// const cEMIMessage = CEMIFactory.CEMIFactory.newLDataRequestMessage("write", srcAddress, dstAddress, data); | ||
// cEMIMessage.control.ack = this._options.suppress_ack_ldatareq ? 0 : 1; | ||
// cEMIMessage.control.broadcast = 1; | ||
// cEMIMessage.control.priority = 3; | ||
// cEMIMessage.control.addressType = 1; | ||
// cEMIMessage.control.hopCount = 6; | ||
// this._incSeqNumber(); // 26/12/2021 | ||
// const seqNum = this._getSeqNumber(); | ||
// const knxPacketRequest = KNXProtocol.KNXProtocol.newKNXTunnelingRequest(this._channelID, seqNum, cEMIMessage); | ||
// if (!this._options.suppress_ack_ldatareq) this._setTimerWaitingForACK(knxPacketRequest); | ||
// this.send(knxPacketRequest); | ||
// // 06/12/2021 Echo the sent telegram. Last parameter is the echo true/false | ||
// try { | ||
// if (this._options.localEchoInTunneling) this.emit(KNXClientEvents.indication, knxPacketRequest, true); | ||
// } catch (error) { | ||
// } | ||
// } | ||
// } | ||
writeRaw(dstAddress, _rawDataBuffer, bitlength) { | ||
@@ -558,4 +511,3 @@ // bitlength is unused and only for backward compatibility | ||
cEMIMessage.control.hopCount = 6; | ||
this._incSeqNumber(); // 26/12/2021 | ||
const seqNum = this._getSeqNumber(); | ||
const seqNum = this._incSeqNumber(); // 26/12/2021 | ||
const knxPacketRequest = KNXProtocol.KNXProtocol.newKNXTunnelingRequest(this._channelID, seqNum, cEMIMessage); | ||
@@ -718,5 +670,6 @@ if (!this._options.suppress_ack_ldatareq) this._setTimerWaitingForACK(knxPacketRequest); | ||
this._sendDisconnectRequestMessage(this._channelID); | ||
//this._timerTimeoutSendDisconnectRequestMessage = setTimeout(() => { | ||
this._setDisconnected("Called from KNXClient Disconnected"); | ||
//}, 1000 * KNXConstants.KNX_CONSTANTS.CONNECT_REQUEST_TIMEOUT); | ||
// 12/03/2021 Set disconnected if not already set by DISCONNECT_RESPONSE sent from the IP Interface | ||
setTimeout(() => { | ||
if (this._connectionState !== STATE.DISCONNECTED) this._setDisconnected("Forced call from KNXClient Disconnect() function, because the KNX Interface hasn't sent the DISCONNECT_RESPONSE in time."); | ||
}, 2000); | ||
} | ||
@@ -727,2 +680,8 @@ isConnected() { | ||
_setDisconnected(_sReason = "") { | ||
try { | ||
if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.debug("KNXClient: called _setDisconnected " + this._options.ipAddr + ":" + this._options.ipPort + " " + _sReason); | ||
} catch (error) { | ||
} | ||
this._connectionState = STATE.DISCONNECTED; | ||
this.stopHeartBeat(); | ||
if (this._timerTimeoutSendDisconnectRequestMessagetimer !== null) clearTimeout(this._timerTimeoutSendDisconnectRequestMessagetimer); | ||
@@ -732,11 +691,3 @@ this._timerTimeoutSendDisconnectRequestMessage = null; | ||
if (this._tunnelReqTimer !== null) clearTimeout(this._tunnelReqTimer); | ||
this.stopHeartBeat(); | ||
this._connectionState = STATE.DISCONNECTED; | ||
try { | ||
this.emit(KNXClientEvents.disconnected, this._options.ipAddr + ":" + this._options.ipPort + " " + _sReason); | ||
} catch (error) { | ||
} | ||
this._clientTunnelSeqNumber = -1; | ||
this._clearToSend = true; // 26/12/2021 allow to send | ||
this._channelID = null; | ||
@@ -749,2 +700,8 @@ | ||
try { | ||
this.emit(KNXClientEvents.disconnected, this._options.ipAddr + ":" + this._options.ipPort + " " + _sReason); | ||
} catch (error) { | ||
} | ||
this._clearToSend = true; // 26/12/2021 allow to send | ||
} | ||
@@ -767,3 +724,3 @@ _runHeartbeat() { | ||
_incSeqNumber(seq) { | ||
_incSeqNumber() { | ||
this._clientTunnelSeqNumber++; | ||
@@ -881,3 +838,3 @@ if (this._clientTunnelSeqNumber > 255) { | ||
} | ||
this._setDisconnected("Received Disconnect Response"); | ||
this._setDisconnected("Received DISCONNECT_RESPONSE from the KNX interface."); | ||
} | ||
@@ -897,3 +854,6 @@ else if (knxHeader.service_type === KNXConstants.KNX_CONSTANTS.DISCONNECT_REQUEST) { | ||
this._sendDisconnectResponseMessage(knxDisconnectRequest.channelID); | ||
this._setDisconnected("Received Disconnect Request"); | ||
// 12/03/2021 Added 1 sec delay. | ||
setTimeout(() => { | ||
this._setDisconnected("Received KNX packet: DISCONNECT_REQUEST, ChannelID:" + this._channelID + " Host:" + this._options.ipAddr + ":" + this._options.ipPort); | ||
}, 1000); | ||
} | ||
@@ -900,0 +860,0 @@ else if (knxHeader.service_type === KNXConstants.KNX_CONSTANTS.TUNNELING_REQUEST) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
939015
9133
467