Fixes to driver commands
This commit is contained in:
parent
1f0b214c97
commit
6e9ceee6cf
|
@ -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 });
|
||||
});
|
||||
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue