telephonyserverplugins/simtsy/src/CSimSignalStrength.cpp
branchRCL_3
changeset 20 07a122eea281
parent 19 630d2f34d719
equal deleted inserted replaced
19:630d2f34d719 20:07a122eea281
     1 // Copyright (c) 2001-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18 
    18 
    19 /**
    19 /**
    20  @file
    20  @file
    21 */
    21 */
    22 
    22 
    23 
       
    24 
       
    25 #include "OstTraceDefinitions.h"
       
    26 #ifdef OST_TRACE_COMPILER_IN_USE
       
    27 #include "CSimSignalStrengthTraces.h"
       
    28 #endif
       
    29 
       
    30 #include <testconfigfileparser.h>
    23 #include <testconfigfileparser.h>
    31 #include "CSimSignalStrength.h"
    24 #include "CSimSignalStrength.h"
    32 #include "CSimPhone.h"
    25 #include "CSimPhone.h"
       
    26 #include "Simlog.h"
    33 #include "simtsyglobalproperties.h"
    27 #include "simtsyglobalproperties.h"
    34 
    28 
    35 const TInt KSignalStrengthGranularity=5;		// < Granularity for signal strength list array
    29 const TInt KSignalStrengthGranularity=5;		// < Granularity for signal strength list array
    36 
    30 
    37 CSimSignalStrength* CSimSignalStrength::NewL(CSimPhone* aPhone)
    31 CSimSignalStrength* CSimSignalStrength::NewL(CSimPhone* aPhone)
    71  */
    65  */
    72 	{
    66 	{
    73 	iTimer=CSimTimer::NewL(iPhone);
    67 	iTimer=CSimTimer::NewL(iPhone);
    74 	iSignalStrengthInfo=new(ELeave) CArrayFixFlat<TSignalStrengthInfo>(KSignalStrengthGranularity);
    68 	iSignalStrengthInfo=new(ELeave) CArrayFixFlat<TSignalStrengthInfo>(KSignalStrengthGranularity);
    75 
    69 
    76 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_CONSTRUCTL_1, "Starting to parse Signal Strength config parameters...");
    70 	LOGSS1("Starting to parse Signal Strength config parameters...");
    77 	
    71 	
    78 	const CTestConfigItem* item=NULL;
    72 	const CTestConfigItem* item=NULL;
    79 	TInt ret=KErrNone;
    73 	TInt ret=KErrNone;
    80 	item=CfgFile()->Item(KSSNotifyCap);
    74 	item=CfgFile()->Item(KSSNotifyCap);
    81 
    75 
   108 
   102 
   109 		TInt duration,ss,ssb,err;
   103 		TInt duration,ss,ssb,err;
   110 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,duration);
   104 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,duration);
   111 		if(ret!=KErrNone)
   105 		if(ret!=KErrNone)
   112 			{
   106 			{
   113 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_CONSTRUCTL_2, "WARNING - CONFIGURATION FILE PARSING - Reading element DURATION returned %d (element no. %d) from tag %s.",ret,0,KSSLevel);
   107 			LOGPARSERR("duration",ret,0,&KSSLevel);
   114 			continue;
   108 			continue;
   115 			}
   109 			}
   116 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,ss);
   110 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,ss);
   117 		if(ret!=KErrNone)
   111 		if(ret!=KErrNone)
   118 			{
   112 			{
   119 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_CONSTRUCTL_3, "WARNING - CONFIGURATION FILE PARSING - Reading element SS returned %d (element no. %d) from tag %s.",ret,1,KSSLevel);
   113 			LOGPARSERR("ss",ret,1,&KSSLevel);
   120 			continue;
   114 			continue;
   121 			}
   115 			}
   122 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,ssb);
   116 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,ssb);
   123 		if(ret!=KErrNone)
   117 		if(ret!=KErrNone)
   124 			{
   118 			{
   125 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_CONSTRUCTL_4, "WARNING - CONFIGURATION FILE PARSING - Reading element SSB returned %d (element no. %d) from tag %s.",ret,2,KSSLevel);
   119 			LOGPARSERR("ssb",ret,2,&KSSLevel);
   126 			continue;
   120 			continue;
   127 			}
   121 			}
   128 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,err);
   122 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,err);
   129 		if (ret == KErrNotFound)
   123 		if (ret == KErrNotFound)
   130 			{
   124 			{
   131 			err = KErrNone;
   125 			err = KErrNone;
   132 			}
   126 			}
   133 		else
   127 		else
   134 			{
   128 			{
   135 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_CONSTRUCTL_5, "Reading element SSB returned %d (element no. %d) from tag %s expected 0 or -1" ,ret,3,KSSLevel);
   129 			LOGPARSERRANGE("ssb",ret,3,&KSSLevel,"0 or -1");
   136 			}
   130 			}
   137 
   131 
   138 		TSignalStrengthInfo ssInfo;
   132 		TSignalStrengthInfo ssInfo;
   139 		ssInfo.iDuration=duration;
   133 		ssInfo.iDuration=duration;
   140 		ssInfo.iLevel=ss;
   134 		ssInfo.iLevel=ss;
   141 		ssInfo.iBar=(TInt8)ssb;
   135 		ssInfo.iBar=(TInt8)ssb;
   142 		ssInfo.iErr = err;
   136 		ssInfo.iErr = err;
   143 		iSignalStrengthInfo->AppendL(ssInfo);
   137 		iSignalStrengthInfo->AppendL(ssInfo);
   144 		}
   138 		}
   145 	
   139 	
   146 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_CONSTRUCTL_6, "...Finished parsing Signal Strength config parameters...");
   140 	LOGSS1("...Finished parsing Signal Strength config parameters...");
   147 
   141 
   148 	if(iSignalStrengthInfo->Count()!=0)
   142 	if(iSignalStrengthInfo->Count()!=0)
   149 		{
   143 		{
   150 		iSSIndex=0;
   144 		iSSIndex=0;
   151 		iCurrentLevel=iSignalStrengthInfo->At(0).iLevel;
   145 		iCurrentLevel=iSignalStrengthInfo->At(0).iLevel;
   220  * @param aPckg2		The second parameter package.  This is populated with the signal
   214  * @param aPckg2		The second parameter package.  This is populated with the signal
   221  *						strength bar level.
   215  *						strength bar level.
   222  * @return TInt			Standard error value.
   216  * @return TInt			Standard error value.
   223  */
   217  */
   224 	{
   218 	{
   225 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_GETSIGNALSTRENGTH_1, ">>CSimSignalStrength::GetSignalStrength");
   219 	LOGSS1(">>CSimSignalStrength::GetSignalStrength");
   226 	TPckg<TInt32>* ssPckg=(TPckg<TInt32>*)aPckg1;
   220 	TPckg<TInt32>* ssPckg=(TPckg<TInt32>*)aPckg1;
   227 	TInt32& ss=(*ssPckg)();
   221 	TInt32& ss=(*ssPckg)();
   228 	TPckg<TInt8>* ssbPckg=(TPckg<TInt8>*)aPckg2;
   222 	TPckg<TInt8>* ssbPckg=(TPckg<TInt8>*)aPckg2;
   229 	TInt8& ssb=(*ssbPckg)();
   223 	TInt8& ssb=(*ssbPckg)();
   230 
   224 
   234 		return KErrNone;
   228 		return KErrNone;
   235 		}
   229 		}
   236 
   230 
   237 	ss=iCurrentLevel;
   231 	ss=iCurrentLevel;
   238 	ssb=iCurrentBar;
   232 	ssb=iCurrentBar;
   239 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_GETSIGNALSTRENGTH_2, "<<CSimSignalStrength::GetSignalStrength with level=%d dB and bar=%d",(TInt)iCurrentLevel,(TInt)iCurrentBar);
   233 	LOGSS3("<<CSimSignalStrength::GetSignalStrength with level=%d dB and bar=%d",iCurrentLevel,iCurrentBar);
   240 	iPhone->ReqCompleted(aReqHandle,iCurrentError);
   234 	iPhone->ReqCompleted(aReqHandle,iCurrentError);
   241 	return KErrNone;
   235 	return KErrNone;
   242 	}
   236 	}
   243 
   237 
   244 TInt CSimSignalStrength::NotifySignalStrengthChange(TTsyReqHandle aReqHandle,TDes8* aPckg1, TDes8* aPckg2)
   238 TInt CSimSignalStrength::NotifySignalStrengthChange(TTsyReqHandle aReqHandle,TDes8* aPckg1, TDes8* aPckg2)
   252  * @param aPckg2		The second parameter package.  This is populated with the signal
   246  * @param aPckg2		The second parameter package.  This is populated with the signal
   253  *						strength bar level.
   247  *						strength bar level.
   254  * @return TInt			Standard error value.
   248  * @return TInt			Standard error value.
   255  */
   249  */
   256 	{
   250 	{
   257 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_NOTIFYSIGNALSTRENGTHCHANGE_1, ">>CSimSignalStrength::NotifySignalStrengthChange");
   251 	LOGSS1(">>CSimSignalStrength::NotifySignalStrengthChange");
   258 	TPckg<TInt32>* ssPckg=(TPckg<TInt32>*)aPckg1;
   252 	TPckg<TInt32>* ssPckg=(TPckg<TInt32>*)aPckg1;
   259 	TInt32& ss=(*ssPckg)();
   253 	TInt32& ss=(*ssPckg)();
   260 	TPckg<TInt8>* ssbPckg=(TPckg<TInt8>*)aPckg2;
   254 	TPckg<TInt8>* ssbPckg=(TPckg<TInt8>*)aPckg2;
   261 	TInt8& ssb=(*ssbPckg)();
   255 	TInt8& ssb=(*ssbPckg)();
   262 
   256 
   279  * Cancel a previous request to be notified of a change in signal strength.
   273  * Cancel a previous request to be notified of a change in signal strength.
   280  */
   274  */
   281 	{
   275 	{
   282 	if(iSSChangeNotificationPending)
   276 	if(iSSChangeNotificationPending)
   283 		{
   277 		{
   284 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_NOTIFYSIGNALSTRENGTHCHANGECANCEL_1, "CSimSignalStrength::NotifySignalStrengthChange has been cancelled");
   278 		LOGSS1("CSimSignalStrength::NotifySignalStrengthChange has been cancelled");
   285 		iSSChangeNotificationPending=EFalse;
   279 		iSSChangeNotificationPending=EFalse;
   286 		iPhone->ReqCompleted(iSSChangeNotificationReqHandle,KErrCancel);
   280 		iPhone->ReqCompleted(iSSChangeNotificationReqHandle,KErrCancel);
   287 		}
   281 		}
   288 	else 
   282 	else 
   289 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_NOTIFYSIGNALSTRENGTHCHANGECANCEL_2, "CSimSignalStrength::NotifySignalStrengthChange was not outstanding and hasn't been cancelled");
   283 		LOGSS1("CSimSignalStrength::NotifySignalStrengthChange was not outstanding and hasn't been cancelled");
   290 	}
   284 	}
   291 
   285 
   292 void CSimSignalStrength::TimerCallBack(TInt /*aId*/)
   286 void CSimSignalStrength::TimerCallBack(TInt /*aId*/)
   293 /**
   287 /**
   294  * The timer callback function.  This function will be called when the timer
   288  * The timer callback function.  This function will be called when the timer
   312 	if(iSSChangeNotificationPending)
   306 	if(iSSChangeNotificationPending)
   313 		{
   307 		{
   314 		iSSChangeNotificationPending=EFalse;
   308 		iSSChangeNotificationPending=EFalse;
   315 		*iSSChangeNotificationSSLevel=iCurrentLevel;
   309 		*iSSChangeNotificationSSLevel=iCurrentLevel;
   316 		*iSSChangeNotificationSSBarLevel=iCurrentBar;
   310 		*iSSChangeNotificationSSBarLevel=iCurrentBar;
   317 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_TIMERCALLBACK_1, "<<CSimSignalStrength::NotifySignalStrengthChange with level=%d dB and bar=%d",(TInt)iCurrentLevel,(TInt)iCurrentBar);
   311 		LOGSS3("<<CSimSignalStrength::NotifySignalStrengthChange with level=%d dB and bar=%d",iCurrentLevel,iCurrentBar);
   318 		iPhone->ReqCompleted(iSSChangeNotificationReqHandle,iCurrentError);
   312 		iPhone->ReqCompleted(iSSChangeNotificationReqHandle,iCurrentError);
   319 		}
   313 		}
   320 	iTimer->Start(iSignalStrengthInfo->At(iSSIndex).iDuration,this);
   314 	iTimer->Start(iSignalStrengthInfo->At(iSSIndex).iDuration,this);
   321 	}
   315 	}
   322 
   316 
   335  *
   329  *
   336  * @param aNewVal The new signal strength value (number of bars)
   330  * @param aNewVal The new signal strength value (number of bars)
   337  */
   331  */
   338 void CSimSignalStrength::PubSubCallback(TInt aNewVal)
   332 void CSimSignalStrength::PubSubCallback(TInt aNewVal)
   339 	{
   333 	{
   340 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_PUBSUBCALLBACK_1, "CSimSignalStrength::SignalStrengthChangeCallBack newVal=%d", aNewVal);
   334 	LOGSS2("CSimSignalStrength::SignalStrengthChangeCallBack newVal=%d", aNewVal);
   341 	if (iCurrentBar == aNewVal)
   335 	if (iCurrentBar == aNewVal)
   342 		{
   336 		{
   343 		return;
   337 		return;
   344 		}
   338 		}
   345 	iCurrentBar = (TInt8) aNewVal;
   339 	iCurrentBar = (TInt8) aNewVal;
   346 	if(iSSChangeNotificationPending)
   340 	if(iSSChangeNotificationPending)
   347 		{
   341 		{
   348 		iSSChangeNotificationPending=EFalse;
   342 		iSSChangeNotificationPending=EFalse;
   349 		*iSSChangeNotificationSSLevel=iCurrentLevel;
   343 		*iSSChangeNotificationSSLevel=iCurrentLevel;
   350 		*iSSChangeNotificationSSBarLevel=iCurrentBar;
   344 		*iSSChangeNotificationSSBarLevel=iCurrentBar;
   351 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_PUBSUBCALLBACK_2, "<<CSimSignalStrength::NotifySignalStrengthChange with level=%d dB and bar=%d",(TInt)iCurrentLevel,(TInt)iCurrentBar);
   345 		LOGSS3("<<CSimSignalStrength::NotifySignalStrengthChange with level=%d dB and bar=%d",iCurrentLevel,iCurrentBar);
   352 		iPhone->ReqCompleted(iSSChangeNotificationReqHandle,iCurrentError);
   346 		iPhone->ReqCompleted(iSSChangeNotificationReqHandle,iCurrentError);
   353 		}
   347 		}
   354 	}
   348 	}