25
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: Handles the commands "AT+COPS=..." and "AT+COPS?"
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef C_CATCOPSCMD_H
|
|
20 |
#define C_CATCOPSCMD_H
|
|
21 |
|
|
22 |
#include <e32base.h>
|
|
23 |
#include <e32cmn.h>
|
|
24 |
#include <rmmcustomapi.h>
|
|
25 |
#include <etelpckt.h>
|
|
26 |
#include <etelmm.h>
|
|
27 |
#include <mmretrieve.h>
|
|
28 |
#include "modematplugin.h"
|
|
29 |
|
|
30 |
class MCmdPluginObserver;
|
|
31 |
class CRetrieveMobilePhoneDetectedNetworks;
|
|
32 |
|
|
33 |
/** Handler types for the AT commands */
|
|
34 |
enum TCmdHandlerType
|
|
35 |
{
|
|
36 |
ECmdHandlerTypeUndefined,
|
|
37 |
ECmdHandlerTypeTest, // For command "AT+COPS=?"
|
|
38 |
ECmdHandlerTypeRead, // For command "AT+COPS?"
|
|
39 |
ECmdHandlerTypeSet // For command "AT+COPS=..."
|
|
40 |
};
|
|
41 |
|
|
42 |
/** Keeps track of the current operation for the state machine */
|
|
43 |
enum TCurrentOperation
|
|
44 |
{
|
|
45 |
EIdle = 0,
|
|
46 |
EInspectModeAndProcessCommand = 1,
|
|
47 |
EAutomaticallyRegisterToNetwork = 2,
|
|
48 |
EManuallyRegisterToNetwork = 3,
|
|
49 |
EManuallyRegisterToNetworkAndChooseAccTech = 4,
|
|
50 |
EGetNetworkInfoOperatorName = 5,
|
|
51 |
ESetSystemNetworkBand = 6,
|
|
52 |
EUpdateAvailableNetworkOperators = 7,
|
|
53 |
EListAvailableNetworkOperators = 8
|
|
54 |
};
|
|
55 |
|
|
56 |
/** These are in the same order as in 3GPP TS 27.007 V8.4.1 */
|
|
57 |
enum TOperatorFormat
|
|
58 |
{
|
|
59 |
EFormatLong,
|
|
60 |
EFormatShort,
|
|
61 |
EFormatNumeric
|
|
62 |
};
|
|
63 |
|
|
64 |
/** These are in the same order as in 3GPP TS 27.007 V8.4.1 */
|
|
65 |
enum TNetworkRegistrationMode
|
|
66 |
{
|
|
67 |
EModeAutomatic,
|
|
68 |
EModeManual,
|
|
69 |
EModeDeregister,
|
|
70 |
EModeSetFormatParameter,
|
|
71 |
EModeManualAutomatic,
|
|
72 |
};
|
|
73 |
|
|
74 |
/** Currently selected access technology for outgoing replies.
|
|
75 |
* S60 uses definitions from RMobilePhone class, but they are
|
|
76 |
* in diffent order and cannot be used directly.
|
|
77 |
* These are in the same order as in 3GPP TS 27.007 V8.4.1 */
|
|
78 |
enum TAccessTechnology
|
|
79 |
{
|
|
80 |
EGSM = 0,
|
|
81 |
EGSMCompact = 1,
|
|
82 |
EUDMA = 2,
|
|
83 |
EGSMwithEGPRS = 3,
|
|
84 |
EHSDPA = 4,
|
|
85 |
EHSUPA = 5,
|
|
86 |
EUDMAwithHSDPAandHSUPA = 6,
|
|
87 |
EAccTechNotSet = 255
|
|
88 |
};
|
|
89 |
|
|
90 |
/**
|
|
91 |
* Class for handling commands "AT+COPS?" and "AT+COPS=..."
|
|
92 |
*
|
|
93 |
* @since TB9.2
|
|
94 |
*/
|
|
95 |
NONSHARABLE_CLASS( CATCOPSCmd ) : public CActive, public CATCommandHandlerBase
|
|
96 |
{
|
|
97 |
|
|
98 |
public:
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Two-phased constructor.
|
|
102 |
* @param aCallback Callback
|
|
103 |
* @return Instance of self
|
|
104 |
*/
|
|
105 |
static CATCOPSCmd* NewL( MCmdPluginObserver* aCallback );
|
|
106 |
|
|
107 |
/**
|
|
108 |
* Destructor.
|
|
109 |
*/
|
|
110 |
virtual ~CATCOPSCmd();
|
|
111 |
|
|
112 |
protected:
|
|
113 |
/**
|
|
114 |
* From CActive. Called when asynchronous request completes.
|
|
115 |
* @since TB9.2
|
|
116 |
* @param None
|
|
117 |
* @return None
|
|
118 |
*/
|
|
119 |
virtual void RunL();
|
|
120 |
|
|
121 |
virtual void DoCancel();
|
|
122 |
|
|
123 |
private:
|
|
124 |
|
|
125 |
CATCOPSCmd( MCmdPluginObserver* aCallback );
|
|
126 |
|
|
127 |
void ConstructL();
|
|
128 |
|
|
129 |
/**
|
|
130 |
* Reports the support status of an AT command. This is a synchronous API.
|
|
131 |
*
|
|
132 |
* @param aCmd The AT command. Its format may vary depending on the
|
|
133 |
* specification. E.g. in BT HFP case, the command may contain
|
|
134 |
* a character carriage return (<cr>) in the end.
|
|
135 |
* @return ETrue if the command is supported; EFalse otherwise.
|
|
136 |
*/
|
|
137 |
TBool IsCommandSupported( const TDesC8& aCmd );
|
|
138 |
|
|
139 |
/**
|
|
140 |
* Handles an AT command. Cancelling of the pending request is done by
|
|
141 |
* HandleCommandCancel(). The implementation in the extension plugin should
|
|
142 |
* be asynchronous.
|
|
143 |
*
|
|
144 |
* The extension plugin which accepts this command is responsible to supply
|
|
145 |
* the result codes and response and to format result codes properly, e.g.
|
|
146 |
* in BT HFP case, the format should be <cr><lf><result code><cr><lf>
|
|
147 |
*
|
|
148 |
* After an extension plugin has handled or decided to reject the given AT
|
|
149 |
* command, it must inform ATEXT by HandleCommandCompleted() with a proper
|
|
150 |
* error code.
|
|
151 |
*
|
|
152 |
* @since TB9.2
|
|
153 |
* @param aCmd The AT command to be handled. Its format may vary depending
|
|
154 |
* on the specification. E.g. in BT HFP case, the command may
|
|
155 |
* contain a character carriage return (<cr>) in the end.
|
|
156 |
* @param aReply When passed in, contains the built in answer filled by
|
|
157 |
* ATEXT if it is not empty; when command handling completes
|
|
158 |
* successfully, contains the result codes and responses to
|
|
159 |
* this command; Its ownership always belongs to ATEXT, plugin
|
|
160 |
* may reallocate its space when needed.
|
|
161 |
* @param aReplyNeeded Reply needed if ETrue, no reply otherwise. If EFalse,
|
|
162 |
* the aReply must not contain the reply, otherwise it
|
|
163 |
* must contain verbose or numeric reply (ATV0/1) or an
|
|
164 |
* empty string reply (with ATQ).
|
|
165 |
* @return None
|
|
166 |
*/
|
|
167 |
void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded );
|
|
168 |
|
|
169 |
/**
|
|
170 |
* Cancels a pending HandleCommand request.
|
|
171 |
*
|
|
172 |
* @since TB9.2
|
|
173 |
* @return None
|
|
174 |
*/
|
|
175 |
void HandleCommandCancel();
|
|
176 |
|
|
177 |
|
|
178 |
private:
|
|
179 |
|
|
180 |
|
|
181 |
void HandleCommandTest( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded );
|
|
182 |
void HandleCommandRead( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded );
|
|
183 |
void HandleCommandSet( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded );
|
|
184 |
|
|
185 |
void HandleError();
|
|
186 |
|
|
187 |
/**
|
|
188 |
* This method parses the parameter part of command and populates
|
|
189 |
* iParamArray class member. Quotation marks are removed in process.
|
|
190 |
*
|
|
191 |
* @since TB9.2
|
|
192 |
* @param aCmd The AT command.
|
|
193 |
* @return Leaves in out of memory case.
|
|
194 |
*/
|
|
195 |
void ExtractParametersL(const TDesC8& aCmd);
|
|
196 |
|
|
197 |
/**
|
|
198 |
* This method strips all quotation parms from the string passed in.
|
|
199 |
*
|
|
200 |
* @since TB9.2
|
|
201 |
* @param aParameter one parameter from AT command as extracted by ExtractParametersL.
|
|
202 |
* @return None
|
|
203 |
*/
|
|
204 |
void RemoveQuotationMarks(TPtr8& aParameter);
|
|
205 |
|
|
206 |
/**
|
|
207 |
* This method returns the selected mode in aMode.
|
|
208 |
* It also checks that there are enough parameters for the mode in question.
|
|
209 |
*
|
|
210 |
* @since TB9.2
|
|
211 |
* @param aParameter one parameter from AT command as extracted by ExtractParametersL.
|
|
212 |
* @param aMode contains the converted parameter if method completed successfully.
|
|
213 |
* @return KErrArgument if mode is invalid or there is not enough parameters.
|
|
214 |
* KErrNone if iParamArray contains all the parameters the mode requires.
|
|
215 |
*/
|
|
216 |
TInt GetModeAndCheckParameterCount(const TDesC8& aParameter, TNetworkRegistrationMode &aMode);
|
|
217 |
|
|
218 |
/**
|
|
219 |
* This method converts an AT command parameter to numeric format value and checks it is valid.
|
|
220 |
*
|
|
221 |
* @since TB9.2
|
|
222 |
* @param aParameter one parameter from AT command as extracted by ExtractParametersL.
|
|
223 |
* @param aFormat contains the converted parameter if method completed successfully.
|
|
224 |
* @return KErrArgument if format is invalid.
|
|
225 |
* KErrNone if format is valid.
|
|
226 |
*/
|
|
227 |
TInt GetFormatFromParameter(const TDesC8& aParameter, RMmCustomAPI::TOperatorNameType &aFormat);
|
|
228 |
|
|
229 |
/**
|
|
230 |
* This method converts an AT command parameter to numeric access technology value and checks it is valid.
|
|
231 |
*
|
|
232 |
* @since TB9.2
|
|
233 |
* @param aParameter one parameter from AT command as extracted by ExtractParametersL.
|
|
234 |
* @param aAccTech contains the converted parameter if method completed successfully.
|
|
235 |
* @return KErrArgument if acc. tech. is invalid.
|
|
236 |
* KErrNone if acc. tech. is valid.
|
|
237 |
*/
|
|
238 |
TInt GetAccTechFromParameter(const TDesC8& aParameter, TAccessTechnology &aAccTech);
|
|
239 |
|
|
240 |
/**
|
|
241 |
* This method converts an AT command parameter to ETel compatible operator values
|
|
242 |
*
|
|
243 |
* @since TB9.2
|
|
244 |
* @param aDetectedNetworks contains the list of networks. May be NULL.
|
|
245 |
* @param aFormat contains the format (numeric/text) of operator parameter.
|
|
246 |
* @param aOperatorParameter contains the operator parameter string.
|
|
247 |
* @param aMcc contains the converted parameter if method completed successfully.
|
|
248 |
* @param aMnc contains the converted parameter if method completed successfully.
|
|
249 |
* @return KErrArgument if operator parameter invalid,
|
|
250 |
* KErrNotFound if operator list exists but the operator is not in it,
|
|
251 |
* or the operator list is missing. (Required if aFormat is text.)
|
|
252 |
* KErrNone if conversion succeeds. aMcc and aMnc contain ETel compatible operator values.
|
|
253 |
*/
|
|
254 |
TInt ConvertOperatorToMccMnc(const CMobilePhoneNetworkListV2 *aDetectedNetworks,
|
|
255 |
const RMmCustomAPI::TOperatorNameType aFormat,
|
|
256 |
const TBuf<KMaxOperatorNameLength>& aOperatorParameter,
|
|
257 |
RMobilePhone::TMobilePhoneNetworkCountryCode& aMcc,
|
|
258 |
RMobilePhone::TMobilePhoneNetworkIdentity& aMnc);
|
|
259 |
|
|
260 |
/**
|
|
261 |
* This method initiates an automatic network registration.
|
|
262 |
*
|
|
263 |
* @since TB9.2
|
|
264 |
* @return None
|
|
265 |
*/
|
|
266 |
void AutomaticNetworkRegistration();
|
|
267 |
|
|
268 |
/**
|
|
269 |
* This method initiates a manual network registration.
|
|
270 |
*
|
|
271 |
* @since TB9.2
|
|
272 |
* @param aMcc contains the country code part of ETel operator info.
|
|
273 |
* @param aMnc contains the network code part of ETel operator info.
|
|
274 |
* @return None
|
|
275 |
*/
|
|
276 |
void ManualNetworkRegistration(const RMobilePhone::TMobilePhoneNetworkCountryCode& aMcc,
|
|
277 |
const RMobilePhone::TMobilePhoneNetworkIdentity& aMnc);
|
|
278 |
|
|
279 |
/**
|
|
280 |
* This method initiates a manual network registration and access technology selection.
|
|
281 |
*
|
|
282 |
* @since TB9.2
|
|
283 |
* @param aMcc contains the country code part of ETel operator info.
|
|
284 |
* @param aMnc contains the network code part of ETel operator info.
|
|
285 |
* @param aAccTech contains the access technology in ETel compatible format.
|
|
286 |
* @return None
|
|
287 |
*/
|
|
288 |
void ManualNetworkRegistration( const RMobilePhone::TMobilePhoneNetworkCountryCode& aMcc,
|
|
289 |
const RMobilePhone::TMobilePhoneNetworkIdentity& aMnc,
|
|
290 |
const TAccessTechnology aAccTech);
|
|
291 |
|
|
292 |
/**
|
|
293 |
* This is a helper function used by RunL
|
|
294 |
*
|
|
295 |
* @since TB9.2
|
|
296 |
* @return standard Symbian OS return code.
|
|
297 |
*/
|
|
298 |
TInt InspectModeAndProcessCommand();
|
|
299 |
|
|
300 |
/**
|
|
301 |
* This method contructs a response for the test command.
|
|
302 |
*
|
|
303 |
* @since TB9.2
|
|
304 |
* @return None. Leaves with standar symbian OS error code on error.
|
|
305 |
*/
|
|
306 |
void ConstructNetworkListResponseL();
|
|
307 |
|
|
308 |
/**
|
|
309 |
* This method contructs a response for the read command.
|
|
310 |
*
|
|
311 |
* @since TB9.2
|
|
312 |
* @return standard Symbian OS return code.
|
|
313 |
*/
|
|
314 |
TInt ConstructNetworkInfoResponse();
|
|
315 |
|
|
316 |
/**
|
|
317 |
* This helper method converts the ETel access technology into
|
|
318 |
* 3GPP TS 27.007 V8.4.1 compatible format.
|
|
319 |
*
|
|
320 |
* @since TB9.2
|
|
321 |
* @param aAccTech contains the access technology in ETel compatible format.
|
|
322 |
* @return Standard Symbian OS return code.
|
|
323 |
*/
|
|
324 |
TInt SolveAccessTechnology(RMobilePhone::TMobilePhoneNetworkAccess &aAccessTech);
|
|
325 |
|
|
326 |
/**
|
|
327 |
* This helper method finalises the response and sends it.
|
|
328 |
*
|
|
329 |
* @since TB9.2
|
|
330 |
* @param aIsOK tells whether to create an OK or ERROR response.
|
|
331 |
* @param aReply contains the response string to be sent before OK, if any.
|
|
332 |
* @return None
|
|
333 |
*/
|
|
334 |
void CreateReply(TBool aIsOK, const TDesC8 &aReply = KNullDesC8);
|
|
335 |
|
|
336 |
private: // data
|
|
337 |
|
|
338 |
/**
|
|
339 |
* Callback to call when accessing plugin information
|
|
340 |
*/
|
|
341 |
MCmdPluginObserver* iCallback;
|
|
342 |
|
|
343 |
/**
|
|
344 |
* Handler type for the three AT commands
|
|
345 |
*/
|
|
346 |
TCmdHandlerType iCmdHandlerType;
|
|
347 |
|
|
348 |
/**
|
|
349 |
* Telephony server instance.
|
|
350 |
*/
|
|
351 |
RTelServer iServer;
|
|
352 |
|
|
353 |
/**
|
|
354 |
* Phone instance, used for network selection.
|
|
355 |
*/
|
|
356 |
RMobilePhone iPhone;
|
|
357 |
|
|
358 |
/**
|
|
359 |
* Telephony Custom API instance, used for setting
|
|
360 |
* the access technology (only GSM and UDMA supported).
|
|
361 |
*/
|
|
362 |
RMmCustomAPI iCustomApi;
|
|
363 |
|
|
364 |
/**
|
|
365 |
* Current network info collected via the RMobilePhone is stored here.
|
|
366 |
*/
|
|
367 |
RMobilePhone::TMobilePhoneNetworkInfoV2 iNetworkInfo;
|
|
368 |
|
|
369 |
/**
|
|
370 |
* The parameters extracted from the AT command are stored here.
|
|
371 |
*/
|
|
372 |
RPointerArray<HBufC8> iParamArray;
|
|
373 |
|
|
374 |
/**
|
|
375 |
* Used for getting the static packet capabilities of the phone.
|
|
376 |
* This is needed for supporting more detailed access technology.
|
|
377 |
*/
|
|
378 |
RPacketService iPacketService;
|
|
379 |
|
|
380 |
/**
|
|
381 |
* The format of the operator parameter is stored here.
|
|
382 |
* it is used both for interpreting the incoming operator and
|
|
383 |
* responding with correctly formatted outgoing operator info.
|
|
384 |
* this can be done because it is specified that the latest incoming
|
|
385 |
* format info is also used for responses from that onwards.
|
|
386 |
*/
|
|
387 |
RMmCustomAPI::TOperatorNameType iFormat;
|
|
388 |
|
|
389 |
/**
|
|
390 |
* The requested/current network registration mode is stored here. It is used
|
|
391 |
* also when responding to the Read command. This can be done because the two
|
|
392 |
* operations are completely independent.
|
|
393 |
*/
|
|
394 |
TNetworkRegistrationMode iRegistrationMode;
|
|
395 |
|
|
396 |
/**
|
|
397 |
* The requested/current access tehcnology is stored here. It is used
|
|
398 |
* also when responding to the Read and Test commands. This can be done
|
|
399 |
* because the operations are completely independent.
|
|
400 |
*/
|
|
401 |
TAccessTechnology iAccTech;
|
|
402 |
|
|
403 |
/**
|
|
404 |
* The incoming reply buffer is kept here. Not owned.
|
|
405 |
*/
|
|
406 |
RBuf8* iReply;
|
|
407 |
|
|
408 |
/**
|
|
409 |
* The currently running operation is kept here.
|
|
410 |
*/
|
|
411 |
TCurrentOperation iCurrentOperation;
|
|
412 |
|
|
413 |
/**
|
|
414 |
* The country code part of ETel compatible operator info.
|
|
415 |
*/
|
|
416 |
RMobilePhone::TMobilePhoneNetworkCountryCode iMcc;
|
|
417 |
|
|
418 |
/**
|
|
419 |
* The network code part of ETel compatible operator info.
|
|
420 |
*/
|
|
421 |
RMobilePhone::TMobilePhoneNetworkIdentity iMnc;
|
|
422 |
|
|
423 |
/**
|
|
424 |
* Used for retrieving a list of networks the phone detected.
|
|
425 |
*/
|
|
426 |
CRetrieveMobilePhoneDetectedNetworks *iRetrieveDetectedNetworks;
|
|
427 |
|
|
428 |
/**
|
|
429 |
* Used for reading the list the CRetrieveMobilePhoneDetectedNetworks returned.
|
|
430 |
*/
|
|
431 |
CMobilePhoneNetworkListV2 *iDetectedNetworks;
|
|
432 |
};
|
|
433 |
|
|
434 |
#endif // C_LCLISTALLCMD_H
|