Add API method for fetching device commands
This commit is contained in:
parent
fbadbac5c6
commit
d9c0229a62
|
@ -38,6 +38,7 @@
|
|||
this.server.get("/robots/:robotid", this.getRobotByName);
|
||||
this.server.get("/robots/:robotid/devices", this.getDevices);
|
||||
this.server.get("/robots/:robotid/devices/:deviceid", this.getDeviceByName);
|
||||
this.server.get("/robots/:robotid/devices/:deviceid/commands", this.getDeviceCommands);
|
||||
this.server.listen(this.port, this.host, function() {
|
||||
return Logger.info("" + _this.server.name + " is listening at " + _this.server.url);
|
||||
});
|
||||
|
@ -78,6 +79,15 @@
|
|||
});
|
||||
};
|
||||
|
||||
Server.prototype.getDeviceCommands = function(req, res, next) {
|
||||
var deviceid, robotid;
|
||||
robotid = req.params.robotid;
|
||||
deviceid = req.params.deviceid;
|
||||
return master.findRobotDevice(robotid, deviceid, function(err, device) {
|
||||
return res.send(err ? err : device.data().commands);
|
||||
});
|
||||
};
|
||||
|
||||
return Server;
|
||||
|
||||
})();
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace "Api", ->
|
|||
@server.get "/robots/:robotid", @getRobotByName
|
||||
@server.get "/robots/:robotid/devices", @getDevices
|
||||
@server.get "/robots/:robotid/devices/:deviceid", @getDeviceByName
|
||||
@server.get "/robots/:robotid/devices/:deviceid/commands", @getDeviceCommands
|
||||
|
||||
@server.listen @port, @host, =>
|
||||
Logger.info "#{@server.name} is listening at #{@server.url}"
|
||||
|
@ -50,3 +51,10 @@ namespace "Api", ->
|
|||
|
||||
master.findRobotDevice robotid, deviceid, (err, device) ->
|
||||
res.send if err then err else device.data()
|
||||
|
||||
getDeviceCommands: (req, res, next) ->
|
||||
robotid = req.params.robotid
|
||||
deviceid = req.params.deviceid
|
||||
|
||||
master.findRobotDevice robotid, deviceid, (err, device) ->
|
||||
res.send if err then err else device.data().commands
|
||||
|
|
Loading…
Reference in New Issue