From e123ef406aec174a44ba5a0bee9cdfbd1e88ceb8 Mon Sep 17 00:00:00 2001 From: Colin Kuebler Date: Fri, 17 May 2024 09:49:23 -0400 Subject: [PATCH 1/5] fix(client): use the configured interface/IPAddress --- src/bacnet-client.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/bacnet-client.js b/src/bacnet-client.js index ee9d756..fa78437 100644 --- a/src/bacnet-client.js +++ b/src/bacnet-client.js @@ -16,19 +16,13 @@ module.exports = function (RED) { this.name = config.name this.adpuTimeout = parseInt(config.adpuTimeout) || 6000 this.port = parseInt(config.port) || 47808 - this.IPAddress = config.IPAddress || '0.0.0.0' + this.interface = config.interface || '0.0.0.0' this.broadcastAddress = config.broadcastAddress || '0.0.0.255' const node = this node.devices = [] - if (node.IPAddress) { - bacnetCore.internalDebugLog('client with IP settings') - node.client = new BACnet({ adpuTimeout: node.adpuTimeout, port: node.port, interface: node.IPAddress, broadcastAddress: node.broadcastAddress }) - } else { - bacnetCore.internalDebugLog('client without IP settings') - node.client = new BACnet({ adpuTimeout: node.adpuTimeout, port: node.port }) - } + node.client = new BACnet({ adpuTimeout: node.adpuTimeout, port: node.port, interface: node.interface, broadcastAddress: node.broadcastAddress }) if (node.client) { node.client.on('iAm', (device) => { @@ -52,7 +46,7 @@ module.exports = function (RED) { node.client.close() node.client = null node.devices = [] - node.client = new BACnet({ adpuTimeout: node.adpuTimeout, port: node.port, interface: node.IPAddress, broadcastAddress: node.broadcastAddress }) + node.client = new BACnet({ adpuTimeout: node.adpuTimeout, port: node.port, interface: node.interface, broadcastAddress: node.broadcastAddress }) }) } From 6dc2909065f1225d60deef8f401597aaf64088b7 Mon Sep 17 00:00:00 2001 From: Colin Kuebler Date: Fri, 17 May 2024 09:49:33 -0400 Subject: [PATCH 2/5] fix(client): match config placeholders with defaults --- src/bacnet-client.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bacnet-client.html b/src/bacnet-client.html index 963f69b..9ef1dc6 100644 --- a/src/bacnet-client.html +++ b/src/bacnet-client.html @@ -29,11 +29,11 @@
- +
- +
From 1a2596039319f3b022a5382268955471be36d849 Mon Sep 17 00:00:00 2001 From: Colin Kuebler Date: Fri, 17 May 2024 09:51:39 -0400 Subject: [PATCH 3/5] fix: remove config requirements for runtime properties --- src/bacnet-read.html | 4 ++-- src/bacnet-read.js | 18 +++++++++++++----- src/bacnet-write.html | 8 ++++---- src/bacnet-write.js | 16 ++++++++++++---- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/bacnet-read.html b/src/bacnet-read.html index 13614e1..b343e56 100644 --- a/src/bacnet-read.html +++ b/src/bacnet-read.html @@ -13,9 +13,9 @@ defaults: { name: {value: ''}, objectType: {value: ''}, - instance: {type: "BACnet-Instance", required:true}, + instance: {type: "BACnet-Instance"}, propertyId: {value: ''}, - device: {type: "BACnet-Device", required:true}, + device: {type: "BACnet-Device"}, server: {type: "BACnet-Client", required:true}, multipleRead: {value: false} }, diff --git a/src/bacnet-read.js b/src/bacnet-read.js index aa0511a..5087078 100644 --- a/src/bacnet-read.js +++ b/src/bacnet-read.js @@ -18,11 +18,19 @@ module.exports = function (RED) { this.propertyId = parseInt(config.propertyId) this.multipleRead = config.multipleRead - this.instance = RED.nodes.getNode(config.instance) - this.objectInstance = parseInt(this.instance.instanceAddress) || 0 - - this.device = RED.nodes.getNode(config.device) - this.deviceIPAddress = this.device.deviceAddress || '127.0.0.1' + if (config.instance) { + this.instance = RED.nodes.getNode(config.instance) + this.objectInstance = this.instance.instanceAddress + } else { + this.objectInstance = 0 + } + + if (config.device) { + this.device = RED.nodes.getNode(config.device) + this.deviceIPAddress = this.device.deviceAddress + } else { + this.deviceIPAddress = '127.0.0.1' + } this.connector = RED.nodes.getNode(config.server) diff --git a/src/bacnet-write.html b/src/bacnet-write.html index 125b173..3dadc3a 100644 --- a/src/bacnet-write.html +++ b/src/bacnet-write.html @@ -13,12 +13,12 @@ defaults: { name: {value: ''}, objectType: {value: '', required:true, validate: RED.validators.number()}, - instance: {type: "BACnet-Instance", required:true}, - valueTag: {value: '', required:true, validate: RED.validators.number()}, + instance: {type: "BACnet-Instance"}, + valueTag: {value: '', validate: RED.validators.number()}, valueValue: {value: ''}, - propertyId: {value: '', required:true, validate: RED.validators.number()}, + propertyId: {value: '', validate: RED.validators.number()}, priority: {value: ''}, - device: {type: "BACnet-Device", required:true}, + device: {type: "BACnet-Device"}, server: {type: "BACnet-Client", required:true}, multipleWrite: {value: false} }, diff --git a/src/bacnet-write.js b/src/bacnet-write.js index b682fcc..648b9b7 100644 --- a/src/bacnet-write.js +++ b/src/bacnet-write.js @@ -24,11 +24,19 @@ module.exports = function (RED) { this.multipleWrite = config.multipleWrite - this.instance = RED.nodes.getNode(config.instance) - this.objectInstance = parseInt(this.instance.instanceAddress) || 0 + if (config.instance) { + this.instance = RED.nodes.getNode(config.instance) + this.objectInstance = this.instance.instanceAddress + } else { + this.objectInstance = 0 + } - this.device = RED.nodes.getNode(config.device) - this.deviceIPAddress = this.device.deviceAddress || '127.0.0.1' // IPv6 it is :: - but configure Node-RED too + if (config.device) { + this.device = RED.nodes.getNode(config.device) + this.deviceIPAddress = this.device.deviceAddress + } else { + this.deviceIPAddress = '127.0.0.1' + } this.connector = RED.nodes.getNode(config.server) From 00ef6474cb73c28749c9d7bbbe95b18776c9c89a Mon Sep 17 00:00:00 2001 From: Colin Kuebler Date: Fri, 17 May 2024 09:59:24 -0400 Subject: [PATCH 4/5] fix(client): restore listeners after client error --- src/bacnet-client.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bacnet-client.js b/src/bacnet-client.js index fa78437..4fbb688 100644 --- a/src/bacnet-client.js +++ b/src/bacnet-client.js @@ -22,9 +22,9 @@ module.exports = function (RED) { const node = this node.devices = [] - node.client = new BACnet({ adpuTimeout: node.adpuTimeout, port: node.port, interface: node.interface, broadcastAddress: node.broadcastAddress }) + function setupClient () { + node.client = new BACnet({ adpuTimeout: node.adpuTimeout, port: node.port, interface: node.interface, broadcastAddress: node.broadcastAddress }) - if (node.client) { node.client.on('iAm', (device) => { node.devices.push(device) bacnetCore.internalDebugLog('iAm Event') @@ -46,10 +46,12 @@ module.exports = function (RED) { node.client.close() node.client = null node.devices = [] - node.client = new BACnet({ adpuTimeout: node.adpuTimeout, port: node.port, interface: node.interface, broadcastAddress: node.broadcastAddress }) + setupClient() }) } + setupClient() + node.on('input', function (msg) { msg.devices = node.devices node.send(msg) From 96cfeab2c34c1e4f9464f68cca5e09d71612a601 Mon Sep 17 00:00:00 2001 From: Colin Kuebler Date: Fri, 17 May 2024 10:56:46 -0400 Subject: [PATCH 5/5] chore: add contributor --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 431ebf3..8088f26 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,9 @@ }, { "name": "Fabio Huser (node-bacstack)" + }, + { + "name": "Colin Kuebler (kueblc)" } ], "license": "MIT",