new bacnet()
- Source:
To be able to communicate to BACNET devices, you have to initialize a new bacnet instance.
Example
const bacnet = require('node-bacnet');
const client = new bacnet({
port: 47809, // Use BAC1 as communication port
interface: '192.168.251.10', // Listen on a specific interface
broadcastAddress: '192.168.251.255', // Use the subnet broadcast address
apduTimeout: 6000 // Wait twice as long for response
});
Parameters:
Name |
Type |
Attributes |
Default |
Description |
this._settings |
object
|
<optional>
|
|
The options object used for parameterizing the bacnet. |
options.port |
number
|
<optional>
|
47808
|
BACNET communication port for listening and sending. |
options.interface |
string
|
<optional>
|
|
Specific BACNET communication interface if different from primary one. |
options.broadcastAddress |
string
|
<optional>
|
255.255.255.255
|
The address used for broadcast messages. |
options.apduTimeout |
number
|
<optional>
|
3000
|
The timeout in milliseconds until a transaction should be interpreted as error. |
Methods
(static) close()
- Source:
Unloads the current bacnet instance and closes the underlying UDP socket.
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
client.close();
(static) confirmedCOVNotification(receiver, monitoredObject, subscribeId, initiatingDeviceId, lifetime, values, optionsopt, next)
- Source:
The confirmedCOVNotification command is used to push notifications to other
systems that have registered with us via a subscribeCOV message.
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
const settings = {deviceId: 123}; // our BACnet device
// Items saved from subscribeCOV message
const monitoredObject = {type: 1, instance: 1};
const subscriberProcessId = 123;
client.confirmedCOVNotification(
'192.168.1.43',
monitoredObject,
subscriberProcessId,
settings.deviceId,
30, // should be lifetime of subscription really
[
{
property: { id: bacnet.enum.PropertyIdentifier.PRESENT_VALUE },
value: [
{value: 123, type: bacnet.enum.ApplicationTag.REAL},
],
},
],
(err) => {
console.log('error: ', err);
}
);
Parameters:
Name |
Type |
Attributes |
Description |
receiver |
string
|
|
IP address of the target device. |
monitoredObject |
object
|
|
The object being monitored, from subscribeCOV.
Properties
Name |
Type |
Description |
type |
number
|
Object type. |
instance |
number
|
Object instance. |
|
subscribeId |
number
|
|
Subscriber ID from subscribeCOV, |
initiatingDeviceId |
number
|
|
Our BACnet device ID. |
lifetime |
number
|
|
Number of seconds left until the subscription expires. |
values |
array
|
|
values for the monitored object. See example. |
options |
object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Description |
maxSegments |
MaxSegmentsAccepted
|
<optional>
|
The maximimal allowed number of segments. |
maxApdu |
MaxApduLengthAccepted
|
<optional>
|
The maximal allowed APDU size. |
invokeId |
number
|
<optional>
|
The invoke ID of the confirmed service telegram. |
|
next |
function
|
|
The callback containing an error, in case of a failure and value object in case of success. |
(static) deviceCommunicationControl(receiver, timeDuration, enableDisable, optionsopt, next)
- Source:
The deviceCommunicationControl command enables or disables network communication of the target device.
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
client.deviceCommunicationControl('192.168.1.43', 0, bacnet.enum.EnableDisable.DISABLE, (err) => {
console.log('error: ', err);
});
Parameters:
Name |
Type |
Attributes |
Description |
receiver |
string
|
|
IP address of the target device. |
timeDuration |
number
|
|
The time to hold the network communication state in seconds. 0 for infinite. |
enableDisable |
EnableDisable
|
|
The network communication state to set. |
options |
object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Description |
maxSegments |
MaxSegmentsAccepted
|
<optional>
|
The maximimal allowed number of segments. |
maxApdu |
MaxApduLengthAccepted
|
<optional>
|
The maximal allowed APDU size. |
invokeId |
number
|
<optional>
|
The invoke ID of the confirmed service telegram. |
password |
string
|
<optional>
|
The optional password used to set the network communication state. |
|
next |
function
|
|
The callback containing an error, in case of a failure and value object in case of success. |
(static) iAmResponse(receiver, deviceId, segmentation, vendorId)
- Source:
The iAmResponse command is sent as a reply to a whoIs request.
Parameters:
Name |
Type |
Description |
receiver |
object
|
address to send packet to, null for local broadcast. |
deviceId |
number
|
Our device ID. |
segmentation |
number
|
an enum.Segmentation value. |
vendorId |
number
|
The numeric ID assigned to the organisation providing this application. |
(static) readProperty(receiver, objectId, propertyId, optionsopt, next)
- Source:
The readProperty command reads a single property of an object from a device.
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
client.readProperty('192.168.1.43', {type: 8, instance: 44301}, 28, (err, value) => {
console.log('value: ', value);
});
Parameters:
Name |
Type |
Attributes |
Description |
receiver |
string
|
|
IP address of the target device. |
objectId |
object
|
|
The BACNET object ID to read.
Properties
Name |
Type |
Description |
type |
number
|
The BACNET object type to read. |
instance |
number
|
The BACNET object instance to read. |
|
propertyId |
number
|
|
The BACNET property id in the specified object to read. |
options |
object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Description |
maxSegments |
MaxSegmentsAccepted
|
<optional>
|
The maximimal allowed number of segments. |
maxApdu |
MaxApduLengthAccepted
|
<optional>
|
The maximal allowed APDU size. |
invokeId |
number
|
<optional>
|
The invoke ID of the confirmed service telegram. |
arrayIndex |
number
|
<optional>
|
The array index of the property to be read. |
|
next |
function
|
|
The callback containing an error, in case of a failure and value object in case of success. |
(static) readPropertyMultiple(receiver, propertiesArray, optionsopt, next)
- Source:
The readPropertyMultiple command reads multiple properties in multiple objects from a device.
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
const requestArray = [
{objectId: {type: 8, instance: 4194303}, properties: [{id: 8}]}
];
client.readPropertyMultiple('192.168.1.43', requestArray, (err, value) => {
console.log('value: ', value);
});
Parameters:
Name |
Type |
Attributes |
Description |
receiver |
string
|
|
IP address of the target device. |
propertiesArray |
Array.<object>
|
|
List of object and property specifications to be read.
Properties
Name |
Type |
Description |
objectId |
object
|
Specifies which object to read.
Properties
Name |
Type |
Description |
type |
number
|
The BACNET object type to read. |
instance |
number
|
The BACNET object instance to read. |
|
properties |
Array.<object>
|
List of properties to be read.
Properties
Name |
Type |
Description |
id |
number
|
The BACNET property id in the specified object to read. Also supports 8 for all properties. |
|
|
options |
object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Description |
maxSegments |
MaxSegmentsAccepted
|
<optional>
|
The maximimal allowed number of segments. |
maxApdu |
MaxApduLengthAccepted
|
<optional>
|
The maximal allowed APDU size. |
invokeId |
number
|
<optional>
|
The invoke ID of the confirmed service telegram. |
|
next |
function
|
|
The callback containing an error, in case of a failure and value object in case of success. |
(static) readPropertyResponse(receiver, invokeId, objectId, property, optionsopt)
- Source:
The readPropertyResponse call sends a response with information about one of our properties.
Parameters:
Name |
Type |
Attributes |
Description |
receiver |
string
|
|
IP address of the target device. |
invokeId |
number
|
|
ID of the original readProperty request. |
objectId |
object
|
|
objectId from the original request, |
property |
object
|
|
property being read, taken from the original request. |
options |
object
|
<optional>
|
varying behaviour for special circumstances
Properties
Name |
Type |
Attributes |
Description |
forwardedFrom |
string
|
<optional>
|
If functioning as a BBMD, the IP address this message originally came from. |
|
(static) reinitializeDevice(receiver, state, optionsopt, next)
- Source:
The reinitializeDevice command initiates a restart of the target device.
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
client.reinitializeDevice('192.168.1.43', bacnet.enum.ReinitializedState.COLDSTART, (err, value) => {
console.log('value: ', value);
});
Parameters:
Name |
Type |
Attributes |
Description |
receiver |
string
|
|
IP address of the target device. |
state |
ReinitializedState
|
|
The type of restart to be initiated. |
options |
object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Description |
maxSegments |
MaxSegmentsAccepted
|
<optional>
|
The maximimal allowed number of segments. |
maxApdu |
MaxApduLengthAccepted
|
<optional>
|
The maximal allowed APDU size. |
invokeId |
number
|
<optional>
|
The invoke ID of the confirmed service telegram. |
password |
string
|
<optional>
|
The optional password used to restart the device. |
|
next |
function
|
|
The callback containing an error, in case of a failure and value object in case of success. |
(static) resultResponse(receiver, resultCode)
- Source:
The resultResponse is a BVLC-Result message used to respond to certain events, such as BBMD registration.
This message cannot be wrapped for passing through a BBMD, as it is used as a BBMD control message.
Parameters:
Name |
Type |
Description |
receiver |
string
|
IP address of the target device. |
resultCode |
number
|
Single value from BvlcResultFormat enum. |
(static) timeSync(receiver, dateTime)
- Source:
The timeSync command sets the time of a target device.
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
client.timeSync('192.168.1.43', new Date());
Parameters:
Name |
Type |
Description |
receiver |
string
|
IP address of the target device. |
dateTime |
date
|
The date and time to set on the target device. |
(static) timeSyncUTC(receiver, dateTime)
- Source:
The timeSyncUTC command sets the UTC time of a target device.
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
client.timeSyncUTC('192.168.1.43', new Date());
Parameters:
Name |
Type |
Description |
receiver |
string
|
IP address of the target device. |
dateTime |
date
|
The date and time to set on the target device. |
(static) unconfirmedCOVNotification(receiver, subscriberProcessId, initiatingDeviceId, monitoredObjectId, timeRemaining, values)
- Source:
The unconfirmedCOVNotification command sends an unconfirmed COV notification to a device
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
client.unconfirmedCOVNotification(
'127.0.0.1',
3,
433,
{type: 2, instance: 122},
120,
[
{
property: {id: 85},
value: [{type: baEnum.ApplicationTag.REAL, value: 12.3}]
},
{
property: {id: 111},
value: [{type: baEnum.ApplicationTag.BIT_STRING, value: 0xFFFF}]
}
]);
Parameters:
Name |
Type |
Description |
receiver |
string
|
IP address of the target device. |
subscriberProcessId |
number
|
The process id which was used by a target device in the subscription. |
initiatingDeviceId |
number
|
The id of this device. |
monitoredObjectId |
object
|
Specifies about which object the notification is.
Properties
Name |
Type |
Description |
type |
number
|
The BACNET object type of the notification. |
instance |
number
|
The BACNET object instance of the notification. |
|
timeRemaining |
number
|
How long the subscription is still active in seconds. |
values |
Array.<object>
|
List of properties with updated values.
Properties
Name |
Type |
Description |
property |
object
|
Property specifications.
Properties
Name |
Type |
Description |
id |
number
|
The updated BACNET property id. |
index |
number
|
The array index of the updated property. |
|
value |
Array.<object>
|
A list of updated values.
Properties
Name |
Type |
Description |
type |
ApplicationTag
|
The data-type of the updated value. |
value |
object
|
The actual updated value. |
|
priority |
number
|
The priority of the updated property. |
|
(static) whoIs(receiver, optionsopt)
- Source:
The whoIs command discovers all BACNET devices in a network.
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
client.whoIs();
Parameters:
Name |
Type |
Attributes |
Description |
receiver |
string
|
|
IP address of the target device. |
options |
object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Description |
lowLimit |
number
|
<optional>
|
Minimal device instance number to search for. |
highLimit |
number
|
<optional>
|
Maximal device instance number to search for. |
|
Fires:
(static) writeProperty(receiver, objectId, propertyId, values, optionsopt, next)
- Source:
The writeProperty command writes a single property of an object to a device.
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
client.writeProperty('192.168.1.43', {type: 8, instance: 44301}, 28, [
{type: bacnet.enum.ApplicationTag.REAL, value: 100}
], (err, value) => {
console.log('value: ', value);
});
Parameters:
Name |
Type |
Attributes |
Description |
receiver |
string
|
|
IP address of the target device. |
objectId |
object
|
|
The BACNET object ID to write.
Properties
Name |
Type |
Description |
type |
number
|
The BACNET object type to write. |
instance |
number
|
The BACNET object instance to write. |
|
propertyId |
number
|
|
The BACNET property id in the specified object to write. |
values |
Array.<object>
|
|
A list of values to be written to the specified property.
Properties
Name |
Type |
Description |
type |
ApplicationTag
|
The data-type of the value to be written. |
value |
number
|
The actual value to be written. |
|
options |
object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Description |
maxSegments |
MaxSegmentsAccepted
|
<optional>
|
The maximimal allowed number of segments. |
maxApdu |
MaxApduLengthAccepted
|
<optional>
|
The maximal allowed APDU size. |
invokeId |
number
|
<optional>
|
The invoke ID of the confirmed service telegram. |
arrayIndex |
number
|
<optional>
|
The array index of the property to be read. |
priority |
number
|
<optional>
|
The priority of the value to be written. |
|
next |
function
|
|
The callback containing an error, in case of a failure and value object in case of success. |
(static) writePropertyMultiple(receiver, values, optionsopt, next)
- Source:
The writePropertyMultiple command writes multiple properties in multiple objects to a device.
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
const values = [
{objectId: {type: 8, instance: 44301}, values: [
{property: {id: 28, index: 12}, value: [{type: bacnet.enum.ApplicationTag.BOOLEAN, value: true}], priority: 8}
]}
];
client.writePropertyMultiple('192.168.1.43', values, (err, value) => {
console.log('value: ', value);
});
Parameters:
Name |
Type |
Attributes |
Description |
receiver |
string
|
|
IP address of the target device. |
values |
Array.<object>
|
|
List of object and property specifications to be written.
Properties
Name |
Type |
Description |
objectId |
object
|
Specifies which object to read.
Properties
Name |
Type |
Description |
type |
number
|
The BACNET object type to read. |
instance |
number
|
The BACNET object instance to read. |
|
values |
Array.<object>
|
List of properties to be written.
Properties
Name |
Type |
Description |
property |
object
|
Property specifications to be written.
Properties
Name |
Type |
Description |
id |
number
|
The BACNET property id in the specified object to write. |
index |
number
|
The array index of the property to be written. |
|
value |
Array.<object>
|
A list of values to be written to the specified property.
Properties
Name |
Type |
Description |
type |
ApplicationTag
|
The data-type of the value to be written. |
value |
object
|
The actual value to be written. |
|
priority |
number
|
The priority to be used for writing to the property. |
|
|
options |
object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Description |
maxSegments |
MaxSegmentsAccepted
|
<optional>
|
The maximimal allowed number of segments. |
maxApdu |
MaxApduLengthAccepted
|
<optional>
|
The maximal allowed APDU size. |
invokeId |
number
|
<optional>
|
The invoke ID of the confirmed service telegram. |
|
next |
function
|
|
The callback containing an error, in case of a failure and value object in case of success. |
Events
error
- Source:
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
client.on('error', (err) => {
console.log('Error occurred: ', err);
client.close();
});
Parameters:
Name |
Type |
Description |
err |
error
|
The error object thrown by the underlying transport layer. |
iAm
- Source:
The iAm event represents the response to a whoIs request to detect all
devices in a BACNET network.
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
client.on('iAm', (msg) => {
console.log(
'address: ', msg.header.address,
' - deviceId: ', msg.payload.deviceId,
' - maxApdu: ', msg.payload.maxApdu,
' - segmentation: ', msg.payload.segmentation,
' - vendorId: ', msg.payload.vendorId
);
});
Parameters:
Name |
Type |
Description |
deviceId |
number
|
The BACNET device-id of the detected device. |
maxApdu |
number
|
The max APDU size the detected device supports. |
segmentation |
number
|
The type of segmentation the detected device supports. |
vendorId |
number
|
The BACNET vendor-id of the detected device. |
timeSync
- Source:
The timeSync event represents the request to synchronize the local time to
the received time.
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
client.on('timeSync', (msg) => {
console.log(
'address: ', msg.header.address,
' - dateTime: ', msg.payload.dateTime
);
});
Parameters:
Name |
Type |
Description |
dateTime |
date
|
The time to be synchronized to. |
whoIs
- Source:
The whoIs event represents the request for an IAm reponse to detect all
devices in a BACNET network.
Example
const bacnet = require('node-bacnet');
const client = new bacnet();
client.on('whoIs', (msg) => {
console.log(
'address: ', msg.header.address,
' - lowLimit: ', msg.payload.lowLimit,
' - highLimit: ', msg.payload.highLimit
);
});
Parameters:
Name |
Type |
Attributes |
Description |
lowLimit |
number
|
<optional>
|
The lowest BACnet ID being queried. |
highLimit |
number
|
<optional>
|
The highest BACnet ID being queried. |