New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

knxultimate

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knxultimate - npm Package Compare versions

Comparing version 1.0.15 to 1.0.16

6

CHANGELOG.md

@@ -10,2 +10,8 @@ ![Sample Node](img/logo.png)

<p>
<b>Version 1.0.16</b> - April 2022<br/>
- Changed: the KNX Gateway don't care anymore for ROUTING_LOST_MESSAGE and ROUTING_BUSY. Previously, it was disconnecting. Now it only advises in LOG.<br/>
- Added sample on how to decode incoming datagram's values<br/>
- Updated README and samples.<br/>
</p>
<p>
<b>Version 1.0.15</b> - March 2022<br/>

@@ -12,0 +18,0 @@ - Further optimization for the garbage collector.<br/>

2

package.json
{
"name": "knxultimate",
"description": "KNX IP protocol implementation for Node. This is the ENGINE of Node-Red KNX-Ultimate node.",
"version": "1.0.15",
"version": "1.0.16",
"engines": {

@@ -6,0 +6,0 @@ "node": ">=14"

@@ -79,8 +79,8 @@ ![Logo](img/logo-big.png)

**Commands to be used to write to the KNX BUS**
## CONTROL THE CLIENT
See the examples also.
|Property|Description|
|Method|Description|
|--|--|
| .Connect() | Connects to the KNX Gateway |
| .Disconnect() | Gracefully disconnects from the KNX Gateway |
| .write (GA, payload, datapoint) | Sends a WRITE telegram to the BUS. **GA** is the group address (for example "0/0/1"), **payload** is the value you want to send (for example true), **datapoint** is a string representing the datapoint (for example "5.001") |

@@ -91,7 +91,28 @@ | .respond (GA, payload, datapoint) | Sends a RESPONSE telegram to the BUS. **GA** is the group address (for example "0/0/1"), **payload** is the value you want to send (for example true), **datapoint** is a string representing the datapoint (for example "5.001") |

<br/>
<br/>
|Properties|Description|
|--|--|
| .isConnected() | Returns **true** if you the client is connected to the KNX Gateway Router/Interface, **false** if not connected. |
| ._getClearToSend() | Returns **true** if you can send a telegram, **false** if the client is still waiting for the last telegram's ACK or whenever the client cannot temporary send the telegram. |
<br/>
<br/>
## DECONDING THE TELEGRAMS FROM BUS
Decoding is very simple.
Just require the dptlib and use it to decode the RAW telegram
```javascript
const dptlib = require('./src/dptlib');
let dpt = dptlib.resolve("1.001");
let jsValue = dptlib.fromBuffer(RAW VALUE (SEE SAMPLES), dpt); // THIS IS THE DECODED VALUE
```
<br/>
<br/>
## Simple sample (you can find this sample in the "simpleSample.js" file):

@@ -101,2 +122,3 @@

const knx = require("./index.js");
const dptlib = require('./src/dptlib');

@@ -124,9 +146,31 @@ // Set the properties

// Traffic
// This function is called whenever a KNX telegram arrives from BUS
// Get the event
let _evt = "";
let dpt = "";
let jsValue;
if (_datagram.cEMIMessage.npdu.isGroupRead) _evt = "GroupValue_Read";
if (_datagram.cEMIMessage.npdu.isGroupResponse) _evt = "GroupValue_Response";
if (_datagram.cEMIMessage.npdu.isGroupWrite) _evt = "GroupValue_Write";
console.log("src: " + _datagram.cEMIMessage.srcAddress.toString() + " dest: " + _datagram.cEMIMessage.dstAddress.toString(), " event: " + _evt);
// Get the source Address
let _src = _datagram.cEMIMessage.srcAddress.toString();
// Get the destination GA
let _dst = _datagram.cEMIMessage.dstAddress.toString()
// Get the RAW Value
let _Rawvalue = _datagram.cEMIMessage.npdu.dataValue;
// Decode the telegram.
if (_dst === "0/1/1") {
// We know that 0/1/1 is a boolean DPT 1.001
dpt = dptlib.resolve("1.001");
jsValue = dptlib.fromBuffer(_Rawvalue, dpt)
} else if (_dst === "0/1/2") {
// We know that 0/1/2 is a boolean DPT 232.600 Color RGB
dpt = dptlib.resolve("232.600");
jsValue = dptlib.fromBuffer(_Rawvalue, dpt)
}
console.log("src: " + _src + " dest: " + _dst, " event: " + _evt, " value: " + jsValue);
});

@@ -136,3 +180,2 @@ knxUltimateClient.on(knx.KNXClient.KNXClientEvents.connected, info => {

console.log("Connected. On Duty", info);
// WARNING, THIS WILL WRITE ON YOUR KNX BUS!

@@ -261,2 +304,25 @@ knxUltimateClient.write("0/1/1", false, "1.001");

console.log("Connected. On Duty", info)
// Check wether knxUltimateClient is clear to send the next telegram.
// This should be called bevore any .write, .response, and .read request.
// If not clear to send, retry later because the knxUltimateClient is busy in sending another telegram.
console.log("Clear to send: " + knxUltimateClient._getClearToSend())
// // Send a WRITE telegram to the KNX BUS
// // You need: group address, payload (true/false/or any message), datapoint as string
let payload = true;
if (knxUltimateClient._getClearToSend()) knxUltimateClient.write("0/1/1", payload, "1.001");
// Send a color RED to an RGB datapoint
payload = { red: 125, green: 0, blue: 0 };
if (knxUltimateClient._getClearToSend()) knxUltimateClient.write("0/1/2", payload, "232.600");
// // Send a READ request to the KNX BUS
if (knxUltimateClient._getClearToSend()) knxUltimateClient.read("0/0/1");
// Send a RESPONSE telegram to the KNX BUS
// You need: group address, payload (true/false/or any message), datapoint as string
payload = false;
if (knxUltimateClient._getClearToSend()) knxUltimateClient.respond("0/0/1", payload, "1.001");
});

@@ -275,54 +341,38 @@ knxUltimateClient.on(knx.KNXClient.KNXClientEvents.connecting, info => {

// Traffic
// This function is called whenever a KNX telegram arrives from BUS
// Get the event
let _evt = "";
let dpt = "";
let jsValue;
if (_datagram.cEMIMessage.npdu.isGroupRead) _evt = "GroupValue_Read";
if (_datagram.cEMIMessage.npdu.isGroupResponse) _evt = "GroupValue_Response";
if (_datagram.cEMIMessage.npdu.isGroupWrite) _evt = "GroupValue_Write";
console.log("src: " + _datagram.cEMIMessage.srcAddress.toString() + " dest: " + _datagram.cEMIMessage.dstAddress.toString(), " event: " + _evt);
// Get the source Address
let _src = _datagram.cEMIMessage.srcAddress.toString();
// Get the destination GA
let _dst = _datagram.cEMIMessage.dstAddress.toString()
// Get the RAW Value
let _Rawvalue = _datagram.cEMIMessage.npdu.dataValue;
// Decode the telegram.
if (_dst === "0/1/1") {
// We know that 0/1/1 is a boolean DPT 1.001
dpt = dptlib.resolve("1.001");
jsValue = dptlib.fromBuffer(_Rawvalue, dpt)
} else if (_dst === "0/1/2") {
// We know that 0/1/2 is a boolean DPT 232.600 Color RGB
dpt = dptlib.resolve("232.600");
jsValue = dptlib.fromBuffer(_Rawvalue, dpt)
}
console.log("src: " + _src + " dest: " + _dst, " event: " + _evt, " value: " + jsValue);
}
console.log("WARNING: I'm about to write to your BUS in 10 seconds! Press Control+C to abort!")
// WRITE SOMETHING
// WARNING, THIS WILL WRITE TO YOUR BUS !!!!
setTimeout(() => {
// 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.
// This should be called bevore any .write, .response, and .read request.
// If not clear to send, retry later because the knxUltimateClient is busy in sending another telegram.
console.log("Clear to send: " + knxUltimateClient._getClearToSend())
// // Send a WRITE telegram to the KNX BUS
// // You need: group address, payload (true/false/or any message), datapoint as string
let payload = true;
knxUltimateClient.write("0/1/1", payload, "1.001");
// Send a color RED to an RGB datapoint
payload = { red: 125, green: 0, blue: 0 };
knxUltimateClient.write("0/1/2", payload, "232.600");
// // Send a READ request to the KNX BUS
knxUltimateClient.read("0/0/1");
// Send a RESPONSE telegram to the KNX BUS
// You need: group address, payload (true/false/or any message), datapoint as string
payload = false;
knxUltimateClient.respond("0/0/1", payload, "1.001");
}, 5000);
// Disconnect after 20 secs.
setTimeout(() => {
knxUltimateClient.Disconnect();
if (knxUltimateClient.isConnected()) knxUltimateClient.Disconnect();
}, 20000);
```
```
<br/>

@@ -339,4 +389,6 @@ <br/>

```javascript
const knx = require("./index.js");
const KNXsecureKeyring = require("./src/KNXsecureKeyring.js");
const dptlib = require('./src/dptlib');

@@ -421,3 +473,4 @@ // This is the content of the ETS Keyring file obtained doing this: https://www.youtube.com/watch?v=OpR7ZQTlMRU

console.log("Connected. On Duty", info)
// Write something to the BUS
if (knxUltimateClient._getClearToSend()) knxUltimateClient.write("0/1/1", false, "1.001");
});

@@ -434,18 +487,40 @@ knxUltimateClient.on(knx.KNXClient.KNXClientEvents.connecting, info => {

// Traffic
let _evt = "";
if (_datagram.cEMIMessage.npdu.isGroupRead) _evt = "GroupValue_Read";
if (_datagram.cEMIMessage.npdu.isGroupResponse) _evt = "GroupValue_Response";
if (_datagram.cEMIMessage.npdu.isGroupWrite) _evt = "GroupValue_Write";
console.log("src: " + _datagram.cEMIMessage.srcAddress.toString() + " dest: " + _datagram.cEMIMessage.dstAddress.toString(), " event: " + _evt);
// This function is called whenever a KNX telegram arrives from BUS
// Get the event
let _evt = "";
let dpt = "";
let jsValue;
if (_datagram.cEMIMessage.npdu.isGroupRead) _evt = "GroupValue_Read";
if (_datagram.cEMIMessage.npdu.isGroupResponse) _evt = "GroupValue_Response";
if (_datagram.cEMIMessage.npdu.isGroupWrite) _evt = "GroupValue_Write";
// Get the source Address
let _src = _datagram.cEMIMessage.srcAddress.toString();
// Get the destination GA
let _dst = _datagram.cEMIMessage.dstAddress.toString()
// Get the RAW Value
let _Rawvalue = _datagram.cEMIMessage.npdu.dataValue;
// Decode the telegram.
if (_dst === "0/1/1") {
// We know that 0/1/1 is a boolean DPT 1.001
dpt = dptlib.resolve("1.001");
jsValue = dptlib.fromBuffer(_Rawvalue, dpt)
} else if (_dst === "0/1/2") {
// We know that 0/1/2 is a boolean DPT 232.600 Color RGB
dpt = dptlib.resolve("232.600");
jsValue = dptlib.fromBuffer(_Rawvalue, dpt)
}
console.log("src: " + _src + " dest: " + _dst, " event: " + _evt, " value: " + jsValue);
}
knxUltimateClient.Connect();
// Wait some seconds, just for fun
await new Promise((resolve, reject) => setTimeout(resolve, 6000));
await new Promise((resolve, reject) => setTimeout(resolve, 10000));
// WARNING, THIS WILL WRITE ON YOUR KNX BUS!
if (knxUltimateClient.isConnected()) knxUltimateClient.write("0/1/1", false, "1.001");
// Disconnects
if (knxUltimateClient.isConnected()) knxUltimateClient.Disconnect();

@@ -455,3 +530,2 @@ }

go();
```

@@ -458,0 +532,0 @@

@@ -109,2 +109,25 @@ const knx = require("./index.js");

console.log("Connected. On Duty", info)
// Check wether knxUltimateClient is clear to send the next telegram.
// This should be called bevore any .write, .response, and .read request.
// If not clear to send, retry later because the knxUltimateClient is busy in sending another telegram.
console.log("Clear to send: " + knxUltimateClient._getClearToSend())
// // Send a WRITE telegram to the KNX BUS
// // You need: group address, payload (true/false/or any message), datapoint as string
let payload = true;
if (knxUltimateClient._getClearToSend()) knxUltimateClient.write("0/1/1", payload, "1.001");
// Send a color RED to an RGB datapoint
payload = { red: 125, green: 0, blue: 0 };
if (knxUltimateClient._getClearToSend()) knxUltimateClient.write("0/1/2", payload, "232.600");
// // Send a READ request to the KNX BUS
if (knxUltimateClient._getClearToSend()) knxUltimateClient.read("0/0/1");
// Send a RESPONSE telegram to the KNX BUS
// You need: group address, payload (true/false/or any message), datapoint as string
payload = false;
if (knxUltimateClient._getClearToSend()) knxUltimateClient.respond("0/0/1", payload, "1.001");
});

@@ -123,51 +146,35 @@ knxUltimateClient.on(knx.KNXClient.KNXClientEvents.connecting, info => {

// Traffic
// This function is called whenever a KNX telegram arrives from BUS
// Get the event
let _evt = "";
let dpt = "";
let jsValue;
if (_datagram.cEMIMessage.npdu.isGroupRead) _evt = "GroupValue_Read";
if (_datagram.cEMIMessage.npdu.isGroupResponse) _evt = "GroupValue_Response";
if (_datagram.cEMIMessage.npdu.isGroupWrite) _evt = "GroupValue_Write";
console.log("src: " + _datagram.cEMIMessage.srcAddress.toString() + " dest: " + _datagram.cEMIMessage.dstAddress.toString(), " event: " + _evt);
// Get the source Address
let _src = _datagram.cEMIMessage.srcAddress.toString();
// Get the destination GA
let _dst = _datagram.cEMIMessage.dstAddress.toString()
// Get the RAW Value
let _Rawvalue = _datagram.cEMIMessage.npdu.dataValue;
// Decode the telegram.
if (_dst === "0/1/1") {
// We know that 0/1/1 is a boolean DPT 1.001
dpt = dptlib.resolve("1.001");
jsValue = dptlib.fromBuffer(_Rawvalue, dpt)
} else if (_dst === "0/1/2") {
// We know that 0/1/2 is a boolean DPT 232.600 Color RGB
dpt = dptlib.resolve("232.600");
jsValue = dptlib.fromBuffer(_Rawvalue, dpt)
}
console.log("src: " + _src + " dest: " + _dst, " event: " + _evt, " value: " + jsValue);
}
console.log("WARNING: I'm about to write to your BUS in 10 seconds! Press Control+C to abort!")
// WRITE SOMETHING
// WARNING, THIS WILL WRITE TO YOUR BUS !!!!
setTimeout(() => {
// 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.
// This should be called bevore any .write, .response, and .read request.
// If not clear to send, retry later because the knxUltimateClient is busy in sending another telegram.
console.log("Clear to send: " + knxUltimateClient._getClearToSend())
// // Send a WRITE telegram to the KNX BUS
// // You need: group address, payload (true/false/or any message), datapoint as string
let payload = true;
knxUltimateClient.write("0/1/1", payload, "1.001");
// Send a color RED to an RGB datapoint
payload = { red: 125, green: 0, blue: 0 };
knxUltimateClient.write("0/1/2", payload, "232.600");
// // Send a READ request to the KNX BUS
knxUltimateClient.read("0/0/1");
// Send a RESPONSE telegram to the KNX BUS
// You need: group address, payload (true/false/or any message), datapoint as string
payload = false;
knxUltimateClient.respond("0/0/1", payload, "1.001");
}, 5000);
// Disconnect after 20 secs.
setTimeout(() => {
knxUltimateClient.Disconnect();
if (knxUltimateClient.isConnected()) knxUltimateClient.Disconnect();
}, 20000);
const knx = require("./index.js");
const KNXsecureKeyring = require("./src/KNXsecureKeyring.js");
const dptlib = require('./src/dptlib');

@@ -83,3 +84,4 @@ // This is the content of the ETS Keyring file obtained doing this: https://www.youtube.com/watch?v=OpR7ZQTlMRU

console.log("Connected. On Duty", info)
// Write something to the BUS
if (knxUltimateClient._getClearToSend()) knxUltimateClient.write("0/1/1", false, "1.001");
});

@@ -96,30 +98,43 @@ knxUltimateClient.on(knx.KNXClient.KNXClientEvents.connecting, info => {

// Traffic
let _evt = "";
if (_datagram.cEMIMessage.npdu.isGroupRead) _evt = "GroupValue_Read";
if (_datagram.cEMIMessage.npdu.isGroupResponse) _evt = "GroupValue_Response";
if (_datagram.cEMIMessage.npdu.isGroupWrite) _evt = "GroupValue_Write";
console.log("src: " + _datagram.cEMIMessage.srcAddress.toString() + " dest: " + _datagram.cEMIMessage.dstAddress.toString(), " event: " + _evt);
// This function is called whenever a KNX telegram arrives from BUS
// Get the event
let _evt = "";
let dpt = "";
let jsValue;
if (_datagram.cEMIMessage.npdu.isGroupRead) _evt = "GroupValue_Read";
if (_datagram.cEMIMessage.npdu.isGroupResponse) _evt = "GroupValue_Response";
if (_datagram.cEMIMessage.npdu.isGroupWrite) _evt = "GroupValue_Write";
// Get the source Address
let _src = _datagram.cEMIMessage.srcAddress.toString();
// Get the destination GA
let _dst = _datagram.cEMIMessage.dstAddress.toString()
// Get the RAW Value
let _Rawvalue = _datagram.cEMIMessage.npdu.dataValue;
// Decode the telegram.
if (_dst === "0/1/1") {
// We know that 0/1/1 is a boolean DPT 1.001
dpt = dptlib.resolve("1.001");
jsValue = dptlib.fromBuffer(_Rawvalue, dpt)
} else if (_dst === "0/1/2") {
// We know that 0/1/2 is a boolean DPT 232.600 Color RGB
dpt = dptlib.resolve("232.600");
jsValue = dptlib.fromBuffer(_Rawvalue, dpt)
}
console.log("src: " + _src + " dest: " + _dst, " event: " + _evt, " value: " + jsValue);
}
knxUltimateClient.Connect();
// Wait some seconds, just for fun
await new Promise((resolve, reject) => setTimeout(resolve, 6000));
await new Promise((resolve, reject) => setTimeout(resolve, 10000));
// WARNING, THIS WILL WRITE ON YOUR KNX BUS!
if (knxUltimateClient.isConnected()) knxUltimateClient.write("0/1/1", false, "1.001");
// Disconnects
if (knxUltimateClient.isConnected()) knxUltimateClient.Disconnect();
}
go();
go();
const knx = require("./index.js");
const dptlib = require('./src/dptlib');

@@ -24,9 +25,31 @@ // Set the properties

// Traffic
// This function is called whenever a KNX telegram arrives from BUS
// Get the event
let _evt = "";
let dpt = "";
let jsValue;
if (_datagram.cEMIMessage.npdu.isGroupRead) _evt = "GroupValue_Read";
if (_datagram.cEMIMessage.npdu.isGroupResponse) _evt = "GroupValue_Response";
if (_datagram.cEMIMessage.npdu.isGroupWrite) _evt = "GroupValue_Write";
console.log("src: " + _datagram.cEMIMessage.srcAddress.toString() + " dest: " + _datagram.cEMIMessage.dstAddress.toString(), " event: " + _evt);
// Get the source Address
let _src = _datagram.cEMIMessage.srcAddress.toString();
// Get the destination GA
let _dst = _datagram.cEMIMessage.dstAddress.toString()
// Get the RAW Value
let _Rawvalue = _datagram.cEMIMessage.npdu.dataValue;
// Decode the telegram.
if (_dst === "0/1/1") {
// We know that 0/1/1 is a boolean DPT 1.001
dpt = dptlib.resolve("1.001");
jsValue = dptlib.fromBuffer(_Rawvalue, dpt)
} else if (_dst === "0/1/2") {
// We know that 0/1/2 is a boolean DPT 232.600 Color RGB
dpt = dptlib.resolve("232.600");
jsValue = dptlib.fromBuffer(_Rawvalue, dpt)
}
console.log("src: " + _src + " dest: " + _dst, " event: " + _evt, " value: " + jsValue);
});

@@ -36,3 +59,2 @@ knxUltimateClient.on(knx.KNXClient.KNXClientEvents.connected, info => {

console.log("Connected. On Duty", info);
// WARNING, THIS WILL WRITE ON YOUR KNX BUS!

@@ -39,0 +61,0 @@ knxUltimateClient.write("0/1/1", false, "1.001");

@@ -142,2 +142,3 @@ // Made with love by Supergiovane

}
conn = null;
});

@@ -160,3 +161,3 @@

this._clientSocket.on(SocketEvents.listening, function () {
});

@@ -181,4 +182,6 @@ let conn = this;

} catch (error) { }
conn = null;
return;
}
conn = null;
//this._localPort = this._clientSocket.address().port;// 07/12/2021 Get the local port used bu the socket

@@ -604,3 +607,3 @@ });

let conn = this;
this._clientSocket.connect( this._peerPort, this._peerHost, function () {
this._clientSocket.connect(this._peerPort, this._peerHost, function () {
// conn._timer = setTimeout(() => {

@@ -613,2 +616,3 @@ // conn._timer = null;

if (conn._options.isSecureKNXEnabled) conn._sendSecureSessionRequestMessage(new TunnelCRI.TunnelCRI(knxLayer));
conn = null;
});

@@ -749,3 +753,3 @@

_processInboundMessage(msg, rinfo) {
try {

@@ -773,3 +777,3 @@ // Composing debug string

this.emit(KNXClientEvents.error, new Error('ROUTING_LOST_MESSAGE'));
this._setDisconnected("Routing Lost Message");
//this._setDisconnected("Routing Lost Message"); // 31/03/2022 Commented, because it doesn't matter. Non need to disconnect.
return;

@@ -780,3 +784,3 @@ } catch (error) { }

this.emit(KNXClientEvents.error, new Error('ROUTING_BUSY'));
this._setDisconnected("Routing Busy");
//this._setDisconnected("Routing Busy"); // 31/03/2022 Commented, because it doesn't matter. Non need to disconnect.
return;

@@ -783,0 +787,0 @@ } catch (error) { }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc