How to find out carrier signal strength programmatically
core-telephony, ios, ios6, ipad, iphone
Solution
`getSignalStrength()` is showing negated dB attenuation, e.g. -(-60) == 60. The call in is displaying it more conventionally as a measurement less than zero. Yes, these kinds of variations are typical. Even in strictly controlled conditions you can get +/- 20 decibels. One way you can fix it is to take a series of measurements over time, say every second, and keep a running list of the last 10 or so measurements. Then report the mean or median or some other statistic. In my experience this cuts down the variation a lot. You can also do standard deviation to provide a measure of reliability.
Problem
Here is the code that I have used to find out carrier signal strength: ``` int getSignalStrength() { void *libHandle = dlopen("/System/Library/Frameworks/CoreTelephony.framework/CoreTelephony", RTLD_LAZY); int (*CTGetSignalStrength)(); CTGetSignalStrength = dlsym(libHandle, "CTGetSignalStrength"); if( CTGetSignalStrength == NULL) NSLog(@"Could not find CTGetSignalStrength"); int result = CTGetSignalStrength(); dlclose(libHandle); return result; } ``` It is giving me values between 60 to 100, but when I test the signal strength in device by calling to this `*3001#12345#*` number it showed me as `-65`. Below I have attached the screenshot. Is the value coming from `getSignalStrength()` accurate? Then why is it returning positive values always?