joinAccessoryHotspot does not fail if wrong passphrase is provided

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")
}
}
Answered by DTS Engineer in 836370022
Written by psamji in 781942021
I always see the message "connection succeded" even if I provide an incorrect passphrase.

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 (-:

Accepted Answer
Written by psamji in 781942021
I always see the message "connection succeded" even if I provide an incorrect passphrase.

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 (-:

Filed enhancement request FB17335956 for the issue.

joinAccessoryHotspot does not fail if wrong passphrase is provided
 
 
Q