Git Product home page Git Product logo

node-bacstack's Introduction

Platform Node Contrib BACnet® NodeJS_Version NPM download Build Status Coverage Status Gitpod Ready-to-Code

node-bacnet

node-bacnetLogo64

The BACnet® protocol library written in pure JavaScript.

BACnet® is a protocol to interact with building automation devices defined by ASHRAE.

Usage

Add node-bacnet to your project by using:

npm install --save node-bacnet

The API documentation is available under GitHub Page of Docs.

Features

The BACnet® standard defines a wide variety of services as part of the specification. While node-bacnet tries to be as complete as possible, following services are already supported at this point in time:

Service Execute Handle
Who Is yes yes
I Am yes¹ yes
Who Has yes¹ yes¹
I Have yes¹ yes¹
Time Sync yes yes
UTC Time Sync yes yes
Read Property yes yes¹
Read Property Multiple yes yes¹
Read Range yes¹ yes¹
Write Property yes yes¹
Write Property Multiple yes yes¹
Add List Element yes¹ yes¹
Remove List Element yes¹ yes¹
Create Object yes¹ yes¹
Delete Object yes¹ yes¹
Subscribe COV yes¹ yes¹
Confirmed COV Notification yes¹ yes¹
Subscribe Property yes¹ yes¹
Atomic Read File yes¹ yes¹
Atomic Write File yes¹ yes¹
Reinitialize Device yes yes¹
Device Communication Control yes yes¹
Get Alarm Summary yes¹ yes¹
Get Event Information yes¹ yes¹
Get Enrollment Summary yes¹ yes¹
Acknowledge Alarm yes¹ yes¹
Confirmed Event Notification yes¹ yes¹
Unconfirmed Event Notification yes¹ yes¹
Unconfirmed Private Transfer yes¹ yes¹
Confirmed Private Transfer yes¹ yes¹
Register Foreign Device no yes¹
Distribute Broadcast to Network no yes¹

¹ Support implemented as Beta (untested, undocumented, breaking interface)

Contributing

This package is based on the work of Fabio Huser and is now community driven. The group is searching for active collaborators to finish that library to become a good piece of Open Source. Implementing and maintaining a protocol stack is a lot of work, therefore any help is appreciated, from creating issues, to contributing documentation, fixing issues, sending pull requests and adding new features.

Please follow the Contribution Guide when submitting any changes. Ask the active NPM publishers if you need some advice to start your contribution!

License

The MIT License

Copyright (c) 2018-2020 Community Driven

Copyright (c) 2017-2019 Fabio Huser

Note: This is not an official product of the BACnet Advocacy Group. BACnet® is a registered trademark of American Society of Heating, Refrigerating and Air-Conditioning Engineers (ASHRAE).

node-bacstack's People

Contributors

adam-nielsen avatar apollon77 avatar biancode avatar dependabot[bot] avatar dopry avatar fh1ch avatar kfenner avatar klemensas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-bacstack's Issues

Cleanup JSDocs

  • correctly mark option properties as optional
  • make sure "receiver" is somehow described as the allowed string/object mixture

"Error: BacnetError - Class:5 - Code:67"

Node Version:12.16.1

Node BACstack Version: 0.0.1-beta.22

Hey together,

I am running the bacstack with a Siemens DXR2 Room Automation Device and I can greatly read all my data.
But I can not write data. With the bacstack V0.0.1-beta.14 I always got the result "undefined" and I couldn't figure out what is the problem.
Now I receive "Error: BacnetError - Class:5 - Code:67" which is probably because of better error handling. Based on the handbook it is a "reject unrecognized Service" but no clue what to do with this message or where to search.

Also already had a look in here:
fh1ch/node-bacstack-browser#2
But no help for me yet.

Anybody has Ideas on this?

Greets
Tom

sent date with timeSync is last month

Node Version: 12.20.0

Node BACstack Version: 0.2.4

  • [ x ] Bug Report

Current Behaviour (Bug Report)

I sent time synchronization with current date, but a day of last month is sent.
Current date is April 13, 2021.

sample code:

const bacnet = require('node-bacnet');
const client = new bacnet();

client.timeSync(MY_DEVICE_IP, new Date());
// MY_DEVICE_IP is actually a valid IP

Expected Behaviour (Bug Report)

I expected timeSynchronization with "Date: April 13, 2021," is sent, but timeSynchronization with "Date: March 13, 2021," is sent

Suspicious code

In JavaScript, the getMonth() method returns the month from 0 to 11.
If library sends it as is, it means last month's data in the BACnet protocol.
So it need call getMonth() + 1 to create buffer in encodeBacnetDate.

code to be fixed:

buffer.buffer[buffer.offset++] = value.getMonth();

BUG always using port 47808

Node Version: v14.17.0

Node BACstack Version: 1.0.0

  • [X ] Bug Report
  • Feature Request
  • Question

Note: Make sure you have read the FAQs
before logging this issue.

Feature Request / Question

Current Behaviour (Bug Report)

const bacnetClient = new Bacnet({
port: 47809, // Use BAC1 as communication port
interface: '192.168.222.11', // Listen on a specific interface
broadcastAddress: '192.168.222.255', // Use the subnet broadcast address
apduTimeout: 60000 // Wait twice as long for response
});

currently discovering in port 47808,but in options there is 47809.

So the bug in transport.js Line 100.
this._server.send(buffer, 0, offset, port || DEFAULT_BACNET_PORT , address);

variable "port" is undefined.

Expected Behaviour (Bug Report)

Steps to reproduce Issue (Bug Report)

Fix acknowledgeAlarm integration test

  1. bacnet - acknowledgeAlarm integration
    should return a timeout error if no device is available:

    Uncaught AssertionError: expected 'BacnetError - Class:5 - Code:67' to deeply equal 'ERR_TIMEOUT'

    • expected - actual

    -BacnetError - Class:5 - Code:67
    +ERR_TIMEOUT

    at /Volumes/Dev/GitHub/node-bacstack/test/integration/acknowledge-alarm.spec.js:12:32
    at /Volumes/Dev/GitHub/node-bacstack/lib/client.js:510:1529
    at _invokeStore. (lib/client.js:42:491)
    at Client._invokeCallback (lib/client.js:37:222)
    at Client._processError (lib/client.js:55:640)
    at Client._handlePdu (lib/client.js:116:1807)
    at Client._handleNpdu (lib/client.js:126:1001)
    at Client._receiveData (lib/client.js:143:240)
    at Socket. (lib/transport.js:3:633)
    at UDP.onMessage [as onmessage] (dgram.js:924:8)

How to read a specific Object Instance inside a Device Instance

Node Version: X.Y.Z

Node BACstack Version: X.Y.Z

  • Bug Report
  • [ x ] Feature Request
  • [ x ] Question

Note: Make sure you have read the FAQs
before logging this issue.

Feature Request / Question

Hello all, my questio is quite simple, i wanty to read a property (present value for ex) so, the propertyID: 85
To test, i have downloaded this: http://bacnet.sourceforge.net/
and i run this command to query a property:
./bacrp --mac 192.168.1.12 1012 2 13 present-value
or
./bacrp --mac 192.168.1.12 1012 2 13 85

192.168.1.12
is ip of the device i want to query

1012
is the DEVICE instance

2
is the object-type (like analog, etc...)

13
os the OBJECT instance

property
85, for present value according to bacnet protocol.

According to the node-bacstack doc, to read a property, i need to:
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);
});

But, i cant put the OBJECT instance somewhere, so... what can i do ? I am quite stuck and i feel i am doing something wrong.. but i can see where

Using with MS/TP Router

Node Version: 10.15.0

Node BACstack Version: 0.2.4

  • Question

Note: Make sure you have read the FAQs
before logging this issue.

Feature Request / Question

I am trying to use node-bacstack with devices behind a MS/TP router. It is unclear to me how to use node-bacstack to accomplish this. The NET and ADR is not obvious or clear to me. I am trying to discover the devices behind device 156 and read/write their properties. I'm new to MS/TP.

Below is the WHOIS return from /examples/read-device.js
image

Device 156 is the MS/TP router that has child devices/properties. The readproperties function included in the /examples/read-devices.js retuned this JSON for device 156
image

A bacnet explorer returned this for device 156
image

Here is code. Mostly unchanged from the example.

read-device.zip

write docs for lib

Please, start your testing and do some documentation in the code to fill up the jsdocs!

Read/Write values to a "virtual device" with a 4-byte mac address.

Node Version: 16.3.0

Node BACstack Version: 0.2.4

  • Bug Report
  • Feature Request
  • Question

Note: Make sure you have read the FAQs
before logging this issue.

Feature Request / Question

I'm trying to communicate with a "virtual" device that contains a 4-byte MAC address as seen in the attached Wireshark capture. I can see the devices perfectly fine in YABE, but I cannot discover these devices during a whoIs and haven't been successful with readProperty either.

virtualDeviceMacLength

properties: [{id: 8}] results in Error: ERR_TIMEOUT

Node Version: v12.19.0
Node BACstack Version: [email protected]

  • [x ] Bug Report

Expected Behaviour (Bug Report)

  • using the readPropertyMultiple command with the properties: [{id: 8}] results in Error: ERR_TIMEOUT, although it should support 8 for all properties

  • tried increasing the adpuTimeout: 9000 but still got the same result Error: ERR_TIMEOUT

  • the code does work if called with singular properties like properties: [{id: 77},{id: 28},{id: 85},{id: 111}]

  • in the last working version from the original library node-bacstack the results are as expected ie: with properties: [{id: 8}] we get the correct value object.

  • my sample code

//setup the BACnet comms
const bacnet = require('node-bacnet');
const client = new bacnet({
  port: 47808,                          // Use BAC0 as communication port
  interface: '192.168.222.84',          // Listen on a specific interface
  broadcastAddress: '192.168.222.255',  // Use the subnet broadcast address
  adpuTimeout: 6000                     // Wait twice as long for response
});


// get what we want to read/write
const requestArray = [
  {objectId: {type: 8, instance: 1010220}, properties: [{id: 8}]}    //this results in ERR_TIMEOUT
  //{objectId: {type: 8, instance: 1010220}, properties: [{id: 77},{id: 28},{id: 85},{id: 111}]} //this works
];

// now send the request
client.readPropertyMultiple('192.168.222.222', requestArray, (err, object) => {
  console.log('Returned obj. = ', JSON.stringify(object,null,2));
  console.log('ERRORS if any or NULL :: ', err);
  // IMP close the open listening socket
  client.close();
});

device number when using this library

When running a program using this library (subscribing to COVs, reading and writing properties, etc), what is the local device ID? Is there a way to set it to something specific?

Configuring BBMD / Connecting to foreign devices

Node Version: 14.2

Node BACstack Version: 0.2.4

  • Bug Report
  • Feature Request
  • Question

Note: Make sure you have read the FAQs
before logging this issue.

Feature Request / Question

I am running a Bacnet-device on a foreign network via a VPN-tunnel. In other Bacnet-software I have to configure a BBMD that is running on the foreign bacnet-device. How can I configure the BBMD in node-bacstack?

In client.js I have found line 505:

sender: { // Address of the host we are directly connected to. String, IP:port. address: remoteAddress, // If the host is a BBMD passing messages along to another node, this // is the address of the distant BACnet node. String, IP:port. // Typically we won't have network connectivity to this address, but // we have to include it in replies so the host we are connect to knows // where to forward the messages. forwardedFrom: null, },

Let's say the device I want to connect to and on which the BBMD is running has the IP "192.168.151.51".
My machine has the IP "192.168.67.253".
Both networks are connected via a VPN-Router.
What lines do I have to change so that I can establish a connection? Do you have an example?

PS: I am sure that the connection between the bacnet-device and my machine is working, because I tested it with BACeye software.

Issues when getting Protocol_Object_Types_Supported in device object type

Node Version: 20.2.0

Node BACstack Version: 0.2.4

  • Bug Report
  • Feature Request
  • [ x] Question

Note: Make sure you have read the FAQs
before logging this issue.

Feature Request / Question

I'm getting Protocol_Object_Types_Supported (BACnetObjectTypesSupported) using readPropertyMultiple, the returned values I get are { value: [ 0, 1, 0, 0, 0, 0, 0, 1 ], bitsUsed: 60} when I drill down to them. However this does not cover all possible values for each as per ASHRAE 135-2020, in this there are 63 possible values.
When I monitor the value coming in over wireshark using YABE to check its represented as "protocol-object-types-supported: (Bit String) (FFFFFFFFTFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFTFFF)" with the T's representing Device and Network which is what I expect to see.
Do I need to do something with the returning value to have it match up?
Please ignore my ignorance if I'm missing something obvious.

Current Behaviour (Bug Report)

Expected Behaviour (Bug Report)

Steps to reproduce Issue (Bug Report)

Issue on broadcast to 255.255.255.255

Node Version: 12

Node BACstack Version: 0.1.1-beta.1

  • Bug Report
  • Feature Request
  • Question

Note: Make sure you have read the FAQs
before logging this issue.

Current Behaviour (Bug Report)

Not sending a read to correct BACnet device

Expected Behaviour (Bug Report)

Send bacnet read to correct device not broadcast on 255.255.255.255

Steps to reproduce Issue (Bug Report)

image

// issue is that the destination is 255.255.255.255
// my host is 192.168.0.22
// target device is  192.168.0.201

const bacnet = require('./index');
const options = {
    deviceId: 1234,
    apduTimeout: 6000,

    };
const client = new bacnet({options, port: 47808, interface: '192.168.0.22', broadcastAddress: '255.255.255.255'});

// tried with and without the broadcastAddress
// const client = new bacnet({options, port: 47808, interface: '192.168.0.22'});


// Read Device Object
const requestArray = [{
  objectId: {type: 1, instance: 1},
  properties: [{id: 85}]
}];
client.readPropertyMultiple('192.168.0.201', requestArray, (err, value) => {
  console.log('value: ', JSON.stringify(value));
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.