26
|
1 |
// Copyright (c) 2010 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 |
// This file contains the implementation of the AT command parser and common utilities
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#ifndef ATCOMMANDPARSER_H
|
|
19 |
#define ATCOMMANDPARSER_H
|
|
20 |
|
|
21 |
#include <e32std.h>
|
|
22 |
|
|
23 |
|
|
24 |
/**
|
|
25 |
* This class parses a given AT command into command type, command handler type and parameters.
|
|
26 |
*
|
|
27 |
*/
|
|
28 |
NONSHARABLE_CLASS(TAtCommandParser)
|
|
29 |
{
|
|
30 |
public:
|
|
31 |
/**
|
|
32 |
* AT command handler type which determines how the command is interpreted.
|
|
33 |
*/
|
|
34 |
enum TCommandHandlerType
|
|
35 |
{
|
|
36 |
ECmdHandlerTypeUndefined = KErrNotFound,
|
|
37 |
ECmdHandlerTypeBase = 0x01, // For command "AT+COMMAND"
|
|
38 |
ECmdHandlerTypeSet = 0x02, // For command "AT+COMMAND="
|
|
39 |
ECmdHandlerTypeRead = 0x04, // For command "AT+COMMAND?"
|
|
40 |
ECmdHandlerTypeTest = 0x08, // For command "AT+COMMAND=?"
|
|
41 |
};
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Extended AT commands supported by this parser.
|
|
45 |
*/
|
|
46 |
enum TCommandType
|
|
47 |
{
|
|
48 |
EUnknown = KErrNotFound,
|
|
49 |
ECmdAtCfun = 0,
|
|
50 |
ECmdAtCbc,
|
|
51 |
ECmdAtClck,
|
|
52 |
ECmdAtCpwd,
|
|
53 |
ECmdAtCpin,
|
|
54 |
ECmdAtCusd,
|
32
|
55 |
ECmdAtCnum,
|
|
56 |
ECmdAtCmee
|
26
|
57 |
};
|
|
58 |
public:
|
|
59 |
TAtCommandParser();
|
|
60 |
|
|
61 |
/**
|
|
62 |
* @param aCmd AT command to be parsed
|
|
63 |
*/
|
|
64 |
TAtCommandParser(const TDesC8& aCmd);
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Parse a new AT command. Previously parsed AT command is lost.
|
|
68 |
* @param aCmd AT command to be parsed
|
|
69 |
*/
|
|
70 |
void ParseAtCommand(const TDesC8& aCmd);
|
|
71 |
|
|
72 |
/**
|
|
73 |
* @return AT command type @see CAtCommandParser::TCommandType
|
|
74 |
*/
|
|
75 |
TCommandType Command() const;
|
|
76 |
|
|
77 |
/**
|
|
78 |
* @return AT Command handler type @see CAtCommandParser::TCommandHandlerType
|
|
79 |
*/
|
|
80 |
TCommandHandlerType CommandHandlerType() const;
|
|
81 |
|
|
82 |
/**
|
|
83 |
* @return Next available parameter. KNullDesC8 if no more parameters.
|
|
84 |
*/
|
|
85 |
TPtrC8 NextParam();
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Gets the integer value of the next parameter.
|
|
89 |
*
|
|
90 |
* @param aValue the integer value of the parameter
|
|
91 |
* @return Symbian system wide error codes
|
|
92 |
*/
|
|
93 |
TInt NextIntParam(TInt& aValue);
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Get the next text string without quote.
|
|
97 |
* This function validate the parameter is a valid string.
|
|
98 |
* if the parameter is absent, it returns KErrNotFound.
|
|
99 |
* if the parameter is an invalid string such as not in a pair of double quotes, it returns KErrArgument
|
32
|
100 |
* @param aParam the text string without quotes
|
|
101 |
* @return Symbian system wide error codes
|
26
|
102 |
*/
|
32
|
103 |
TInt NextTextParam(TPtrC8& aParam);
|
26
|
104 |
|
|
105 |
/**
|
|
106 |
* Get ISA hash code for security code
|
|
107 |
* Phone lock code is encoded by using ISA hash. This hash algorithm is implemented in remotemgmt component
|
|
108 |
* This function is copied and modified from CSCPServer::HashISACode()
|
|
109 |
* @param aPasscode passcode to be encoded
|
|
110 |
* @param aHashCode encoded output
|
|
111 |
* @return Symbian system wide error codes
|
|
112 |
*/
|
|
113 |
TInt HashSecurityCode(const TDesC8& aPasscode, TDes8& aHashCode);
|
|
114 |
|
|
115 |
private:
|
|
116 |
TLex8 iCmd;
|
|
117 |
TCommandType iCmdType;
|
|
118 |
TCommandHandlerType iCmdHandlerType;
|
|
119 |
};
|
|
120 |
|
|
121 |
#endif // ATCOMMANDPARSER_H
|