Reputation: 73
I need to run a program in Objective C. I found the code for getting wifi signal strength.
I am not getting the mobilewifi.h file ? Where would this be available. I googled it up.
Moreover, I am unaware of where should I keep this file in the project ? in which .m file ? App Delegate ??
The code is :
#include <math.h>
#include <MobileWiFi.h>
WiFiManagerRef manager = WiFiManagerClientCreate(kCFAllocatorDefault, 0);
CFArrayRef devices = WiFiManagerClientCopyDevices(_manager);
WiFiDeviceClientRef client = (WiFiDeviceClientRef)CFArrayGetValueAtIndex(devices, 0);
CFDictionaryRef data = (CFDictionaryRef)WiFiDeviceClientCopyProperty(_device, CFSTR("RSSI"));
CFNumberRef scaled = (CFNumberRef)WiFiDeviceClientCopyProperty(_device, kWiFiScaledRSSIKey);
CFNumberRef RSSI = (CFNumberRef)CFDictionaryGetValue(data, CFSTR("RSSI_CTL_AGR"));
int raw;
CFNumberGetValue(RSSI, kCFNumberIntType, &raw);
float strength;
CFNumberGetValue(scaled, kCFNumberFloatType, &strength);
CFRelease(scaled);
strength *= -1;
// Apple uses -3.0.
int bars = (int)ceilf(strength * -3.0f);
bars = MAX(1, MIN(bars, 3));
printf("WiFi signal strength: %d dBm\n\t Bars: %d\n", raw, bars);
CFRelease(data);
CFRelease(scaled);
CFRelease(devices);
CFRelease(manager);
Upvotes: 3
Views: 899
Reputation: 40030
You can find the headers here:
https://github.com/Cykey/ios-reversed-headers/blob/master/MobileWiFi/MobileWiFi.h
Upvotes: 1