I am trying to connect to an accessory's WiFi network using the below code and I always see the message "connection succeded" even if I provide an incorrect passphrase. I tried with different accessories and see the same behavior.
hotspotConfigurationManager.joinAccessoryHotspot(accessory, passphrase: passphrase) { error in if let error = error { print("connection failed: \(error.localizedDescription)") } else { print("connection succeeded") } }
This doesn’t surprise me. At one point we added this text to the documentation for the apply(_:completionHandler:)
method:
The system calls your completion handler when it has applied the Wi-Fi level configuration. A successful configuration doesnʼt mean the device has joined that Wi-Fi network.
I believe that the same logic applies to joinAccessoryHotspot(_:passphrase:)
, that is, the routine completes successfully once the Wi-Fi configuration has been committed to the Wi-Fi stack, but that doesn’t tell you whether the device was able to successfully join the network.
If you’d like to see this behaviour change, I encourage you to file an enhancement request [1] for a better way to handle this situation.
Please post your bug number, just for the record.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] Or is it a bug report? Honestly, it doesn’t really matter in this case (-: