获取基站求助
CTelephony GetCurrentNetworkInfo 获取基站信息,为什么除了取出aCountryCode=460外其它的值如Cellid一直不成功.能力也应该给了
代码如下:
.h
#ifndef MYTELEPHONY_H
#define MYTELEPHONY_H
#include <e32base.h>
#include <Etel3rdParty.h>
class CMyTelephony : public CActive
{
public:
static void GetIMSIL(TDes& aIMSI);
static void GetIMEIL(TDes& aIMEI);
static void GetPhoneType(TDes& aPhoneType);
static void GetNetworkInfo(TDes& aCountryCode, TDes& aNetworkId, TUint aLocationAreaCode, TUint aCellId);
//static void GetNetworkInfo(TUint aLocationAreaCode, TUint aCellId);
static void DialPhone(const TDesC& aPhoneId);
static CMyTelephony* NewL();
protected:
void DoCancel();
void RunL();
private:
static CMyTelephony* NewLC();
~CMyTelephony();
CMyTelephony();
void ConstructL();
void GetSubscriberId();
void GetCurrentNetworkInfo();
void GetPhoneId();
private:
CTelephony* iTelephony;
CTelephony::TCancellationRequest iRequest;
CTelephony::TSubscriberIdV1 iSubscriberId;
CTelephony::TSubscriberIdV1Pckg iSubscriberIdPckg;
CTelephony::TPhoneIdV1 iPhoneId;
CTelephony::TPhoneIdV1Pckg iPhoneIdPckg;
CTelephony::TCallId iCallId;
TBuf<32> iPhoneType;
CTelephony::TNetworkInfoV1 iNetworkInfoV1;
CTelephony::TNetworkInfoV1Pckg iNetworkInfoV1Pckg;
//RTimer iTimer; // Provides async timing service
public :
void DialNewCall(const TDesC& aTelNumber);
};
#endif // MYTELEPHONY_H
.cpp:
// MyTelephony.cpp
//
#include <e32svr.h>
#include "MyTelephony.h"
#include <f32file.h>
//class CTelephony;
CMyTelephony* CMyTelephony::NewLC()
{
CMyTelephony* self = new (ELeave) CMyTelephony;
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CMyTelephony* CMyTelephony::NewL()
{
CMyTelephony* self = CMyTelephony::NewLC();
CleanupStack::Pop(self);
return self;
}
void CMyTelephony::GetIMSIL(TDes& aIMSI)
{
CMyTelephony* telephony = CMyTelephony::NewL();
telephony->GetSubscriberId();
aIMSI = telephony->iSubscriberId.iSubscriberId;
delete telephony;
}
void CMyTelephony::GetIMEIL(TDes& aIMEI)
{
CMyTelephony* telephony = CMyTelephony::NewL();
telephony->GetPhoneId();
aIMEI = telephony->iPhoneId.iSerialNumber;
delete telephony;
}
void CMyTelephony::GetPhoneType(TDes& aPhoneType)
{
CMyTelephony* telephony = CMyTelephony::NewL();
telephony->GetPhoneId();
aPhoneType.Copy(telephony->iPhoneId.iManufacturer);
aPhoneType.Append(telephony->iPhoneId.iModel);
delete telephony;
}
void CMyTelephony::GetNetworkInfo(TDes& aCountryCode, TDes& aNetworkId, TUint aLocationAreaCode, TUint aCellId)
//void CMyTelephony::GetNetworkInfo(TUint aLocationAreaCode, TUint aCellId)
{
CMyTelephony* telephony = CMyTelephony::NewL();
telephony->GetCurrentNetworkInfo();
aCountryCode = telephony->iNetworkInfoV1.iCountryCode;
aNetworkId = telephony->iNetworkInfoV1.iNetworkId;
aLocationAreaCode = telephony->iNetworkInfoV1.iLocationAreaCode;
aCellId = telephony->iNetworkInfoV1.iCellId;
delete telephony;
}
void CMyTelephony::DialPhone(const TDesC& aPhoneId)
{
#ifndef __WINS__ //真实设备 This only works on target machine
CMyTelephony* telephony = CMyTelephony::NewLC();
telephony->DialNewCall(aPhoneId);
#else //模拟器 Return a fake IMEI when working onemulator
#endif
}
void CMyTelephony::DoCancel()
{
iTelephony->CancelAsync(iRequest);
iTelephony->CancelAsync(CTelephony::EDialNewCallCancel);
//iTimer.Cancel();
}
void CMyTelephony::RunL()
{
CActiveScheduler::Stop();
}
CMyTelephony::~CMyTelephony()
{
delete iTelephony;
//iTimer.Close(); // Destroy the RTimer object
}
CMyTelephony::CMyTelephony():CActive(CActive::EPriorityStandard), iSubscriberIdPckg(iSubscriberId),iPhoneIdPckg(iPhoneId),iNetworkInfoV1Pckg(iNetworkInfoV1)
{
CActiveScheduler::Add(this);
}
void CMyTelephony::ConstructL()
{
iTelephony = CTelephony::NewL();
//User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer
}
void CMyTelephony::GetSubscriberId()
{
Cancel();
iRequest = CTelephony::EGetSubscriberIdCancel;
iTelephony->GetSubscriberId(iStatus, iSubscriberIdPckg);
SetActive();
CActiveScheduler::Start();
}
void CMyTelephony::GetCurrentNetworkInfo()
{
Cancel();
iRequest = CTelephony::EGetCurrentNetworkInfoCancel;
//CTelephony::TNetworkInfoV1Pckg networkInfoPckg(iNetworkInfoV1);
//iStatus = KRequestPending;
iTelephony->GetCurrentNetworkInfo(iStatus, iNetworkInfoV1Pckg);
//iTelephony->NotifyChange(iStatus,CTelephony::ECurrentNetworkInfoChange,iNetworkInfoV1Pckg);
SetActive();
CActiveScheduler::Start();
}
void CMyTelephony::GetPhoneId()
{
Cancel();
iRequest = CTelephony::EGetPhoneIdCancel;
iTelephony->GetPhoneId(iStatus, iPhoneIdPckg);
SetActive();
CActiveScheduler::Start();
}
/*
141. * 拨打电话
142. * */
void CMyTelephony::DialNewCall(const TDesC& aTelNumber)
{
CTelephony::TTelNumber telNumber(aTelNumber);
CTelephony::TCallParamsV1 callParams;
callParams.iIdRestrict = CTelephony::ESendMyId;
CTelephony::TCallParamsV1Pckg callParamsPckg(callParams);
iTelephony->DialNewCall(iStatus, callParamsPckg, telNumber, iCallId);
SetActive();
}
代码也是参考网上的,为什么一直不成功困扰好久了,望兄弟忙帮帮忙,谢谢
另我的调试手机nokia6120c有其它软件能够取出基站的
[解决办法]
发现网络是中国移动等信息都有,就是没有我想取的Lac和cell,郁闷
[解决办法]
发现问题所在了
[解决办法]
这可真是发挥了天下文章一大抄看你会钞不会抄的光荣传统啊。你看着文章抄的,这文章copy的,是一点都没错啊,到时候再把文章标题一起搬过来,那就更完美了啊!!!!!!!!!
[解决办法]