— Created 2015年08月18日 by Shane Stanley
— Modified 2015年08月18日 by Takaaki Naganoya
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "CoreWLAN"
–Get WLAN Device Name
set allNames to current application’s CWInterface’s interfaceNames()’s allObjects()
log allNames as list of string or string
–> (NSArray) {"en0"} –@MacBook Pro Retina 2012
set hitF to false
repeat with i from 1 to allNames’s |count|()
set aInterface to (current application’s CWInterface’s interfaceWithName:(allNames’s objectAtIndex:(i – 1)))
if aInterface’s serviceActive() as boolean then
set hitF to true
exit repeat
end if
end repeat
if hitF = false then return false –There is No WiFi Device
–WiFi device is Power On ?
repeat 10 times
set aPower to (aInterface’s powerOn()) as boolean
if aPower = false then
–ActiveなWLANがない場合(WiFiをオフにしている)にはWiFiパワーオン
set wRes to aInterface’s setPower:true |error|:(missing value)
delay 1
else
exit repeat
end if
end repeat
if aPower = false then return false –I could not power on WiFi deveice
set aChan to aInterface’s wlanChannel()
–> (CWChannel) <CWChannel: 0x60000040cdd0> [channelNumber=1(2GHz), channelWidth={20MHz}]
set chanNumber to aChan’s channelNumber()
log chanNumber
–> 52
set chanBand to aChan’s channelBand() — 0 = unknown, 1 = 2GHz, 2 = 5GHz
log chanBand
–> 2
set chanWidth to aChan’s channelWidth() — 0 = unknown, 1 = 20MHz, 2 = 40MHz
log chanWidth
–> 2
set aTransRate to aInterface’s transmitRate()
log aTransRate
–> 162.0
set aChannnels to aInterface’s supportedWLANChannels()
–> (NSSet) {(CWChannel) <CWChannel: 0x60800020fad0> [channelNumber=1(2GHz), channelWidth={20MHz}, active], (CWChannel) <CWChannel: 0x60800020fb90> [channelNumber=2(2GHz), channelWidth={20MHz}, active], ……………(CWChannel) <CWChannel: 0x608000208410> [channelNumber=64(5GHz), channelWidth={20MHz}, DFS], (CWChannel) <CWChannel: 0x60800020f9e0> [channelNumber=136(5GHz), channelWidth={20MHz}, DFS]}
set aSSIDdata to aInterface’s ssidData()
–> (NSData) <45787472 xxxxxxxx xxxxxxxx xxxx>
set aSSID to aInterface’s ssid() as text
–> "Extreme net_5G"
set aActive to aInterface’s serviceActive()
–> true
set aSecurity to aInterface’s security()
–> 4
set aRSSIval to aInterface’s rssiValue()
–> -72
set aPower to aInterface’s powerOn()
–> true
set aNoise to aInterface’s noiseMeasurement()
–> -91
set aIFname to aInterface’s interfaceName() as text
–> "en0"
set aMode to aInterface’s interfaceMode()
–> 1
set aHWAddress to aInterface’s hardwareAddress() as text
–> "b8:xx:xx:xx:xx:xx"–MAC Address
set aCountry to aInterface’s countryCode() as text
–> "JP"
set aConfig to aInterface’s configuration()
–> (CWConfiguration) <CWConfiguration: 0x6100002348e0>
set aCacheRes to aInterface’s cachedScanResults()
–> (NSSet) {(CWNetwork) <CWNetwork: 0x618000402740> ……………… [channelNumber=11(2GHz), channelWidth={20MHz}], ibss=0]}
set aBSSID to aInterface’s bssid() as text
–> "10:XX:XX:XX:XX:XX"
set aPhyMode to aInterface’s activePHYMode()
–> 4