Test For BSSID Match Failing

My actions testing for a specific BSSID address is showing "true" even when the BSSID is different from the address entered in the action. I am attempting to use the BSSID to identify which location I'm at when connecting to the company's wifi because the network names are not unique.

Am I misusing the "with BSSID" action? Has anyone else seen this issue? Is there another test to uniquely identify the location when the network names are identical?

Are you on Monterey? A quick test with KM on macOS 12 shows this condition always evaluating to "True" -- even when the test string is "Ooops!" -- but the same action performs as expected in High Sierra.

It might be relevant that Apple made some changes to the airport utility in macOS 12 -- in particular it doesn't return BSSID or Country unless run with sudo. (@peternlewis -- don't know if you can do anything about this on the KM side?)

We can use the airport utility to create a workaround, but because it now needs sudo you'll have to do some setup first and add it to your sudoers file so you don't have to authenticate.

In Terminal, type sudo visudo /private/etc/sudoers.d/airport and authenticate, to create (or edit if it already exists) a sudoers file containing your airport utility exceptions.

Hit the I key to enter "Insert mode" and type in:

username ALL=NOPASSWD: /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I

...replacing username with your account's short username. Hit the ESC key and then type :wq to save and exit.

Open another Terminal window and check this works by typing

sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I

...and you should get a bunch of Wi-Fi info, without being asked for your password. If you are on your work network, this is a good time to grab the BSSID!

You can now use this example macro:
BSSID test.kmmacros (3.3 KB)

...and test things are working. As implied by the "contains" field, airport returns an "abbreviated" MAC address which omits any leading 0 of a pair -- you might be more used to seeing the example address of aa:aa:aa:b:c:d as aa:aa:aa:0b:0c:0d -- so watch out for that.

You may have to test against a list of BSSIDs -- they uniquely identify access points, so you'll need one entry for every AP at work (apologies if I'm stating things you already know...).

This is all theoretical, not something I've used myself beyond a quick test while writing it -- I'd love to hear how you get on!

Nige_S,

I am on Monterey and I was certain that this macro used to work successfully before Monterey as well! I'm not familiar with sudo and all the ins & outs of airport utility, so no need to apologize.

I'll have to dig into your suggestion and let you know.

Thanks,

Anthony

According to the interface headers:

  • BSSID information is not available unless Location Services is enabled and the user has authorized the calling app to use location services.

Unfortunately, the system doesn't take the request as a request for location services, so it does not add Keyboard Maestro to the list of Location Services apps in the System Preferences. I'm not actually sure how to poke the system into adding Keyboard Maestro to that list, and there is no obvious way to do it manually.

1 Like