|
1 /* |
|
2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Class for handling SUPL_END message. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <hash.h> |
|
21 |
|
22 #include "epos_comasuplend.h" |
|
23 #include "lbs/epos_comasuplposition.h" |
|
24 #include "lbs/epos_eomasuplposerrors.h" |
|
25 #include "lbs/epos_comasuplvelocity.h" |
|
26 |
|
27 #include "epos_comasupltrace.h" |
|
28 #include "epos_comasuplendstate.h" |
|
29 #include "epos_omasuplconstants.h" |
|
30 |
|
31 #include "epos_comasuplasnbase.h" |
|
32 |
|
33 _LIT(KTraceFileName,"SUPL_OMA_SESSION::EPos_COMASuplEndState.cpp"); |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // COMASuplEndState::COMASuplEndState |
|
39 // C++ constructor can NOT contain any code, that might leave. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 COMASuplEndState::COMASuplEndState(COMASuplEnd::TOMASuplStatusCode aStatusCode,COMASuplAsnHandlerBase* aOMASuplAsnHandlerBase): |
|
43 iOMASuplAsnHandlerBase(aOMASuplAsnHandlerBase) |
|
44 { |
|
45 iMessageTimeOut = 0; |
|
46 iCurrentState = ESUPL_END; |
|
47 iStatusCode = aStatusCode; |
|
48 iSetStatusCode = ETrue; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // COMASuplEndState::COMASuplEndState |
|
53 // C++ constructor can NOT contain any code, that might leave. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 COMASuplEndState::COMASuplEndState(COMASuplAsnHandlerBase* aOMASuplAsnHandlerBase):iOMASuplAsnHandlerBase(aOMASuplAsnHandlerBase) |
|
57 { |
|
58 iMessageTimeOut = 0; |
|
59 iCurrentState = ESUPL_END; |
|
60 iSetStatusCode = EFalse; |
|
61 } |
|
62 // ----------------------------------------------------------------------------- |
|
63 // COMASuplEndState::~COMASuplEndState |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 COMASuplEndState::~COMASuplEndState() |
|
67 { |
|
68 delete iHSLPAddress; |
|
69 delete iEncodedSuplInit; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // COMASuplEndState::ConstructL |
|
74 // Symbian 2nd phase constructor can leave. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void COMASuplEndState::ConstructL(HBufC8* aEncodedSuplInit, HBufC8* aHSLPAddress) |
|
78 { |
|
79 COMASuplState::BaseConstructL(); |
|
80 iTrace->Trace(_L("COMASuplEndState::ConstructL..."), KTraceFileName, __LINE__); |
|
81 |
|
82 if(aEncodedSuplInit) |
|
83 { |
|
84 TInt len = aEncodedSuplInit->Length(); |
|
85 if(len > 0) |
|
86 { |
|
87 iEncodedSuplInit = HBufC8::NewL(len); |
|
88 *iEncodedSuplInit = *aEncodedSuplInit; |
|
89 } |
|
90 |
|
91 } |
|
92 |
|
93 if(aHSLPAddress) |
|
94 { |
|
95 TInt len = aHSLPAddress->Length(); |
|
96 |
|
97 if(len > 0) |
|
98 { |
|
99 iHSLPAddress = HBufC8::NewL(len); |
|
100 *iHSLPAddress = *aHSLPAddress; |
|
101 } |
|
102 |
|
103 } |
|
104 |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // COMASuplEndState::NewL |
|
109 // Two-phased constructor. |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 COMASuplEndState* COMASuplEndState::NewL(COMASuplEnd::TOMASuplStatusCode aStatusCode,COMASuplAsnHandlerBase* aOMASuplAsnHandlerBase, |
|
113 HBufC8* aEncodedSuplInit, |
|
114 HBufC8* aHSLPAddress) |
|
115 { |
|
116 COMASuplEndState* self = new ( ELeave ) COMASuplEndState(aStatusCode,aOMASuplAsnHandlerBase); |
|
117 CleanupStack::PushL( self ); |
|
118 self->ConstructL(aEncodedSuplInit, aHSLPAddress); |
|
119 CleanupStack::Pop(self); |
|
120 return self; |
|
121 } |
|
122 // ----------------------------------------------------------------------------- |
|
123 // COMASuplEndState::NewL |
|
124 // Two-phased constructor. |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 COMASuplEndState* COMASuplEndState::NewL(COMASuplAsnHandlerBase* aOMASuplAsnHandlerBase,HBufC8* aEncodedSuplInit, HBufC8* aHSLPAddress) |
|
128 { |
|
129 COMASuplEndState* self = new ( ELeave ) COMASuplEndState(aOMASuplAsnHandlerBase); |
|
130 CleanupStack::PushL( self ); |
|
131 self->ConstructL(aEncodedSuplInit, aHSLPAddress); |
|
132 CleanupStack::Pop(self); |
|
133 return self; |
|
134 } |
|
135 // ----------------------------------------------------------------------------- |
|
136 // COMASuplEndState::GenerateMessage |
|
137 // Generates SUPL_END message |
|
138 // (other items were commented in a header). |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 TInt COMASuplEndState::GenerateMessageL() |
|
142 { |
|
143 iTrace->Trace(_L("Start of COMASuplEndState::GenerateMessage"), KTraceFileName, __LINE__); |
|
144 if(iEncodedSuplInit) |
|
145 { |
|
146 iVerPresent = ComputeSuplEndVerL(); |
|
147 |
|
148 if(iVerPresent) |
|
149 { |
|
150 if(iMsgStateObserver) |
|
151 { |
|
152 iMsgStateObserver->OperationCompleteL(KErrNone); |
|
153 return KErrNone; |
|
154 } |
|
155 |
|
156 } |
|
157 else |
|
158 { |
|
159 iMsgStateObserver->OperationCompleteL(KErrGeneral); |
|
160 return KErrGeneral; |
|
161 } |
|
162 } |
|
163 else |
|
164 { |
|
165 if(iMsgStateObserver) |
|
166 { |
|
167 iMsgStateObserver->OperationCompleteL(KErrNone); |
|
168 return KErrNone; |
|
169 } |
|
170 } |
|
171 |
|
172 return KErrNone; |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // COMASuplEndState::EncodeMessageL |
|
177 // Encodes message ...returns encoded data |
|
178 // (other items were commented in a header). |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 HBufC8* COMASuplEndState::EncodeMessageL(TOMASuplVersion &aSuplVersion,COMASuplSessionID* aSessionId, |
|
182 TInt &aError) |
|
183 { |
|
184 iTrace->Trace(_L("Start of COMASuplEndState::Encode_SUPL_END"), KTraceFileName, __LINE__); |
|
185 |
|
186 COMASuplState::EncodeMessageL(aSuplVersion,aSessionId,aError); |
|
187 |
|
188 |
|
189 COMASuplAsnMessageBase* OMASuplMessageBase = iOMASuplAsnHandlerBase->CreateOMASuplMessageL(COMASuplAsnMessageBase::ESUPL_END); |
|
190 CleanupStack::PushL(OMASuplMessageBase); |
|
191 COMASuplEnd* OMASuplEnd = static_cast<COMASuplEnd*>(OMASuplMessageBase); |
|
192 |
|
193 iTrace->Trace(_L("**************** SUPL END **********************"), KTraceFileName, __LINE__); |
|
194 iTrace->Trace(_L("Created COMASuplEnd"), KTraceFileName, __LINE__); |
|
195 |
|
196 OMASuplEnd->SetMessageBase(aSuplVersion,aSessionId); |
|
197 if(iSetStatusCode) |
|
198 { |
|
199 OMASuplEnd->SetStatusCode(iStatusCode); |
|
200 iTrace->Trace(_L("Status Code in SUPL_END :"), KTraceFileName, __LINE__); |
|
201 TBuf<64> Res; |
|
202 Res.AppendNum(iStatusCode); |
|
203 iTrace->Trace(Res, KTraceFileName, __LINE__); |
|
204 } |
|
205 |
|
206 if(iEncodedSuplInit) |
|
207 { |
|
208 OMASuplEnd->SetVer(iRes); |
|
209 |
|
210 } |
|
211 |
|
212 iTrace->Trace(_L("Starting Encoding...SUPL_END"), KTraceFileName, __LINE__); |
|
213 |
|
214 TInt error = KErrNone; |
|
215 HBufC8 *encodedBuffer = NULL; |
|
216 |
|
217 TRAPD(err,encodedBuffer = iOMASuplAsnHandlerBase->EncodeL(OMASuplEnd,error)); |
|
218 |
|
219 CleanupStack::PopAndDestroy(OMASuplEnd); |
|
220 |
|
221 iTrace->Trace(_L("Encoding Done..."), KTraceFileName, __LINE__); |
|
222 |
|
223 if ( error == KErrNone && err == KErrNone ) |
|
224 { |
|
225 aError = KErrNone; |
|
226 return encodedBuffer; |
|
227 } |
|
228 else |
|
229 { |
|
230 iTrace->Trace(_L("Encoding Failed."), KTraceFileName, __LINE__); |
|
231 aError = error; |
|
232 delete encodedBuffer; |
|
233 encodedBuffer = NULL; |
|
234 } |
|
235 |
|
236 return NULL; |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // COMASuplEndState::StartTimer |
|
241 // StartTimer...starts the timer ... depending on type of message |
|
242 // (other items were commented in a header). |
|
243 // ----------------------------------------------------------------------------- |
|
244 // |
|
245 void COMASuplEndState::StartTimer() |
|
246 { |
|
247 iTrace->Trace(_L("COMASuplEndState::StartTimer...No Use."), KTraceFileName, __LINE__); |
|
248 } |
|
249 |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // COMASuplEndState::ComputeSuplEndVerL |
|
253 // Generates SUPL_POS_INIT message |
|
254 // (other items were commented in a header). |
|
255 // ----------------------------------------------------------------------------- |
|
256 // |
|
257 TBool COMASuplEndState::ComputeSuplEndVerL() |
|
258 { |
|
259 if(!iEncodedSuplInit) //Terminal initiated case |
|
260 { |
|
261 return ETrue; |
|
262 } |
|
263 |
|
264 if(iEncodedSuplInit && (iEncodedSuplInit->Length()) > 0 && |
|
265 iHSLPAddress && iHSLPAddress->Length() > 0) |
|
266 { |
|
267 TInt blockSize = 64; |
|
268 TChar ipad = 0x36; |
|
269 TChar opad = 0x5c; |
|
270 TBuf8<64> key0; |
|
271 TInt i; |
|
272 |
|
273 CMessageDigest* sha1 = CMessageDigestFactory::NewDigestLC( |
|
274 CMessageDigest::ESHA1 ); |
|
275 |
|
276 // Step 1: Append 0x00 to the key to create a string of size = blocksize |
|
277 key0.SetLength( blockSize ); |
|
278 key0.FillZ(); |
|
279 |
|
280 if ( iHSLPAddress->Length() != blockSize ) |
|
281 { |
|
282 // If key greater than the block size of digest which is 64 |
|
283 // then hash the key to get a 20 byte code |
|
284 if ( iHSLPAddress->Length() > blockSize ) |
|
285 { |
|
286 TPtrC8 hashedKey = sha1->Hash(*iHSLPAddress ); |
|
287 for ( i = 0; i < hashedKey.Length(); i++ ) |
|
288 { |
|
289 key0[i] = hashedKey[i]; |
|
290 } |
|
291 sha1->Reset(); |
|
292 } |
|
293 else if ( iHSLPAddress->Length() < blockSize ) |
|
294 { |
|
295 for ( i = 0; i < iHSLPAddress->Length(); i++ ) |
|
296 { |
|
297 key0[i] = (*iHSLPAddress)[i]; |
|
298 } |
|
299 } |
|
300 } |
|
301 else |
|
302 { |
|
303 for ( i = 0; i < iHSLPAddress->Length(); i++ ) |
|
304 { |
|
305 key0[i] = (*iHSLPAddress)[i]; |
|
306 } |
|
307 } |
|
308 |
|
309 |
|
310 // Step 2: XOR the string obtained in Step 1 with ipad |
|
311 for ( TInt i = 0; i < blockSize; i++ ) |
|
312 { |
|
313 iRes.Append( key0[i] ^ ipad ); |
|
314 } |
|
315 |
|
316 #ifdef PRINT_MESSAGE |
|
317 iTrace->Trace(_L("ipad of server address "), KTraceFileName, __LINE__); |
|
318 PrintHex(iRes,__LINE__); |
|
319 #endif |
|
320 |
|
321 // Step 3: Append the message to the string resulting from Step 2 |
|
322 HBufC8* messageKeyString = |
|
323 HBufC8::NewLC( iEncodedSuplInit->Size() + iRes.Size() ); |
|
324 messageKeyString->Des().Append( iRes ); |
|
325 messageKeyString->Des().Append( *iEncodedSuplInit ); |
|
326 |
|
327 |
|
328 // Step 4: Generate hash code of the string resulting in Step 3 |
|
329 iRes.FillZ(); |
|
330 iRes.Zero(); |
|
331 TPtrC8 innerHashedMessage = sha1->Hash( messageKeyString->Des() ); |
|
332 HBufC8* step4Msg = HBufC8::NewLC(innerHashedMessage.Size()); |
|
333 step4Msg->Des().Append(innerHashedMessage); |
|
334 sha1->Reset(); |
|
335 // Truncate the hash output to 64 bits |
|
336 |
|
337 // Step 5: XOR the string obtained in Step 1 with opad |
|
338 HBufC8* hmacString = HBufC8::NewLC( step4Msg->Size() + blockSize ); |
|
339 for ( TInt i = 0; i < blockSize; i++ ) |
|
340 { |
|
341 hmacString->Des().Append( key0[i] ^ opad ); |
|
342 } |
|
343 |
|
344 #ifdef PRINT_MESSAGE |
|
345 iTrace->Trace(_L("xor ofserver address with opad"), KTraceFileName, __LINE__); |
|
346 PrintHex(hmacString->Des(),__LINE__); |
|
347 #endif |
|
348 |
|
349 // Step 6: Append the string obtained in step 4 to the string |
|
350 // obtained in Step 5 |
|
351 hmacString->Des().Append( step4Msg->Des() ); |
|
352 |
|
353 |
|
354 // Step 7: Generate hash code of the string resulting from Step 6 |
|
355 iRes.FillZ(); |
|
356 iRes.Zero(); |
|
357 TPtrC8 hmacSha1Code = sha1->Hash( hmacString->Des() ); |
|
358 |
|
359 // Truncate hash output to 64 bits |
|
360 iRes.Copy( hmacSha1Code.Ptr(), 8 ); |
|
361 |
|
362 CleanupStack::PopAndDestroy( hmacString ); |
|
363 CleanupStack::PopAndDestroy( step4Msg ); |
|
364 CleanupStack::PopAndDestroy( messageKeyString ); |
|
365 CleanupStack::PopAndDestroy( sha1 ); |
|
366 |
|
367 #ifdef PRINT_MESSAGE |
|
368 iTrace->Trace(_L("Final ver..."), KTraceFileName, __LINE__); |
|
369 PrintHex(iRes,__LINE__); |
|
370 #endif |
|
371 return ETrue; |
|
372 |
|
373 } |
|
374 |
|
375 return EFalse; |
|
376 } |
|
377 |
|
378 |
|
379 // ----------------------------------------------------------------------------- |
|
380 // COMASuplEndState::ProcessMessage |
|
381 // process message... |
|
382 // (other items were commented in a header). |
|
383 // ----------------------------------------------------------------------------- |
|
384 // |
|
385 TInt COMASuplEndState::ProcessMessageL(COMASuplAsnMessageBase* aDecodedMessage) |
|
386 { |
|
387 |
|
388 COMASuplEnd* OMASuplEnd = static_cast <COMASuplEnd *>(aDecodedMessage); |
|
389 COMASuplEnd::TOMASuplStatusCode statusCode; |
|
390 TInt error = OMASuplEnd->StatusCode(statusCode); |
|
391 iStatusCode = statusCode; |
|
392 OMASuplEnd->Position(iOMASuplPosition); |
|
393 LogReceivedPosition(); |
|
394 |
|
395 if(error == KErrOMASuplParamNotSet ) |
|
396 { |
|
397 return KErrNone; |
|
398 } |
|
399 else |
|
400 { |
|
401 return KErrCompletion; //Error in status code |
|
402 } |
|
403 } |
|
404 |
|
405 // ----------------------------------------------------------------------------- |
|
406 // COMASuplEndState::CancelOperation |
|
407 // Cancels Operation...Cancels operation |
|
408 // (other items were commented in a header). |
|
409 // ----------------------------------------------------------------------------- |
|
410 // |
|
411 void COMASuplEndState::CancelOperation() |
|
412 { |
|
413 COMASuplState::CancelOperation(); |
|
414 iTrace->Trace(_L("COMASuplEndState::CancelOperation..."), KTraceFileName, __LINE__); |
|
415 } |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
|
418 // COMASuplEndState::GetPosition |
|
419 // Retrive Position |
|
420 // (other items were commented in a header). |
|
421 // ----------------------------------------------------------------------------- |
|
422 // |
|
423 COMASuplPosition* COMASuplEndState::GetPosition() const |
|
424 { |
|
425 return iOMASuplPosition; |
|
426 } |
|
427 |
|
428 void COMASuplEndState::LogReceivedPosition() const |
|
429 { |
|
430 #ifdef PRINT_MESSAGE |
|
431 if (iOMASuplPosition) |
|
432 { |
|
433 TBuf <300> positionLog; |
|
434 positionLog.Copy(_L("-------Position Log in SUPL END------------")); |
|
435 TOMASuplUtcTime utcTime; |
|
436 TOMASuplPositionEstimate posEstimate; |
|
437 TDateTime lDateTime; |
|
438 TInt zoneCode; |
|
439 TInt zone; |
|
440 |
|
441 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
442 iOMASuplPosition->GetPosition(utcTime,posEstimate ); |
|
443 utcTime.GetUtcTime(lDateTime,zoneCode,zone); |
|
444 |
|
445 positionLog.Copy(_L("UTC Time Log : ")); |
|
446 positionLog.Append(_L("Year : ")); |
|
447 positionLog.AppendNum(lDateTime.Year()); |
|
448 positionLog.Append(_L("Month : ")); |
|
449 positionLog.AppendNum(lDateTime.Month()); |
|
450 positionLog.Append(_L("Day : ")); |
|
451 positionLog.AppendNum(lDateTime.Day()); |
|
452 positionLog.Append(_L("Hour : ")); |
|
453 positionLog.AppendNum(lDateTime.Hour()); |
|
454 positionLog.Append(_L("Minute : ")); |
|
455 positionLog.AppendNum(lDateTime.Minute()); |
|
456 positionLog.Append(_L("Second : ")); |
|
457 positionLog.AppendNum(lDateTime.Second()); |
|
458 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
459 positionLog.Copy(_L("MicroSecond : ")); |
|
460 positionLog.AppendNum(lDateTime.MicroSecond()); |
|
461 positionLog.Append(_L("Zone Code : ")); |
|
462 positionLog.AppendNum(zoneCode); |
|
463 positionLog.Append(_L("Zone : ")); |
|
464 positionLog.AppendNum(zone); |
|
465 |
|
466 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
467 |
|
468 TOMASuplPositionEstimate::TOMASuplLatitudeSign latSign; |
|
469 TInt latitude; |
|
470 TInt longitude; |
|
471 posEstimate.GetPositionEstimate(latSign,latitude,longitude); |
|
472 positionLog.Copy(_L("Position Estimate : ")); |
|
473 positionLog.Append(_L("latitude Sign : ")); |
|
474 positionLog.AppendNum(latSign); |
|
475 positionLog.Append(_L(" Latitude : ")); |
|
476 positionLog.AppendNum(latitude); |
|
477 positionLog.Append(_L(" Longitude : ")); |
|
478 positionLog.AppendNum(longitude); |
|
479 |
|
480 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
481 |
|
482 TOMASuplUncertainty uncertainty; |
|
483 TInt logError = posEstimate.GetUncertainty(uncertainty); |
|
484 if(!logError) |
|
485 { |
|
486 TInt uncertSemiMajor; |
|
487 TInt uncertSemiMinor; |
|
488 TInt orientMajorAxis; |
|
489 uncertainty.GetUncertainty(uncertSemiMajor,uncertSemiMinor,orientMajorAxis); |
|
490 |
|
491 positionLog.Copy(_L("Uncertainity Semi Major : ")); |
|
492 positionLog.AppendNum(uncertSemiMajor); |
|
493 positionLog.Append(_L(" Uncertainity Semi Minor : ")); |
|
494 positionLog.AppendNum(uncertSemiMinor); |
|
495 positionLog.Append(_L(" Orientation Major Axis : ")); |
|
496 positionLog.AppendNum(orientMajorAxis); |
|
497 } |
|
498 |
|
499 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
500 // Retrieve Confidence |
|
501 TInt confidence; |
|
502 logError = posEstimate.GetConfidence(confidence); |
|
503 if(!logError) |
|
504 { |
|
505 positionLog.Copy(_L("Confidence in Position : ")); |
|
506 positionLog.AppendNum(confidence); |
|
507 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
508 } |
|
509 |
|
510 TOMASuplAltitudeInfo altitudeInfo; |
|
511 logError = posEstimate.GetAltitudeInfo(altitudeInfo); |
|
512 if(!logError) |
|
513 { |
|
514 TOMASuplAltitudeInfo::TOMASuplAltitudeDirection altDirection; |
|
515 TInt altitude; |
|
516 TInt altUncert; |
|
517 altitudeInfo.GetAltitudeInfo(altDirection,altitude,altUncert); |
|
518 |
|
519 positionLog.Copy(_L("Altitude Information ")); |
|
520 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
521 |
|
522 positionLog.Copy(_L("Altitude Direction : ")); |
|
523 positionLog.AppendNum(altDirection); |
|
524 positionLog.Append(_L(" Altitude : ")); |
|
525 positionLog.AppendNum(altitude); |
|
526 positionLog.Append(_L(" Altitude Uncertainity : ")); |
|
527 positionLog.AppendNum(altUncert); |
|
528 } |
|
529 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
530 |
|
531 COMASuplVelocity* velocity = NULL; |
|
532 logError = iOMASuplPosition->GetVelocity(velocity); |
|
533 if(!logError) |
|
534 { |
|
535 iTrace->Trace(_L("Velocity Information"), KTraceFileName, __LINE__); |
|
536 if(velocity) |
|
537 { |
|
538 TBuf<256> msg; |
|
539 TOMASuplVelocityType velocityType = velocity->VelType(); |
|
540 COMASuplHorizVelocity* horizVelocity = velocity->Velocity(); |
|
541 TUint16 bearing; |
|
542 TUint16 horSpeed; |
|
543 switch(velocityType) |
|
544 { |
|
545 case EHorizVelocity: |
|
546 { |
|
547 iTrace->Trace(_L("Velocity Type : EHorizVelocity - Values "), KTraceFileName, __LINE__); |
|
548 horizVelocity->GetHorizVel(bearing,horSpeed); |
|
549 |
|
550 msg.Copy(_L("Bearing : ")); |
|
551 msg.AppendNum(bearing); |
|
552 msg.Append(_L(" Horizontal Speed : ")); |
|
553 msg.AppendNum(horSpeed); |
|
554 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
555 break; |
|
556 } |
|
557 case EHorizAndVertVelocity: |
|
558 { |
|
559 TUint8 verDirect; |
|
560 TUint8 verSpeed; |
|
561 COMASuplHorizAndVertVelocity* horizVertVel = (COMASuplHorizAndVertVelocity*)horizVelocity; |
|
562 horizVertVel->GetHorizAndVertVel(bearing,horSpeed,verDirect,verSpeed); |
|
563 |
|
564 iTrace->Trace(_L("Velocity Type : EHorizVelocity - Values "), KTraceFileName, __LINE__); |
|
565 |
|
566 msg.Copy(_L("Bearing : ")); |
|
567 msg.AppendNum(bearing); |
|
568 msg.Append(_L(" Horizontal Speed : ")); |
|
569 msg.AppendNum(horSpeed); |
|
570 msg.Append(_L(" Vertical Direction : ")); |
|
571 msg.AppendNum(verDirect); |
|
572 msg.Append(_L(" Vertical Speed : ")); |
|
573 msg.AppendNum(verSpeed); |
|
574 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
575 |
|
576 break; |
|
577 } |
|
578 case EHorizUncertVelocity: |
|
579 { |
|
580 TUint8 uncertSpeed; |
|
581 COMASuplHorizUncertVelocity* horizUncertVel = (COMASuplHorizUncertVelocity*)horizVelocity; |
|
582 |
|
583 horizUncertVel->GetHorizUncertVel(bearing,horSpeed,uncertSpeed); |
|
584 |
|
585 iTrace->Trace(_L("Velocity Type : EHorizUncertVelocity - Values "), KTraceFileName, __LINE__); |
|
586 |
|
587 msg.Copy(_L("Bearing : ")); |
|
588 msg.AppendNum(bearing); |
|
589 msg.Append(_L(" Horizontal Speed : ")); |
|
590 msg.AppendNum(horSpeed); |
|
591 msg.Append(_L(" Uncertainity Speed : ")); |
|
592 msg.AppendNum(uncertSpeed); |
|
593 |
|
594 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
595 |
|
596 break; |
|
597 } |
|
598 case EHorizAndVertUncertVelocity: |
|
599 { |
|
600 TUint8 verDirect; |
|
601 TUint8 verSpeed; |
|
602 TUint8 horizUncertSpeed; |
|
603 TUint8 vertUncertSpeed; |
|
604 |
|
605 COMASuplHorizAndVertUncertVelocity* horizVertUncertVel = (COMASuplHorizAndVertUncertVelocity*)horizVelocity; |
|
606 |
|
607 horizVertUncertVel->GetHorizVertUncertVel(bearing,horSpeed,verDirect,verSpeed, |
|
608 horizUncertSpeed,vertUncertSpeed); |
|
609 |
|
610 iTrace->Trace(_L("Velocity Type : EHorizAndVertUncertVelocity - Values "), KTraceFileName, __LINE__); |
|
611 |
|
612 msg.Copy(_L("Bearing : ")); |
|
613 msg.AppendNum(bearing); |
|
614 msg.Append(_L(" Horizontal Speed : ")); |
|
615 msg.AppendNum(horSpeed); |
|
616 msg.Append(_L(" Vertical Direction : ")); |
|
617 msg.AppendNum(verDirect); |
|
618 msg.Append(_L(" Vertical Speed : ")); |
|
619 msg.AppendNum(verSpeed); |
|
620 msg.Append(_L(" Horiz Uncertain Speed : ")); |
|
621 msg.AppendNum(horizUncertSpeed); |
|
622 msg.Append(_L(" Vertical Uncertain Speed : ")); |
|
623 msg.AppendNum(vertUncertSpeed); |
|
624 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
625 break; |
|
626 } |
|
627 } |
|
628 } |
|
629 } |
|
630 } |
|
631 #endif |
|
632 |
|
633 } |
|
634 |
|
635 void COMASuplEndState::PrintHex(const TDesC8& |
|
636 #ifdef PRINT_MESSAGE |
|
637 aBuffer |
|
638 #endif |
|
639 ,TInt |
|
640 #ifdef PRINT_MESSAGE |
|
641 aLine |
|
642 #endif |
|
643 ) |
|
644 { |
|
645 #ifdef PRINT_MESSAGE |
|
646 TBuf<256> buffer; |
|
647 TBuf<2> buff; |
|
648 _LIT16(KFormat1,"%02x"); |
|
649 TInt len = aBuffer.Length(); |
|
650 for(TInt i = 0 ; i <len; i++) |
|
651 { |
|
652 buff.Zero(); |
|
653 buff.Format(KFormat1,aBuffer[i]); |
|
654 buffer.Append(buff); |
|
655 buffer.Append(_L(" ")); |
|
656 } |
|
657 |
|
658 iTrace->Trace(buffer, KTraceFileName, aLine); |
|
659 #endif |
|
660 } |
|
661 |
|
662 COMASuplEnd::TOMASuplStatusCode COMASuplEndState::GetStatusCode() |
|
663 { |
|
664 return iStatusCode; |
|
665 } |
|
666 // End of File |
|
667 |
|
668 |
|
669 |
|
670 |