Using Private API to Read Wifi Rssi Value

Using Private API To read WiFi RSSI Value

I ended up using this workaround:

+ (int) wifiStrength {
UIApplication *app = [UIApplication sharedApplication];
NSArray *subviews = [[[app valueForKey:@"statusBar"] valueForKey:@"foregroundView"] subviews];
NSString *dataNetworkItemView = nil;

for (id subview in subviews) {
if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
dataNetworkItemView = subview;
break;
}
}

return[[dataNetworkItemView valueForKey:@"wifiStrengthRaw"] intValue];
}

Works without any entitlements or jailbreaking

How to use iOS CNCopyCurrentNetworkInfo to read WIFI signal strength (RSSI)?

if you want to be App Store conform I see no way -- there is no public api for that


the answer here mentioned a C function that does what you want but it isn't public api:

Accessing iPhone WiFi Information via SDK

further info on how to use that function:

Accessing & Using the MobileWiFi.framework

NOTE: private api may break at any point and this might even be broken already anyways

CCNCopyCurrentNetworkInfo won't help you AFAIK -- you CAN misuse the captive networks API to get the current SSID but I don't see how it could get you the RSSI

Reading Rssi value without connecting any wi-fi

In conjunction with the previous answer, you can add code inside of the following timer to check it every few seconds. Of course you can modify how long you want the timer to execute.

 var timer = new Timer();
timer.Tick += new EventHandler(timer_Tick);
timer.Interval = 2000; //2 seconds
timer.Start();

void timer_Tick(object sender, EventArgs e)
{
..your code here..
}


Related Topics



Leave a reply



Submit