Prevent from switching Wi-Fi networks

I have two wifi access points at home: "downstairs" and "upstairs". They're both WPA2.

If I'm upstairs and connected to "upstairs" and my laptop goes to sleep, when I reactivate it, it connects to "downstairs" as it is higher in the list, but the signal is too low and I have to switch it manually to "upstairs". How can I prevent that?

Remark: I don't want "upstairs" or "downstairs" to have priority: it depends on where I stand in the house. I just want OSX to stick with the network I have selected, whichever it is. I don't want to re-type the lengthy password all the time neither ("forget network" is probably not the way to go).

Script or third-party program welcome...

OS X 10.10

EDIT I originally wrote I wanted to stick to current network, as opposed to switching to another weaker network. But if all APs have the same name and password, then the seamless switch is ok to me. See this answer and this advise:

"(...) let the client devices each decide which is best to use" - "Make all the Wi-Fi networks in your home the same. Your life will be better for it."


I also have two wifi access points at my home, and have found out the best way for OS X to switch between both automatically and choose the one with the best signal is to name both access points with exactly the same name with the same passwords so OS X sees them as identical. Works great with my AirPort Extreme (downstairs) and Time Machine (upstairs) which extends the downstairs wifi.


You could use a script to check the RSSI value of the currently connected SSID. If it is above a certain threshold, than change to other SSID with lower RSSI. This could be run manually or paired with a Launch Daemon that is triggered by network change.

In the below script you would just have to change en1 to your wifi interface. Also set your desired threshold for the RSSI value. In the below script I set it for 65. The first time it runs it will prompt for a password to allow netowrksetup to access the system. Otherwise run it as root.

If you create a Launch Daemon I would monitor these three files:

/etc/resolv.conf

/Library/Preferences/SystemConfiguration/NetworkInterfaces.plist

/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist

Script to change SSID if RSSI value is to high.

#!/bin/bash

##Check signal strength of wifi and change if over a certain RSSI threshold.

##Get RSSI strength of WIFI and strip off the - charecter
signalStrength=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep CtlRSSI | awk '{print $2}' | sed 's/^[-]*//'`

##Grab current connected WIFI SSID
wifiID=`networksetup -getairportnetwork en1 | cut -d ":" -f2 | sed 's/^[ t]*//'`

if [[ "$signalStrength" > 65 && "$wifiID" = "Upstairs" ]]; then
    networksetup -setairportnetwork en1 "Downstairs" [password]
    echo "Changing to Downstairs wireless, RSSI signal out of threshold"
elif [[ "$signalStrength" > 65 && "$wifiID" = "Downstairs" ]]; then
    networksetup -setairportnetwork en1 "Upstairs" [password]
    echo "Changing to Upstairs wireless, RSSI signal out of threshold"
fi