所以我试图通过关闭器来监控连接状态:
func reconnect(success: @escaping () -> Void, failure: @escaping () -> Void) {
let manager = NEHotspotConfigurationManager.shared
let ssid = CameraManager.camera.uuid
let password = "password"
let isWEP = false
let hotspotConfiguration = NEHotspotConfiguration(ssid: ssid, passphrase: password, isWEP: isWEP)
hotspotConfiguration.joinOnce = true
manager.apply(hotspotConfiguration) { (error) in
if (error != nil) {
if let error = error {
switch error._code {
case 8:
print("internal error")
failure()
case 7:
NotificationCenter.default.post(name: Notification.Name(rawValue: "cancelFromHotSpot"), object: nil)
failure()
self.stopSession()
case 13:
success()
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
self.startSession()
}
default:
break
}
}
if error == nil {
print("success connecting wifi")
success()
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
self.startSession()
}
}
}
}
然而,在错误为零的情况下,我收到此警报“无法加入网络”,有什么想法吗?