Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix config issues #38

Merged
merged 5 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
},
{
"name": "Fabio Huser (node-bacstack)"
},
{
"name": "Colin Kuebler (kueblc)"
}
],
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/bacnet-client.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
</div>
<div class="form-row">
<label for="node-config-input-interface"><i class="icon-tag"></i> <span data-i18n="bacnet-contrib.label.interface"></span></label>
<input type="text" id="node-config-input-interface" placeholder="127.0.0.1">
<input type="text" id="node-config-input-interface" placeholder="0.0.0.0">
</div>
<div class="form-row">
<label for="node-config-input-broadcastAddress"><i class="icon-tag"></i> <span data-i18n="bacnet-contrib.label.broadcastAddress"></span></label>
<input type="text" id="node-config-input-broadcastAddress" placeholder="127.0.0.255">
<input type="text" id="node-config-input-broadcastAddress" placeholder="0.0.0.255">
</div>
<div class="form-row">
<label for="node-config-input-port"><i class="icon-tag"></i> <span data-i18n="bacnet-contrib.label.port"></span></label>
Expand Down
16 changes: 6 additions & 10 deletions src/bacnet-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,15 @@ 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 })
}
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')
Expand All @@ -52,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.IPAddress, broadcastAddress: node.broadcastAddress })
setupClient()
})
}

setupClient()

node.on('input', function (msg) {
msg.devices = node.devices
node.send(msg)
Expand Down
4 changes: 2 additions & 2 deletions src/bacnet-read.html
Original file line number Diff line number Diff line change
Expand Up @@ -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}
},
Expand Down
18 changes: 13 additions & 5 deletions src/bacnet-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions src/bacnet-write.html
Original file line number Diff line number Diff line change
Expand Up @@ -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}
},
Expand Down
16 changes: 12 additions & 4 deletions src/bacnet-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading