author | mikaruus |
Tue, 19 Oct 2010 13:16:20 +0300 | |
changeset 9 | 8486d82aef45 |
parent 8 | 6295dc2169f3 |
permissions | -rw-r--r-- |
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 |
#ifndef CMODEMATSRV_H |
|
21 |
#define CMODEMATSRV_H |
|
22 |
||
23 |
#include <e32svr.h> |
|
24 |
#include "cmodemathandler.h" //KMaxDteIdCount |
|
25 |
#include "modemattrace.h" |
|
26 |
||
27 |
const TUint8 EAtCmd = 0; |
|
28 |
const TUint8 EGetNvramStatus = 1; |
|
9 | 29 |
const TUint8 KMaxDteCount( 3 ); |
0 | 30 |
|
31 |
/* |
|
32 |
* Reference: i_at_modem_fp_3.1.doc (3.5.2) |
|
33 |
* If the unsolicited data needs to be sent to all of the connected DTE sessions, |
|
34 |
* AT Modem server would send the unsolicited data indication to the client with |
|
35 |
* the dte id as 0xFF. The 0xFF value for the DTE id is reserved for the |
|
36 |
* unsolicited data indication. |
|
37 |
*/ |
|
38 |
const TUint8 KUnsolicitedDataDteId = 0xff; |
|
9 | 39 |
const TUint8 KInitialValue = 0xff; |
0 | 40 |
const TInt KATModemCommandArgumentIndex = 0; |
41 |
const TInt KATModemResponseArgumentIndex = 1; |
|
42 |
const TInt KATModemUnsolicitedDataIndex = 0; |
|
43 |
||
44 |
_LIT8( KEmptyString, ""); |
|
45 |
||
9 | 46 |
#define KMaxBufferLength 1024 |
47 |
||
0 | 48 |
class CModemAtSession; |
49 |
class CAtMessage; |
|
50 |
||
9 | 51 |
|
52 |
class TDteInfo |
|
53 |
{ |
|
54 |
public: |
|
55 |
||
56 |
TUint8 iDevId; |
|
57 |
TUint8 iObjId; |
|
58 |
CModemAtSession* iSession; |
|
59 |
}; |
|
60 |
||
61 |
||
0 | 62 |
/** |
63 |
* CModemAtSrv server core class. CModemAtsrc creates/deletes sessions. Dte-ids are allocated |
|
64 |
* by CmodemAtSrv. |
|
65 |
*/ |
|
66 |
NONSHARABLE_CLASS( CModemAtSrv ) : public CPolicyServer |
|
67 |
{ |
|
68 |
||
69 |
public: |
|
70 |
||
71 |
/** |
|
72 |
* Two-phased constructor. |
|
73 |
*/ |
|
74 |
static CModemAtSrv* NewLC(); |
|
75 |
||
76 |
/** |
|
77 |
* Destructor. |
|
78 |
*/ |
|
79 |
~CModemAtSrv(); |
|
80 |
||
81 |
/** |
|
82 |
* When session is closed, this function is called. |
|
83 |
* @param aSession Reference to the session |
|
84 |
*/ |
|
85 |
void ClientClosed( CModemAtSession* aSession ); |
|
86 |
||
87 |
/** |
|
88 |
* Session count |
|
89 |
* @return Number of sessions open |
|
90 |
*/ |
|
91 |
TInt SessionCount(); |
|
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
92 |
|
0 | 93 |
/** |
94 |
* Connect session to the modem |
|
95 |
* @param CModemAtSession* aSession Pointer to the session |
|
8
6295dc2169f3
New release based on our 2010wk15 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
5
diff
changeset
|
96 |
* @param TATPluginInterface aPluginType Atext or common plugin |
0 | 97 |
* @return Connection status: KErrNone, KErrAlreadyExists |
98 |
*/ |
|
9 | 99 |
TInt ConnectToModemL( CModemAtSession* aSession, TATPluginInterface aPluginType); |
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
100 |
|
0 | 101 |
/** |
9 | 102 |
* HandleSignalInd handles AT_MODEM_SIGNAL_IND and notifying ATV, ATQ and ATE changes. |
0 | 103 |
* @param aDteId Device Terminal ID |
9 | 104 |
* @param aCompleteCode Change in V, Q or E is completed to common plugin. |
105 |
*/ |
|
106 |
void HandleSignalInd( const TUint8 aDteId, const TInt aCompleteCode ); |
|
0 | 107 |
/** |
108 |
* HandleUnsolicitedData |
|
109 |
* @param aDteId Device Terminal ID |
|
110 |
* @param aData Descriptor data |
|
111 |
*/ |
|
8
6295dc2169f3
New release based on our 2010wk15 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
5
diff
changeset
|
112 |
void HandleUnsolicitedData( const TUint8 aDteId, const TDesC8& aData ); |
0 | 113 |
/** |
114 |
* HandleIntermediateDataInd |
|
115 |
* @param aDteId Device Terminal ID |
|
116 |
* @param aPluginType Plugin type |
|
117 |
* @param aResponse Response buffer |
|
118 |
* @param aCommand Command buffer |
|
119 |
*/ |
|
8
6295dc2169f3
New release based on our 2010wk15 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
5
diff
changeset
|
120 |
void HandleIntermediateDataInd( const TUint8 aDteId, const TATPluginInterface aPluginType, const TDesC8& aResponse, const TUint8 aCommand ); |
0 | 121 |
|
122 |
/** |
|
123 |
* HandleATResponse |
|
124 |
* @param aDteId Device Terminal ID |
|
125 |
* @param aResponse Response buffer |
|
126 |
*/ |
|
9 | 127 |
void HandleATResponse( |
128 |
const TUint8 aDteId, |
|
129 |
CModemAtHandler* aHandler, |
|
130 |
const TDesC8& aResponse, |
|
131 |
const TUint8 aCommand ); |
|
0 | 132 |
|
133 |
/** |
|
134 |
* HandleCommandModeChange |
|
9 | 135 |
* @param aDteId dte id which mode is changed |
0 | 136 |
* @param aMode Command mode 0 or data mode 1 |
137 |
*/ |
|
9 | 138 |
void HandleCommandModeChange( TUint8 aDteId, TCommandMode aMode ); |
0 | 139 |
|
140 |
/** |
|
141 |
* AddToSendFifo |
|
142 |
* @param aPluginType Plugin type |
|
143 |
* @param aMessage RMessage2 container class |
|
144 |
*/ |
|
8
6295dc2169f3
New release based on our 2010wk15 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
5
diff
changeset
|
145 |
void AddToSendFifo( const TATPluginInterface aPluginType, CAtMessage* aMessage ); |
0 | 146 |
|
147 |
/** |
|
148 |
* RemoveFirstFromSendFifo |
|
149 |
*/ |
|
150 |
void RemoveFirstFromSendFifo(); |
|
151 |
||
152 |
/** |
|
153 |
* SendNextFromFifo |
|
154 |
*/ |
|
155 |
void SendNextFromFifo(); |
|
156 |
||
157 |
/** |
|
158 |
* CancelFifoRequests |
|
159 |
* @param aSession Session class pointer |
|
160 |
*/ |
|
161 |
void CancelFifoRequests( const CModemAtSession* aSession ); |
|
162 |
||
163 |
/** |
|
164 |
* RemovePipe |
|
9 | 165 |
* @param aHandler pointer to message handler |
0 | 166 |
*/ |
9 | 167 |
void RemovePipe( CModemAtHandler* aHandler ); |
168 |
||
169 |
/** |
|
170 |
* Sets DteID for this session |
|
171 |
* @param aDteId DteId |
|
172 |
* @param aConnectionError error |
|
173 |
*/ |
|
174 |
void SetDteIdAndConnect( const TUint8 aDteId, const TInt aConnectionError ); |
|
175 |
||
176 |
/** |
|
177 |
* Check if pipe is in data mode |
|
178 |
* @param CModemAtHandler* aHandler |
|
179 |
* @return True, if pipe is in datamode |
|
180 |
*/ |
|
181 |
TBool IsPipeInDataMode( CModemAtHandler* aHandler ); |
|
182 |
||
183 |
/** |
|
184 |
* Check if text message mode is on |
|
185 |
* @param aHandler pointer to message handler |
|
186 |
* @return ETrue, if +CMGS or +CMGS command has been received |
|
187 |
*/ |
|
188 |
TBool IsTextMessageMode( CModemAtHandler* aHandler ); |
|
189 |
||
190 |
/** |
|
191 |
* Peek if AT command is for sending text messages or if it's reply |
|
192 |
* needs to be notified to ATEXT. This will reduce ISI message overhead, otherwise |
|
193 |
* AT&V command would be needed every time when V, Q or E setting is changed. |
|
194 |
* @param CModemAtHandler* aHandler |
|
195 |
* @param TDes8& aCmd |
|
196 |
*/ |
|
197 |
void PeekAtCommand( CModemAtHandler* aHandler, TDes8& aCmd ); |
|
198 |
||
199 |
/** |
|
200 |
* Check if echo has been notified to common plug-in. |
|
201 |
* @return ETrue or EFalse. |
|
202 |
*/ |
|
203 |
TBool IsEchoNotified( const TUint8 aEchoValue ); |
|
8
6295dc2169f3
New release based on our 2010wk15 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
5
diff
changeset
|
204 |
|
6295dc2169f3
New release based on our 2010wk15 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
5
diff
changeset
|
205 |
/** |
9 | 206 |
* Check if V, Q or E command is ongoing, to handle AT_MODEM_SIGNAL_IND correctly. |
207 |
* @return ETrue or EFalse. |
|
208 |
*/ |
|
209 |
TBool IsSettingQueryOngoing(); |
|
210 |
||
211 |
/** |
|
212 |
* Check if there is unsolicited data available in buffer, before there are active requests. |
|
213 |
* @return ETrue or EFalse. |
|
214 |
*/ |
|
215 |
TBool IsUnsolicitedDataInBuffer(); |
|
216 |
||
217 |
/** |
|
218 |
* Get unsolicited data available in buffer, before there are active requests. |
|
219 |
* @return ETrue or EFalse. |
|
220 |
*/ |
|
221 |
void GetUnsolicitedDataInBuffer( TDes8& aData ); |
|
222 |
||
223 |
/** |
|
224 |
* Reset unsolicited data in temporary buffer. |
|
225 |
*/ |
|
226 |
void ResetUnsolicitedDataInBuffer(); |
|
227 |
||
228 |
/** |
|
229 |
* Stores device info so that it's available when |
|
230 |
* plugin for the device is created |
|
231 |
* @param TUint8 aDevId |
|
232 |
* @param TUint8 aObjId |
|
233 |
*/ |
|
234 |
void AddDevice( TUint8 aDevId, TUint8 aObjId ); |
|
235 |
||
236 |
/** |
|
237 |
* Remove device info |
|
238 |
* @param TUint8 aDevId |
|
239 |
* @param TUint8 aObjId |
|
240 |
*/ |
|
241 |
void RemoveDevice( TUint8 aDevId, TUint8 aObjId ); |
|
242 |
||
243 |
/** |
|
244 |
* calculates number of different DTE's connected |
|
245 |
* @return number of dte's conntected |
|
246 |
*/ |
|
247 |
TUint8 GetDteCount(); |
|
0 | 248 |
|
249 |
private: |
|
250 |
||
251 |
/** |
|
252 |
* Creates a new session to client |
|
253 |
* |
|
254 |
* @param aVersion the version |
|
255 |
* @param aMessage not used |
|
256 |
* @return The new created session |
|
257 |
*/ |
|
258 |
CSession2* NewSessionL( const TVersion& aVersion, |
|
259 |
const RMessage2& aMessage ) const; |
|
260 |
||
261 |
/** |
|
262 |
* Constructor |
|
263 |
* |
|
264 |
* @param aPriority This AO's priority |
|
265 |
*/ |
|
266 |
CModemAtSrv( TInt aPriority ); |
|
267 |
||
268 |
/** |
|
269 |
* Two-Phase constructor |
|
270 |
*/ |
|
271 |
void ConstructL(); |
|
9 | 272 |
|
273 |
/** |
|
274 |
* Gets free ISC channel id |
|
275 |
* |
|
276 |
* @param aChannel free channel id is inserted to this param |
|
277 |
* @return TInt KErrNone if free channel found, otherwise KErrNotFound |
|
278 |
*/ |
|
279 |
TInt GetFreeChannelId( TUint8& aChannel ); |
|
0 | 280 |
|
281 |
||
282 |
private: // data |
|
283 |
||
284 |
RPointerArray<CModemAtSession> iSessions; //Sessions from R-interface |
|
285 |
RPointerArray<CAtMessage> iAtMessageArray; |
|
286 |
CModemAtHandler* iHandler; |
|
8
6295dc2169f3
New release based on our 2010wk15 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
5
diff
changeset
|
287 |
TUint8 iDteId; |
9 | 288 |
|
289 |
TUint8 iEcho; |
|
290 |
TUint8 iEchoNotified; |
|
291 |
TBool iEchoQueryIsOngoing; |
|
292 |
||
293 |
TUint8 iVerbose; |
|
294 |
TUint8 iVerboseNotified; |
|
295 |
TBool iVerboseQueryIsOngoing; |
|
296 |
||
297 |
TUint8 iQuiet; |
|
298 |
TUint8 iQuietNotified; |
|
299 |
TBool iQuietQueryIsOngoing; |
|
300 |
||
301 |
TUint8 iCarriageReturn; |
|
302 |
TBool iCarriageReturnFound; |
|
303 |
||
304 |
TBuf8<KMaxBufferLength> iTemporaryUnsolicitedData; |
|
305 |
RArray<TDteInfo> iDteInfo; |
|
306 |
TBuf8<KMaxDteCount> iFreeChannels; |
|
307 |
||
0 | 308 |
}; |
309 |
||
310 |
#endif // CMODEMATSRV_H |
|
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
311 |