60
|
1 |
/*
|
|
2 |
*
|
|
3 |
* Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
|
|
4 |
* All rights reserved.
|
|
5 |
* This component and the accompanying materials are made available
|
|
6 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
7 |
* which accompanies this distribution, and is available
|
|
8 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
9 |
*
|
|
10 |
* Original Contributors:
|
|
11 |
* Comarch S.A. - original contribution.
|
|
12 |
*
|
|
13 |
* Contributors:
|
|
14 |
*
|
|
15 |
* Description:
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
#ifndef HFPCOMMAND_H_
|
|
20 |
#define HFPCOMMAND_H_
|
|
21 |
|
|
22 |
#include <e32base.h>
|
|
23 |
|
|
24 |
/** Profile helpful constants */
|
|
25 |
_LIT8(KHsHFPCommandPrefix,"AT");
|
|
26 |
_LIT8(KHsHFPCommandSuffix,"\r\n");
|
|
27 |
_LIT8(KHsHFPBRSFCommand,"+BRSF");
|
|
28 |
_LIT8(KHsHFPCIEVCommand,"+CIEV");
|
|
29 |
_LIT8(KHsHFPCHUPCommand,"+CHUP");
|
|
30 |
_LIT8(KHsHFPCINDCommand,"+CIND");
|
|
31 |
_LIT8(KHsHFPCMERCommand,"+CMER");
|
|
32 |
_LIT8(KHsHFPCOPSCommand,"+COPS");
|
|
33 |
_LIT8(KHsHFPVGSCommand,"+VGS");
|
|
34 |
_LIT8(KHsHFPVGMCommand,"+VGM");
|
|
35 |
_LIT8(KHsHFPBLDNCommand,"+BLDN");
|
|
36 |
_LIT8(KHsHFPCLIPCommand,"+CLIP");
|
|
37 |
_LIT8(KHsHFPOKCommand,"\r\nOK\r\n");
|
|
38 |
_LIT8(KHsHFPERRORCommand,"\r\nERROR\r\n");
|
|
39 |
_LIT8(KHsHFPRINGCommand,"\r\nRING\r\n");
|
|
40 |
_LIT8(KHsHFPATACommand,"ATA");
|
|
41 |
_LIT8(KHsHFPATACommandWithoutPrefix,"A");
|
|
42 |
_LIT8(KHsHFPATDCommand,"ATD");
|
|
43 |
_LIT8(KHsHFPATDCommandWithoutPrefix,"D");
|
|
44 |
_LIT8(KHsHFPParamsSeparator,",");
|
|
45 |
_LIT8(KHsHFPCommandSeparator,"\r\n\r\n");
|
|
46 |
_LIT8(KHsHFPIndicatorParamsSeparator,"),");
|
|
47 |
_LIT8(KHsHFPATTestModeDes,"=?");
|
|
48 |
_LIT8(KHsHFPATWriteModeDes,"=");
|
|
49 |
_LIT8(KHsHFPATReadModeDes,"?");
|
|
50 |
_LIT8(KHsHFPATTestModeDesAG,"=?");
|
|
51 |
_LIT8(KHsHFPATWriteModeDesAG,": ");
|
|
52 |
_LIT8(KHsHFPATReadModeDesAG,"?");
|
|
53 |
|
|
54 |
/** Max size of HFP AT param */
|
|
55 |
const TInt KHsHFPMaxATParamSize = 256;
|
|
56 |
|
|
57 |
/** Max size of VGS or VGM param*/
|
|
58 |
const TInt KHsHFPMaxVolumeLevelParamSize = 2;
|
|
59 |
|
|
60 |
/**
|
|
61 |
* @brief Represents singular AT command parameter.
|
|
62 |
*/
|
|
63 |
class TATParam
|
|
64 |
{
|
|
65 |
public:
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Constructor
|
|
69 |
*
|
|
70 |
* @param aValue param descriptor
|
|
71 |
*/
|
|
72 |
TATParam(const TDesC8& aValue);
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Returns the parameter as text.
|
|
76 |
*
|
|
77 |
* @return the non-modifiable pointer descriptor
|
|
78 |
*/
|
|
79 |
const TDesC8& Des() const;
|
|
80 |
|
|
81 |
/**
|
|
82 |
* Returns the paramater as integer value (if conversion is possible)
|
|
83 |
*
|
|
84 |
* @return integer value
|
|
85 |
*/
|
|
86 |
TInt IntL() const;
|
|
87 |
|
|
88 |
private:
|
|
89 |
/** Buffer for AT param */
|
|
90 |
TBuf8<KHsHFPMaxATParamSize> iValue;
|
|
91 |
};
|
|
92 |
|
|
93 |
/** Array of AT params */
|
|
94 |
typedef RArray<TATParam> RATParamArray;
|
|
95 |
|
|
96 |
/** HFP AT commands types enum */
|
|
97 |
enum THsHFPCommandType
|
|
98 |
{
|
|
99 |
EHFPCmdBRSF,
|
|
100 |
EHFPCmdCIEV,
|
|
101 |
EHFPCmdCHUP,
|
|
102 |
EHFPCmdOK,
|
|
103 |
EHFPCmdERROR,
|
|
104 |
EHFPCmdCIND,
|
|
105 |
EHFPCmdCMER,
|
|
106 |
EHFPCmdCOPS,
|
|
107 |
EHFPCmdRING,
|
|
108 |
EHFPCmdATA,
|
|
109 |
EHFPCmdVGS,
|
|
110 |
EHFPCmdVGM,
|
|
111 |
EHFPCmdBLDN,
|
|
112 |
EHFPCmdATD,
|
|
113 |
EHFPCmdCLIP,
|
|
114 |
EHFPCmdUnknown
|
|
115 |
};
|
|
116 |
|
|
117 |
/** HFP AT commands modes enum */
|
|
118 |
enum THsHFPCommandMode
|
|
119 |
{
|
|
120 |
/** = */
|
|
121 |
ECmdModeWrite,
|
|
122 |
/** ? */
|
|
123 |
ECmdModeRead,
|
|
124 |
/** =? */
|
|
125 |
ECmdModeTest,
|
|
126 |
/** empty without params */
|
|
127 |
ECmdModeNormal,
|
|
128 |
/** empty with params */
|
|
129 |
ECmdModeOther,
|
|
130 |
/** unknown mode - default */
|
|
131 |
ECmdUnknownMode
|
|
132 |
};
|
|
133 |
|
|
134 |
/**
|
|
135 |
* @brief AT command representation
|
|
136 |
*/
|
|
137 |
class CHsHFPCommand : public CBase
|
|
138 |
{
|
|
139 |
|
|
140 |
public:
|
|
141 |
|
|
142 |
/**
|
|
143 |
* Two-phased constructor.
|
|
144 |
*
|
|
145 |
* @return class instance
|
|
146 |
*/
|
|
147 |
static CHsHFPCommand* NewL();
|
|
148 |
|
|
149 |
/**
|
|
150 |
* Two-phased constructor.
|
|
151 |
*
|
|
152 |
* @return class instance
|
|
153 |
*/
|
|
154 |
static CHsHFPCommand* NewLC();
|
|
155 |
|
|
156 |
/**
|
|
157 |
* Destructor
|
|
158 |
*/
|
|
159 |
~CHsHFPCommand();
|
|
160 |
|
|
161 |
public:
|
|
162 |
/**
|
|
163 |
* Sets type of AT command
|
|
164 |
*
|
|
165 |
* @param aType type
|
|
166 |
* @return KErrNone if successful, otherwise one of the system-wide error codes
|
|
167 |
*/
|
|
168 |
TInt SetType(const THsHFPCommandType aType);
|
|
169 |
|
|
170 |
/**
|
|
171 |
* Sets mode of AT command
|
|
172 |
*
|
|
173 |
* @param aMode mode
|
|
174 |
* @return KErrNone if successful, otherwise one of the system-wide error codes
|
|
175 |
*/
|
|
176 |
TInt SetMode(const THsHFPCommandMode aMode);
|
|
177 |
|
|
178 |
/**
|
|
179 |
* Sets params of AT command
|
|
180 |
*
|
|
181 |
* @param aParams array of params
|
|
182 |
* @return KErrNone if successful, otherwise one of the system-wide error codes
|
|
183 |
*/
|
|
184 |
TInt SetParams(const RATParamArray& aParams);
|
|
185 |
|
|
186 |
/**
|
|
187 |
* Sets flag which denotes if AT command was sent from AG or HF
|
|
188 |
*
|
|
189 |
* @param aFromAG AT command source
|
|
190 |
*/
|
|
191 |
void SetSource(const TBool aFromAG);
|
|
192 |
|
|
193 |
/**
|
|
194 |
* Returns the AT command as text
|
|
195 |
*
|
|
196 |
* @param aBuf on exit contains command as descriptor
|
|
197 |
*/
|
|
198 |
void ToDes8(TDes8& aBuf) const;
|
|
199 |
|
|
200 |
/**
|
|
201 |
* Returns the AT command type
|
|
202 |
*
|
|
203 |
* @return type of command
|
|
204 |
*/
|
|
205 |
THsHFPCommandType Type() const;
|
|
206 |
|
|
207 |
/**
|
|
208 |
* Returns the AT command mode
|
|
209 |
*
|
|
210 |
* @return mode of command
|
|
211 |
*/
|
|
212 |
THsHFPCommandMode Mode() const;
|
|
213 |
|
|
214 |
/**
|
|
215 |
* Returns the AT command source
|
|
216 |
*
|
|
217 |
* @return flag that denotes if AT command was sent from AG or HF
|
|
218 |
*/
|
|
219 |
TBool FromAG() const;
|
|
220 |
|
|
221 |
/**
|
|
222 |
* Returns the AT command params
|
|
223 |
*
|
|
224 |
* @return array of params
|
|
225 |
*/
|
|
226 |
const RATParamArray& Params() const;
|
|
227 |
|
|
228 |
/**
|
|
229 |
* Clones CHsHFPCommand object
|
|
230 |
*
|
|
231 |
* @param aCmdFrom source
|
|
232 |
* @param aCmdTo destination
|
|
233 |
*/
|
|
234 |
static void CopyL(const CHsHFPCommand& aCmdFrom, CHsHFPCommand& aCmdTo);
|
|
235 |
|
|
236 |
private:
|
|
237 |
/**
|
|
238 |
* Constructor for performing 1st stage construction
|
|
239 |
*/
|
|
240 |
CHsHFPCommand();
|
|
241 |
|
|
242 |
/**
|
|
243 |
* Constructor for performing 2nd stage construction
|
|
244 |
*/
|
|
245 |
void ConstructL();
|
|
246 |
|
|
247 |
private:
|
|
248 |
|
|
249 |
/** Granulity of AT params array */
|
|
250 |
const TInt KParamArrayGranularity = 3;
|
|
251 |
|
|
252 |
/** Max length of AT type descriptor */
|
|
253 |
const TInt KTypeDesMaxLength = 9;
|
|
254 |
|
|
255 |
/** Max length of AT mode descriptor */
|
|
256 |
const TInt KModeDesMaxLength = 3;
|
|
257 |
|
|
258 |
/** Max length of AT param descriptor */
|
|
259 |
const TInt KParamsDesMaxLength = 200;
|
|
260 |
|
|
261 |
/** Command type */
|
|
262 |
THsHFPCommandType iType;
|
|
263 |
|
|
264 |
/** Command mode */
|
|
265 |
THsHFPCommandMode iMode;
|
|
266 |
|
|
267 |
/** Denotes if AT command was sent from AG or HF */
|
|
268 |
TBool iFromAG;
|
|
269 |
|
|
270 |
/** Array of params */
|
|
271 |
RATParamArray iParams;
|
|
272 |
|
|
273 |
/** Command type as descriptor */
|
|
274 |
RBuf8 iTypeDes;
|
|
275 |
|
|
276 |
/** Command mode as descriptor */
|
|
277 |
RBuf8 iModeDes;
|
|
278 |
|
|
279 |
/** Command params as descriptor */
|
|
280 |
RBuf8 iParamsDes;
|
|
281 |
};
|
|
282 |
|
|
283 |
#endif /* HFPCOMMAND_H_ */
|