Skip to content

Commit

Permalink
In the midst of Tessel wifi off
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyman727 committed Nov 14, 2015
1 parent 79192a5 commit 4f3b5ba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
11 changes: 9 additions & 2 deletions bin/tessel-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,11 @@ makeCommand('wifi')
// TODO: Refactor switch case into controller.wifi
if (opts.list) {
callControllerWith('printAvailableNetworks', opts);
} else if (opts.off) {
callControllerWith('disableWifi', opts);
} else if (opts.off || opts.on) {
if (opts.off) {
opts.on = false;
}
callControllerWith('setWiFiState', opts);
} else if (opts.ssid && opts.password) {
callControllerWith('connectToNetwork', opts);
} else {
Expand All @@ -211,6 +214,10 @@ makeCommand('wifi')
flag: true,
help: 'Disable the wireless network'
})
.option('on', {
flag: true,
help: 'Enable the wireless network'
})
.help('Configure the wireless connection');

parser.command('key')
Expand Down
4 changes: 2 additions & 2 deletions lib/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,10 @@ controller.connectToNetwork = function(opts) {
});
};

controller.disableWifi = function(opts) {
controller.setWiFiState = function(opts) {
opts.authorized = true;
return controller.standardTesselCommand(opts, function(tessel) {
return tessel.setWiFiState(false);
return tessel.setWiFiState(opts.on);
});
};

Expand Down
3 changes: 3 additions & 0 deletions lib/tessel/wifi.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,8 @@ Tessel.prototype.setWiFiState = function(enable) {
})
.then(function committed() {
return self.simpleExec(commands.reconnectWifi());
})
.then(function log() {
logs.info("Wifi", enable ? "Enabled." : "Disabled.");
});
};

0 comments on commit 4f3b5ba

Please sign in to comment.