Yes - both the current network and potential networks can be scripted from unix command line / shell so that extends to most automation languages - including AppleScript. I'd make your final program in python or swift, but here's how to start your process with signal strength.
Getting the current connected network is easy and quick. The relevant entries for signal and noise are the raw radio values on the channel negotiated but it would be better to key off Transmit Rate since as long as you have faster than X network, it doesn't really matter what noise / signal since the transmit rate drops down when the signal drops or the noise raises.
system_profiler SPAirPortDataType
:
AC88U_5G:
PHY Mode: 802.11ac
BSSID: 54:36:9b:2d:78:e2
Channel: 149
Country Code: CN
Network Type: Infrastructure
Security: WPA2 Personal
Signal / Noise: -26 dBm / -81 dBm
Transmit Rate: 867
MCS Index: 9
Other Local Wi-Fi Networks:
AC88U:
PHY Mode: 802.11n
BSSID: 54:36:9b:2d:78:e1
Channel: 7
Country Code: CN
Network Type: Infrastructure
Security: WPA2 Personal
Signal / Noise: -18 dBm / 0 dBm
Scanning all possible radios and channels is quite slower (5 to 10 seconds instead of a fraction of a second to run) than the simple dump above, so you'd need a program to handle that or a script that's a lot more savvy. I'd start with airport --scan
and filter for your preferred SSID or known MAC address on your base stations:
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport --scan
Once you've scanned, the system_profiler
should report more results as the scan results seem to be cached locally for a while.
WiFi engineers perform this optimization all the time by controlling the MCS / Transmit rate. Simply choose all transmit rates you wish to evict all clients for your main radio and once they lose connection at the preferred high speeds, all OS will drop and then pick up the next radio that's available. Much easier than rolling out custom scripts to all the devices that connect to your two radios.
Also, it goes without saying - if you could make both radios broadcast on the same SSID - then your Apple products would just roam but maybe you have a good reason to not have the same network name and simplify your work.
And to answer @nohillside question "how to decide which Wi-Fi is stronger" here are some guidelines.
