Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

get_wifi_info() does not attempt to activate wifi - Mac OS 10.6 #20

Closed
drewreece opened this issue Jul 27, 2010 · 8 comments
Closed

get_wifi_info() does not attempt to activate wifi - Mac OS 10.6 #20

drewreece opened this issue Jul 27, 2010 · 8 comments

Comments

@drewreece
Copy link
Contributor

The get_wifi_info function (in platform/mac/functions) either returns information from the scanner utility - (/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I)
or it returns nothing for the $wifi_points variable. The geo module uses $wifi_points to get the location, but if $wifi_points is empty it makes no attempt to activate wifi.

Wouldn't it make sense to turn airport on if the scanner returns an 'Off' status? Then recheck the status & only return an empty value for $wifi_points if that scan fails.

@drewreece
Copy link
Contributor Author

Changing the function get_wifi_info() to enable wifi if it is off seems to fix it ...
but it does result in the wifi state changing permanently & potentially could alert the user.
If the state is turned back off it breaks the ability to get the access point scan data for the geo module. get_wifi_access_points() (modules/geo/functions) will also use the airport command but the wifi card will be in its disabled state.

I think prey should detect the wifi state and then return it to this state after completing any scans etc.

Here is my changed function.

get_wifi_info() {
wifi_info=$airport -I | grep -v "Off"
if [ -n $wifi_info ]; then
# Turn on wifi
networksetup -setairportpower Airport on 2>/dev/null
wifi_info=$airport -I | grep -v "Off"
fi
}

@drewreece
Copy link
Contributor Author

Added to my fork…
http://github.com/drewreece/prey

…but I'm too stupid to add a commit message !

@tomas
Copy link
Contributor

tomas commented Sep 13, 2010

Merged! Closing...

@drewreece
Copy link
Contributor Author

Sorry Tomas, you need to pull again, I reviewed it and it broke. There were too many arguments for the if statement and the test for nonzero (-n) was backwards, it needs to be a test for zero (-z).

Sorry

@tomas
Copy link
Contributor

tomas commented Oct 25, 2010

I believe we're done with this (on 0.4.4), are we not?

@drewreece
Copy link
Contributor Author

This is in 0.4.4 but I tried testing on a new install of OSX & I couldn't get a connection to work when my access point was set to no security. I think I need to create a new access point & run some more tests.

@tomas
Copy link
Contributor

tomas commented Nov 25, 2010

Any news drew? We're about to pack a new release so it would be great to make sure this bug is out.

@drewreece
Copy link
Contributor Author

Tomas,
The -n test fails to activate the wifi (when connected via ethernet) for an access point scan. If the test is -z the wifi will be activated.

The 0.4.4 release is correct with the -z test.

Cheers,
Drew

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants