Skip to content

Commit

Permalink
improvements based on @rwaldron's review
Browse files Browse the repository at this point in the history
  • Loading branch information
Frijol committed Nov 25, 2015
1 parent 1fb583e commit 68cb254
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions lib/tessel/wifi.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Tessel.prototype.connectToNetwork = function(opts) {
})
.then(function() {
// Then make sure wireless is enabled
return self.setWiFiState(true);
return self.simpleExec(commands.turnOnWifi(true));
})
.then(function() {
// Then set the new credientials
Expand All @@ -111,20 +111,16 @@ Tessel.prototype.connectToNetwork = function(opts) {
logs.info('Credentials set. Checking connection...');
self.connection.exec(commands.ubusListen())
.then(function(remoteProcess) {
remoteProcess.stdout.on('data', function(data) {
if (data.toString().indexOf('ifup') > -1) {
logs.info('Successfully connected!');
// End the connection
return self.connection.end()
.then(resolve);
}
});
remoteProcess.stderr.on('data', function(data) {
logs.info('Error connecting:', data.toString());
// End the connection
return self.connection.end()
.then(resolve);
});
self.receive(remoteProcess).then(function(data) {
if (data.indexOf('ifup') > -1) {
logs.info('Successfully connected!');
return resolve();
}
})
.catch(function(error) {
logs.err('Error connecting:', error);
return resolve();
});
setTimeout(function() {
logs.info('Timed out waiting to verify connection. Run `t2 wifi` to manually verify connection. If not connected, ensure you have entered the correct network credentials.');
// End the connection
Expand Down

0 comments on commit 68cb254

Please sign in to comment.