Skip to content

Commit

Permalink
Opens a menu to select a Tessel if the desired Tessel is ambigious
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyman727 committed Sep 29, 2015
1 parent 3e07b97 commit 0d8f923
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions lib/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,23 @@ Tessel.get = function(opts) {
tessels = reconciledTessels;
// Run the heuristics to pick which Tessel to use
return controller.runHeuristics(opts, tessels)
.then(logAndFinish);
.then(function finalSection(tessel) {
// If the heuristics were able to narrow it down to a single Tessel
if (tessel) {
// Log we found it and return it to the caller
return logAndFinish(tessel);
}
// If we couldn't narrow it down
else {
// Open up an interactive menu for the user to choose
return controller.menu.create(tessels, {}, 'Which Tessel did you mean to use?')
// Once they choose
.then(function(tessel) {
// Log we found it and return it to the caller
return logAndFinish(tessel);
});
}
});
});
}
}
Expand Down Expand Up @@ -688,15 +704,15 @@ controller.menu = {
if (tessel.lanConnection) {

if (!tessel.lanConnection.authorized) {
rtm.add(index + ') ' + tessel.name + ': ' + tessel.lanConnection.ip + ' (not authorized) \n');
rtm.add(index + ') ' + tessel.name + ': ' + '[LAN] (not authorized) \n');
} else {
rtm.add(index + ') ' + tessel.name + ': ' + tessel.lanConnection.ip + ' (authorized) \n');
rtm.add(index + ') ' + tessel.name + ': [LAN] \n');
}

} else if (tessel.usbConnection) {
rtm.add(index + ') ' + tessel.name + ': [USB] \n');
} else {
reject('Type of Tessel unkonwn: ', tessel);
reject('Type of Tessel unknown: ', tessel);
}
done();
},
Expand Down

0 comments on commit 0d8f923

Please sign in to comment.