0
|
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 the License "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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#include "modemat_atext.h"
|
|
21 |
#include "modemattrace.h"
|
|
22 |
|
|
23 |
const TInt KMaxCommandCount(160);
|
|
24 |
|
|
25 |
const char* const atCommands[] =
|
|
26 |
{
|
|
27 |
("ATS0"),
|
|
28 |
("ATS1"),
|
|
29 |
("ATS2"),
|
|
30 |
("ATS3"),
|
|
31 |
("ATS4"),
|
|
32 |
("ATS5"),
|
|
33 |
("ATS6"),
|
|
34 |
("ATS7"),
|
|
35 |
("ATS8"),
|
|
36 |
("ATS10"),
|
|
37 |
("ATS12"),
|
|
38 |
("ATS25"),
|
|
39 |
("ATE"),
|
|
40 |
("ATE0"),
|
|
41 |
("ATE1"),
|
|
42 |
("ATQ"),
|
|
43 |
("ATQ0"),
|
|
44 |
("ATQ1"),
|
|
45 |
("ATV"),
|
|
46 |
("ATV0"),
|
|
47 |
("ATV1"),
|
|
48 |
("ATX"),
|
|
49 |
("ATX0"),
|
|
50 |
("ATX1"),
|
|
51 |
("ATX2"),
|
|
52 |
("ATX3"),
|
|
53 |
("ATX4"),
|
|
54 |
("ATX5"),
|
|
55 |
("AT&C"),
|
|
56 |
("AT&C0"),
|
|
57 |
("AT&C1"),
|
|
58 |
("AT&D"),
|
|
59 |
("AT&D0"),
|
|
60 |
("AT&D1"),
|
|
61 |
("AT&D2"),
|
|
62 |
("AT&D3"),
|
|
63 |
("AT+IFC"),
|
|
64 |
("AT+ILRR"),
|
|
65 |
("ATS25"),
|
|
66 |
("AT&S"),
|
|
67 |
("AT&S0"),
|
|
68 |
("AT&S1"),
|
|
69 |
("AT&K"),
|
|
70 |
("AT&K0"),
|
|
71 |
("AT&K3"),
|
|
72 |
("AT&K4"),
|
|
73 |
("ATZ"),
|
|
74 |
("ATZ0"),
|
|
75 |
("ATZ1"),
|
|
76 |
("AT&F"),
|
|
77 |
("AT&F0"),
|
|
78 |
("ATI"), //ati0-255 accepted
|
|
79 |
("AT+GMI"),
|
|
80 |
("AT+GMM"),
|
|
81 |
("AT+GMR"),
|
|
82 |
("AT+GSN"),
|
|
83 |
("AT+GCAP"),
|
|
84 |
("AT&V"),
|
|
85 |
("AT&V0"),
|
|
86 |
("AT&V1"),
|
|
87 |
("AT&V2"),
|
|
88 |
("AT&W"),
|
|
89 |
("AT&W0"),
|
|
90 |
("AT&W1"),
|
|
91 |
("AT&Y"),
|
|
92 |
("AT&Y0"),
|
|
93 |
("AT&Y1"),
|
|
94 |
("AT+CGMI"),
|
|
95 |
("AT+CGMM"),
|
|
96 |
("AT+CGMR"),
|
|
97 |
("AT+CGSN"),
|
|
98 |
("AT+CSCS"),
|
|
99 |
("AT+CIMI"),
|
|
100 |
("AT+WS46"),
|
|
101 |
("ATD"),
|
|
102 |
("ATA"),
|
|
103 |
("ATH"),
|
|
104 |
("ATH0"),
|
|
105 |
("ATO"),
|
|
106 |
("ATO0"),
|
|
107 |
("ATT"),
|
|
108 |
("ATP"),
|
|
109 |
("AT+DS"),
|
|
110 |
("AT+DR"),
|
|
111 |
("ATB"),
|
|
112 |
("ATB0"),
|
|
113 |
("ATB1"),
|
|
114 |
("ATB2"),
|
|
115 |
("AT+CSTA"),
|
|
116 |
("AT+CHUP"),
|
|
117 |
("AT+CR"),
|
|
118 |
("AT+CEER"),
|
|
119 |
("AT+CRC"),
|
|
120 |
("AT+CSNS"),
|
|
121 |
("AT+CVHU"),
|
|
122 |
("AT+CREG"),
|
|
123 |
("AT+COPS"),
|
|
124 |
("AT+CLIP"),
|
|
125 |
("AT+CLIR"),
|
|
126 |
("AT+COLP"),
|
|
127 |
("AT+CCFC"),
|
|
128 |
("AT+CCWA"),
|
|
129 |
("AT+CHLD"),
|
|
130 |
("AT+CLCC"),
|
|
131 |
("AT+CSSN"),
|
|
132 |
("AT+CPAS"),
|
|
133 |
("AT+CSQ"),
|
|
134 |
("AT+CMEE"),
|
|
135 |
("AT+CSMS"),
|
|
136 |
("AT+CPMS"),
|
|
137 |
("AT+CMGF"),
|
|
138 |
("AT+CSCA"),
|
|
139 |
("AT+CSMP"),
|
|
140 |
("AT+CSDH"),
|
|
141 |
("AT+CSAS"),
|
|
142 |
("AT+CRES"),
|
|
143 |
("AT+CMGS"),
|
|
144 |
("AT+CMGC"),
|
|
145 |
("AT+CMMS"),
|
|
146 |
("AT+CGSMS"),
|
|
147 |
("AT+FCLASS"),
|
|
148 |
("AT+VTS"),
|
|
149 |
("AT+CGDCONT"),
|
|
150 |
("AT+CGEQREQ"),
|
|
151 |
("AT+CGEQMIN"),
|
|
152 |
("AT+CGEQNEG"),
|
|
153 |
("AT+CGREG"),
|
|
154 |
("AT+CGATT"),
|
|
155 |
("AT+CGACT"),
|
|
156 |
("AT+CGDATA"),
|
|
157 |
("AT+CGDSCONT"),
|
|
158 |
("AT+CGTFT"),
|
|
159 |
("AT+CGCMOD"),
|
|
160 |
("AT+CBCIE"),
|
|
161 |
("AT*NAUTODISC"),
|
|
162 |
("AT*NRLP"),
|
|
163 |
("AT*NSYNCSEQ"),
|
|
164 |
("AT*NVTMODE"),
|
|
165 |
("AT*NTRACE"),
|
|
166 |
("AT*NNET"),
|
|
167 |
("AT*NOKIAFBUS"),
|
|
168 |
("AT*NPTTLOGIN"),
|
|
169 |
("AT*NPTTLOGOFF"),
|
|
170 |
("AT*NPTTATTACH"),
|
|
171 |
("AT*NPTTDETACH"),
|
|
172 |
("AT*NPTT"),
|
|
173 |
("AT*NTESTSYSTEM"),
|
|
174 |
("AT*NLOGGING"),
|
|
175 |
("AT*NBALOCK"),
|
|
176 |
("AT*NCHLOCK"),
|
|
177 |
("AT*NCELLBARR"),
|
|
178 |
("AT*NEOTD"),
|
|
179 |
("AT*NTESTAUDIO"),
|
|
180 |
("AT*NSECLOCK"),
|
|
181 |
("AT*NSYSLOCK"),
|
|
182 |
("AT*NUMAMODE"),
|
|
183 |
("AT*NSMSROUTE"),
|
|
184 |
("AT"),
|
|
185 |
("LAST")
|
|
186 |
};
|
|
187 |
const TInt KPartLength = KDefaultCmdBufLength;
|
|
188 |
const TInt KPackets = 10;
|
|
189 |
|
|
190 |
_LIT8(KATDCommand,"ATD");
|
|
191 |
_LIT8(KATICommand,"ATI");
|
|
192 |
_LIT8(KLastCommand,"LAST");
|
|
193 |
|
|
194 |
|
|
195 |
TPtrC8 CModemATExt::GetAtCommand( TInt aNumber ) //list of supported commands for this plugin
|
|
196 |
{
|
|
197 |
C_TRACE((_L("CModemATExt::GetAtCommand(%d)"), aNumber));
|
|
198 |
const TUint8 **keys = (const TUint8**) atCommands;
|
|
199 |
TPtrC8 keyword( aNumber < KMaxCommandCount ? keys[ aNumber ] : keys[ KMaxCommandCount - 1 ] );
|
|
200 |
return keyword;
|
|
201 |
}
|
|
202 |
|
|
203 |
CModemATExt* CModemATExt::NewL()
|
|
204 |
{
|
|
205 |
C_TRACE((_L("CModemATExt::NewL")));
|
|
206 |
CModemATExt* self = new (ELeave) CModemATExt();
|
|
207 |
CleanupStack::PushL(self);
|
|
208 |
self->ConstructL();
|
|
209 |
CleanupStack::Pop(self);
|
|
210 |
return self;
|
|
211 |
}
|
|
212 |
|
|
213 |
CModemATExt::~CModemATExt()
|
|
214 |
{
|
|
215 |
C_TRACE((_L("CModemATExt::~CModemATExt()")));
|
|
216 |
if (iReplyBuffer)
|
|
217 |
{
|
|
218 |
delete iReplyBuffer;
|
|
219 |
iReplyBuffer = NULL;
|
|
220 |
}
|
|
221 |
|
|
222 |
if(iUnsolicitedBuffer)
|
|
223 |
{
|
|
224 |
delete iUnsolicitedBuffer;
|
|
225 |
iUnsolicitedBuffer = NULL;
|
|
226 |
}
|
|
227 |
if( iCommandBuf )
|
|
228 |
{
|
|
229 |
delete iCommandBuf;
|
|
230 |
iCommandBuf = NULL;
|
|
231 |
}
|
|
232 |
iRModemAt.Disconnect();
|
|
233 |
}
|
|
234 |
|
|
235 |
TBool CModemATExt::IsCommandSupported( const TDesC8& aCmd)
|
|
236 |
{
|
|
237 |
C_TRACE((_L("CModemATExt::IsCommandSupported")));
|
|
238 |
DUMP_MESSAGE((aCmd));
|
|
239 |
|
|
240 |
if(aCmd.Find( KATDCommand )!=KErrNotFound)
|
|
241 |
{
|
|
242 |
C_TRACE((_L("ATD")));
|
|
243 |
return ETrue;
|
|
244 |
}
|
|
245 |
if(aCmd.Find(KATICommand)!=KErrNotFound)
|
|
246 |
{
|
|
247 |
C_TRACE((_L("ATI")));
|
|
248 |
return ETrue;
|
|
249 |
}
|
|
250 |
for ( TInt i = 0; i < KMaxCommandCount; i++ )
|
|
251 |
{
|
|
252 |
C_TRACE((_L("round %d"),i));
|
|
253 |
if( GetAtCommand(i).Find(KLastCommand) != KErrNotFound)
|
|
254 |
{
|
|
255 |
// All messages have been searched so the command is not supported
|
|
256 |
C_TRACE((_L("********* COMMAND IS NOT SUPPORTED ********* ")));
|
|
257 |
DUMP_MESSAGE(aCmd);
|
|
258 |
return EFalse;
|
|
259 |
}
|
|
260 |
|
|
261 |
if(aCmd.Find(GetAtCommand(i))!=KErrNotFound)
|
|
262 |
{
|
|
263 |
//just command
|
|
264 |
C_TRACE((_L("Command"),i));
|
|
265 |
if(aCmd.Length()==GetAtCommand(i).Length())
|
|
266 |
{
|
|
267 |
C_TRACE((_L("Ok"),i));
|
|
268 |
return ETrue;
|
|
269 |
}
|
|
270 |
|
|
271 |
if(aCmd.Length()>GetAtCommand(i).Length()) //setting command
|
|
272 |
{
|
|
273 |
C_TRACE((_L("Setting")));
|
|
274 |
if( aCmd[GetAtCommand(i).Length()] == '=' ||
|
|
275 |
aCmd[GetAtCommand(i).Length()] == '?' )
|
|
276 |
{
|
|
277 |
C_TRACE((_L("Ok"),i));
|
|
278 |
return ETrue;
|
|
279 |
}
|
|
280 |
}
|
|
281 |
}
|
|
282 |
}
|
|
283 |
C_TRACE((_L("return EFalse")));
|
|
284 |
return EFalse;
|
|
285 |
}
|
|
286 |
|
|
287 |
void CModemATExt::HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded )
|
|
288 |
{
|
|
289 |
C_TRACE((_L("CModemATExt::HandleCommand()" )));
|
|
290 |
DUMP_MESSAGE(aCmd);
|
|
291 |
|
|
292 |
iReply = &aReply;
|
|
293 |
iReplyNeeded = aReplyNeeded;
|
|
294 |
if( iCommandBuf )
|
|
295 |
{
|
|
296 |
delete iCommandBuf;
|
|
297 |
iCommandBuf = NULL;
|
|
298 |
}
|
|
299 |
iCommandBuf = HBufC8::New( aCmd.Length() + 1 );
|
|
300 |
TPtr8 ptr = iCommandBuf->Des();
|
|
301 |
ptr.Append( aCmd );
|
|
302 |
ptr.Append( iCarriageReturn );
|
|
303 |
iRModemAt.HandleATCommand( ptr, iReplyPtr );
|
|
304 |
}
|
|
305 |
|
|
306 |
void CModemATExt::HandleCommandCancel()
|
|
307 |
{
|
|
308 |
C_TRACE((_L("CModemATExt::HandleCommandCancel()")));
|
|
309 |
iRModemAt.HandleATCommandCancel();
|
|
310 |
}
|
|
311 |
|
|
312 |
TInt CModemATExt::NextReplyPartLength()
|
|
313 |
{
|
|
314 |
C_TRACE((_L("CModemATExt::NextReplyPartLength()")));
|
|
315 |
return Min( iReplyPtr.Length(), KPartLength);
|
|
316 |
}
|
|
317 |
|
|
318 |
TInt CModemATExt::GetNextPartOfReply( RBuf8& aNextReply )
|
|
319 |
{
|
|
320 |
C_TRACE((_L("CModemATExt::GetNextPartOfReply()")));
|
|
321 |
aNextReply.Create(iReplyPtr,KPartLength);
|
|
322 |
iReplyPtr.Delete(0,KPartLength);
|
|
323 |
return KErrNone;
|
|
324 |
}
|
|
325 |
|
|
326 |
void CModemATExt::ReceiveUnsolicitedResult()
|
|
327 |
{
|
|
328 |
C_TRACE((_L("CModemATExt::ReceiveUnsolicitedResult()")));
|
|
329 |
iRModemAt.ReceiveUnsolicitedResult(iUnsolicitedPtr);
|
|
330 |
}
|
|
331 |
|
|
332 |
void CModemATExt::ReceiveUnsolicitedResultCancel()
|
|
333 |
{
|
|
334 |
C_TRACE((_L("CModemATExt::ReceiveUnsolicitedResultCancel")));
|
|
335 |
iRModemAt.ReceiveUnsolicitedResultCancel();
|
|
336 |
}
|
|
337 |
|
|
338 |
TBool CModemATExt::HandleEditorModeInput( const TDesC8& /*aInput*/,
|
|
339 |
RBuf8& /*aReply*/,
|
|
340 |
TBool& /*aEchoOn*/)
|
|
341 |
{
|
|
342 |
C_TRACE((_L("CModemATExt::HandleEditorModeInput()")));
|
|
343 |
return EFalse; //commands are execute commands, this function is newer called
|
|
344 |
}
|
|
345 |
|
|
346 |
void CModemATExt::ReportNvramStatusChange( const TDesC8& /*aNvram*/ )
|
|
347 |
{
|
|
348 |
C_TRACE((_L("CModemATExt::ReportNvramStatusChange()")));
|
|
349 |
//Ignored in this plugin
|
|
350 |
}
|
|
351 |
|
|
352 |
|
|
353 |
CModemATExt::CModemATExt() :
|
|
354 |
iReplyBuffer(NULL),
|
|
355 |
iReplyPtr(0, 0),
|
|
356 |
iUnsolicitedPtr(0, 0),
|
|
357 |
iUnsolicitedBuffer(NULL),
|
|
358 |
iReply(NULL),
|
|
359 |
iReplyNeeded(EFalse)
|
|
360 |
{
|
|
361 |
C_TRACE((_L("CModemATExt::CModemATExt()")));
|
|
362 |
}
|
|
363 |
|
|
364 |
void CModemATExt::ConstructL()
|
|
365 |
{
|
|
366 |
C_TRACE((_L("CModemATExt::ConstructL()")));
|
|
367 |
iReplyBuffer = HBufC8::NewL( KDefaultCmdBufLength * KPackets );
|
|
368 |
iReplyPtr.Set( iReplyBuffer->Des() );
|
|
369 |
iUnsolicitedBuffer = HBufC8::NewL(KDefaultCmdBufLength);
|
|
370 |
}
|
|
371 |
|
|
372 |
void CModemATExt::ReportConnectionName( const TDesC8& aName )
|
|
373 |
{
|
|
374 |
C_TRACE((_L("CModemATExt::ReportConnectionName()")));
|
|
375 |
DUMP_MESSAGE((aName));
|
|
376 |
iName.Copy(aName);
|
|
377 |
iRModemAt.Connect(EATExtPlugin, iName, this);
|
|
378 |
}
|
|
379 |
|
|
380 |
void CModemATExt::HandleATCommandCompleted( TInt aErr )
|
|
381 |
{
|
|
382 |
C_TRACE((_L("CModemATExt::HandleATCommandCompleted()")));
|
|
383 |
|
|
384 |
if(iReplyNeeded)
|
|
385 |
{
|
|
386 |
C_TRACE((_L("Reply needed")));
|
|
387 |
iReply->Create( iReplyPtr,KPartLength );
|
|
388 |
}
|
|
389 |
|
|
390 |
iReplyPtr.Delete(0, KPartLength);
|
|
391 |
C_TRACE((_L("Error status %d"),aErr));
|
|
392 |
|
|
393 |
if( aErr == KErrNone)
|
|
394 |
{
|
|
395 |
C_TRACE((_L("No errors")));
|
|
396 |
HandleCommandCompleted(aErr, EReplyTypeOk);
|
|
397 |
}
|
|
398 |
else
|
|
399 |
{
|
|
400 |
C_TRACE((_L("Reply Error")));
|
|
401 |
HandleCommandCompleted(aErr, EReplyTypeError);
|
|
402 |
}
|
|
403 |
}
|
|
404 |
|
|
405 |
void CModemATExt::HandleUnsolicitedResultReceived( TInt /*aErr*/ )
|
|
406 |
{
|
|
407 |
C_TRACE((_L("CModemATExt::HandleUnsolicitedResultReceived")));
|
|
408 |
SendUnsolicitedResult( iUnsolicitedPtr );
|
|
409 |
}
|
|
410 |
|
|
411 |
void CModemATExt::HandleSignalIndication( TInt /*aErr*/ )
|
|
412 |
{
|
|
413 |
C_TRACE((_L("CModemATExt::HandleSignalIndication")));
|
|
414 |
//COMMON plugin handles signal indications
|
|
415 |
}
|
|
416 |
|
|
417 |
void CModemATExt::ReportExternalHandleCommandError()
|
|
418 |
{
|
|
419 |
C_TRACE((_L("CModemATExt::ReportExternalHandleCommandError()")));
|
|
420 |
//external error occurred, cancel AT-command
|
|
421 |
iRModemAt.HandleATCommandCancel();
|
|
422 |
}
|
|
423 |
|
|
424 |
void CModemATExt::HandleCommandModeChanged( TInt /*aErr*/, TCommandMode /*aMode*/ )
|
|
425 |
{
|
|
426 |
C_TRACE((_L("CModemATExt::HandleCommandModeChanged()")));
|
|
427 |
//COMMON plugin handles mode change requests
|
|
428 |
}
|
|
429 |
// End of File
|