How to determine the carrier signal level programmatically

Here is the code I used to determine the power of the carrier signal:

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 gives me values ​​from 60 to 100, but when I test the signal level in the device, calling this number *3001#12345#* , it showed me as -65 . Below I have attached a screenshot. Is the value coming from getSignalStrength() accurate? Then why does it always return positive values?

enter image description here

+4
source share
5 answers

getSignalStrength() shows a negative dB attenuation, for example. - (- 60) == 60. The call displays it more conditionally as a measurement less than zero. Yes, these species are typical. Even under strictly controlled conditions, you can get +/- 20 decibels. One way to fix this is to take a series of measurements over time, say every second, and save a list of the last 10 or so measurements. Then report average or average or some other statistics. In my experience, this significantly reduces the variation. You can also perform standard deviation to ensure reliability.

+7
source

My observation in CTGetSignalStrength() in CoreTelephony is that it returns the RSSI(Received Signal Strength Indication) value of the carrier signal power. My experiments with this return values ​​between a range of 0 - 100, which, in my opinion, is the "signal percentage" of the carrier according to this .

Also, iOS does not measure signal strength linearly according to this

I also noticed that even when we have 5 bars in the status bar, the RSSI value may not be 100.

+5
source

getSignalStrength() gives the result on a negative scale. The difference can be controlled using a high-pass filter.

You must collect the results of the last 10 observations. When adding a new observation, take the average of the last 10 observations. Multiply it by 0.1. Take the current reading and multiply it by 0.9. Add both. If the total number of observations is more than 10, delete the oldest observation for the next calculation.

This will make your result more reliable, and you can also effectively respond to sudden changes in signal strength.

+3
source

I would recommend reading in decibel measure. The following link should help. How to read signal strength

+1
source

As with many signals, getSignalStrength() should be used in conjunction with the high-pass filter algorithm.

Also make sure that for some time the average time (10-15 consecutive measurements). And it's normal that it gives a negative result, the dB signals for telephony are :-)

+1
source

Source: https://habr.com/ru/post/1469435/


All Articles