44
|
1 |
// Copyright (c) 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 |
// The set command controls the presentation of an unsolicited result code +CGREG:
|
|
15 |
// <stat> when <n>=1 and there is a change in the MT's GPRS network registration
|
|
16 |
// status, or code +CGREG: <stat>[,<lac>,<ci>] when <n>=2 and there is a change of the
|
|
17 |
// network cell.
|
|
18 |
// The read command returns the status of result code presentation and an integer <stat>
|
|
19 |
// which shows whether the network has currently indicated the registration of the MT.
|
|
20 |
// Location information elements <lac> and <ci> are returned only when <n>=2 and MT
|
|
21 |
// is registered in the network.
|
|
22 |
// Defined values
|
|
23 |
// <n>:
|
|
24 |
// 0 disable network registration unsolicited result code
|
|
25 |
// 1 enable network registration unsolicited result code +CGREG: <stat>
|
|
26 |
// 2 enable network registration and location information unsolicited result code
|
|
27 |
// +CGREG: <stat>[,<lac>,<ci>]
|
|
28 |
// <stat>:
|
|
29 |
// 0 not registered, ME is not currently searching a new operator to register to
|
|
30 |
// 1 registered, home network
|
|
31 |
// 2 not registered, but ME is currently searching a new operator to register to
|
|
32 |
// 3 registration denied
|
|
33 |
// 4 unknown
|
|
34 |
// 5 registered, roaming
|
|
35 |
// <lac>:
|
|
36 |
// string type; two byte location area code in hexadecimal format.
|
|
37 |
// <ci>:
|
|
38 |
// string type; two byte cell ID in hexadecimal format
|
|
39 |
|
|
40 |
#include "atgprsntwkregstatus.h" // Header file for this source file
|
|
41 |
#include "mslogger.h" // For LOGTEXT macros
|
|
42 |
#include "atgprsntwkregstatuschange.h"
|
|
43 |
|
|
44 |
_LIT8(KATGprsNtwkRegStatusCommand, "AT+CGREG?\r");
|
|
45 |
_LIT8(KATGetGprsNetworkRegResponse,"+CGREG:");
|
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
// CATGprsNtwkRegStatus::NewL
|
|
49 |
// other items were commented in a header
|
|
50 |
// ---------------------------------------------------------------------------
|
|
51 |
CATGprsNtwkRegStatus* CATGprsNtwkRegStatus::NewL(CGlobalPhonemanager& aGloblePhone,
|
|
52 |
CCtsyDispatcherCallback& aCtsyDispatcherCallback,
|
|
53 |
CATGprsNtwkRegStatusChange& aNtwkRegStatusChange)
|
|
54 |
{
|
|
55 |
CATGprsNtwkRegStatus* self = new(ELeave) CATGprsNtwkRegStatus(aGloblePhone,
|
|
56 |
aCtsyDispatcherCallback,
|
|
57 |
aNtwkRegStatusChange);
|
|
58 |
CleanupStack::PushL(self );
|
|
59 |
self->ConstructL();
|
|
60 |
CleanupStack::Pop(self );
|
|
61 |
return self ;
|
|
62 |
}
|
|
63 |
|
|
64 |
// ---------------------------------------------------------------------------
|
|
65 |
// CATGprsNtwkRegStatus::CATGprsNtwkRegStatus
|
|
66 |
// other items were commented in a header
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
CATGprsNtwkRegStatus::CATGprsNtwkRegStatus(CGlobalPhonemanager& aGloblePhone,
|
|
69 |
CCtsyDispatcherCallback& aCtsyDispatcherCallback,
|
|
70 |
CATGprsNtwkRegStatusChange& aNtwkRegStatusChange)
|
|
71 |
:CAtCommandBase(aGloblePhone,aCtsyDispatcherCallback),
|
|
72 |
iNtwkRegStatusChange(aNtwkRegStatusChange)
|
|
73 |
{
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
// CATGprsNtwkRegStatus::ConstructL
|
|
78 |
// other items were commented in a header
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
void CATGprsNtwkRegStatus::ConstructL()
|
|
81 |
{
|
|
82 |
CAtCommandBase::ConstructL();
|
|
83 |
}
|
|
84 |
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
// CATGprsNtwkRegStatus::~CATGprsNtwkRegStatus
|
|
87 |
// other items were commented in a header
|
|
88 |
// ---------------------------------------------------------------------------
|
|
89 |
CATGprsNtwkRegStatus::~CATGprsNtwkRegStatus()
|
|
90 |
{
|
|
91 |
}
|
|
92 |
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
// CATGprsNtwkRegStatus::StartRequestL
|
|
95 |
// other items were commented in a header
|
|
96 |
// ---------------------------------------------------------------------------
|
|
97 |
void CATGprsNtwkRegStatus::StartRequest()
|
|
98 |
{
|
|
99 |
iNtwkRegStatusChange.Disable();
|
|
100 |
ExecuteCommand();
|
|
101 |
}
|
|
102 |
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
// CATGprsNtwkRegStatus::ExecuteCommand
|
|
105 |
// other items were commented in a header
|
|
106 |
// ---------------------------------------------------------------------------
|
|
107 |
void CATGprsNtwkRegStatus::ExecuteCommand()
|
|
108 |
{
|
|
109 |
iTxBuffer.Copy(KATGprsNtwkRegStatusCommand);
|
|
110 |
Write();
|
|
111 |
}
|
|
112 |
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
// CATGprsNtwkRegStatus::ParseResponseL
|
|
115 |
// other items were commented in a header
|
|
116 |
//
|
|
117 |
// ---------------------------------------------------------------------------
|
|
118 |
void CATGprsNtwkRegStatus::ParseResponseL(const TDesC8& /*aResponseBuf*/)
|
|
119 |
{
|
|
120 |
if (CurrentLine().Match(KLtsyOkString) != 0)
|
|
121 |
{
|
|
122 |
iError = KErrGeneral;
|
|
123 |
return;
|
|
124 |
}
|
|
125 |
RArray<TPtrC8> array;
|
|
126 |
CleanupClosePushL(array);
|
|
127 |
iParser->ParseRespondedBuffer(array,PrecedingLine());
|
|
128 |
TInt Count = array.Count();
|
|
129 |
if (Count < 1)
|
|
130 |
{
|
|
131 |
CleanupStack::PopAndDestroy();
|
|
132 |
iError = KErrGeneral;
|
|
133 |
return ;
|
|
134 |
}
|
|
135 |
if( array[0].MatchF(KATGetGprsNetworkRegResponse)==KErrNotFound)
|
|
136 |
{
|
|
137 |
CleanupStack::PopAndDestroy();
|
|
138 |
iError = KErrGeneral;
|
|
139 |
return ;
|
|
140 |
}
|
|
141 |
|
|
142 |
// Skip over one parameter
|
|
143 |
TInt val = 0;
|
|
144 |
TLex8 lex(array[2]);
|
|
145 |
lex.Val(val);
|
|
146 |
// Convert scond value to equivalent EtelMM enum
|
|
147 |
switch(val)
|
|
148 |
{
|
|
149 |
case 0: // ETSI value as defined in ETSI 07.07 section 10.1.14
|
|
150 |
iGprsRegistrationStatus = RPacketService::ENotRegisteredNotSearching;
|
|
151 |
break;
|
|
152 |
case 1: // ETSI value as defined in ETSI 07.07 section 10.1.14
|
|
153 |
iGprsRegistrationStatus=RPacketService::ERegisteredOnHomeNetwork;
|
|
154 |
break;
|
|
155 |
case 2: // ETSI value as defined in ETSI 07.07 section 10.1.14
|
|
156 |
iGprsRegistrationStatus=RPacketService::ENotRegisteredSearching;
|
|
157 |
break;
|
|
158 |
case 3: // ETSI value as defined in ETSI 07.07 section 10.1.14
|
|
159 |
iGprsRegistrationStatus=RPacketService::ERegistrationDenied;
|
|
160 |
break;
|
|
161 |
case 4: // ETSI value as defined in ETSI 07.07 section 10.1.14
|
|
162 |
iGprsRegistrationStatus=RPacketService::EUnknown;
|
|
163 |
break;
|
|
164 |
case 5: // ETSI value as defined in ETSI 07.07 section 10.1.14
|
|
165 |
iGprsRegistrationStatus=RPacketService::ERegisteredRoaming;
|
|
166 |
break;
|
|
167 |
default:
|
|
168 |
iGprsRegistrationStatus = RPacketService::EUnknown;
|
|
169 |
break;
|
|
170 |
}
|
|
171 |
CleanupStack::PopAndDestroy(&array);
|
|
172 |
iError = KErrNone;
|
|
173 |
} //ParseResponseL
|
|
174 |
|
|
175 |
// ---------------------------------------------------------------------------
|
|
176 |
// CATGprsNtwkRegStatus::EventSignal
|
|
177 |
// other items were commented in a header
|
|
178 |
// ---------------------------------------------------------------------------
|
|
179 |
void CATGprsNtwkRegStatus::EventSignal(TAtEventSource aEventSource, TInt aStatus)
|
|
180 |
{
|
|
181 |
if(KErrNone ==aStatus)
|
|
182 |
{
|
|
183 |
if(aEventSource == EReadCompletion)
|
|
184 |
{
|
|
185 |
aStatus = iError;
|
|
186 |
}
|
|
187 |
else
|
|
188 |
return;
|
|
189 |
}
|
|
190 |
iCtsyDispatcherCallback.CallbackPacketServicesGetPacketNetworkRegistrationStatusComp(aStatus,
|
|
191 |
iGprsRegistrationStatus);
|
|
192 |
iNtwkRegStatusChange.Enable();
|
|
193 |
CAtCommandBase::Complete();
|
|
194 |
iPhoneGlobals.iEventSignalActive = EFalse;
|
|
195 |
}
|
|
196 |
|
|
197 |
// End of file
|
|
198 |
|