Class: Device

BCS. Device


new Device(address, options)

Handles communication with BCS.

Parameters:
Name Type Description
address string

IP Address for BCS

options options

for BCS. Currently only supports authentication. ex. {auth: {username: 'x', password: 'y'}}

Properties:
Name Type Description
ready boolean

Ready to communicate with BCS (other properties are not valid until ready is true)

type string

BCS type, eg BCS-460

version string

BCS firmware version, eg, 4.0.0

helpers BCS.Helpers

Helpers object

probeCount number

The number of temp probes supported by the BCS hardware

inputCount number

The number of discrete inputs supported by the BCS hardware

outputCount number

The number of outputs supported by the BCS hardware

Source:

Methods


on(event, callback)

Add an event listener

Parameters:
Name Type Description
event String

The event to respond to. ('ready', 'notReady')

callback callback

The function to be called when the event is triggered

Source:

read(resource)

Read from the BCS API

Parameters:
Name Type Description
resource String

The API endpoint to query

Source:
Returns:

A Promise of the response from the API

Type
Promise.Object
Example
var bcs = BCS.Device("192.168.0.63");
   bcs.read('device').then(function (response) {
       alert("BCS Name:" + response.name);
   });

<private> trigger(event, arg)

Trigger an event listener

Parameters:
Name Type Description
event String

The event to trigger

arg Object

Argument to pass to the callback

Source:

write(resource, JSON)

Write to the BCS API

Parameters:
Name Type Description
resource String

The API endpoint to update

JSON Object

object to POST to the API

Source:
Returns:

A Promise of the response from the API

Type
Promise.Object