I use the code from here to get device's IP address, and it works fine if device already connect to specific Wi-Fi, but if I use NEHotspotConfigurationManager
to force divice connect to Wi-Fi, it returns something strange, what's the problem?
Here's my code:
let configuration = NEHotspotConfiguration.init(ssid: "SSID", passphrase: "password", isWEP: false)
configuration.joinOnce = true
NEHotspotConfigurationManager.shared.apply(configuration) { (error) in
if error != nil {
if error?.localizedDescription == "already associated." {
ip = self.getIPAddresses() // return 192.168.x.x
} else {
// no connected
}
} else {
// connected
ip = self.getIPAddresses() // return fe80::6034:fb02:100:0%pdp_ip0
}
NOTE: getIPAddresses()
is just the same with the code from here