• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Detecting AirPort Power Enabled
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting AirPort Power Enabled


  • Subject: Re: Detecting AirPort Power Enabled
  • From: Bill Cheeseman <email@hidden>
  • Date: Thu, 1 Oct 2009 08:20:54 -0400


On Oct 1, 2009, at 4:52 AM, Quinn wrote:

At 06:57 -0400 30/9/09, Bill Cheeseman wrote:
I've written a Cocoa method using the System Configuration framework to detect whether the AirPort card is powered on.

Taking a step back for a minute, have you thought about doing this with CoreWLAN rather than System Configuration. CoreWLAN has a specific method, -[CWInterface power], to check whether the interface is powered up. You can also register for a notification, kCWPowerDidChangeNotification, that's sent when the state changes.

Thanks, Quinn, I had not thought to look at CoreWLAN.

My need is simple: to detect whether the computer is configured so that it can detect nearby wi-fi hotspots, if any, so that Core Location will work. No need for notifications; no need to turn anything on; no need to detect a network; no need to join a network -- just detect current status of the AirPort card settings and return YES if the card is on and the port is active. I warn and leave it up to the user to change the configuration if the result is NO.

At first glance, I guess I would do something like this? --

1. Get supported interfaces.

2. If nil or empty array, return NO.

3. Otherwise, iterate array, create each interface in turn in order to examine it, and look for power == YES -- returning YES if I find one, NO otherwise. Or do I just need to iterate for an interface with name "en2" because there can be only one of them and the AirPort port will always be "en2"?

Or does +interface do what I need without having to scan supported interfaces? I'm not clear what "supported" means in +supportedInterfaces, and I'm not sure what "the primary interface" means in the doc.

I'm assuming that this approach will return YES only if a location with an AirPort port exists in System Preferences AND it is the current location. Right? (I ask because I find that if I use System Preferences to switch from a location with a connected wi-fi network to a location without an AirPort port, the AirPort card still indicates in the menu extra that it is actively searching for a network, but it doesn't find one.)

I'm also assuming that this approach will return YES on a fresh machine with an AirPort card on which Network preferences have never been altered in any way. It appears from my experience and communications from Allan Nathanson that the System Configuration framework will not have created a configuration dictionary or a "PowerEnabled" key-value pair for the AirPort interface in this situation. But CoreWLAN would of course have taken account of these defaults and return the correct results, anyway, including YES in the interface's 'power' property. Right?

I'm sure my status as a novice in network matters is showing....

--

Bill Cheeseman
email@hidden
_______________________________________________
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


  • Follow-Ups:
    • Re: Detecting AirPort Power Enabled
      • From: Bill Cheeseman <email@hidden>
References: 
 >Re: Detecting AirPort Power Enabled (From: Quinn <email@hidden>)

  • Prev by Date: Re: kCFErrorDomainCFNetwork == NSURLErrorDomain ; // But headers say otherwise
  • Next by Date: Re: Detecting AirPort Power Enabled
  • Previous by thread: Re: Detecting AirPort Power Enabled
  • Next by thread: Re: Detecting AirPort Power Enabled
  • Index(es):
    • Date
    • Thread