OSX 無線LAN情報取得
Objective-cでCWInterfaceクラスを用いて、mac bookの無線LANの接続情報を取得するコードを書いてみました。
Objective-Cはまだ触り初めでよく分かっていません。今後iOS,OSXの無線LAN関係でできることを調べてみようと思います。
参考:CWInterface Class Reference
#import <Foundation/Foundation.h> #import <CoreWLAN/CoreWLAN.h> int main() { @autoreleasepool { CWInterface *wifi = [CWInterface interface]; NSLog(@"BSSID: %@", wifi.bssid); NSLog(@"SSID: %@", wifi.ssid); NSLog(@"MAC Address: %@", wifi.hardwareAddress); NSLog(@"rssiValue: %ld", wifi.rssiValue); NSLog(@"noise measurement: %ld", wifi.noiseMeasurement); NSLog(@"transmit power: %ld", wifi.transmitPower); NSLog(@"transmit rate: %f", wifi.transmitRate); static NSString *phyMode[]= {@"none",@"IEEE802.11a",@"IEEE802.11b",@"IEEE802.11g",@"IEEE802.11n",@"IEEE802.11ac"}; NSLog(@"phy mode: %@", phyMode[wifi.activePHYMode]); static NSString *interfaceType[] = {@"none",@"STA",@"IBSS",@"AP"}; NSLog(@"interface type: %@", interfaceType[wifi.interfaceMode]); static NSString *securityType[] = {@"none",@"WEP",@"WPA-Personal",@"WPA-Personal-Mixed",@"WPA2-Personal",@"Personal",@"DynamicWEP",@"WPA-Enterprise",@"WPA-Enterprise-Mixed",@"WPA2-Enterprise",@"Enterprise",@"unknown"}; NSLog(@"security type: %@", securityType[wifi.security]); CWChannel *channel = wifi.wlanChannel; NSLog(@"channel number: %ld", channel.channelNumber); static NSString *channelBand[] = {@"none",@"2.4GHz",@"5GHz"}; NSLog(@"channel band: %@", channelBand[channel.channelBand]); static NSString *bandWidth[] = {@"none",@"20MHz",@"40MHz",@"80MHz",@"160MHz"}; NSLog(@"band width: %@", bandWidth[channel.channelWidth]); } return 0; }