sindresorhus / Actions

⚙️ Supercharge your shortcuts
https://sindresorhus.com/actions
MIT License
2.58k stars 109 forks source link

Action: 'Join Wifi' does not support open wifi networks (aka local wifi with no password) #263

Closed bluemodena closed 1 month ago

bluemodena commented 1 month ago

Description

I am using the 'Join Wifi' action to join a local (no internet access) wifi network with no password. it is fairly typical of simple wifi devices like this to not have a password. How do I escape or enter null in the password field in the shortcut so that it run without error? joinWifiShortcut

macOS/iOS version

iOS 17.5.1

Shortcut URL

No response

bluemodena commented 1 month ago

I've never coded in Swift before but I dug in to the apple code to see if what I am asking for it possible. Just need a configurable way to indicate is the configuration is an open wifi network, and then call the appropriate method. The network’s passphrase credential: for WPA or WPA2 personal networks, 8-63 characters; for static 64-bit WEP, 10 hexadecimal digits; for static 128-bit WEP, 26 hexadecimal digits. Which is why when I enter null for the password, it doesn't work,

https://developer.apple.com/documentation/networkextension/nehotspotconfiguration Class NEHotspotConfiguration() support multiple configurations.
init(ssid: String) Creates a new hotspot configuration, identified by an SSID, for an open Wi-Fi network. init(ssid: String, passphrase: String, isWEP: Bool) Creates a new hotspot configuration, identified by an SSID, for a protected WEP or WPA/WPA2 personal Wi-Fi network.

private func join() async throws {

if !os(macOS)

    let configuration = NEHotspotConfiguration(
        ssid: ssid,
        passphrase: password,
        isWEP: isWEP
    )
    configuration.hidden = isHidden
            // if open wifi 
               try await NEHotspotConfigurationManager.shared.apply(ssid) 
    // else
                      try await NEHotspotConfigurationManager.shared.apply(configuration)
            #endif
}

Hope this helps

sindresorhus commented 1 month ago

This is fixed in the latest TestFlight build: https://testflight.apple.com/join/fJGUrsZx

bluemodena commented 1 month ago

Oh wow, that is great. I'm away from home this weekend and don't have access to my open wifi camera right now. I'll try it out Sunday evening

bluemodena commented 1 month ago

Crap sorry.. Hit the wrong button

bluemodena commented 1 month ago

Sindre, I can confirm this now works with open WiFi networks. Thank you for addressing this so quickly!

I wasn't sure if there was something else you need to do before I close this issue, but it is OK to close it.