How to use tinkerforge - 2 common examples

To help you get started, we’ve selected a few tinkerforge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Tinkerforge / generators / javascript / ExampleAuthenticate.js View on Github external
var Tinkerforge = require('tinkerforge');

var HOST = 'localhost';
var PORT = 4223;
var SECRET = 'My Authentication Secret!';

ipcon = new Tinkerforge.IPConnection(); // Create IP connection
ipcon.connect(HOST, PORT,
    function(error) {
        console.log('Error: '+error);
    }
); // Connect to brickd

// Disable auto reconnect mechanism, in case we have the wrong secret. If the authentication is successful, reenable it.
ipcon.setAutoReconnect(false);

// Register Connected Callback
ipcon.on(Tinkerforge.IPConnection.CALLBACK_CONNECTED,
    // Authenticate each time the connection got (re-)established
    function(connectReason) {
        switch(connectReason) {
        case Tinkerforge.IPConnection.CONNECT_REASON_REQUEST:
            console.log('Connected by request');
github Tinkerforge / generators / javascript / ExampleEnumerate.js View on Github external
var Tinkerforge = require('tinkerforge');

var HOST = 'localhost';
var PORT = 4223;

ipcon = new Tinkerforge.IPConnection(); // Create IP connection
ipcon.connect(HOST, PORT,
    function(error) {
        console.log('Error: '+error);
    }
); // Connect to brickd

// Register Connected Callback
ipcon.on(Tinkerforge.IPConnection.CALLBACK_CONNECTED,
    function(connectReason) {
        // Trigger Enumerate
        ipcon.enumerate();
    }
);

// Register Enumerate Callback
ipcon.on(Tinkerforge.IPConnection.CALLBACK_ENUMERATE,

tinkerforge

JavaScript API Bindings for Tinkerforge Bricks and Bricklets

CC0
Latest version published 2 months ago

Package Health Score

60 / 100
Full package analysis

Popular tinkerforge functions