node-red-contrib-knx-ultimate 1.4.3 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@
6
6
 
7
7
  # CHANGELOG
8
8
 
9
+ <p>
10
+ <b>Version 1.4.4</b> - October 2022<br/>
11
+ - FIX: fixed an issue accurring when you put a wrong IP/hostname in the configuration gateway. Leaving node-red running with such wrong configuration, after a month or so, all UDP channels remain occupied until reboot. Thanks to @tarag for reporting that.<br/>
12
+ </p>
9
13
  <p>
10
14
  <b>Version 1.4.3</b> - October 2022<br/>
11
15
  - Changed view for JSON objects (will display the RAW value instead of the JSON) in the KNXUltimate Viewer node.<br/>
@@ -84,7 +84,7 @@ const optionsDefaults = {
84
84
  }
85
85
 
86
86
  class KNXClient extends EventEmitter {
87
- constructor (options) {
87
+ constructor(options) {
88
88
  if (options === undefined) {
89
89
  options = optionsDefaults
90
90
  }
@@ -188,7 +188,7 @@ class KNXClient extends EventEmitter {
188
188
  this._numFailedTelegramACK = 0 // 25/12/2021 Keep count of the failed tunnelig ACK telegrams
189
189
  }
190
190
 
191
- get channelID () {
191
+ get channelID() {
192
192
  return this._channelID
193
193
  }
194
194
 
@@ -215,7 +215,7 @@ class KNXClient extends EventEmitter {
215
215
  // DPT19: null,
216
216
  // DPT20: null
217
217
  // };
218
- getKNXDataBuffer (_data, _dptid) {
218
+ getKNXDataBuffer(_data, _dptid) {
219
219
  const adpu = {}
220
220
  DPTLib.populateAPDU(_data, adpu, _dptid)
221
221
  const iDatapointType = parseInt(_dptid.substr(0, _dptid.indexOf('.')))
@@ -253,7 +253,7 @@ class KNXClient extends EventEmitter {
253
253
  // }
254
254
  // });
255
255
  // }
256
- send (knxPacket) {
256
+ send(knxPacket) {
257
257
  // Logging
258
258
  if (this.sysLogger !== undefined && this.sysLogger !== null) {
259
259
  try {
@@ -320,7 +320,7 @@ class KNXClient extends EventEmitter {
320
320
  * @param {KNXDataBuffer} data
321
321
  */
322
322
  // sendWriteRequest(dstAddress, data) {
323
- write (dstAddress, data, dptid) {
323
+ write(dstAddress, data, dptid) {
324
324
  if (this._connectionState !== STATE.CONNECTED) throw new Error('The socket is not connected. Unable to access the KNX BUS')
325
325
 
326
326
  // Get the Data Buffer from the plain value
@@ -363,7 +363,7 @@ class KNXClient extends EventEmitter {
363
363
  }
364
364
 
365
365
  // sendResponseRequest
366
- respond (dstAddress, data, dptid) {
366
+ respond(dstAddress, data, dptid) {
367
367
  if (this._connectionState !== STATE.CONNECTED) throw new Error('The socket is not connected. Unable to access the KNX BUS')
368
368
 
369
369
  // Get the Data Buffer from the plain value
@@ -405,7 +405,7 @@ class KNXClient extends EventEmitter {
405
405
  }
406
406
 
407
407
  // sendReadRequest
408
- read (dstAddress) {
408
+ read(dstAddress) {
409
409
  if (this._connectionState !== STATE.CONNECTED) throw new Error('The socket is not connected. Unable to access the KNX BUS')
410
410
 
411
411
  if (typeof dstAddress === 'string') dstAddress = KNXAddress.createFromString(dstAddress, KNXAddress.TYPE_GROUP)
@@ -443,7 +443,7 @@ class KNXClient extends EventEmitter {
443
443
  }
444
444
  }
445
445
 
446
- writeRaw (dstAddress, _rawDataBuffer, bitlength) {
446
+ writeRaw(dstAddress, _rawDataBuffer, bitlength) {
447
447
  // bitlength is unused and only for backward compatibility
448
448
 
449
449
  if (this._connectionState !== STATE.CONNECTED) throw new Error('The socket is not connected. Unable to access the KNX BUS')
@@ -500,14 +500,14 @@ class KNXClient extends EventEmitter {
500
500
  }
501
501
  }
502
502
 
503
- startHeartBeat () {
503
+ startHeartBeat() {
504
504
  this.stopHeartBeat()
505
505
  this._heartbeatFailures = 0
506
506
  this._heartbeatRunning = true
507
507
  this._runHeartbeat()
508
508
  }
509
509
 
510
- stopHeartBeat () {
510
+ stopHeartBeat() {
511
511
  if (this._heartbeatTimer !== null) {
512
512
  this._heartbeatRunning = false
513
513
  clearTimeout(this._heartbeatTimer)
@@ -543,7 +543,7 @@ class KNXClient extends EventEmitter {
543
543
  // this._awaitingResponseType = KNXConstants.KNX_CONSTANTS.DESCRIPTION_RESPONSE;
544
544
  // this._sendDescriptionRequestMessage(host, port);
545
545
  // }
546
- Connect (knxLayer = TunnelCRI.TunnelTypes.TUNNEL_LINKLAYER) {
546
+ Connect(knxLayer = TunnelCRI.TunnelTypes.TUNNEL_LINKLAYER) {
547
547
  if (this._clientSocket == null) {
548
548
  throw new Error('No client socket defined')
549
549
  }
@@ -611,7 +611,7 @@ class KNXClient extends EventEmitter {
611
611
  }
612
612
  }
613
613
 
614
- getConnectionStatus () {
614
+ getConnectionStatus() {
615
615
  if (this._clientSocket == null) {
616
616
  throw new Error('No client socket defined')
617
617
  }
@@ -641,12 +641,18 @@ class KNXClient extends EventEmitter {
641
641
  } catch (error) { }
642
642
  }
643
643
 
644
- Disconnect () {
644
+ Disconnect() {
645
645
  if (this._clientSocket === null) {
646
646
  throw new Error('No client socket defined')
647
647
  }
648
648
  // 20/04/2022 this._channelID === null can happen when the KNX Gateway is already disconnected
649
649
  if (this._channelID === null) {
650
+ // 11/10/2022 Close the socket
651
+ try {
652
+ this._clientSocket.close()
653
+ } catch (error) {
654
+ if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.debug('KNXClient: into Disconnect(), this._clientSocket.close(): ' + this._options.ipAddr + ':' + this._options.ipPort + ' ' + error.message)
655
+ }
650
656
  throw new Error('KNX Socket is already disconnected')
651
657
  }
652
658
  this.stopHeartBeat()
@@ -663,11 +669,11 @@ class KNXClient extends EventEmitter {
663
669
  }, 2000)
664
670
  }
665
671
 
666
- isConnected () {
672
+ isConnected() {
667
673
  return this._connectionState === STATE.CONNECTED
668
674
  }
669
675
 
670
- _setDisconnected (_sReason = '') {
676
+ _setDisconnected(_sReason = '') {
671
677
  try {
672
678
  if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.debug('KNXClient: called _setDisconnected ' + this._options.ipAddr + ':' + this._options.ipPort + ' ' + _sReason)
673
679
  } catch (error) {
@@ -692,7 +698,7 @@ class KNXClient extends EventEmitter {
692
698
  this._clearToSend = true // 26/12/2021 allow to send
693
699
  }
694
700
 
695
- _runHeartbeat () {
701
+ _runHeartbeat() {
696
702
  if (this._heartbeatRunning) {
697
703
  this.getConnectionStatus()
698
704
  const t = setTimeout(() => { // 21/03/2022 fixed possible memory leak. Previously was setTimeout without "let t = ".
@@ -701,16 +707,16 @@ class KNXClient extends EventEmitter {
701
707
  }
702
708
  }
703
709
 
704
- _getSeqNumber () {
710
+ _getSeqNumber() {
705
711
  return this._clientTunnelSeqNumber
706
712
  }
707
713
 
708
714
  // 26/12/2021 Handle the busy state, for example while waiting for ACK
709
- _getClearToSend () {
715
+ _getClearToSend() {
710
716
  return (this._clearToSend !== undefined ? this._clearToSend : true)
711
717
  }
712
718
 
713
- _incSeqNumber () {
719
+ _incSeqNumber() {
714
720
  this._clientTunnelSeqNumber++
715
721
  if (this._clientTunnelSeqNumber > 255) {
716
722
  this._clientTunnelSeqNumber = 0
@@ -721,7 +727,7 @@ class KNXClient extends EventEmitter {
721
727
  // _keyFromCEMIMessage(cEMIMessage) {
722
728
  // return cEMIMessage.dstAddress.toString();
723
729
  // }
724
- _setTimerWaitingForACK (knxTunnelingRequest) {
730
+ _setTimerWaitingForACK(knxTunnelingRequest) {
725
731
  this._clearToSend = false // 26/12/2021 stop sending until ACK received
726
732
  const timeoutErr = new errors.RequestTimeoutError(`RequestTimeoutError seqCounter:${knxTunnelingRequest.seqCounter}, DestAddr:${knxTunnelingRequest.cEMIMessage.dstAddress.toString() || 'Non definito'}, AckRequested:${knxTunnelingRequest.cEMIMessage.control.ack}, timed out waiting telegram acknowledge by ${this._options.ipAddr || 'No Peer host detected'}`)
727
733
  if (this._timerWaitingForACK !== null) clearTimeout(this._timerWaitingForACK)
@@ -748,7 +754,7 @@ class KNXClient extends EventEmitter {
748
754
  }, KNXConstants.KNX_CONSTANTS.TUNNELING_REQUEST_TIMEOUT * 1000)
749
755
  }
750
756
 
751
- _processInboundMessage (msg, rinfo) {
757
+ _processInboundMessage(msg, rinfo) {
752
758
  try {
753
759
  // Composing debug string
754
760
  try {
@@ -992,31 +998,31 @@ class KNXClient extends EventEmitter {
992
998
  }
993
999
  }
994
1000
 
995
- _sendDescriptionRequestMessage () {
1001
+ _sendDescriptionRequestMessage() {
996
1002
  this.send(KNXProtocol.KNXProtocol.newKNXDescriptionRequest(new HPAI.HPAI(this._options.localIPAddress)))
997
1003
  }
998
1004
 
999
- _sendSearchRequestMessage () {
1005
+ _sendSearchRequestMessage() {
1000
1006
  // this.send(KNXProtocol.KNXProtocol.newKNXSearchRequest(new HPAI.HPAI(this._options.localIPAddress, this._localPort)), KNXConstants.KNX_CONSTANTS.KNX_PORT, KNXConstants.KNX_CONSTANTS.KNX_IP);
1001
1007
  }
1002
1008
 
1003
- _sendConnectRequestMessage (cri) {
1009
+ _sendConnectRequestMessage(cri) {
1004
1010
  this.send(KNXProtocol.KNXProtocol.newKNXConnectRequest(cri))
1005
1011
  }
1006
1012
 
1007
- _sendConnectionStateRequestMessage (channelID) {
1013
+ _sendConnectionStateRequestMessage(channelID) {
1008
1014
  this.send(KNXProtocol.KNXProtocol.newKNXConnectionStateRequest(channelID))
1009
1015
  }
1010
1016
 
1011
- _sendDisconnectRequestMessage (channelID) {
1017
+ _sendDisconnectRequestMessage(channelID) {
1012
1018
  this.send(KNXProtocol.KNXProtocol.newKNXDisconnectRequest(channelID))
1013
1019
  }
1014
1020
 
1015
- _sendDisconnectResponseMessage (channelID, status = KNXConstants.ConnectionStatus.E_NO_ERROR) {
1021
+ _sendDisconnectResponseMessage(channelID, status = KNXConstants.ConnectionStatus.E_NO_ERROR) {
1016
1022
  this.send(KNXProtocol.KNXProtocol.newKNXDisconnectResponse(channelID, status))
1017
1023
  }
1018
1024
 
1019
- _sendSecureSessionRequestMessage (cri) {
1025
+ _sendSecureSessionRequestMessage(cri) {
1020
1026
  const oHPAI = new HPAI.HPAI('0.0.0.0', 0, this._options.hostProtocol === 'TunnelTCP' ? KNXConstants.KNX_CONSTANTS.IPV4_TCP : KNXConstants.KNX_CONSTANTS.IPV4_UDP)
1021
1027
  this.send(KNXProtocol.KNXProtocol.newKNXSecureSessionRequest(cri, oHPAI))
1022
1028
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-knx-ultimate",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "Control your KNX intallation via Node-Red! Single Node KNX IN/OUT with optional ETS group address importer. Easy to use and highly configurable.",
5
5
  "dependencies": {
6
6
  "mkdirp": "1.0.4",