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,
|
45
|
56 |
ECmdAtCmee,
|
|
57 |
ECmdAtHver,
|
|
58 |
ECmdAtCgsn,
|
47
|
59 |
ECmdAtGsn,
|
45
|
60 |
ECmdAtCgmr,
|
47
|
61 |
ECmdAtGmr,
|
45
|
62 |
ECmdAtCgmi,
|
47
|
63 |
ECmdAtGmi,
|
45
|
64 |
ECmdAtCmgw,
|
47
|
65 |
ECmdAtCmgd,
|
|
66 |
ECmdAtCmgf,
|
|
67 |
ECmdAtCgmm,
|
|
68 |
ECmdAtGmm,
|
|
69 |
ECmdAtI,
|
|
70 |
ECmdAtI0,
|
|
71 |
ECmdAtI1,
|
|
72 |
ECmdAtI2,
|
|
73 |
ECmdAtI3,
|
|
74 |
ECmdAtI4,
|
|
75 |
ECmdAtScpbr,
|
|
76 |
ECmdAtScpbw
|
26
|
77 |
};
|
|
78 |
public:
|
|
79 |
TAtCommandParser();
|
|
80 |
|
|
81 |
/**
|
|
82 |
* @param aCmd AT command to be parsed
|
|
83 |
*/
|
|
84 |
TAtCommandParser(const TDesC8& aCmd);
|
|
85 |
|
|
86 |
/**
|
|
87 |
* Parse a new AT command. Previously parsed AT command is lost.
|
|
88 |
* @param aCmd AT command to be parsed
|
|
89 |
*/
|
|
90 |
void ParseAtCommand(const TDesC8& aCmd);
|
|
91 |
|
|
92 |
/**
|
|
93 |
* @return AT command type @see CAtCommandParser::TCommandType
|
|
94 |
*/
|
|
95 |
TCommandType Command() const;
|
|
96 |
|
|
97 |
/**
|
|
98 |
* @return AT Command handler type @see CAtCommandParser::TCommandHandlerType
|
|
99 |
*/
|
|
100 |
TCommandHandlerType CommandHandlerType() const;
|
|
101 |
|
|
102 |
/**
|
|
103 |
* @return Next available parameter. KNullDesC8 if no more parameters.
|
|
104 |
*/
|
|
105 |
TPtrC8 NextParam();
|
|
106 |
|
|
107 |
/**
|
|
108 |
* Gets the integer value of the next parameter.
|
|
109 |
*
|
|
110 |
* @param aValue the integer value of the parameter
|
|
111 |
* @return Symbian system wide error codes
|
|
112 |
*/
|
|
113 |
TInt NextIntParam(TInt& aValue);
|
|
114 |
|
|
115 |
/**
|
|
116 |
* Get the next text string without quote.
|
|
117 |
* This function validate the parameter is a valid string.
|
|
118 |
* if the parameter is absent, it returns KErrNotFound.
|
|
119 |
* if the parameter is an invalid string such as not in a pair of double quotes, it returns KErrArgument
|
32
|
120 |
* @param aParam the text string without quotes
|
|
121 |
* @return Symbian system wide error codes
|
26
|
122 |
*/
|
32
|
123 |
TInt NextTextParam(TPtrC8& aParam);
|
26
|
124 |
|
|
125 |
/**
|
|
126 |
* Get ISA hash code for security code
|
|
127 |
* Phone lock code is encoded by using ISA hash. This hash algorithm is implemented in remotemgmt component
|
|
128 |
* This function is copied and modified from CSCPServer::HashISACode()
|
|
129 |
* @param aPasscode passcode to be encoded
|
|
130 |
* @param aHashCode encoded output
|
|
131 |
* @return Symbian system wide error codes
|
|
132 |
*/
|
|
133 |
TInt HashSecurityCode(const TDesC8& aPasscode, TDes8& aHashCode);
|
|
134 |
|
|
135 |
private:
|
|
136 |
TLex8 iCmd;
|
|
137 |
TCommandType iCmdType;
|
|
138 |
TCommandHandlerType iCmdHandlerType;
|
|
139 |
};
|
|
140 |
|
|
141 |
#endif // ATCOMMANDPARSER_H
|