Skip to content

Library for communicating asynchronously with the BCS using JavaScript Promises

License

Notifications You must be signed in to change notification settings

embeddedcc/bcs-promise

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BCS Promise

A JavaScript library to interface with the BCS using Promises/Futures. Primarily tested in the browser, but should work with or easily adapt to node.js.

Dependencies

  • browser-request - for making asynchronous calls to the BCS
  • Q - for Promises support

The versions of these dependencies used for testing are included in this repository in the vendor/js directory, but other versions may work as well.

Usage

BCS.Device

BCS.Device provides a very thin wrapper to communicate with the BCS. When initializing the BCS.Device object, the BCS is queried to ensure connectivity and to determine the type of the device. You should wait until the ready event is triggered before using the API.

For example:

var bcs = new BCS.Device('192.168.0.63');
bcs.on('ready', function () {
    bcs.read('device').then(function (response) {
        console.log("BCS Name: " + response.name);
    });
});

BCS.Helpers

The constructor for BCS.Device also adds a helpers property that is an instance of BCS.Helpers. This class provides some helper methods to make working with data from the BCS easier.

For example:

var bcs = new BCS.Device('192.168.0.63');
bcs.on('ready', function () {
    bcs.helpers.getTempValues().then(function (temps) {
        console.log("Temp probe 1 temperature: " + temps[0]);
    });
});

License

Copyright (c) 2014 Brent Rahn Licensed under the MIT license.

About

Library for communicating asynchronously with the BCS using JavaScript Promises

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%