tinkerforge-device-manager

0.7.0 • Public • Published

Tinkerforge Device Manager

A node library to make connecting to and accessing Tinkerforge devices easier. Created at the University of Applied Sciences in Osnabrueck.

Supported Devices

Currently supported Tinkerforge devices:

Example

Consider you have a Humidity V2 Bricklet connected to a Master Brick. You can then use the device manager to get the Humidity V2 Bricklet via its UID or its device identifier. The process is as follows:

  1. Initialize the device manager (dm.initialize())
  2. Set a callback that is called for each connected device (e.g. dm.setConnectCallback(start);)
  3. In start(device) you'll have the current device as a wrapper object. Now you can check the type and register listeners (or do anything else)

Here is a full example (see also test.js):

var dm = require('./index.js');
 
// You can pass host and port, default is 'localhost' and 4223
dm.initialize();
 
// This will call start for each enumerated device
dm.setConnectCallback(start);
 
function start(device) {
    // Check the name of the current device
    console.log(device.getName());
 
    // Humidity V2 Bricklet
    if (device.getDeviceIdentifier() == 283) {
        device.registerListener(humidityChanged)
    }
 
    // Accelerometer Bricklet
    if (device.getDeviceIdentifier() == 250) {
        device.registerListener(accelerationChanged)
    }
 
    // And so on...
}
 
function humidityChanged(valObject) {
    console.log(valObject);
}
 
function accelerationChanged(valObject) {
    console.log(valObject);
}

Readme

Keywords

Package Sidebar

Install

npm i tinkerforge-device-manager

Weekly Downloads

1

Version

0.7.0

License

ISC

Unpacked Size

66.5 kB

Total Files

33

Last publish

Collaborators

  • nmeseth