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. |
- Source:
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 |
version |
string | BCS firmware version, eg, |
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 |
Methods
-
on(event, callback)
-
Add an event listener
Parameters:
Name Type Description eventString The event to respond to. ('ready', 'notReady')
callbackcallback The function to be called when the event is triggered
-
read(resource)
-
Read from the BCS API
Parameters:
Name Type Description resourceString The API endpoint to query
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 eventString The event to trigger
argObject Argument to pass to the callback
-
write(resource, JSON)
-
Write to the BCS API
Parameters:
Name Type Description resourceString The API endpoint to update
JSONObject object to POST to the API
Returns:
A Promise of the response from the API
- Type
- Promise.Object