24
|
1 |
// Copyright (c) 2001-2009 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 |
//
|
|
15 |
|
|
16 |
#include "gprs.h"
|
|
17 |
#include "Gprscontext.h"
|
|
18 |
#include "mSLOGGER.H"
|
|
19 |
#include <pcktcs.h>
|
|
20 |
#include "AtGprsClass.h"
|
|
21 |
#include "ATIO.H"
|
|
22 |
#include <etelpckt.h>
|
|
23 |
#include "TSYCONFG.H"
|
|
24 |
#include "NOTIFY.H"
|
|
25 |
#include "Matstd.h"
|
|
26 |
|
|
27 |
|
|
28 |
/**
|
|
29 |
* @file
|
|
30 |
* This file implements the CATGprsClass class which is one of the state machine used by the
|
|
31 |
* GPRS AT TSY library.
|
|
32 |
* This state machine uses the "AT+CGCLASS" command.
|
|
33 |
*/
|
|
34 |
|
|
35 |
CATGprsClass* CATGprsClass::NewL(CATIO* aIo, CTelObject* aTelObject, CATInit* aInit, CPhoneGlobals* aPhoneGlobals)
|
|
36 |
/**
|
|
37 |
* Standard 2 phase constructor.
|
|
38 |
* @param aIo pointer to communication object.
|
|
39 |
* @param aTelObject pointer to parent.
|
|
40 |
* @param aInit pointer to AT phone init object.
|
|
41 |
* @param aPhoneGlobals pointer to phone global wide states.
|
|
42 |
*/
|
|
43 |
{
|
|
44 |
CATGprsClass* p=new(ELeave) CATGprsClass(aIo, aTelObject, aInit, aPhoneGlobals);
|
|
45 |
CleanupStack::PushL(p);
|
|
46 |
p->ConstructL();
|
|
47 |
CleanupStack::Pop();
|
|
48 |
return p;
|
|
49 |
}
|
|
50 |
|
|
51 |
void CATGprsClass::ConstructL()
|
|
52 |
/**
|
|
53 |
* Construct all objects that can leave.
|
|
54 |
*/
|
|
55 |
{
|
|
56 |
CATCommands::ConstructL();
|
|
57 |
}
|
|
58 |
|
|
59 |
CATGprsClass::CATGprsClass(CATIO* aIo, CTelObject* aTelObject, CATInit* aInit, CPhoneGlobals* aPhoneGlobals)
|
|
60 |
: CATCommands(aIo, aTelObject, aInit, aPhoneGlobals)
|
|
61 |
/**
|
|
62 |
* Constructor.
|
|
63 |
* @param aIo pointer to communication object.
|
|
64 |
* @param aTelObject pointer to parent.
|
|
65 |
* @param aInit pointer to AT phone init object.
|
|
66 |
* @param aPhoneGlobals pointer to phone global wide states.
|
|
67 |
*/
|
|
68 |
{
|
|
69 |
LOGTEXT(_L8("CATGprsClass::CATGprsClass called"));
|
|
70 |
}
|
|
71 |
|
|
72 |
|
|
73 |
CATGprsClass::~CATGprsClass()
|
|
74 |
/**
|
|
75 |
* Destructor.
|
|
76 |
*/
|
|
77 |
{
|
|
78 |
LOGTEXT(_L8("CATGprsClass::~CATGprsClass called"));
|
|
79 |
iIo->RemoveExpectStrings(this);
|
|
80 |
}
|
|
81 |
|
|
82 |
void CATGprsClass::Start(TTsyReqHandle aTsyReqHandle, TAny* aParams)
|
|
83 |
/**
|
|
84 |
* This is the standard entry point for sending class command.
|
|
85 |
*/
|
|
86 |
{
|
|
87 |
iClass = REINTERPRET_CAST(RPacketService::TMSClass*, aParams);
|
|
88 |
if(MakeupCGCLASS(*iClass) == KErrNotSupported)
|
|
89 |
{
|
|
90 |
iTelObject->ReqCompleted(aTsyReqHandle, KErrArgument);
|
|
91 |
return;
|
|
92 |
}
|
|
93 |
iReqHandle = aTsyReqHandle;
|
|
94 |
iState=ESendClassCommand;
|
|
95 |
Write(KGprsCommandTimeOut);
|
|
96 |
}
|
|
97 |
|
|
98 |
void CATGprsClass::Stop(TTsyReqHandle aTsyReqHandle)
|
|
99 |
/**
|
|
100 |
*/
|
|
101 |
{
|
|
102 |
LOGTEXT(_L8("CATGprsClass::Stop called"));
|
|
103 |
if(iState!=EATNotInProgress && aTsyReqHandle==iReqHandle)
|
|
104 |
{
|
|
105 |
LOGTEXT(_L8("CATGprsClass::Stop Cancelling client request"));
|
|
106 |
Complete(KErrCancel,ETimeOutCompletion);
|
|
107 |
}
|
|
108 |
}
|
|
109 |
|
|
110 |
void CATGprsClass::CompleteWithIOError(TEventSource aSource,TInt aStatus)
|
|
111 |
/**
|
|
112 |
* This Function completes the command from the client with an error.
|
|
113 |
* @param aSource source of event from communication class.
|
|
114 |
* @param aStatus status of event.
|
|
115 |
*/
|
|
116 |
{
|
|
117 |
LOGTEXT(_L8("CATGprsClass::CompleteWithIOError called"));
|
|
118 |
Complete(aStatus, aSource);
|
|
119 |
}
|
|
120 |
|
|
121 |
|
|
122 |
void CATGprsClass::Complete(TInt aError,TEventSource aSource)
|
|
123 |
/**
|
|
124 |
* This Function completes the command from the client.
|
|
125 |
*
|
|
126 |
* @param aError an error code to relay to client.
|
|
127 |
*/
|
|
128 |
{
|
|
129 |
LOGTEXT2(_L8("CATGprsClass::Complete called error: %d"), aError);
|
|
130 |
RemoveStdExpectStrings();
|
|
131 |
iIo->WriteAndTimerCancel(this);
|
|
132 |
iIo->RemoveExpectStrings(this);
|
|
133 |
if (aError==KErrNone)
|
|
134 |
{
|
|
135 |
((CGprs*)iTelObject)->SetCurrentMSClass(*iClass);
|
|
136 |
}
|
|
137 |
|
|
138 |
// Allow our base class to do its thing and then complete the client request
|
|
139 |
CATCommands::Complete(aError,aSource);
|
|
140 |
iTelObject->ReqCompleted(iReqHandle, aError);
|
|
141 |
|
|
142 |
iState=EATNotInProgress;
|
|
143 |
}
|
|
144 |
|
|
145 |
|
|
146 |
void CATGprsClass::EventSignal(TEventSource aSource)
|
|
147 |
/**
|
|
148 |
* This function contains the state machine for the command. The states flow consecutively and are
|
|
149 |
* described below.
|
|
150 |
*
|
|
151 |
* @par ESendClassCommand
|
|
152 |
* Wait for response to the AT+CGCLASS=%S command.
|
|
153 |
*
|
|
154 |
* @par EClassReadComplete
|
|
155 |
* Reads the Modem's response to the AT+CGCLASS=%S command and completes the request.
|
|
156 |
*
|
|
157 |
*/
|
|
158 |
{
|
|
159 |
if ((aSource==ETimeOutCompletion) )
|
|
160 |
{
|
|
161 |
LOGTEXT(_L8("CATGprsClass::EventSignal, Timeout"));
|
|
162 |
Complete(KErrTimedOut,aSource);
|
|
163 |
return;
|
|
164 |
}
|
|
165 |
switch(iState)
|
|
166 |
{
|
|
167 |
case ESendClassCommand:
|
|
168 |
{
|
|
169 |
LOGTEXT(_L8("CATGprsClass::EventSignal, ESendConnectCommand"));
|
|
170 |
__ASSERT_ALWAYS(aSource==EWriteCompletion,Panic(EATCommand_IllegalCompletionWriteExpected));
|
|
171 |
StandardWriteCompletionHandler(aSource, KGprsCommandTimeOut);
|
|
172 |
iState = EClassReadComplete;
|
|
173 |
}
|
|
174 |
break;
|
|
175 |
case EClassReadComplete:
|
|
176 |
{
|
|
177 |
LOGTEXT(_L8("CATGprsClass::EventSignal, EConnectReadComplete"));
|
|
178 |
__ASSERT_ALWAYS(aSource==EReadCompletion,Panic(EATCommand_IllegalCompletionReadExpected));
|
|
179 |
TInt ret = ValidateExpectString();
|
|
180 |
Complete(ret, aSource);
|
|
181 |
}
|
|
182 |
break;
|
|
183 |
case EATNotInProgress:
|
|
184 |
break;
|
|
185 |
default:
|
|
186 |
{
|
|
187 |
LOGTEXT(_L8("CATGprsClass::EventSignal, Default, panic"));
|
|
188 |
Panic(EIllegalEvent);
|
|
189 |
}
|
|
190 |
}
|
|
191 |
}
|
|
192 |
|
|
193 |
TInt CATGprsClass::MakeupCGCLASS(RPacketService::TMSClass aClass)
|
|
194 |
/**
|
|
195 |
* This function creates the AT+CGCLASS string to send to the phone.
|
|
196 |
* The main task of this function is to populate iTxBuffer.
|
|
197 |
* @param aClass MSClass to set.
|
|
198 |
*/
|
|
199 |
{
|
|
200 |
_LIT8(KCGClass, "AT+CGCLASS=%S\r");
|
|
201 |
switch(aClass)
|
|
202 |
{
|
|
203 |
case RPacketService::EMSClassDualMode:
|
|
204 |
iTxBuffer.Format(KCGClass, &KMSClassA);
|
|
205 |
break;
|
|
206 |
case RPacketService::EMSClassSuspensionRequired:
|
|
207 |
iTxBuffer.Format(KCGClass, &KMSClassB);
|
|
208 |
break;
|
|
209 |
case RPacketService::EMSClassAlternateMode:
|
|
210 |
iTxBuffer.Format(KCGClass, &KMSClassCAlternateMode);
|
|
211 |
break;
|
|
212 |
case RPacketService::EMSClassPacketSwitchedOnly:
|
|
213 |
iTxBuffer.Format(KCGClass, &KMSClassCGPRSOnly);
|
|
214 |
break;
|
|
215 |
case RPacketService::EMSClassCircuitSwitchedOnly:
|
|
216 |
iTxBuffer.Format(KCGClass, &KMSClassCCircuitSwitchedOnly);
|
|
217 |
break;
|
|
218 |
default:
|
|
219 |
return KErrNotSupported;
|
|
220 |
}
|
|
221 |
return KErrNone;
|
|
222 |
}
|