-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wifi.connection(): Fetch network settings, normalize values #195
Wifi.connection(): Fetch network settings, normalize values #195
Conversation
I can't wait to check this out! On Wed, Aug 3, 2016, 12:32 AM Nick Hehr notifications@github.com wrote:
|
callback(error); | ||
}); | ||
} else { | ||
return callback(null, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this return
necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, nope. Will fix. 👍
@rwaldron You were correct about assuming too much success with the IP parsing. I've added a recursive check for an IP "Bcast" because an immediate check after restarting the wifi chip results in an error. |
// This function keeps checking for that IP until it's available. | ||
function recursiveIP(network) { | ||
setImmediate(() => { | ||
childProcess.exec('ifconfig wlan0', (error, ipResults) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since childProcess.exec
is already going to call its callback asynchronously, I don't think this needs to be wrapped in setImmediate
(unless I've misunderstood something)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're probably correct. I think this was me not really understanding the how childProcess.exec
works. I'll try removing it and testing tonight. 👍
@rwaldron You were also correct about not needing the |
LGTM feel free to merge |
Fixes #178 - get connection info from system instead of in-memory cache
Fixes #190 - normalize security value on connection settings to match the standard configuration values, i.e.
none
,wep
,psk
,psk2
Fixes #192 - set a usable value to the connection
ip
property as opposed to of the seemingly random array of strings asips
.This build changes how the
Wifi.connection
method works, making it an asynchronous request to the system requiring acallback
argument to return the network settings. This will require a change of the documentation before releasing to the public, with a reference to that release version this change was made.Smoke test:
Update a Tessel with the
node/teasel-export.js
from this PR. (See this gist for how to do this usingsip
)mkdir t2-firmware-178
cd t2-firmware-178
t2 init
t2 wifi --ssid YourWifiNetwork --pass PasswordIfNeeded
Replace the content of index.js with the following:
t2 run index.js
You should get a result like the following:
Pinging at least @rwaldron, @reconbot, @johnnyman727 for review and/or smoke testing.