From 16cdb56be6a5a03cd83ade8f140b2cfaa0504e57 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Mon, 7 Sep 2015 08:47:25 -0700 Subject: [PATCH] Simple example of how to use dynamic devices --- examples/start-device/start-device.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/start-device/start-device.js diff --git a/examples/start-device/start-device.js b/examples/start-device/start-device.js new file mode 100644 index 0000000..cb5fe40 --- /dev/null +++ b/examples/start-device/start-device.js @@ -0,0 +1,25 @@ +"use strict"; + +var Cylon = require("cylon"); + +Cylon.robot({ + connections: { + loopback: { adaptor: "loopback" } + }, + + connectPinger: function() { + this.device("pinger", + {connection: "loopback", driver: "ping"}); + this.startDevice(this.devices.pinger, function() { + console.log("Get ready to ping..."); + }); + }, + + work: function(my) { + my.connectPinger(); + + every((1).second(), function() { + console.log(my.pinger.ping()); + }); + } +}).start();