Fixes to driver commands

This commit is contained in:
Andrew Stewart 2014-08-11 15:29:35 -07:00
parent 1f0b214c97
commit 6e9ceee6cf
3 changed files with 4 additions and 4 deletions

View File

@ -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 });
});

View File

@ -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];
}
}

View File

@ -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
};
};