|
1 // Copyright (c) 2008-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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalTechnology |
|
19 |
|
20 */ |
|
21 |
|
22 #include "ULP.h" |
|
23 #include "suplstart.h" |
|
24 #include "supldevloggermacros.h" |
|
25 #include "suplrrlpasn1common.h" |
|
26 #include <math.h> |
|
27 |
|
28 /** |
|
29 Default minimum horizontal accuracy in meters |
|
30 */ |
|
31 const TInt KLbsSuplMinHorAccDefault = 20; |
|
32 |
|
33 |
|
34 /** |
|
35 Static factory constructor |
|
36 */ |
|
37 EXPORT_C CSuplStart* CSuplStart::NewL() |
|
38 { |
|
39 SUPLLOG(ELogP1, "CSuplStart::NewL() Begin\n"); |
|
40 CSuplStart* self = CSuplStart::NewLC(); |
|
41 SUPLLOG(ELogP1, "CSuplStart::NewL() End\n"); |
|
42 CleanupStack::Pop(self); |
|
43 return self; |
|
44 } |
|
45 |
|
46 /** |
|
47 Static factory constructor |
|
48 */ |
|
49 EXPORT_C CSuplStart* CSuplStart::NewLC() |
|
50 { |
|
51 SUPLLOG(ELogP1, "CSuplStart::NewL() Begin\n"); |
|
52 CSuplStart* self = new (ELeave) CSuplStart(); |
|
53 CleanupStack::PushL(self); |
|
54 self->ConstructL(); |
|
55 SUPLLOG(ELogP1, "CSuplStart::NewLC() End\n"); |
|
56 return self; |
|
57 } |
|
58 |
|
59 /** |
|
60 Constructor |
|
61 */ |
|
62 CSuplStart::CSuplStart() |
|
63 : CSuplMessageBase::CSuplMessageBase(ESuplStart, ETrue) |
|
64 { |
|
65 SUPLLOG(ELogP1, "CSuplMessageBase::CSuplMessageBase() Begin\n"); |
|
66 SUPLLOG(ELogP1, "CSuplMessageBase::CSuplMessageBase() End\n"); |
|
67 } |
|
68 |
|
69 |
|
70 /** |
|
71 Second stage constructor |
|
72 */ |
|
73 void CSuplStart::ConstructL() |
|
74 { |
|
75 // call the base class ConstructL() to create data structures |
|
76 CSuplMessageBase::ConstructL(); |
|
77 |
|
78 // local reference to context object |
|
79 OSCTXT* pctxt = iControl->getCtxtPtr(); |
|
80 |
|
81 iData->message.t = T_UlpMessage_msSUPLSTART; |
|
82 iData->message.u.msSUPLSTART = (ASN1T_SUPLSTART*)rtxMemAllocZ(pctxt, sizeof(ASN1T_SUPLSTART)); |
|
83 LeaveIfAllocErrorL(); |
|
84 } |
|
85 |
|
86 |
|
87 /** |
|
88 Destructor |
|
89 */ |
|
90 CSuplStart::~CSuplStart() |
|
91 { |
|
92 SUPLLOG(ELogP1, "CSuplStart::~CSuplStart() Begin\n"); |
|
93 SUPLLOG(ELogP1, "CSuplStart::~CSuplStart() End\n"); |
|
94 } |
|
95 |
|
96 |
|
97 /** |
|
98 SetCapabilities() |
|
99 |
|
100 Populates the SET Capabilities parameter of the outgoing SUPL START message. |
|
101 |
|
102 SET Capabilities |
|
103 - Pos Technology (m) Bitmask indicating technologies the SET supports |
|
104 - Pref Method (m) which GPS mode the SET prefers (TA, TB, noPref) |
|
105 - Pos Protocol (m) which underlying positioning protocols are supported |
|
106 |
|
107 @param aCapabilities, current capabilities reported by LBS subsystem |
|
108 @return error indication, KErrNone otherwise |
|
109 */ |
|
110 EXPORT_C TInt CSuplStart::SetCapabilities(TLbsNetPosCapabilities& aCapabilities) |
|
111 { |
|
112 SUPLLOG(ELogP1, "CSuplStart::SetCapabilities() Begin\n"); |
|
113 __ASSERT_DEBUG(iData->message.u.msSUPLSTART != NULL, User::Invariant()); |
|
114 |
|
115 TInt err = PopulateSetCapabilities(aCapabilities, iData->message.u.msSUPLSTART->sETCapabilities); |
|
116 |
|
117 SUPLLOG(ELogP1, "CSuplStart::SetCapabilities() End\n"); |
|
118 return err; |
|
119 } |
|
120 |
|
121 |
|
122 /** |
|
123 SetLocationId() |
|
124 |
|
125 Set the location ID parameter |
|
126 |
|
127 Location ID - Describes the globally unique cell identification of the most current serving cell. |
|
128 Cell Info (m) The following cell IDs are supported: |
|
129 - GSM Cell Info |
|
130 - WCDMA Cell Info |
|
131 - CDMA Cell Info |
|
132 Status (m) Describes whether or not the cell info is: |
|
133 - Not Current, last known cell info |
|
134 - Current, the present cell info |
|
135 - Unknown (ie not known whether the cell id is current or not current) |
|
136 |
|
137 Note: The Status parameter does NOT apply to WCDMA optional parameters |
|
138 (Frequency Info, Primary Scrambling Code and Measured Results List). Frequency |
|
139 Info, Primary Scrambling Code and Measured Results List, if present, are always |
|
140 considered to be correct for the current cell. |
|
141 |
|
142 @param aLocationId, describes the current location |
|
143 @return error indication, KErrNone otherwise |
|
144 */ |
|
145 EXPORT_C TInt CSuplStart::SetLocationId(const CSuplLocationId& aLocationId) |
|
146 { |
|
147 __ASSERT_DEBUG(iData->message.u.msSUPLSTART != NULL, User::Invariant()); |
|
148 SUPLLOG(ELogP1, "CSuplStart::SetLocationId() Begin\n"); |
|
149 |
|
150 TInt err = PopulateLocationId(aLocationId, iData->message.u.msSUPLSTART->locationId); |
|
151 |
|
152 SUPLLOG(ELogP1, "CSuplStart::SetLocationId() End\n"); |
|
153 return err; |
|
154 } |
|
155 |
|
156 |
|
157 /** |
|
158 SetQoP() |
|
159 |
|
160 Set the QoP parameter |
|
161 |
|
162 QoP - the desired quality of position |
|
163 horacc (m) (0..127) |
|
164 veracc (o) (0..127) |
|
165 maxLocAge (o) (0..65535) |
|
166 delay (o) (0..7) |
|
167 |
|
168 @param aQuality, the required quality of position |
|
169 @return error indication, KErrNone otherwise |
|
170 */ |
|
171 EXPORT_C TInt CSuplStart::SetQoP(TLbsNetPosRequestQuality& aQuality) |
|
172 { |
|
173 __ASSERT_DEBUG(iData->message.u.msSUPLSTART != NULL, User::Invariant()); |
|
174 SUPLLOG(ELogP1, "CSuplStart::SetQoP() Begin\n"); |
|
175 |
|
176 // pointer to message body |
|
177 ASN1T_SUPLSTART* msgBody = iData->message.u.msSUPLSTART; |
|
178 |
|
179 // local reference to context object |
|
180 iControl->getCtxtPtr(); |
|
181 |
|
182 // indicate that the optional QoP component is present |
|
183 msgBody->m.qoPPresent = 1; |
|
184 |
|
185 // Horizontal accuracy |
|
186 if (aQuality.MinHorizontalAccuracy() != 0) |
|
187 { |
|
188 msgBody->qoP.horacc = Uncertainty(aQuality.MinHorizontalAccuracy()); |
|
189 } |
|
190 else |
|
191 { |
|
192 msgBody->qoP.horacc = Uncertainty(KLbsSuplMinHorAccDefault); |
|
193 } |
|
194 |
|
195 // vertical accuracy |
|
196 if (aQuality.MinVerticalAccuracy() != 0) |
|
197 { |
|
198 msgBody->qoP.veracc = UncertaintyAltitude(aQuality.MinVerticalAccuracy()); |
|
199 msgBody->qoP.m.veraccPresent = 1; |
|
200 } |
|
201 |
|
202 // max location age / max fix age |
|
203 TTimeIntervalMicroSeconds maxAge = aQuality.MaxFixAge(); |
|
204 if (maxAge.Int64() != 0) |
|
205 { |
|
206 TInt64 maxAgeSeconds = maxAge.Int64() / KLbsMilliSeconds; |
|
207 if (maxAgeSeconds > 65535) |
|
208 { |
|
209 // limit to 16 bits (65535 = 2^16 - 1) |
|
210 maxAgeSeconds = 65535; |
|
211 } |
|
212 msgBody->qoP.maxLocAge = maxAgeSeconds; |
|
213 msgBody->qoP.m.maxLocAgePresent = 1; |
|
214 } |
|
215 |
|
216 // delay / max fix time |
|
217 TTimeIntervalMicroSeconds maxFixTime = aQuality.MaxFixTime(); |
|
218 if (maxFixTime.Int64() != 0) |
|
219 { |
|
220 msgBody->qoP.m.delayPresent = 1; |
|
221 TInt seconds = maxFixTime.Int64() / KLbsMilliSeconds; |
|
222 if (seconds <= 1) |
|
223 { |
|
224 msgBody->qoP.delay = 0; |
|
225 } |
|
226 else if (seconds <= 2) |
|
227 { |
|
228 msgBody->qoP.delay = 1; |
|
229 } |
|
230 else if (seconds <= 4) |
|
231 { |
|
232 msgBody->qoP.delay = 2; |
|
233 } |
|
234 else if (seconds <= 8) |
|
235 { |
|
236 msgBody->qoP.delay = 3; |
|
237 } |
|
238 else if (seconds <= 16) |
|
239 { |
|
240 msgBody->qoP.delay = 4; |
|
241 } |
|
242 else if (seconds <= 32) |
|
243 { |
|
244 msgBody->qoP.delay = 5; |
|
245 } |
|
246 else if (seconds <= 64) |
|
247 { |
|
248 msgBody->qoP.delay = 6; |
|
249 } |
|
250 else |
|
251 { |
|
252 // maximum value |
|
253 msgBody->qoP.delay = 7; |
|
254 } |
|
255 } |
|
256 |
|
257 SUPLLOG(ELogP1, "CSuplStart::SetQoP() End\n"); |
|
258 return KErrNone; |
|
259 } |
|
260 |