如何以编程方式找出载波信号强度 [英] How to find out carrier signal strength programatically
问题描述
以下是我用来查找载波信号强度的代码:
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;
}
它给我60到100之间的值,但当我测试信号时设备强度通过调用此 * 3001#12345#*
数字显示为 -65
。下面我附上了截图。来自 getSignalStrength()
的值是否准确?那为什么它总是返回正值?
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?
推荐答案
getSignalStrength()
显示否定的dB衰减,例如 - ( - 60)== 60.呼入将更常规地显示为小于零的测量值。是的,这些变化是典型的。即使在严格控制的条件下,您也可以获得+/- 20分贝。解决这个问题的一种方法是随着时间的推移进行一系列测量,比如每秒,并保留最近10次测量的运行列表。然后报告平均值或中位数或其他统计数据。根据我的经验,这会大大减少变化。您也可以使用标准偏差来衡量可靠性。
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.
这篇关于如何以编程方式找出载波信号强度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!