Giter Site home page Giter Site logo

node-bacstack's Introduction

Node BACstack

A BACnet protocol stack written in pure JavaScript. BACnet is a protocol to interact with building automation devices defined by ASHRAE.

Note: This is an early prototype and shall not be considerate as stable. Use it with caution and at your own risk!

Usage

Add Node BACstack to your project by using:

$ npm install --save bacstack

Client

To be able to communicate to BACNET devices, you have to initialize a new bacstack instance. Hereby, following options are avilable:

  • option [object] - The options object used for parameterising the bacstack.
    • port [number] - BACNET communication port for listening and sending. Default is 47808. Optional.
    • interface [string] - Specific BACNET communication interface if different from primary one. Optional.
    • broadcastAddress [string] - The address used for broadcast messages. Default is 255.255.255.255. Optional.
    • adpuTimeout [number] - The timeout in milliseconds until a transaction should be interpreted as error. Default is 3000. Optional.
var bacnet = require('bacstack');
var client = 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
  adpuTimeout: 6000                     // Wait twice as long for response
});

Who Is

The whoIs command discovers all BACNET devices in the network.

  • lowLimit [number] - Minimal device instance number to search for. Optional.
  • highLimit [number] - Maximal device instance number to search for. Optional.
  • address [string] - Unicast address if command should device directly. Optional.
var bacnet = require('bacstack');
var client = bacnet();

client.on('iAm', function(address, deviceId, maxAdpu, segmentation, vendorId) {
  console.log('address: ', address, ' - deviceId: ', deviceId, ' - maxAdpu: ', maxAdpu, ' - segmentation: ', segmentation, ' - vendorId: ', vendorId);
});

client.whoIs();

Read Property

The readProperty command reads a single property of an object from a device.

  • address [string] - IP address of the target device.
  • objectType [number] - The BACNET object type to read.
  • objectInstance [number] - The BACNET object instance to read.
  • propertyId [number] - The BACNET property id in the specified object to read.
  • arrayIndex [number] - 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.
var bacnet = require('bacstack');
var client = bacnet();

client.readProperty('192.168.1.43', 8, 44301, 28, null, function(err, value) {
  console.log('value: ', value);
});

Write Property

The writeProperty command writes a single property of an object to a device.

  • address [string] - IP address of the target device.
  • objectType [number] - The BACNET object type to write.
  • objectInstance [number] - IP address of the target device.
  • propertyId [number] - The BACNET property id in the specified object to write.
  • priority [number] - The priority to be used for writing to the property.
  • valueList [array] - A list of values to be written to the speicifed property. The Tag value has to be a BacnetApplicationTags declaration as specified in lib/bacnet-enum.js.
  • next [function] - The callback containing an error, in case of a failure and value object in case of success.

propertyId, ,

var bacnet = require('bacstack');
var client = bacnet();

client.writeProperty('192.168.1.43', 8, 44301, 28, 12, [{Tag: 4, Value: 100}], function(err, value) {
  console.log('value: ', value);
});

Read Property Multiple

The readPropertyMultiple command reads multiple properties in multiple objects from a device.

  • address [string] - IP address of the target device.
  • propertyIdAndArrayIndex [array] - List of object and property specifications to be read.
    • objectIdentifier [object] - Specifies which object to read.
      • type [number] - The BACNET object type to read.
      • instance [number] - The BACNET object instance to read.
    • propertyReferences [array] - List of properties to be read.
      • propertyIdentifier [number] - The BACNET property id in the specified object to read. Also supports 8 for all properties.
  • next [function] - The callback containing an error, in case of a failure and value object in case of success.
var bacnet = require('bacstack');
var client = bacnet();

var requestArray = [
  {objectIdentifier: {type: 8, instance: 4194303}, propertyReferences: [{propertyIdentifier: 8}]}
];
client.readPropertyMultiple('192.168.1.43', requestArray, function(err, value) {
  console.log('value: ', value);
});

License

The MIT License

Copyright (c) 2017 Fabio Huser [email protected]

node-bacstack's People

Contributors

fh1ch avatar

Watchers

 avatar James Cloos avatar

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.