title: Accessing & Using the MobileWiFi.framework
body: <p>For a personal project of mine, I'm trying to retrieve iPhone WiFi signal strength. I'm fully aware that this in the land of undocumented goodness, so please refrain from the "No Appstore" answers. :)</p>
  
  <p>Anywho, I've been reading up on previous WiFi Network Scanner Apps (<a href="http://code.google.com/p/iphone-wireless/wiki/Stumbler" rel="noreferrer">WiFi Stumbler</a>), but I'm afraid most (if not all) reflect outdated SDK documentation. Hopefully, this question will also provide some centralized / insightful material with the most recent iPhone SDK 3.1.2.</p>
  
  <p>Here's my incomplete/not-working code:</p>
  
  <p>.h</p>
  
  <pre><code> void *libHandle;
   void *airportHandle; 
   int (*open)(void *);
   int (*bind)(void *, NSString *);
   int (*close)(void *);
   int (*scan)(void *, NSArray **, void *);
  </code></pre>
  
  <p>.m</p>
  
  <pre><code>libHandle = dlopen("/System/Library/PrivateFrameworks/MobileWiFi.framework/MobileWiFi",RTLD_LAZY);
  
  open = dlsym(libHandle, "Apple80211Open");
  bind = dlsym(libHandle, "Apple80211BindToInterface");
  close = dlsym(libHandle, "Apple80211Close");
  scan = dlsym(libHandle, "Apple80211Scan");
  
  open(&amp;airportHandle);
  bind(airportHandle, @"en0");
  
  NSLog(@"Result %@",libHandle);
  </code></pre>
  
  <p>When executed on the device, it'll produce my ever-so-favorite... </p>
  
  <blockquote>
    <p>Exception Type:  EXC_BAD_ACCESS (SIGSEGV)</p>
  </blockquote>
  
  <p>I'm thinking the dynamic loading call, isn't loading anything. The directory: <em>/System/Library/PrivateFrameworks/</em> only lists a Info.plist file with no binaries or aliases.</p>
  
  <p>Probably doing something terribly wrong (wrong directory?)... appreciate any help!</p>
  
  <p>Also, as a follow up. To extract the WiFi information, it might be done by:</p>
  
  <pre><code>GetInfoCopy = dlsym(libHandle, "Apple80211GetInfoCopy");
  </code></pre>
  
  <p>And my questions are 1) Has anybody had any luck with this? 2) How do you get a header dump like I would using with class-dump on Objective-C libraries (because MobileWifi is in C)?</p>