1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2001-2010 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 |
23 #include <testconfigfileparser.h> |
30 #include <testconfigfileparser.h> |
24 #include "CSimSignalStrength.h" |
31 #include "CSimSignalStrength.h" |
25 #include "CSimPhone.h" |
32 #include "CSimPhone.h" |
26 #include "Simlog.h" |
|
27 #include "simtsyglobalproperties.h" |
33 #include "simtsyglobalproperties.h" |
28 |
34 |
29 const TInt KSignalStrengthGranularity=5; // < Granularity for signal strength list array |
35 const TInt KSignalStrengthGranularity=5; // < Granularity for signal strength list array |
30 |
36 |
31 CSimSignalStrength* CSimSignalStrength::NewL(CSimPhone* aPhone) |
37 CSimSignalStrength* CSimSignalStrength::NewL(CSimPhone* aPhone) |
102 |
108 |
103 TInt duration,ss,ssb,err; |
109 TInt duration,ss,ssb,err; |
104 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,duration); |
110 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,duration); |
105 if(ret!=KErrNone) |
111 if(ret!=KErrNone) |
106 { |
112 { |
107 LOGPARSERR("duration",ret,0,&KSSLevel); |
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); |
108 continue; |
114 continue; |
109 } |
115 } |
110 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,ss); |
116 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,ss); |
111 if(ret!=KErrNone) |
117 if(ret!=KErrNone) |
112 { |
118 { |
113 LOGPARSERR("ss",ret,1,&KSSLevel); |
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); |
114 continue; |
120 continue; |
115 } |
121 } |
116 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,ssb); |
122 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,ssb); |
117 if(ret!=KErrNone) |
123 if(ret!=KErrNone) |
118 { |
124 { |
119 LOGPARSERR("ssb",ret,2,&KSSLevel); |
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); |
120 continue; |
126 continue; |
121 } |
127 } |
122 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,err); |
128 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,err); |
123 if (ret == KErrNotFound) |
129 if (ret == KErrNotFound) |
124 { |
130 { |
125 err = KErrNone; |
131 err = KErrNone; |
126 } |
132 } |
127 else |
133 else |
128 { |
134 { |
129 LOGPARSERRANGE("ssb",ret,3,&KSSLevel,"0 or -1"); |
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); |
130 } |
136 } |
131 |
137 |
132 TSignalStrengthInfo ssInfo; |
138 TSignalStrengthInfo ssInfo; |
133 ssInfo.iDuration=duration; |
139 ssInfo.iDuration=duration; |
134 ssInfo.iLevel=ss; |
140 ssInfo.iLevel=ss; |
135 ssInfo.iBar=(TInt8)ssb; |
141 ssInfo.iBar=(TInt8)ssb; |
136 ssInfo.iErr = err; |
142 ssInfo.iErr = err; |
137 iSignalStrengthInfo->AppendL(ssInfo); |
143 iSignalStrengthInfo->AppendL(ssInfo); |
138 } |
144 } |
139 |
145 |
140 LOGSS1("...Finished parsing Signal Strength config parameters..."); |
146 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_CONSTRUCTL_6, "...Finished parsing Signal Strength config parameters..."); |
141 |
147 |
142 if(iSignalStrengthInfo->Count()!=0) |
148 if(iSignalStrengthInfo->Count()!=0) |
143 { |
149 { |
144 iSSIndex=0; |
150 iSSIndex=0; |
145 iCurrentLevel=iSignalStrengthInfo->At(0).iLevel; |
151 iCurrentLevel=iSignalStrengthInfo->At(0).iLevel; |
214 * @param aPckg2 The second parameter package. This is populated with the signal |
220 * @param aPckg2 The second parameter package. This is populated with the signal |
215 * strength bar level. |
221 * strength bar level. |
216 * @return TInt Standard error value. |
222 * @return TInt Standard error value. |
217 */ |
223 */ |
218 { |
224 { |
219 LOGSS1(">>CSimSignalStrength::GetSignalStrength"); |
225 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_GETSIGNALSTRENGTH_1, ">>CSimSignalStrength::GetSignalStrength"); |
220 TPckg<TInt32>* ssPckg=(TPckg<TInt32>*)aPckg1; |
226 TPckg<TInt32>* ssPckg=(TPckg<TInt32>*)aPckg1; |
221 TInt32& ss=(*ssPckg)(); |
227 TInt32& ss=(*ssPckg)(); |
222 TPckg<TInt8>* ssbPckg=(TPckg<TInt8>*)aPckg2; |
228 TPckg<TInt8>* ssbPckg=(TPckg<TInt8>*)aPckg2; |
223 TInt8& ssb=(*ssbPckg)(); |
229 TInt8& ssb=(*ssbPckg)(); |
224 |
230 |
246 * @param aPckg2 The second parameter package. This is populated with the signal |
252 * @param aPckg2 The second parameter package. This is populated with the signal |
247 * strength bar level. |
253 * strength bar level. |
248 * @return TInt Standard error value. |
254 * @return TInt Standard error value. |
249 */ |
255 */ |
250 { |
256 { |
251 LOGSS1(">>CSimSignalStrength::NotifySignalStrengthChange"); |
257 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_NOTIFYSIGNALSTRENGTHCHANGE_1, ">>CSimSignalStrength::NotifySignalStrengthChange"); |
252 TPckg<TInt32>* ssPckg=(TPckg<TInt32>*)aPckg1; |
258 TPckg<TInt32>* ssPckg=(TPckg<TInt32>*)aPckg1; |
253 TInt32& ss=(*ssPckg)(); |
259 TInt32& ss=(*ssPckg)(); |
254 TPckg<TInt8>* ssbPckg=(TPckg<TInt8>*)aPckg2; |
260 TPckg<TInt8>* ssbPckg=(TPckg<TInt8>*)aPckg2; |
255 TInt8& ssb=(*ssbPckg)(); |
261 TInt8& ssb=(*ssbPckg)(); |
256 |
262 |
273 * Cancel a previous request to be notified of a change in signal strength. |
279 * Cancel a previous request to be notified of a change in signal strength. |
274 */ |
280 */ |
275 { |
281 { |
276 if(iSSChangeNotificationPending) |
282 if(iSSChangeNotificationPending) |
277 { |
283 { |
278 LOGSS1("CSimSignalStrength::NotifySignalStrengthChange has been cancelled"); |
284 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_NOTIFYSIGNALSTRENGTHCHANGECANCEL_1, "CSimSignalStrength::NotifySignalStrengthChange has been cancelled"); |
279 iSSChangeNotificationPending=EFalse; |
285 iSSChangeNotificationPending=EFalse; |
280 iPhone->ReqCompleted(iSSChangeNotificationReqHandle,KErrCancel); |
286 iPhone->ReqCompleted(iSSChangeNotificationReqHandle,KErrCancel); |
281 } |
287 } |
282 else |
288 else |
283 LOGSS1("CSimSignalStrength::NotifySignalStrengthChange was not outstanding and hasn't been cancelled"); |
289 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_NOTIFYSIGNALSTRENGTHCHANGECANCEL_2, "CSimSignalStrength::NotifySignalStrengthChange was not outstanding and hasn't been cancelled"); |
284 } |
290 } |
285 |
291 |
286 void CSimSignalStrength::TimerCallBack(TInt /*aId*/) |
292 void CSimSignalStrength::TimerCallBack(TInt /*aId*/) |
287 /** |
293 /** |
288 * The timer callback function. This function will be called when the timer |
294 * The timer callback function. This function will be called when the timer |
306 if(iSSChangeNotificationPending) |
312 if(iSSChangeNotificationPending) |
307 { |
313 { |
308 iSSChangeNotificationPending=EFalse; |
314 iSSChangeNotificationPending=EFalse; |
309 *iSSChangeNotificationSSLevel=iCurrentLevel; |
315 *iSSChangeNotificationSSLevel=iCurrentLevel; |
310 *iSSChangeNotificationSSBarLevel=iCurrentBar; |
316 *iSSChangeNotificationSSBarLevel=iCurrentBar; |
311 LOGSS3("<<CSimSignalStrength::NotifySignalStrengthChange with level=%d dB and bar=%d",iCurrentLevel,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); |
312 iPhone->ReqCompleted(iSSChangeNotificationReqHandle,iCurrentError); |
318 iPhone->ReqCompleted(iSSChangeNotificationReqHandle,iCurrentError); |
313 } |
319 } |
314 iTimer->Start(iSignalStrengthInfo->At(iSSIndex).iDuration,this); |
320 iTimer->Start(iSignalStrengthInfo->At(iSSIndex).iDuration,this); |
315 } |
321 } |
316 |
322 |
329 * |
335 * |
330 * @param aNewVal The new signal strength value (number of bars) |
336 * @param aNewVal The new signal strength value (number of bars) |
331 */ |
337 */ |
332 void CSimSignalStrength::PubSubCallback(TInt aNewVal) |
338 void CSimSignalStrength::PubSubCallback(TInt aNewVal) |
333 { |
339 { |
334 LOGSS2("CSimSignalStrength::SignalStrengthChangeCallBack newVal=%d", aNewVal); |
340 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSIGNALSTRENGTH_PUBSUBCALLBACK_1, "CSimSignalStrength::SignalStrengthChangeCallBack newVal=%d", aNewVal); |
335 if (iCurrentBar == aNewVal) |
341 if (iCurrentBar == aNewVal) |
336 { |
342 { |
337 return; |
343 return; |
338 } |
344 } |
339 iCurrentBar = (TInt8) aNewVal; |
345 iCurrentBar = (TInt8) aNewVal; |
340 if(iSSChangeNotificationPending) |
346 if(iSSChangeNotificationPending) |
341 { |
347 { |
342 iSSChangeNotificationPending=EFalse; |
348 iSSChangeNotificationPending=EFalse; |
343 *iSSChangeNotificationSSLevel=iCurrentLevel; |
349 *iSSChangeNotificationSSLevel=iCurrentLevel; |
344 *iSSChangeNotificationSSBarLevel=iCurrentBar; |
350 *iSSChangeNotificationSSBarLevel=iCurrentBar; |
345 LOGSS3("<<CSimSignalStrength::NotifySignalStrengthChange with level=%d dB and bar=%d",iCurrentLevel,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); |
346 iPhone->ReqCompleted(iSSChangeNotificationReqHandle,iCurrentError); |
352 iPhone->ReqCompleted(iSSChangeNotificationReqHandle,iCurrentError); |
347 } |
353 } |
348 } |
354 } |