24 #include "cmodemathandler.h" //KMaxDteIdCount |
24 #include "cmodemathandler.h" //KMaxDteIdCount |
25 #include "modemattrace.h" |
25 #include "modemattrace.h" |
26 |
26 |
27 const TUint8 EAtCmd = 0; |
27 const TUint8 EAtCmd = 0; |
28 const TUint8 EGetNvramStatus = 1; |
28 const TUint8 EGetNvramStatus = 1; |
|
29 const TUint8 KMaxDteCount( 3 ); |
29 |
30 |
30 /* |
31 /* |
31 * Reference: i_at_modem_fp_3.1.doc (3.5.2) |
32 * Reference: i_at_modem_fp_3.1.doc (3.5.2) |
32 * If the unsolicited data needs to be sent to all of the connected DTE sessions, |
33 * If the unsolicited data needs to be sent to all of the connected DTE sessions, |
33 * AT Modem server would send the unsolicited data indication to the client with |
34 * AT Modem server would send the unsolicited data indication to the client with |
34 * the dte id as 0xFF. The 0xFF value for the DTE id is reserved for the |
35 * the dte id as 0xFF. The 0xFF value for the DTE id is reserved for the |
35 * unsolicited data indication. |
36 * unsolicited data indication. |
36 */ |
37 */ |
37 const TUint8 KUnsolicitedDataDteId = 0xff; |
38 const TUint8 KUnsolicitedDataDteId = 0xff; |
38 |
39 const TUint8 KInitialValue = 0xff; |
39 const TInt KATModemCommandArgumentIndex = 0; |
40 const TInt KATModemCommandArgumentIndex = 0; |
40 const TInt KATModemResponseArgumentIndex = 1; |
41 const TInt KATModemResponseArgumentIndex = 1; |
41 const TInt KATModemUnsolicitedDataIndex = 0; |
42 const TInt KATModemUnsolicitedDataIndex = 0; |
42 |
43 |
43 _LIT8( KEmptyString, ""); |
44 _LIT8( KEmptyString, ""); |
44 |
45 |
|
46 #define KMaxBufferLength 1024 |
|
47 |
45 class CModemAtSession; |
48 class CModemAtSession; |
46 class CAtMessage; |
49 class CAtMessage; |
|
50 |
|
51 |
|
52 class TDteInfo |
|
53 { |
|
54 public: |
|
55 |
|
56 TUint8 iDevId; |
|
57 TUint8 iObjId; |
|
58 CModemAtSession* iSession; |
|
59 }; |
|
60 |
47 |
61 |
48 /** |
62 /** |
49 * CModemAtSrv server core class. CModemAtsrc creates/deletes sessions. Dte-ids are allocated |
63 * CModemAtSrv server core class. CModemAtsrc creates/deletes sessions. Dte-ids are allocated |
50 * by CmodemAtSrv. |
64 * by CmodemAtSrv. |
51 */ |
65 */ |
80 * Connect session to the modem |
94 * Connect session to the modem |
81 * @param CModemAtSession* aSession Pointer to the session |
95 * @param CModemAtSession* aSession Pointer to the session |
82 * @param TATPluginInterface aPluginType Atext or common plugin |
96 * @param TATPluginInterface aPluginType Atext or common plugin |
83 * @return Connection status: KErrNone, KErrAlreadyExists |
97 * @return Connection status: KErrNone, KErrAlreadyExists |
84 */ |
98 */ |
85 TInt ConnectToModem( CModemAtSession* aSession, TATPluginInterface aPluginType); |
99 TInt ConnectToModemL( CModemAtSession* aSession, TATPluginInterface aPluginType); |
86 |
100 |
87 /** |
101 /** |
88 * HandleSignalInd |
102 * HandleSignalInd handles AT_MODEM_SIGNAL_IND and notifying ATV, ATQ and ATE changes. |
89 * @param aDteId Device Terminal ID |
103 * @param aDteId Device Terminal ID |
90 */ |
104 * @param aCompleteCode Change in V, Q or E is completed to common plugin. |
91 void HandleSignalInd( const TUint8 aDteId ); |
105 */ |
|
106 void HandleSignalInd( const TUint8 aDteId, const TInt aCompleteCode ); |
92 /** |
107 /** |
93 * HandleUnsolicitedData |
108 * HandleUnsolicitedData |
94 * @param aDteId Device Terminal ID |
109 * @param aDteId Device Terminal ID |
95 * @param aData Descriptor data |
110 * @param aData Descriptor data |
96 */ |
111 */ |
107 /** |
122 /** |
108 * HandleATResponse |
123 * HandleATResponse |
109 * @param aDteId Device Terminal ID |
124 * @param aDteId Device Terminal ID |
110 * @param aResponse Response buffer |
125 * @param aResponse Response buffer |
111 */ |
126 */ |
112 void HandleATResponse( const TUint8 aDteId, const TDesC8& aResponse, const TUint8 aCommand ); |
127 void HandleATResponse( |
|
128 const TUint8 aDteId, |
|
129 CModemAtHandler* aHandler, |
|
130 const TDesC8& aResponse, |
|
131 const TUint8 aCommand ); |
113 |
132 |
114 /** |
133 /** |
115 * HandleCommandModeChange |
134 * HandleCommandModeChange |
|
135 * @param aDteId dte id which mode is changed |
116 * @param aMode Command mode 0 or data mode 1 |
136 * @param aMode Command mode 0 or data mode 1 |
117 */ |
137 */ |
118 void HandleCommandModeChange( TCommandMode aMode ); |
138 void HandleCommandModeChange( TUint8 aDteId, TCommandMode aMode ); |
119 |
139 |
120 /** |
140 /** |
121 * AddToSendFifo |
141 * AddToSendFifo |
122 * @param aPluginType Plugin type |
142 * @param aPluginType Plugin type |
123 * @param aMessage RMessage2 container class |
143 * @param aMessage RMessage2 container class |
140 */ |
160 */ |
141 void CancelFifoRequests( const CModemAtSession* aSession ); |
161 void CancelFifoRequests( const CModemAtSession* aSession ); |
142 |
162 |
143 /** |
163 /** |
144 * RemovePipe |
164 * RemovePipe |
145 */ |
165 * @param aHandler pointer to message handler |
146 void RemovePipe(); |
166 */ |
147 |
167 void RemovePipe( CModemAtHandler* aHandler ); |
148 /** |
168 |
149 * Sets DteID for this session |
169 /** |
150 * @param aDteId DteId |
170 * Sets DteID for this session |
151 * @param aConnectionError error |
171 * @param aDteId DteId |
152 */ |
172 * @param aConnectionError error |
|
173 */ |
153 void SetDteIdAndConnect( const TUint8 aDteId, const TInt aConnectionError ); |
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 ); |
|
204 |
|
205 /** |
|
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(); |
154 |
248 |
155 private: |
249 private: |
156 |
250 |
157 /** |
251 /** |
158 * Creates a new session to client |
252 * Creates a new session to client |
173 |
267 |
174 /** |
268 /** |
175 * Two-Phase constructor |
269 * Two-Phase constructor |
176 */ |
270 */ |
177 void ConstructL(); |
271 void ConstructL(); |
|
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 ); |
178 |
280 |
179 |
281 |
180 private: // data |
282 private: // data |
181 |
283 |
182 RPointerArray<CModemAtSession> iSessions; //Sessions from R-interface |
284 RPointerArray<CModemAtSession> iSessions; //Sessions from R-interface |
183 RPointerArray<CAtMessage> iAtMessageArray; |
285 RPointerArray<CAtMessage> iAtMessageArray; |
184 CModemAtHandler* iHandler; |
286 CModemAtHandler* iHandler; |
185 TUint8 iDteId; |
287 TUint8 iDteId; |
|
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 |
186 }; |
308 }; |
187 |
309 |
188 #endif // CMODEMATSRV_H |
310 #endif // CMODEMATSRV_H |
189 |
311 |