node-red-contrib-knx-ultimate 1.3.21 → 1.3.22

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
@@ -4,6 +4,10 @@
4
4
 
5
5
  <br/>
6
6
  <p>
7
+ <b>Version 1.3.22</b> - February 2022<br/>
8
+ - FIX: WriteRaw: some values wasn't sent to the bus due to an hex conversion issue.<br/>
9
+ </p>
10
+ <p>
7
11
  <b>Version 1.3.21</b> - January 2022<br/>
8
12
  - FIX: Node Logger wasn't correclty logging the bus traffic. Fixed.<br/>
9
13
  </p>
@@ -352,7 +352,7 @@ class KNXClient extends EventEmitter {
352
352
  this.send(knxPacketRequest);
353
353
  // 06/12/2021 Echo the sent telegram. Last parameter is the echo true/false
354
354
  try {
355
- if (this._options.localEchoInTunneling) this.emit(KNXClientEvents.indication, knxPacketRequest, true, null);
355
+ if (this._options.localEchoInTunneling) this.emit(KNXClientEvents.indication, knxPacketRequest, true);
356
356
  } catch (error) {
357
357
  }
358
358
 
@@ -397,7 +397,7 @@ class KNXClient extends EventEmitter {
397
397
  this.send(knxPacketRequest);
398
398
  // 06/12/2021 Echo the sent telegram. Last parameter is the echo true/false
399
399
  try {
400
- if (this._options.localEchoInTunneling) this.emit(KNXClientEvents.indication, knxPacketRequest, true, null);
400
+ if (this._options.localEchoInTunneling) this.emit(KNXClientEvents.indication, knxPacketRequest, true);
401
401
  } catch (error) {
402
402
  }
403
403
 
@@ -439,13 +439,63 @@ class KNXClient extends EventEmitter {
439
439
  this.send(knxPacketRequest);
440
440
  // 06/12/2021 Echo the sent telegram. Last parameter is the echo true/false
441
441
  try {
442
- if (this._options.localEchoInTunneling) this.emit(KNXClientEvents.indication, knxPacketRequest, true, null);
442
+ if (this._options.localEchoInTunneling) this.emit(KNXClientEvents.indication, knxPacketRequest, true);
443
443
  } catch (error) {
444
444
  }
445
445
 
446
446
  }
447
447
 
448
448
  }
449
+ // writeRaw(dstAddress, _rawDataBuffer, bitlength) {
450
+ // // bitlength is unused and only for backward compatibility
451
+
452
+ // if (this._connectionState !== STATE.CONNECTED) throw new Error("The socket is not connected. Unable to access the KNX BUS");
453
+
454
+ // if (!Buffer.isBuffer(_rawDataBuffer)) {
455
+ // if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.error('KNXClient: writeRaw: Value must be a buffer! ');
456
+ // return
457
+ // }
458
+
459
+ // // Transform the "data" into a KNDDataBuffer
460
+ // let data = new KNXDataBuffer(_rawDataBuffer);
461
+
462
+ // if (typeof dstAddress === "string") dstAddress = KNXAddress.createFromString(dstAddress, KNXAddress.TYPE_GROUP);
463
+ // let srcAddress = this._options.physAddr;
464
+ // if (this._options.hostProtocol === "Multicast") {
465
+ // // Multicast
466
+ // const cEMIMessage = CEMIFactory.CEMIFactory.newLDataIndicationMessage("write", srcAddress, dstAddress, data);
467
+ // cEMIMessage.control.ack = 0;
468
+ // cEMIMessage.control.broadcast = 1;
469
+ // cEMIMessage.control.priority = 3;
470
+ // cEMIMessage.control.addressType = 1;
471
+ // cEMIMessage.control.hopCount = 6;
472
+ // const knxPacketRequest = KNXProtocol.KNXProtocol.newKNXRoutingIndication(cEMIMessage);
473
+ // this.send(knxPacketRequest);
474
+ // // 06/12/2021 Multivast automaticalli echoes telegrams
475
+
476
+ // } else {
477
+ // // Tunneling
478
+ // const cEMIMessage = CEMIFactory.CEMIFactory.newLDataRequestMessage("write", srcAddress, dstAddress, data);
479
+ // cEMIMessage.control.ack = this._options.suppress_ack_ldatareq ? 0 : 1;
480
+ // cEMIMessage.control.broadcast = 1;
481
+ // cEMIMessage.control.priority = 3;
482
+ // cEMIMessage.control.addressType = 1;
483
+ // cEMIMessage.control.hopCount = 6;
484
+ // this._incSeqNumber(); // 26/12/2021
485
+ // const seqNum = this._getSeqNumber();
486
+ // const knxPacketRequest = KNXProtocol.KNXProtocol.newKNXTunnelingRequest(this._channelID, seqNum, cEMIMessage);
487
+ // if (!this._options.suppress_ack_ldatareq) this._setTimerWaitingForACK(knxPacketRequest);
488
+ // this.send(knxPacketRequest);
489
+ // // 06/12/2021 Echo the sent telegram. Last parameter is the echo true/false
490
+ // try {
491
+ // if (this._options.localEchoInTunneling) this.emit(KNXClientEvents.indication, knxPacketRequest, true);
492
+ // } catch (error) {
493
+ // }
494
+
495
+ // }
496
+
497
+ // }
498
+
449
499
  writeRaw(dstAddress, _rawDataBuffer, bitlength) {
450
500
  // bitlength is unused and only for backward compatibility
451
501
 
@@ -456,8 +506,20 @@ class KNXClient extends EventEmitter {
456
506
  return
457
507
  }
458
508
 
459
- // Transform the "data" into a KNDDataBuffer
460
- let data = new KNXDataBuffer(_rawDataBuffer)
509
+
510
+ let isSixBits = bitlength <= 6;
511
+ let IDataPoint = {
512
+ id: "",
513
+ value: "any",
514
+ type: { type: isSixBits },
515
+ bind: null,
516
+ read: () => null,
517
+ write: null
518
+ }
519
+ // Get the KNDDataBuffer
520
+ var baseBufferFromBitLenght = Buffer.alloc((bitlength / 8)); // The buffer lenght must be like specified by bitlenght
521
+ _rawDataBuffer.copy(baseBufferFromBitLenght, 0);
522
+ let data = new KNXDataBuffer(baseBufferFromBitLenght, IDataPoint);
461
523
 
462
524
  if (typeof dstAddress === "string") dstAddress = KNXAddress.createFromString(dstAddress, KNXAddress.TYPE_GROUP);
463
525
  let srcAddress = this._options.physAddr;
@@ -488,7 +550,7 @@ class KNXClient extends EventEmitter {
488
550
  this.send(knxPacketRequest);
489
551
  // 06/12/2021 Echo the sent telegram. Last parameter is the echo true/false
490
552
  try {
491
- if (this._options.localEchoInTunneling) this.emit(KNXClientEvents.indication, knxPacketRequest, true, null);
553
+ if (this._options.localEchoInTunneling) this.emit(KNXClientEvents.indication, knxPacketRequest, true);
492
554
  } catch (error) {
493
555
  }
494
556
 
@@ -838,7 +900,7 @@ class KNXClient extends EventEmitter {
838
900
  } catch (error) { }
839
901
 
840
902
  try {
841
- this.emit(KNXClientEvents.indication, knxTunnelingRequest, false, msg.toString("hex"));
903
+ this.emit(KNXClientEvents.indication, knxTunnelingRequest, false);
842
904
  } catch (error) { }
843
905
 
844
906
  } else if (knxTunnelingRequest.cEMIMessage.msgCode === CEMIConstants.CEMIConstants.L_DATA_CON) {
@@ -883,7 +945,7 @@ class KNXClient extends EventEmitter {
883
945
  } catch (error) { }
884
946
  //this.emit(KNXClientEvents.error, `Unexpected Tunnel Ack ${knxTunnelingAck.seqCounter}`);
885
947
  }
886
- }
948
+ }
887
949
 
888
950
  } else if (knxHeader.service_type === KNXConstants.KNX_CONSTANTS.ROUTING_INDICATION) {
889
951
 
@@ -905,7 +967,7 @@ class KNXClient extends EventEmitter {
905
967
  } catch (error) { }
906
968
 
907
969
  try {
908
- this.emit(KNXClientEvents.indication, knxRoutingInd, false, msg.toString("hex"));
970
+ this.emit(KNXClientEvents.indication, knxRoutingInd, false);
909
971
  } catch (error) {
910
972
  }
911
973
  }
@@ -934,7 +996,7 @@ class KNXClient extends EventEmitter {
934
996
  this.emit(KNXClientEvents.error, KNXConnectionStateResponse.KNXConnectionStateResponse.statusToString(knxConnectionStateResponse.status));
935
997
  } catch (error) {
936
998
  }
937
- this._setDisconnected("Awaiting response "+ this._awaitingResponseType + ", received connection state response with status " + knxConnectionStateResponse.status);
999
+ this._setDisconnected("Awaiting response " + this._awaitingResponseType + ", received connection state response with status " + knxConnectionStateResponse.status);
938
1000
  }
939
1001
  else {
940
1002
  if (this._heartbeatTimer !== null) clearTimeout(this._heartbeatTimer);
@@ -814,8 +814,7 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
814
814
 
815
815
  // Handle BUS events
816
816
  // ---------------------------------------------------------------------------------------
817
- //function handleBusEvents(_evt, _src, _dest, _rawValue, _datagram, _isRepeated) {
818
- function handleBusEvents(_datagram, _echoed, _CEMI) {
817
+ function handleBusEvents(_datagram, _echoed) {
819
818
 
820
819
 
821
820
  // _rawValue
@@ -847,22 +846,20 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
847
846
  // 23/03/2021 Supergiovane: Added the CEMI telegram for ETS Diagnostic
848
847
  // #####################################################################
849
848
  let _cemiETS = "";
850
- if (_CEMI !== undefined && _CEMI !== null) {
851
- // I'm receiving a telegram from the BUS
849
+ if (_echoed) {
850
+ // I'm sending a telegram to the BUS in Tunneling mode, with echo enabled.
851
+ // Tunnel: TX to BUS: OK
852
+ try {
853
+ let sCemiFromDatagram = _datagram.cEMIMessage.toBuffer().toString("hex");
854
+ _cemiETS = "2900BCD0" + sCemiFromDatagram.substr(8);
855
+ } catch (error) { _cemiETS = ""; }
856
+ } else {
852
857
  try {
853
858
  // Multicast: RX from BUS: OK
854
859
  // Multicast TX to BUS: OK
855
860
  // Tunnel: RX from BUS: OK
856
- // Tunnel: TX to BUS: see the _echoed below
861
+ // Tunnel: TX to BUS: see the _echoed above
857
862
  _cemiETS = _datagram.cEMIMessage.toBuffer().toString("hex")
858
- } catch (error) { }
859
-
860
- } else if (_echoed) {
861
- // I'm sending a telegram to the BUS
862
- // Tunnel: TX to BUS: OK
863
- try {
864
- let sCemiFromDatagram = _datagram.cEMIMessage.toBuffer().toString("hex");
865
- _cemiETS = "2900BCD0" + sCemiFromDatagram.substr(8);
866
863
  } catch (error) { _cemiETS = ""; }
867
864
  }
868
865
  // #####################################################################
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-knx-ultimate",
3
- "version": "1.3.21",
3
+ "version": "1.3.22",
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
  "fs": "0.0.1-security",