I want to implement code for scan the nearby wifi devices. I am not getting proper solution for this after doing lots of research. Can you please give me proper solution to scan the nearby wifi devices? I have implemented below code. It only getting information of wifi which is already connected. Below is the code:
func getInterfaces() -> Bool {
guard let unwrappedCFArrayInterfaces = CNCopySupportedInterfaces() else {
print("this must be a simulator, no interfaces found")
return false
}
guard let swiftInterfaces = (unwrappedCFArrayInterfaces as NSArray) as? [String] else {
print("System error: did not come back as array of Strings")
return false
}
for interface in swiftInterfaces {
print("Looking up SSID info for \(interface)") // en0
guard let unwrappedCFDictionaryForInterface = CNCopyCurrentNetworkInfo(interface as CFString) else {
print("System error: \(interface) has no information")
return false
}
guard let SSIDDict = (unwrappedCFDictionaryForInterface as NSDictionary) as? [String: AnyObject] else {
print("System error: interface information is not a string-keyed dictionary")
return false
}
print(SSIDDict)
}
return true
}
It return output is below.
Looking up SSID info for en0
["SSIDDATA": <4575726f 74726f6e 6963>, "BSSID": d4:3d:37:14:9:2f, "SSID": Vikas]
Can you please help me to scan the nearby wifi devices functionality?