You can get the SSID and BSSID of the current Wi-Fi. See the Current Wi-Fi network section of TN3111.
Yes, I can get it but let me try to explain the scenario in detail.
I have a Wi-Fi network in a large building, let's assume on a large floor we have one router and two access points of the same wifi network e.g. "Wifi-1":
- router: SSID --> "Wifi-1", BSSID --> f0:88:98:81:11:e1
- access point 1: SSID --> "Wifi-1", BSSID --> f0:88:98:81:12:e2
- access point 2: SSID --> "Wifi-1", BSSID --> f0:88:98:81:13:e3
Now when a user enters the building and connects with the "Wifi-1" using the password e.g. "Password1" and starts using it, assuming the user is currently close to the router and connected to it, I am able to get the info of "router" but couldn't get the info of "access point 1" & "access point 2". I used the SystemConfiguration.CaptiveNetwork and able to fetch the SSID & BSSID of router only which is:
- SSID --> "Wifi-1", BSSID --> f0:88:98:81:11:e1
but at the same time, I need to get the SSID, BSSID, and RSSI (which will be calculated) of both access points too which are access point 1 and access point 2 because these are just the access points of the same Wifi.
Assuming the user starts moving towards access point 1 and reaches very close to it, now the signal strength of router is very weak or vanishes but the signal strength of access point 1 is good so the user will be connected to it seamlessly so that he can continue using the internet services. This is the point where I am able to fetch the information (SSID, BSSID & RSSI (calculated)) of access point 1 which will be:
- SSID --> "Wifi-1", BSSID --> f0:88:98:81:12:e2
Now, when the user starts moving towards access point 2 and reaches closer to it the user will be connected to it, and in my app now I am able to fetch the info of it, which is:
- SSID --> "Wifi-1", BSSID --> f0:88:98:81:13:e3
I am still unable to understand why the information of all these three is not being provided to me at the same time when I am connected with either of these, in my app when all are on the same network.
Below mentioned is my code snipped to get the SSID and BSSID:
import SystemConfiguration.CaptiveNetwork
struct ScanResult {
let ssid: String
let bssid: String
let capabilities: String
let level: Int
let rssi: Int
}
func getWiFiInfo() -> ScanResult? {
guard let interfaces = CNCopySupportedInterfaces() as? [String] else {
return nil
}
var scanResult: ScanResult? = nil
for interface in interfaces {
guard let interfaceInfo = CNCopyCurrentNetworkInfo(interface as CFString) as NSDictionary? else {
return nil
}
guard let ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String else {
return nil
}
guard let bssid = interfaceInfo[kCNNetworkInfoKeyBSSID as String] as? String else {
return nil
}
llet rssi: Int = 0 // Replace it with actual value
scanResult = ScanResult(ssid: ssid, bssid: bssid, capabilities: "", level: rssi, rssi: rssi)
break
}
return scanResult
}
I have tried to explain the scenario in detail.
Here is the example of an applicationn available on the AppStore named: Wifi Analyzer Network Analyze
When I connect to Wifi "Wifi-1" and tap scan option in the application it staart giving me the list of SSID and BSSID of my corruntly connnected device as well as of all the other Access points just like access point 1 & access point 1 even if I am connected to router either of these three.
Just like above application, I want to identify the other access points of my network along with SSID, BSSID and RSSI so that I can get my use cass fulfilled.
Regards,
Aqeel Ahmed