1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // csuplrrlpfsm.h |
|
15 // This file defines the class for the RRLP protocol state machine. |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalTechnology |
|
22 |
|
23 */ |
|
24 |
|
25 #ifndef __CSUPLRRLPFSM_H__ |
|
26 #define __CSUPLRRLPFSM_H__ |
|
27 |
|
28 #include <lbspositioninfo.h> |
|
29 |
|
30 #include "rrlpmessagebase.h" |
|
31 #include "rrlpmeasureposrequest.h" |
|
32 #include "rrlpprotocolerror.h" |
|
33 #include "suplpositioningprotocolfsm.h" |
|
34 |
|
35 // Forwards |
|
36 class CRrlpAssistanceData; |
|
37 class CRrlpAssistanceDataAck; |
|
38 |
|
39 /** This class implementes the RRLP protocol. |
|
40 |
|
41 Only those messages and parameters required by SUPL for AGPS positioning |
|
42 are supported. Optional parameters not related to AGPS are not implemented. |
|
43 |
|
44 @see CStateMachineBase |
|
45 |
|
46 The class also implements a timer observer interface defined by MLbsCallbackTimerObserver |
|
47 @see MLbsCallbackTimerObserver |
|
48 */ |
|
49 class CSuplRrlpFsm : public CSuplPositioningProtocolFsm, public MLbsCallbackTimerObserver |
|
50 { |
|
51 public: |
|
52 // Constructors |
|
53 IMPORT_C static CSuplRrlpFsm* NewL(MSuplPositioningProtocolFsmObserver& aObserver,RLbsAssistanceDataBuilderSet& aDataBuilder); |
|
54 virtual ~CSuplRrlpFsm(); |
|
55 |
|
56 // Methods derived from base class (must be implemented) |
|
57 IMPORT_C void ProcessPositioningMessage(CSuplPosPayload* aMessage); |
|
58 IMPORT_C void CancelMachine(const TCancelSource& aCancelSource, TInt aReason); |
|
59 IMPORT_C void AssistanceDataRequest(const TLbsAssistanceDataGroup& aMask); |
|
60 IMPORT_C void LocationResp(TInt aReason, const TPositionInfoBase& aPosInfo); |
|
61 IMPORT_C bool IsAssistDataRequestAllowed(); |
|
62 |
|
63 protected: |
|
64 // CActive |
|
65 void RunL(); |
|
66 void DoCancel(); |
|
67 |
|
68 private: |
|
69 /** RRLP states (when used with SUPL) |
|
70 These identify the current state within the |
|
71 RRLP procedure. |
|
72 */ |
|
73 enum TRrlpState |
|
74 { |
|
75 /** Not valid */ |
|
76 EStateNull, |
|
77 /** Assistance Data Message received (more on the way)*/ |
|
78 EStateAssitDataChunkRecvd, |
|
79 /** Assitance Data Message received (no more assistance data messages on the way) */ |
|
80 EStateAssitDataAcknowledged, |
|
81 /** Measure Position Request message received from the network */ |
|
82 EStateMeasureReqRecvd, |
|
83 /** A positioning request has been sent to SUPL */ |
|
84 EStateRequestHandled, |
|
85 /** A request for additional Assistance Data from LBS is sent to the network */ |
|
86 EStateMoreAssistDataRequested, |
|
87 /** Location response sent to network */ |
|
88 EStateMeasureRespSent, |
|
89 /** An error or a cancel has occured */ |
|
90 EStateErrorRecvd |
|
91 }; |
|
92 |
|
93 /** Timer ID's |
|
94 */ |
|
95 enum TTimerIds |
|
96 { |
|
97 EAssitanceDataChunk, |
|
98 ERequest, |
|
99 EResponseDelay, |
|
100 EMeasureRequestWithAssistanceDataDelay |
|
101 }; |
|
102 private: |
|
103 // Constructor |
|
104 CSuplRrlpFsm(MSuplPositioningProtocolFsmObserver& aObserver, RLbsAssistanceDataBuilderSet& aDataBuilder); |
|
105 void ConstructL(); |
|
106 |
|
107 // MLbsCallbackTimerObserver methods |
|
108 void OnTimerEventL(TInt aTimerId); |
|
109 TInt OnTimerError(TInt aTimerId, TInt aError); |
|
110 |
|
111 // Protocol Timers. |
|
112 void StartAssitanceDataChunkTimer(); |
|
113 void ReceivedAssistanceDataChunkTimer(); |
|
114 void StartRequestTimer(); |
|
115 void ReceivedRequestTimer(); |
|
116 void StartPosResultTimer(TTimeIntervalMicroSeconds aMicroSeconds); |
|
117 void ReceivedPosResultTimer(); |
|
118 // Other timers |
|
119 void StartMeasureRequestWithAssitanceDataTimer(TInt aTime); |
|
120 void ReceivedMeasureRequestWithAssitanceDataTimer(); |
|
121 |
|
122 // Handler functions |
|
123 void HandleAssistanceDataMessage(CRrlpAssistanceData* aData); |
|
124 void HandleMeasurementPositionRequest(CRrlpMeasurePositionRequest* aData); |
|
125 void HandleProtocolError(CRrlpProtocolError* aError); |
|
126 |
|
127 // Others |
|
128 TBool TransistionTo(TRrlpState aState); |
|
129 void TransistionToError(TInt aError); |
|
130 void AddReference(CRrlpMessageBase& aMessage); |
|
131 private: |
|
132 /** Current RRLP state |
|
133 */ |
|
134 TRrlpState iCurrentState; |
|
135 TRrlpState iNextState; |
|
136 |
|
137 /** Last reference number received |
|
138 */ |
|
139 TRrlpReference iLastReferenceNumber; |
|
140 |
|
141 /** Timer in between RRLP messages |
|
142 (it is a protocol error when this timer expires and more assistance data is expected) |
|
143 */ |
|
144 static const TInt KAssistanceDataChunkTimeout; |
|
145 CLbsCallbackTimer* iAssistanceDataChunkTimer; |
|
146 |
|
147 /** Timer for RRLP Measure Position Request after Assitance Data message |
|
148 (it is not always a protocol error when this timer expires) |
|
149 */ |
|
150 const static TInt KRequestTimeout; |
|
151 CLbsCallbackTimer* iRequestTimer; |
|
152 |
|
153 /** Timer for overseeing that LBS responds within the expected delay |
|
154 (the delay is specified in the RRLP Measure Position Request, this |
|
155 timer lasts longer to give LBS's response a chance to arrive before expiry) |
|
156 */ |
|
157 const static TInt KResponseDelayAddition; |
|
158 const static TInt KResponseDelayTimeout; |
|
159 CLbsCallbackTimer* iResponseDelayTimer; |
|
160 |
|
161 /** Timer for allowing assistance data to be processed by LBS if received |
|
162 in the Measurement Request |
|
163 */ |
|
164 const static TInt KMeasureRequestWithAssistanceDataDelay; |
|
165 CLbsCallbackTimer* iMeasureRequestWithAssitanceDataDelayTimer; |
|
166 |
|
167 /** Flag to show location request has been sent to LBS. |
|
168 */ |
|
169 TBool iIsLocReqSentToLbs; |
|
170 |
|
171 /** Location request quality. |
|
172 */ |
|
173 TLbsNetPosRequestQuality iLocReqQuality; |
|
174 |
|
175 /** Location request positioning method. |
|
176 */ |
|
177 TLbsNetPosRequestMethod iPosMethod; |
|
178 |
|
179 /** Assistance data |
|
180 */ |
|
181 RLbsAssistanceDataBuilderSet& iAssistanceData; |
|
182 |
|
183 /** Assistance data mask |
|
184 */ |
|
185 TLbsAssistanceDataGroup iAssistanceDataMask; |
|
186 |
|
187 }; |
|
188 |
|
189 #endif // __CSUPLRRLPFSM_H__ |
|
190 |
|