Jump to content

Javascript API callback beim Remote Switch Bricklet


Recommended Posts

Hallo,

 

ich habe ein Problem mit der Javascript API des Remote Switch Bricklet. Laut API sieht die Funktion zum Schalten einer Steckdose Typ B so aus:

BrickletRemoteSwitch.switchSocketB(address, unit, switchTo[, returnCallback][, errorCallback])

.

 

Leider werden die callback Funktionen bei mir nicht aufgerufen, der Code dazu sieht wie folgt aus (Anpassung des node.js Beispiels).

 

var Tinkerforge = require('tinkerforge');

var HOST = 'localhost';
var PORT = 4223;
var UID = 'nXN'; // Change to your UID

var ipcon = new Tinkerforge.IPConnection(); // Create IP connection
var rs = new Tinkerforge.BrickletRemoteSwitch(UID, ipcon); // Create device object

ipcon.connect(HOST, PORT,
    function (error) {
        console.log('Error: ' + error);
    }
); // Connect to brickd
// Don't use device before ipcon is connected

ipcon.on(Tinkerforge.IPConnection.CALLBACK_CONNECTED,
    function (connectReason) {
        rs.switchSocketB(
            30,
            3,
            Tinkerforge.BrickletRemoteSwitch.SWITCH_TO_ON,
            function() {console.log("Success")},
            function(err) {console.log(err)});
    }
);

console.log('Press key to exit');
process.stdin.on('data',
    function (data) {
        ipcon.disconnect();
        process.exit(0);
    }
);

 

Mache ich etwas falsch oder ist das ein Bug?

 

Beste Grüße,

Jonathan.

Link zu diesem Kommentar
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

×   Du hast formatierten Text eingefügt.   Formatierung jetzt entfernen

  Only 75 emoji are allowed.

×   Dein Link wurde automatisch eingebettet.   Einbetten rückgängig machen und als Link darstellen

×   Dein vorheriger Inhalt wurde wiederhergestellt.   Clear editor

×   Du kannst Bilder nicht direkt einfügen. Lade Bilder hoch oder lade sie von einer URL.

×
×
  • Neu erstellen...