在iphone中获取运营商名称和信号强度返回错误值 [英] get carrier name and signal strength return wrong value in iphone

查看:186
本文介绍了在iphone中获取运营商名称和信号强度返回错误值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇为什么我得到错误的价值来获得运营商名称和信号强度。
这里的代码。

i curious why i get wrong value to get carrier name and signal strength. Here the code.

CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *car = [netinfo subscriberCellularProvider];
NSLog(@"Carrier Name: %@", car.carrierName);
[netinfo release];

为什么我获得价值运营商而不是我使用的运营商?

Why i get value "carrier" instead of carrier i use?

这是获取信号强度的代码

this is code to get signal strength

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();
NSLog(@"Signal strength: %d", result);
dlclose(libHandle);

因为我知道,信号强度是以dBm为单位(负数),但为什么上面的值显示positif值现在显示信号强度?
是否存在任何值映射以显示dBm上的信号强度

as i kno, signal strength is in dBm value (in negative), but why the value above show positif value and now shown the signal strength? is there any value mapping to present the signal strength on dBm

PS我在真正的iphone设备上运行该程序仍然得到错误的值。

P.S i ran the program on the real iphone devices and still get wrong value.

任何帮助都将不胜感激。

any help would be appreciate.

谢谢。

推荐答案

关于运营商:在模拟器上运行代码可以在设备上正确运行 nil 时说 2011 -11-24 10:49:05.182 testapp [12579:707]运营商名称:Vodafone.de ,因此代码绝对正确(使用Xcode 4.2在iOS 5.0.1上运行)。也许你的运营商没有正确填写某些字段?在任何情况下,我都会考虑在其他设备或其他SIM卡上进行测试。

About the carrier: Running your code on the simulator gives me nil while running on a device correctly says 2011-11-24 10:49:05.182 testapp[12579:707] Carrier Name: Vodafone.de, so the code is absolutely correct (running on iOS 5.0.1 using Xcode 4.2). Maybe your carrier didn't fill out some field correctly? In any case I would consider testing on another device or with another SIM card.

关于信号强度:As CTGetSignalStrength 似乎是一个相当无证的API,这些值可能由Apple任意定义(并重新定义)。在任何情况下,这似乎是RSSI值(接收信号强度指示),其或多或少是正数,其中1是最差信号强度而上限是更好。因此,没有预定义(记录且因此稳定)可用的dBm值映射,可能必须通过实验创建映射。

Concerning signal strength: As CTGetSignalStrength seems to be a rather undocumented API the values may be arbitrarily defined by Apple (and redefined as well). In any case this seems to be a RSSI value (received signal strength indication) which is more or less a positive number where 1 is the worst signal strength and upper is better. As such there is no predefined (documented and thus stable) available mapping to dBm values, a mapping would probably have to be created experimentally.

这篇关于在iphone中获取运营商名称和信号强度返回错误值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆