Reputation: 44
How to get SSID, BSSID and channel of all available WiFi networks under Mac OS using Qt C++?
Under Windows I use wlanapi.lib and I get mentioned properties via WlanGetNetworkBssList method. Is there any
thing like this under Mac OS? For example, the list of CWNetwork objects.
I'm trying do it in the following way:
#import <CoreWLAN/CWInterface.h>
CWInterface *currentInterface = [CWInterface interfaceWithName:nil];
if (currentInterface == NULL)
return false;
if([currentInterface power])
{
NSError *err = nil;
NSSet *scanResults = [currentInterface scanForNetworksWithBSSID:nil error:&err];
if (!err)
{
for(CWNetwork *network in scanResults)
{
//print SSID
}
}
}
But the call of "scanForNetworksWithBSSID:nil" occurs error : " Signal name : SIGTRAP Signal meaning : Trace / breakpoint trap "
What does it mean? Could you please advice in this?
Upvotes: 2
Views: 2595
Reputation: 422
Here is the properties that u can retrieve
CWInterface* wifi = [[CWWiFiClient sharedWiFiClient] interface];
NSArray *networkScan = [[wifi scanForNetworksWithName:nil error:nil] allObjects];
for (CWNetwork *network in networkScan) {
NSLog ( @"SSID: %@ ,\n \
BSSID: %@ , \n \
rssiValue: %ld , \n \
noiseMeasurement: %ld, \n\
beaconInterval: %ld , \n \
countryCode: %@ \n ,\
ibss: %i ,\n\
wlanChannel: %@ , \n\
", [network ssid],[network bssid],[network rssiValue],[network noiseMeasurement],(long)[network beaconInterval], [network countryCode] , [network ibss], [[network wlanChannel]description]);
}
Upvotes: 0
Reputation: 790
You can always use QProcess and execute a terminal command:
QStringList arguments;
arguments << "-I";
QProcess process;
process.start("/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport", arguments);
This will fire off the airport command with the -I flag to show information about the current wireless network you are on.
Upvotes: 1