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

Update ESPDevice.swift when applying Wi-Fi Config #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions ESPProvision/ESPDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,29 @@ open class ESPDevice {
completionHandler(self.connectionStatus)
}
ESPLog.log("Successfully conected to SoftAP.")
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
self.getDeviceVersionInfo(completionHandler: completionHandler)
}

//There is no guarranty that the real wi-fi connction to the wi-fi hotspot occured.
//Only the fact tha the configuration was applied. Apple`s security policies....
//We need to precisely request if the device connected to target SSID.

DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {[weak self] in
guard let self = self else { return }

NEHotspotNetwork.fetchCurrent {[weak self] networkOrNil in
guard let self = self else { return }

if let networkInfo = networkOrNil, networkInfo.ssid == ssid {
let status:ESPSessionStatus = .connected
self.connectionStatus = status
self.getDeviceVersionInfo(completionHandler: completionHandler)
}
else {
let status:ESPSessionStatus = .failedToConnect(.softAPConnectionFailure)
self.connectionStatus = status
completionHandler(status)
}
}
}
}
}
}
Expand Down