Monday, June 22, 2009

Getting GSM info like Cell ID, signal Strength on Symbian SDKs

In this tutorial i will demonstarte different ways to get GSM information like
  1. Cell Tower ID
  2. Location Area Code of the current tower (LAC)
  3. Mobile Network Code (MNC)
  4. Mobile Country Code (MCC)
  5. SIM Card Operator
  6. Signal Strength
on different Symbian SDKs

S60_3rd_FP1
=======================================
void CTowerModel::RunL()
{
if(iStatus==KErrNone)
{
if(iCounter == 0)
{
iCounter = 1;
iTelephony->GetSignalStrength( iStatus, iSigStrengthV1Pckg);
}
else
{
iCounter = 0;
iTelephony->GetCurrentNetworkInfo( iStatus, iNetworkInfoV2Pckg);
}
iParent->updateDisplay();
SetActive();
}
}
=======================================
The prevoius code switchs alternatvlty when iCounter=0,
Code gets Signal Strength using
iSignalStrengthV1.iSignalStrength

and when iCounter = 1, Code gets the Network Info like Cell tower id,lac. mcc, mnc
Cell Tower ID ==>iNetworkInfoV2.iCellId
LAC ==>iNetworkInfoV2.iLocationAreaCode
MCC ==>iNetworkInfoV2.iCountryCode
MNC ==> iNetworkInfoV2.iNetworkId
Operator Name ==> iNetworkInfoV2.iShortName

you should add the following CAPABILITY to be able to get Signal Strength
  • Location
  • ReadDeviceData
  • ReadUserData
More detailed code can be found here

S60_2_0_CW
=======================================
void CTowerModel::RunL()
{
if(iStatus==KErrNone)
{
iCellID = 1;
iSignalStrength = 1;
iMobileNetworkCode = 1;
iLocationAreaCode = 1;

MBasicGsmPhoneNetwork::TCurrentNetworkInfo cni;
User::LeaveIfError( phone.GetCurrentNetworkInfo( cni ) );
iCellID = cni.iCellId;
iLocationAreaCode = cni.iLocationAreaCode;
MBasicGsmPhoneNetwork::TNetworkInfo ni = cni.iNetworkInfo;
MBasicGsmPhoneNetwork::TBscNetworkId bni = ni.iId;
iMobileNetworkCode = bni.iMNC;
iMobileCountryCode = bni.iMCC;
TBuf<30> iOperatorName = ni.iLongName;

TInt32 st;
phone.GetSignalStrength(st);
iSignalStrength = st;
iParent->updateView();
}
else
{
iCellID = 0;
iSignalStrength = 0;
iMobileNetworkCode = 0;
iLocationAreaCode = 0;
}
iTimer.After(iStatus,1000000);
SetActive();
}
=======================================

To be able to test this code you might need to include etelbgsm.h File
A screenShot of the emulator Testing
More detailed code can be found here

No comments:

Post a Comment