Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the #connected_network_name method by using networksetup #25

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

arnlen
Copy link
Contributor

@arnlen arnlen commented Apr 12, 2024

The MacOsModel#connected_network_name method is broken since it's using the now removed airport utility (see this issue).

A workaround is to use the networksetup tool.

Without this PR

The output of the command is always nil.

irb(main)> WifiWand::MacOsModel.new.connected_network_name
=> nil

With this PR

It properly returns the connected network name. ✅

irb(main)> WifiWand::MacOsModel.new.connected_network_name
=> Pattara211

@keithrbennett
Copy link
Owner

@arnlen Thank you for this! I have been meaning to get around to dealing with Apple's changes but hadn't had a chance yet. I want to maintain compatibility with older versions of the OS so I will look at testing to see if airport is available and then branching to your code if not. Give me a couple/few days to take a look at all this and I will get back to you.

@keithrbennett keithrbennett merged commit 4b1897e into keithrbennett:main Apr 18, 2024
@keithrbennett
Copy link
Owner

@arnlen Thanks for the PR. I happened to have a network name that had a space in it and noticed that this would only include the last word of the name. I merged your PR but added a fix and simplified it somewhat. Also, I changed the test for 'connected' to be to search for the presence of ''Current Wi-Fi Network: ' rather than the absence of 'not associated' to be a tiny bit safer, for example if error messages were internationalized but success messages were not, or if the network name happened to contain 'not associated' (which is admittedly farfetched but not impossible). Here is the diff from your PR to the current head:

image

@keithrbennett
Copy link
Owner

@arnlen Now that you are a contributor to this project, I need your ok to change the project's license. I'd like to change it from MIT to Apache 2. Is this ok with you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants