Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198
MobileWiFi.framework: Difference between revisions - iPhone Development Wiki

MobileWiFi.framework: Difference between revisions

From iPhone Development Wiki
(Remove useless code)
(Add WiFi signal strength)
Line 6: Line 6:
'''MobileWiFi''' is the framework that manages WiFi functionality on iOS. It replaces the obsolete '''Apple80211''' framework. MobileWiFi.framework has a C API, and a unfinished reverse-engineered header is available [https://gist.github.com/Cykey/5007313 here].
'''MobileWiFi''' is the framework that manages WiFi functionality on iOS. It replaces the obsolete '''Apple80211''' framework. MobileWiFi.framework has a C API, and a unfinished reverse-engineered header is available [https://gist.github.com/Cykey/5007313 here].


== Retrieve a list of known networks ==
== Retrieving a list of known networks ==
<source lang="c">
<source lang="c">
#include <MobileWiFi.h>
WiFiManagerRef manager = WiFiManagerClientCreate();
WiFiManagerRef manager = WiFiManagerClientCreate();


Line 16: Line 18:
CFRelease(manager);
CFRelease(manager);
CFRelease(networks);
CFRelease(networks);
</source>
== Getting the WiFi signal strength ==
<source lang="c">
#include <math.h>
#include <MobileWiFi.h>
// We're not using the manager here but you need to create one for this code to work.
WiFiManagerRef manager = WiFiManagerClientCreate();
CFArrayRef devices = WiFiManagerClientCopyDevices();
WiFiDeviceClientRef client = (WiFiDeviceClientRef)CFArrayGetValueAtIndex(devices, 0);
CFNumberRef RSSI = (CFNumberRef)WiFiDeviceClientCopyProperty(client, kWiFiScaledRSSIKey);
float strength;
CFNumberGetValue(RSSI, kCFNumberFloatType, &strength);
strength = strength * 100;
// Round to the nearest integer.
strength = ceilf(strength);
// Convert to a negative number.
strength = strength * -1;
NSLog(@"WiFi signal strength: %f dBm", strength);
CFRelease(RSSI);
CFRelease(devices);
CFRelease(manager);
</source>
</source>
{{Navbox Frameworks}}
{{Navbox Frameworks}}

Revision as of 16:23, 22 February 2013

MobileWiFi.framework
Private Framework
Availabile 3.0 – present
Headers [headers.cynder.me]


MobileWiFi is the framework that manages WiFi functionality on iOS. It replaces the obsolete Apple80211 framework. MobileWiFi.framework has a C API, and a unfinished reverse-engineered header is available here.

Retrieving a list of known networks

#include <MobileWiFi.h>

WiFiManagerRef manager = WiFiManagerClientCreate();

CFArrayRef networks = WiFiManagerClientCopyNetworks(manager);

NSLog(@"networks: %@", networks);

CFRelease(manager);
CFRelease(networks);

Getting the WiFi signal strength

#include <math.h>
#include <MobileWiFi.h>

// We're not using the manager here but you need to create one for this code to work.
WiFiManagerRef manager = WiFiManagerClientCreate();
CFArrayRef devices = WiFiManagerClientCopyDevices();

WiFiDeviceClientRef client = (WiFiDeviceClientRef)CFArrayGetValueAtIndex(devices, 0);
CFNumberRef RSSI = (CFNumberRef)WiFiDeviceClientCopyProperty(client, kWiFiScaledRSSIKey);

float strength;
CFNumberGetValue(RSSI, kCFNumberFloatType, &strength);

strength = strength * 100;

// Round to the nearest integer.
strength = ceilf(strength);

// Convert to a negative number.
strength = strength * -1;

NSLog(@"WiFi signal strength: %f dBm", strength);

CFRelease(RSSI);
CFRelease(devices);
CFRelease(manager);