Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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');
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,