diff --git a/examples/arduinos_and_skynet/multiple_arduinos_one_skynet_connection.js b/examples/arduinos_and_skynet/multiple_arduinos_one_skynet_connection.js index 3eb90d2..1953854 100644 --- a/examples/arduinos_and_skynet/multiple_arduinos_one_skynet_connection.js +++ b/examples/arduinos_and_skynet/multiple_arduinos_one_skynet_connection.js @@ -28,16 +28,16 @@ skynet = { console.log(data); if (data.payload != null){ var robot, + bot, robots = data.payload.robots; for(var index in robots){ robot = robots[index]; console.log(robot); - my.master.findRobot(robot.name, function(err, bot){ - if (robot.cmd == 'on') - bot.devices[robot.device].turnOn(); - else - bot.devices[robot.device].turnOff(); - }); + bot = Cylon.robots[robot.name]; + if (robot.cmd == 'on') + bot.devices[robot.device].turnOn(); + else + bot.devices[robot.device].turnOff(); } } }); diff --git a/examples/sf-sphero/sf-sphero.js b/examples/sf-sphero/sf-sphero.js index 817f1a7..f9d62a4 100644 --- a/examples/sf-sphero/sf-sphero.js +++ b/examples/sf-sphero/sf-sphero.js @@ -29,9 +29,8 @@ var SalesforceRobot = (function() { msg += "Bucks: " + data.sobject.Bucks__c + ","; msg += "SM_Id: " + data.sobject.Id; console.log(msg); - me.master.findRobot(data.sobject.Sphero_Name__c, function(err, spheroBot) { - spheroBot.react(spheroBot.devices.sphero); - }); + var spheroBot = Cylon.robots[data.sobject.Sphero_Name__c]; + spheroBot.react(spheroBot.devices.sphero); }); }); }; @@ -70,9 +69,8 @@ var SpheroRobot = (function() { spheroName: "" + me.name, bucks: "" + (me.totalBucks++) }); - me.master.findRobot('salesforce', function(err, sf) { - sf.devices.salesforce.push('SpheroController', 'POST', data); - }); + var sf = Cylon.robots['salesforce']; + sf.devices.salesforce.push('SpheroController', 'POST', data); }); }; diff --git a/examples/sf-sphero/sf-sphero.markdown b/examples/sf-sphero/sf-sphero.markdown index f80611c..437f7b0 100644 --- a/examples/sf-sphero/sf-sphero.markdown +++ b/examples/sf-sphero/sf-sphero.markdown @@ -42,9 +42,8 @@ tell it what work we want to do: msg += "Bucks: " + data.sobject.Bucks__c + ","; msg += "SM_Id: " + data.sobject.Id; console.log(msg); - me.master.findRobot(data.sobject.Sphero_Name__c, function(err, spheroBot) { - spheroBot.react(spheroBot.devices.sphero); - }); + var spheroBot = Cylon.robots[data.sobject.Sphero_Name__c]; + spheroBot.react(spheroBot.devices.sphero); }); }); }; @@ -83,9 +82,8 @@ tell it what work we want to do: spheroName: "" + me.name, bucks: "" + (me.totalBucks++) }); - me.master.findRobot('salesforce', function(err, sf) { - sf.devices.salesforce.push('SpheroController', 'POST', data); - }); + var sf = Cylon.robots['salesforce']; + sf.devices.salesforce.push('SpheroController', 'POST', data); }); }; diff --git a/examples/sphero-pebble-sf/sphero-pebble-sf.js b/examples/sphero-pebble-sf/sphero-pebble-sf.js index 2d814be..d38bcd5 100644 --- a/examples/sphero-pebble-sf/sphero-pebble-sf.js +++ b/examples/sphero-pebble-sf/sphero-pebble-sf.js @@ -57,9 +57,8 @@ var SalesforceRobot = (function() { console.log(msg); - me.master.findRobot(name, function(err, spheroBot) { - spheroBot.react(spheroBot.devices.sphero); - }); + var spheroBot = Cylon.robots[name]; + spheroBot.react(spheroBot.devices.sphero); me.spheroReport[name] = bucks; toPebble = ""; @@ -71,9 +70,8 @@ var SalesforceRobot = (function() { toPebble += "" + key + ": $" + val + "\n"; } - me.master.findRobot('pebble', function(error, pebbleBot) { - pebbleBot.message(pebbleBot.devices.pebble, toPebble); - }); + var pebbleBot = Cylon.robots['pebble']; + pebbleBot.message(pebbleBot.devices.pebble, toPebble); }); }); }; @@ -141,9 +139,8 @@ var SpheroRobot = (function() { bucks: "" + (me.totalBucks++) }); - me.master.findRobot('salesforce', function(err, sf) { - sf.devices.salesforce.push("SpheroController", "POST", data); - }); + var sf = Cylon.robots['salesforce']; + sf.devices.salesforce.push("SpheroController", "POST", data); }); }; diff --git a/examples/sphero-pebble-sf/sphero-pebble-sf.markdown b/examples/sphero-pebble-sf/sphero-pebble-sf.markdown index 8b4145b..9aab7cf 100644 --- a/examples/sphero-pebble-sf/sphero-pebble-sf.markdown +++ b/examples/sphero-pebble-sf/sphero-pebble-sf.markdown @@ -78,9 +78,8 @@ Tell it what work we want to do: console.log(msg); - me.master.findRobot(name, function(err, spheroBot) { - spheroBot.react(spheroBot.devices.sphero); - }); + var spheroBot = Cylon.robots[name]; + spheroBot.react(spheroBot.devices.sphero); me.spheroReport[name] = bucks; toPebble = ""; @@ -92,9 +91,8 @@ Tell it what work we want to do: toPebble += "" + key + ": $" + val + "\n"; } - me.master.findRobot('pebble', function(error, pebbleBot) { - pebbleBot.message(pebbleBot.devices.pebble, toPebble); - }); + var pebbleBot = Cylon.robots['pebble']; + pebbleBot.message(pebbleBot.devices.pebble, toPebble); }); }); }; @@ -166,9 +164,8 @@ Tell it what work we want to do: bucks: "" + (me.totalBucks++) }); - me.master.findRobot('salesforce', function(err, sf) { - sf.devices.salesforce.push("SpheroController", "POST", data); - }); + var sf = Cylon.robots['salesforce']; + sf.devices.salesforce.push("SpheroController", "POST", data); }); };