Re: Detecting AirPort Power Enabled
Re: Detecting AirPort Power Enabled
- Subject: Re: Detecting AirPort Power Enabled
- From: Allan Nathanson <email@hidden>
- Date: Wed, 30 Sep 2009 11:57:14 -0400
On Sep 30, 2009, at 11:46 AM, Bill Cheeseman wrote:
On Sep 30, 2009, at 8:41 AM, Allan Nathanson wrote:
On Sep 30, 2009, at 6:57 AM, Bill Cheeseman wrote:
I've written a Cocoa method using the System Configuration
framework to detect whether the AirPort card is powered on. I
first test the current network configuration set for a network
interface of type kSCNetworkInterfaceTypeIEEE80211 (AirPort).
Then, if one is present, I get its configuration dictionary and
extract the value associated with its "PowerEnabled" key. A user
is reporting that this returns nil because the dictionary does not
contain a "PowerEnabled" key at all. I thought it was illegal for
a kSCNetworkInterfaceTypeIEEE80211 interface to have a
configuration dictionary that does NOT contain the "PowerEnabled"
key, so i didn't test for nil.
1. Can a kSCNetworkInterfaceTypeIEEE80211 interface configuration
dictionary lawfully omit a "PowerEnabled" key? Under what
circumstances? Can anybody point me to documentation?
2. I'm doing this in an app that uses the Snow Leopard Core
Location facility to detect (but not join) wi-fi hotspots. Am I
correct in assuming that it could not detect wi-fi hotspots
without (a) an IEEE80211 interface configuration dictionary (b)
whose "PowerEnabled" key reports that the power is turned on?
The configuration dictionaries contain keys/values that specify and/
or change the configuration. If a key/value is absent than a
default value is assumed. For the "PowerEnabled" key, I believe
that we assume that the AirPort interface should be enabled unless
we see that it has explicitly been turned off.
Thanks, that explains the behavior my user is seeing.
A related question: In a pristine system where AirPort is set up but
it has never been turned off and its advanced settings have never
been changed, will the AirPort interface also have a nil
configuration dictionary? Or is it always guaranteed to have a
configuration dictionary if AirPort is on? (In other words, should I
also assume AirPort is enabled if I find a nil configuration
dictionary?)
If I was coding, I'd avoid making any assumptions that a configuration
dictionary or any given key/value must be present. Code defensively
and always expect the unexpected. As to your specific question about
whether AirPort defaults to "on" when no configuration/settings are
present, I think the answer is yes.
- Allan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden