restart process on disconnect to fix reconnect issue
This commit is contained in:
parent
1d0b36c47a
commit
e411dfb3b1
1 changed files with 8 additions and 10 deletions
|
|
@ -115,24 +115,25 @@ var WebsocketController = function(sockets, version) {
|
|||
var comName = '';
|
||||
|
||||
var onGetPorts = function(cb) {
|
||||
|
||||
sp_controller.listPorts(function (ports) {
|
||||
|
||||
sockets.emit('ports', ports);
|
||||
|
||||
if(! cb)
|
||||
return;
|
||||
|
||||
ports.forEach(function(p) {
|
||||
|
||||
if(! /Arduino/gi.test(p.manufacturer))
|
||||
return;
|
||||
|
||||
comName = p.comName;
|
||||
cb(p.comName);
|
||||
|
||||
});
|
||||
|
||||
if(cb)
|
||||
cb(comName);
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
var onConsole = function(line) {
|
||||
|
|
@ -170,11 +171,8 @@ var WebsocketController = function(sockets, version) {
|
|||
return;
|
||||
|
||||
machine.disconnect();
|
||||
|
||||
// turn off power
|
||||
setTimeout(function() {
|
||||
power.writeSync(0);
|
||||
}, 2000);
|
||||
power.writeSync(0);
|
||||
process.exit(0);
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -217,7 +215,7 @@ var WebsocketController = function(sockets, version) {
|
|||
};
|
||||
|
||||
sockets.on('connection', function(socket) {
|
||||
|
||||
|
||||
// turn on powerswitchtail
|
||||
power.writeSync(1);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue