From 6e9ceee6cf1d95e36ed55e44d123c18f84950060 Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Mon, 11 Aug 2014 15:29:35 -0700 Subject: [PATCH] Fixes to driver commands --- lib/api/routes.js | 4 ++-- lib/driver.js | 2 +- lib/test/ping.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api/routes.js b/lib/api/routes.js index 1d799a1..1927692 100644 --- a/lib/api/routes.js +++ b/lib/api/routes.js @@ -102,12 +102,12 @@ router.get("/robots/:robot/devices/:device/events/:event", load, function(req, r }); router.get("/robots/:robot/devices/:device/commands", load, function(req, res) { - res.json({ commands: Object.keys(req.device.commands) }); + res.json({ commands: Object.keys(req.device.driver.commands) }); }); router.all("/robots/:robot/devices/:device/commands/:command", load, function(req, res) { var command = req.device.driver.commands[req.params.command]; - var result = command.apply(req.device, req.commandParams); + var result = command.apply(req.device.driver, req.commandParams); res.json({ result: result }); }); diff --git a/lib/driver.js b/lib/driver.js index d8ba9d0..973bb54 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -47,7 +47,7 @@ Driver.prototype.setupCommands = function(commands) { return "_" + match.toLowerCase(); }).replace(/^_/, ''); - this.commands[snake_case] = this[command].bind(this); + this.commands[snake_case] = this[command]; } } diff --git a/lib/test/ping.js b/lib/test/ping.js index 133f575..48b767b 100644 --- a/lib/test/ping.js +++ b/lib/test/ping.js @@ -15,7 +15,7 @@ var Ping = module.exports = function Ping() { Ping.__super__.constructor.apply(this, arguments); this.commands = { - ping: this.ping.bind(this) + ping: this.ping }; };