Is there a way to auto switch wireless networks depending on signal strength?

Solution 1:

Not saying this is ideal or works well. But Just to give you an idea.

You can use command line tools to write a script that checks the strength. and then changes the network as needed.

To get the strength you can use this command line code:

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I |grep -i "agrCtlRSSI:"

Look at the man pages for /usr/sbin/networksetup for changing the setup.

As an example here is a quick applescript. It only runs once as it is only an example of use. But in your script I would do it as a LaunchAgent There is an app called lingon that simplifies the writing of LaunchAgents. LaunchAgents can startup apps, run scripts at specific times, regularly or when something happens.

I hope this helps

set wifi1 to "wifissid1"
set wifi2 to "wifissid2"

try
    set strength to last word of (do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I |grep -i \"agrCtlRSSI:\"") as number
    log strength
end try
set network to do shell script "/usr/sbin/networksetup -getairportnetwork en1"
log network



if strength is less than 50 then



    if network is not equal to "Current Wi-Fi Network: " & wifi1 then

        do shell script "/usr/sbin/networksetup -setairportnetwork en1 " & wifi1 & " &> /dev/null & "

    end if



else

    if network is not equal to "Current Wi-Fi Network: " & wifi2 then

        do shell script "/usr/sbin/networksetup -setairportnetwork en1 " & wifi2 & " &> /dev/null & "

    end if

end if