|
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 iTrace->Trace(_L("Starting Encoding...SUPL_END"), KTraceFileName, __LINE__); |
|
212 |
|
213 TInt error = KErrNone; |
|
214 HBufC8 *encodedBuffer = NULL; |
|
215 |
|
216 TRAPD(err,encodedBuffer = iOMASuplAsnHandlerBase->EncodeL(OMASuplEnd,error)); |
|
217 |
|
218 CleanupStack::PopAndDestroy(OMASuplEnd); |
|
219 |
|
220 iTrace->Trace(_L("Encoding Done..."), KTraceFileName, __LINE__); |
|
221 |
|
222 if ( error == KErrNone && err == KErrNone ) |
|
223 { |
|
224 aError = KErrNone; |
|
225 return encodedBuffer; |
|
226 } |
|
227 else |
|
228 { |
|
229 iTrace->Trace(_L("Encoding Failed."), KTraceFileName, __LINE__); |
|
230 aError = error; |
|
231 delete encodedBuffer; |
|
232 encodedBuffer = NULL; |
|
233 } |
|
234 |
|
235 return NULL; |
|
236 } |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // COMASuplEndState::StartTimer |
|
240 // StartTimer...starts the timer ... depending on type of message |
|
241 // (other items were commented in a header). |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 void COMASuplEndState::StartTimer() |
|
245 { |
|
246 iTrace->Trace(_L("COMASuplEndState::StartTimer...No Use."), KTraceFileName, __LINE__); |
|
247 } |
|
248 |
|
249 |
|
250 // ----------------------------------------------------------------------------- |
|
251 // COMASuplEndState::ComputeSuplEndVerL |
|
252 // Generates SUPL_POS_INIT message |
|
253 // (other items were commented in a header). |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 TBool COMASuplEndState::ComputeSuplEndVerL() |
|
257 { |
|
258 if(!iEncodedSuplInit) //Terminal initiated case |
|
259 { |
|
260 return ETrue; |
|
261 } |
|
262 |
|
263 if(iEncodedSuplInit && (iEncodedSuplInit->Length()) > 0 && |
|
264 iHSLPAddress && iHSLPAddress->Length() > 0) |
|
265 { |
|
266 TInt blockSize = 64; |
|
267 TChar ipad = 0x36; |
|
268 TChar opad = 0x5c; |
|
269 TBuf8<64> key0; |
|
270 TInt i; |
|
271 |
|
272 CMessageDigest* sha1 = CMessageDigestFactory::NewDigestLC( |
|
273 CMessageDigest::ESHA1 ); |
|
274 |
|
275 // Step 1: Append 0x00 to the key to create a string of size = blocksize |
|
276 key0.SetLength( blockSize ); |
|
277 key0.FillZ(); |
|
278 |
|
279 if ( iHSLPAddress->Length() != blockSize ) |
|
280 { |
|
281 // If key greater than the block size of digest which is 64 |
|
282 // then hash the key to get a 20 byte code |
|
283 if ( iHSLPAddress->Length() > blockSize ) |
|
284 { |
|
285 TPtrC8 hashedKey = sha1->Hash(*iHSLPAddress ); |
|
286 for ( i = 0; i < hashedKey.Length(); i++ ) |
|
287 { |
|
288 key0[i] = hashedKey[i]; |
|
289 } |
|
290 sha1->Reset(); |
|
291 } |
|
292 else if ( iHSLPAddress->Length() < blockSize ) |
|
293 { |
|
294 for ( i = 0; i < iHSLPAddress->Length(); i++ ) |
|
295 { |
|
296 key0[i] = (*iHSLPAddress)[i]; |
|
297 } |
|
298 } |
|
299 } |
|
300 else |
|
301 { |
|
302 for ( i = 0; i < iHSLPAddress->Length(); i++ ) |
|
303 { |
|
304 key0[i] = (*iHSLPAddress)[i]; |
|
305 } |
|
306 } |
|
307 |
|
308 |
|
309 // Step 2: XOR the string obtained in Step 1 with ipad |
|
310 for ( TInt i = 0; i < blockSize; i++ ) |
|
311 { |
|
312 iRes.Append( key0[i] ^ ipad ); |
|
313 } |
|
314 |
|
315 #ifdef PRINT_MESSAGE |
|
316 iTrace->Trace(_L("ipad of server address "), KTraceFileName, __LINE__); |
|
317 PrintHex(iRes,__LINE__); |
|
318 #endif |
|
319 |
|
320 // Step 3: Append the message to the string resulting from Step 2 |
|
321 HBufC8* messageKeyString = |
|
322 HBufC8::NewLC( iEncodedSuplInit->Size() + iRes.Size() ); |
|
323 messageKeyString->Des().Append( iRes ); |
|
324 messageKeyString->Des().Append( *iEncodedSuplInit ); |
|
325 |
|
326 |
|
327 // Step 4: Generate hash code of the string resulting in Step 3 |
|
328 iRes.FillZ(); |
|
329 iRes.Zero(); |
|
330 TPtrC8 innerHashedMessage = sha1->Hash( messageKeyString->Des() ); |
|
331 HBufC8* step4Msg = HBufC8::NewLC(innerHashedMessage.Size()); |
|
332 step4Msg->Des().Append(innerHashedMessage); |
|
333 sha1->Reset(); |
|
334 // Truncate the hash output to 64 bits |
|
335 |
|
336 |
|
337 // Step 5: XOR the string obtained in Step 1 with opad |
|
338 |
|
339 HBufC8* hmacString = HBufC8::NewLC( step4Msg->Size() + blockSize ); |
|
340 for ( TInt i = 0; i < blockSize; i++ ) |
|
341 { |
|
342 hmacString->Des().Append( key0[i] ^ opad ); |
|
343 } |
|
344 |
|
345 #ifdef PRINT_MESSAGE |
|
346 iTrace->Trace(_L("xor ofserver address with opad"), KTraceFileName, __LINE__); |
|
347 PrintHex(hmacString->Des(),__LINE__); |
|
348 #endif |
|
349 |
|
350 // Step 6: Append the string obtained in step 4 to the string |
|
351 // obtained in Step 5 |
|
352 |
|
353 hmacString->Des().Append( step4Msg->Des() ); |
|
354 |
|
355 |
|
356 // Step 7: Generate hash code of the string resulting from Step 6 |
|
357 iRes.FillZ(); |
|
358 iRes.Zero(); |
|
359 TPtrC8 hmacSha1Code = sha1->Hash( hmacString->Des() ); |
|
360 |
|
361 // Truncate hash output to 64 bits |
|
362 iRes.Copy( hmacSha1Code.Ptr(), 8 ); |
|
363 |
|
364 CleanupStack::PopAndDestroy( hmacString ); |
|
365 CleanupStack::PopAndDestroy( step4Msg ); |
|
366 CleanupStack::PopAndDestroy( messageKeyString ); |
|
367 CleanupStack::PopAndDestroy( sha1 ); |
|
368 |
|
369 #ifdef PRINT_MESSAGE |
|
370 iTrace->Trace(_L("Final ver..."), KTraceFileName, __LINE__); |
|
371 PrintHex(iRes,__LINE__); |
|
372 #endif |
|
373 return ETrue; |
|
374 |
|
375 } |
|
376 |
|
377 return EFalse; |
|
378 } |
|
379 |
|
380 |
|
381 // ----------------------------------------------------------------------------- |
|
382 // COMASuplEndState::ProcessMessage |
|
383 // process message... |
|
384 // (other items were commented in a header). |
|
385 // ----------------------------------------------------------------------------- |
|
386 // |
|
387 TInt COMASuplEndState::ProcessMessageL(COMASuplAsnMessageBase* aDecodedMessage) |
|
388 { |
|
389 |
|
390 COMASuplEnd* OMASuplEnd = static_cast <COMASuplEnd *>(aDecodedMessage); |
|
391 COMASuplEnd::TOMASuplStatusCode statusCode; |
|
392 TInt error = OMASuplEnd->StatusCode(statusCode); |
|
393 iStatusCode = statusCode; |
|
394 OMASuplEnd->Position(iOMASuplPosition); |
|
395 LogReceivedPosition(); |
|
396 |
|
397 if(error == KErrOMASuplParamNotSet ) |
|
398 { |
|
399 //OMASuplEnd->Position(iOMASuplPosition); // Changed by Manish |
|
400 return KErrNone; |
|
401 } |
|
402 else |
|
403 { |
|
404 return KErrCompletion; //Error in status code |
|
405 } |
|
406 } |
|
407 |
|
408 // ----------------------------------------------------------------------------- |
|
409 // COMASuplEndState::CancelOperation |
|
410 // Cancels Operation...Cancels operation |
|
411 // (other items were commented in a header). |
|
412 // ----------------------------------------------------------------------------- |
|
413 // |
|
414 void COMASuplEndState::CancelOperation() |
|
415 { |
|
416 COMASuplState::CancelOperation(); |
|
417 iTrace->Trace(_L("COMASuplEndState::CancelOperation..."), KTraceFileName, __LINE__); |
|
418 } |
|
419 |
|
420 // ----------------------------------------------------------------------------- |
|
421 // COMASuplEndState::GetPosition |
|
422 // Retrive Position |
|
423 // (other items were commented in a header). |
|
424 // ----------------------------------------------------------------------------- |
|
425 // |
|
426 COMASuplPosition* COMASuplEndState::GetPosition() const |
|
427 { |
|
428 return iOMASuplPosition; |
|
429 } |
|
430 |
|
431 void COMASuplEndState::LogReceivedPosition() const |
|
432 { |
|
433 #ifdef PRINT_MESSAGE |
|
434 if (iOMASuplPosition) |
|
435 { |
|
436 TBuf <300> positionLog; |
|
437 positionLog.Copy(_L("-------Position Log in SUPL END------------")); |
|
438 TOMASuplUtcTime utcTime; |
|
439 TOMASuplPositionEstimate posEstimate; |
|
440 TDateTime lDateTime; |
|
441 TInt zoneCode; |
|
442 TInt zone; |
|
443 |
|
444 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
445 iOMASuplPosition->GetPosition(utcTime,posEstimate ); |
|
446 utcTime.GetUtcTime(lDateTime,zoneCode,zone); |
|
447 |
|
448 positionLog.Copy(_L("UTC Time Log : ")); |
|
449 positionLog.Append(_L("Year : ")); |
|
450 positionLog.AppendNum(lDateTime.Year()); |
|
451 positionLog.Append(_L("Month : ")); |
|
452 positionLog.AppendNum(lDateTime.Month()); |
|
453 positionLog.Append(_L("Day : ")); |
|
454 positionLog.AppendNum(lDateTime.Day()); |
|
455 positionLog.Append(_L("Hour : ")); |
|
456 positionLog.AppendNum(lDateTime.Hour()); |
|
457 positionLog.Append(_L("Minute : ")); |
|
458 positionLog.AppendNum(lDateTime.Minute()); |
|
459 positionLog.Append(_L("Second : ")); |
|
460 positionLog.AppendNum(lDateTime.Second()); |
|
461 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
462 positionLog.Copy(_L("MicroSecond : ")); |
|
463 positionLog.AppendNum(lDateTime.MicroSecond()); |
|
464 positionLog.Append(_L("Zone Code : ")); |
|
465 positionLog.AppendNum(zoneCode); |
|
466 positionLog.Append(_L("Zone : ")); |
|
467 positionLog.AppendNum(zone); |
|
468 |
|
469 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
470 |
|
471 TOMASuplPositionEstimate::TOMASuplLatitudeSign latSign; |
|
472 TInt latitude; |
|
473 TInt longitude; |
|
474 posEstimate.GetPositionEstimate(latSign,latitude,longitude); |
|
475 positionLog.Copy(_L("Position Estimate : ")); |
|
476 positionLog.Append(_L("latitude Sign : ")); |
|
477 positionLog.AppendNum(latSign); |
|
478 positionLog.Append(_L(" Latitude : ")); |
|
479 positionLog.AppendNum(latitude); |
|
480 positionLog.Append(_L(" Longitude : ")); |
|
481 positionLog.AppendNum(longitude); |
|
482 |
|
483 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
484 |
|
485 TOMASuplUncertainty uncertainty; |
|
486 TInt logError = posEstimate.GetUncertainty(uncertainty); |
|
487 if(!logError) |
|
488 { |
|
489 TInt uncertSemiMajor; |
|
490 TInt uncertSemiMinor; |
|
491 TInt orientMajorAxis; |
|
492 uncertainty.GetUncertainty(uncertSemiMajor,uncertSemiMinor,orientMajorAxis); |
|
493 |
|
494 positionLog.Copy(_L("Uncertainity Semi Major : ")); |
|
495 positionLog.AppendNum(uncertSemiMajor); |
|
496 positionLog.Append(_L(" Uncertainity Semi Minor : ")); |
|
497 positionLog.AppendNum(uncertSemiMinor); |
|
498 positionLog.Append(_L(" Orientation Major Axis : ")); |
|
499 positionLog.AppendNum(orientMajorAxis); |
|
500 } |
|
501 |
|
502 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
503 // Retrieve Confidence |
|
504 TInt confidence; |
|
505 logError = posEstimate.GetConfidence(confidence); |
|
506 if(!logError) |
|
507 { |
|
508 positionLog.Copy(_L("Confidence in Position : ")); |
|
509 positionLog.AppendNum(confidence); |
|
510 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
511 } |
|
512 |
|
513 TOMASuplAltitudeInfo altitudeInfo; |
|
514 logError = posEstimate.GetAltitudeInfo(altitudeInfo); |
|
515 if(!logError) |
|
516 { |
|
517 TOMASuplAltitudeInfo::TOMASuplAltitudeDirection altDirection; |
|
518 TInt altitude; |
|
519 TInt altUncert; |
|
520 altitudeInfo.GetAltitudeInfo(altDirection,altitude,altUncert); |
|
521 |
|
522 positionLog.Copy(_L("Altitude Information ")); |
|
523 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
524 |
|
525 positionLog.Copy(_L("Altitude Direction : ")); |
|
526 positionLog.AppendNum(altDirection); |
|
527 positionLog.Append(_L(" Altitude : ")); |
|
528 positionLog.AppendNum(altitude); |
|
529 positionLog.Append(_L(" Altitude Uncertainity : ")); |
|
530 positionLog.AppendNum(altUncert); |
|
531 } |
|
532 iTrace->Trace(positionLog, KTraceFileName, __LINE__); |
|
533 |
|
534 COMASuplVelocity* velocity = NULL; |
|
535 logError = iOMASuplPosition->GetVelocity(velocity); |
|
536 if(!logError) |
|
537 { |
|
538 iTrace->Trace(_L("Velocity Information"), KTraceFileName, __LINE__); |
|
539 if(velocity) |
|
540 { |
|
541 TBuf<256> msg; |
|
542 TOMASuplVelocityType velocityType = velocity->VelType(); |
|
543 COMASuplHorizVelocity* horizVelocity = velocity->Velocity(); |
|
544 TUint16 bearing; |
|
545 TUint16 horSpeed; |
|
546 switch(velocityType) |
|
547 { |
|
548 case EHorizVelocity: |
|
549 { |
|
550 iTrace->Trace(_L("Velocity Type : EHorizVelocity - Values "), KTraceFileName, __LINE__); |
|
551 horizVelocity->GetHorizVel(bearing,horSpeed); |
|
552 |
|
553 msg.Copy(_L("Bearing : ")); |
|
554 msg.AppendNum(bearing); |
|
555 msg.Append(_L(" Horizontal Speed : ")); |
|
556 msg.AppendNum(horSpeed); |
|
557 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
558 break; |
|
559 } |
|
560 case EHorizAndVertVelocity: |
|
561 { |
|
562 TUint8 verDirect; |
|
563 TUint8 verSpeed; |
|
564 COMASuplHorizAndVertVelocity* horizVertVel = (COMASuplHorizAndVertVelocity*)horizVelocity; |
|
565 horizVertVel->GetHorizAndVertVel(bearing,horSpeed,verDirect,verSpeed); |
|
566 |
|
567 iTrace->Trace(_L("Velocity Type : EHorizVelocity - Values "), KTraceFileName, __LINE__); |
|
568 |
|
569 msg.Copy(_L("Bearing : ")); |
|
570 msg.AppendNum(bearing); |
|
571 msg.Append(_L(" Horizontal Speed : ")); |
|
572 msg.AppendNum(horSpeed); |
|
573 msg.Append(_L(" Vertical Direction : ")); |
|
574 msg.AppendNum(verDirect); |
|
575 msg.Append(_L(" Vertical Speed : ")); |
|
576 msg.AppendNum(verSpeed); |
|
577 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
578 |
|
579 break; |
|
580 } |
|
581 case EHorizUncertVelocity: |
|
582 { |
|
583 TUint8 uncertSpeed; |
|
584 COMASuplHorizUncertVelocity* horizUncertVel = (COMASuplHorizUncertVelocity*)horizVelocity; |
|
585 |
|
586 horizUncertVel->GetHorizUncertVel(bearing,horSpeed,uncertSpeed); |
|
587 |
|
588 iTrace->Trace(_L("Velocity Type : EHorizUncertVelocity - Values "), KTraceFileName, __LINE__); |
|
589 |
|
590 msg.Copy(_L("Bearing : ")); |
|
591 msg.AppendNum(bearing); |
|
592 msg.Append(_L(" Horizontal Speed : ")); |
|
593 msg.AppendNum(horSpeed); |
|
594 msg.Append(_L(" Uncertainity Speed : ")); |
|
595 msg.AppendNum(uncertSpeed); |
|
596 |
|
597 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
598 |
|
599 break; |
|
600 } |
|
601 case EHorizAndVertUncertVelocity: |
|
602 { |
|
603 TUint8 verDirect; |
|
604 TUint8 verSpeed; |
|
605 TUint8 horizUncertSpeed; |
|
606 TUint8 vertUncertSpeed; |
|
607 |
|
608 COMASuplHorizAndVertUncertVelocity* horizVertUncertVel = (COMASuplHorizAndVertUncertVelocity*)horizVelocity; |
|
609 |
|
610 horizVertUncertVel->GetHorizVertUncertVel(bearing,horSpeed,verDirect,verSpeed, |
|
611 horizUncertSpeed,vertUncertSpeed); |
|
612 |
|
613 iTrace->Trace(_L("Velocity Type : EHorizAndVertUncertVelocity - Values "), KTraceFileName, __LINE__); |
|
614 |
|
615 msg.Copy(_L("Bearing : ")); |
|
616 msg.AppendNum(bearing); |
|
617 msg.Append(_L(" Horizontal Speed : ")); |
|
618 msg.AppendNum(horSpeed); |
|
619 msg.Append(_L(" Vertical Direction : ")); |
|
620 msg.AppendNum(verDirect); |
|
621 msg.Append(_L(" Vertical Speed : ")); |
|
622 msg.AppendNum(verSpeed); |
|
623 msg.Append(_L(" Horiz Uncertain Speed : ")); |
|
624 msg.AppendNum(horizUncertSpeed); |
|
625 msg.Append(_L(" Vertical Uncertain Speed : ")); |
|
626 msg.AppendNum(vertUncertSpeed); |
|
627 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
628 break; |
|
629 } |
|
630 } |
|
631 } |
|
632 } |
|
633 } |
|
634 #endif |
|
635 |
|
636 } |
|
637 |
|
638 void COMASuplEndState::PrintHex(const TDesC8& |
|
639 #ifdef PRINT_MESSAGE |
|
640 aBuffer |
|
641 #endif |
|
642 ,TInt |
|
643 #ifdef PRINT_MESSAGE |
|
644 aLine |
|
645 #endif |
|
646 ) |
|
647 { |
|
648 #ifdef PRINT_MESSAGE |
|
649 TBuf<256> buffer; |
|
650 TBuf<2> buff; |
|
651 _LIT16(KFormat1,"%02x"); |
|
652 TInt len = aBuffer.Length(); |
|
653 for(TInt i = 0 ; i <len; i++) |
|
654 { |
|
655 buff.Zero(); |
|
656 buff.Format(KFormat1,aBuffer[i]); |
|
657 buffer.Append(buff); |
|
658 buffer.Append(_L(" ")); |
|
659 } |
|
660 |
|
661 iTrace->Trace(buffer, KTraceFileName, aLine); |
|
662 #endif |
|
663 } |
|
664 |
|
665 COMASuplEnd::TOMASuplStatusCode COMASuplEndState::GetStatusCode() |
|
666 { |
|
667 return iStatusCode; |
|
668 } |
|
669 // End of File |
|
670 |
|
671 |
|
672 |
|
673 |