Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
CleanOMat980Platform.prototype.command = function (command) {
// send command to the robot
var that = this
let cred = this.credentials()
if (cred != undefined) {
this.myRobotViaLocal = new dorita980.Local(cred.blid, cred.pwd, cred.ip); // robot IP address
this.myRobotViaLocal.on('connect', function () {
that.log.debug('connected to robot')
switch (command) {
case 'start':
setTimeout(function(){
that.log.debug('start command')
that.myRobotViaLocal.start().then(() => {
that.log.debug('end connection')
that.myRobotViaLocal.end();
}).catch((err) => {
that.log.error(err);
});
}, 500);
function connect(user, password, ip)
{
adapter.log.info('Connecting to Roomba (' + ip + ')..');
try
{
return new _dorita980.Local(user, password, ip);
}
catch(err)
{
adapter.log.error('Could not connect to Roomba! See debug for more details.');
adapter.log.debug(err.message); // this will not be trigged due to an issue in dorita980 library (see https://github.com/koalazak/dorita980/issues/75 )
return false;
}
}
function connect(user, password, ip)
{
adapter.log.info('Connecting to Roomba..');
try
{
return new _dorita980.Local(user, password, ip);
}
catch(err)
{
adapter.log.warn(err.message); // this will not be trigged due to an issue in dorita980 library (see https://github.com/koalazak/dorita980/issues/75)
}
}
function sendAndDisconnect (method, args, res, next) {
let client = new dorita980.Local(blid, password, knownIP, 2);
client.on('connect', function () {
client[method](args).then(function (resp) {
res.send(resp);
client.end();
}).catch(next);
});
}
handleIP(function (e, ip) {
if (e) throw e;
knownIP = ip;
if (enableLocal === 'yes') {
if (firmwareVersion === 1 || (keepAlive === 'yes')) myRobot.local = new dorita980.Local(blid, password, ip, firmwareVersion);
}
if (enableCloud === 'yes') myRobot.cloud = new dorita980.Cloud(blid, password, firmwareVersion);
});