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 // @file atcommandbase.h |
|
15 // This contains CAtCommandBase which is the base class for AT command |
|
16 // |
|
17 |
|
18 #ifndef ATCOMMANDBASE_H_ |
|
19 #define ATCOMMANDBASE_H_ |
|
20 |
|
21 // system include |
|
22 #include <e32base.h> |
|
23 #include <ctsy/ltsy/cctsydispatchercallback.h> |
|
24 |
|
25 // user include |
|
26 #include "atcommandtype.h" |
|
27 #include "ltsycommondefine.h" |
|
28 #include "respondbufparser.h" |
|
29 #include "requestbase.h" |
|
30 #include "globalphonemanager.h" |
|
31 |
|
32 |
|
33 // const defination |
|
34 const TUint KLtsyGenericBufferSize = 200; |
|
35 |
|
36 // forward class |
|
37 class CGlobalPhonemanager; |
|
38 class CAtManager; |
|
39 class CCommEngine; |
|
40 class CCtsyDispatcherCallback; |
|
41 class MAtCommandExecuteObserver; |
|
42 class CRequestBase; |
|
43 class CATSwitchOnLineMode; |
|
44 |
|
45 /** |
|
46 * This class provide the common functionalities for AT Command |
|
47 * |
|
48 */ |
|
49 class CAtCommandBase : public CRequestBase |
|
50 { |
|
51 public: |
|
52 /** |
|
53 * Destructor |
|
54 * |
|
55 */ |
|
56 virtual ~CAtCommandBase(); |
|
57 public:// pure virtual functions |
|
58 |
|
59 /** |
|
60 * Pure virtual function. Start Execute AT Command |
|
61 */ |
|
62 virtual void ExecuteCommand()=0; |
|
63 |
|
64 /** |
|
65 * Cancel the AT Command execution |
|
66 */ |
|
67 virtual void CancelCommand(); |
|
68 |
|
69 public:// virtual functions |
|
70 /** |
|
71 * Must be called after the AT Command execution get complete |
|
72 */ |
|
73 virtual void Complete(); |
|
74 |
|
75 /** |
|
76 * It can be overrided by inherited class |
|
77 * |
|
78 * @param aResponseBuf Line buf reading from baseband which is |
|
79 * parsered by class CAtCommandBase or CAtCommandBase's subtype |
|
80 */ |
|
81 virtual void ParseResponseL(const TDesC8& aResponseBuf); |
|
82 |
|
83 /** |
|
84 * Virtual Function |
|
85 * This function would be called after one of @see TAtEventSource happened. |
|
86 * Subclass should implement this function. |
|
87 * |
|
88 * @param aEventSource One of them: EReadCompletion, EWriteCompletion and ETimeoutCompletion |
|
89 * @param aStatus KErrNone if the event was complete without any error, or otherwise. |
|
90 */ |
|
91 virtual void EventSignal(TAtEventSource aEventSource, TInt aStatus); |
|
92 public: |
|
93 /** |
|
94 * Return the AT Type |
|
95 * @return TLtsyATCommandType The AT Type and @see TLtsyATCommandType |
|
96 */ |
|
97 TLtsyATCommandType AtType(); |
|
98 |
|
99 /** |
|
100 * Add expected response string after an AT Command was executed |
|
101 * |
|
102 * @param aExpectStr |
|
103 */ |
|
104 void AddExpectStringL(const TDesC8& aExpectStr); |
|
105 |
|
106 /** |
|
107 * Add expected response string after an AT Command was executed |
|
108 * |
|
109 * @param aExpectStr |
|
110 */ |
|
111 void RemoveExpectString(const TDesC8& aExpectStr); |
|
112 |
|
113 /** |
|
114 * Reset and clean all the expect string |
|
115 * |
|
116 */ |
|
117 void RemoveAllExpectString(); |
|
118 |
|
119 /** |
|
120 * Add an AT Command to ATCommandStore |
|
121 * |
|
122 */ |
|
123 void AddUnsolicitedAtCommand(); |
|
124 |
|
125 /** |
|
126 * Remove an AT Command in ATCommandStore |
|
127 * |
|
128 */ |
|
129 void RemoveAtCommand(); |
|
130 |
|
131 /** |
|
132 * Issue writing AT Command to baseband |
|
133 * |
|
134 */ |
|
135 void Write(); |
|
136 |
|
137 /** |
|
138 * Set write and read timout |
|
139 */ |
|
140 void SetTimeOut(TInt aWriteTimeOut, TInt aReadTimeOut); |
|
141 |
|
142 /** |
|
143 * Clean the whole buffer received from baseband |
|
144 */ |
|
145 void ClearBuffer(); |
|
146 |
|
147 /** |
|
148 * Clean the current line in the buffer |
|
149 */ |
|
150 void ClearCurrentLine(); |
|
151 |
|
152 /** |
|
153 * The buffer for storing the all received data from comms engine |
|
154 */ |
|
155 TPtrC8 Buffer() const; |
|
156 |
|
157 /** |
|
158 * The current line in the buffer |
|
159 */ |
|
160 TPtrC8 CurrentLine() const; |
|
161 /** |
|
162 * The last line which had not matched in the buffer |
|
163 */ |
|
164 TPtrC8 PrecedingLine() const; |
|
165 |
|
166 /** |
|
167 * Check if the passed string was matched with Expected AT String |
|
168 * |
|
169 * @param aReadLine |
|
170 * @return TBool ETrue if matched, otherwise EFalse |
|
171 */ |
|
172 virtual TBool MatchExpectString(const TDesC8& aReadLine); |
|
173 /** |
|
174 * Set AT command observer |
|
175 * If the observer was set, the AT command should return the data from baseband back to it but not Dispatcher Callback handler. |
|
176 * |
|
177 * @param aAtCommandObserver The AT command observer @see MAtCommandExecuteObserver |
|
178 */ |
|
179 void SetAtCommandObserver(MAtCommandExecuteObserver* aAtCommandObserver); |
|
180 |
|
181 /** |
|
182 * Remove the AT command observer |
|
183 * |
|
184 */ |
|
185 void RemoveAtCommandObserver(); |
|
186 /** |
|
187 * Will be called by AT Manager whenever a event was triggered |
|
188 * |
|
189 * @param aEventSource |
|
190 * @param aStatus |
|
191 */ |
|
192 void GenericEventSignal(TAtEventSource aEventSource, TInt aStatus); |
|
193 protected: |
|
194 /** |
|
195 * Constructor |
|
196 * |
|
197 * @param aAtManager |
|
198 * @param aCommEngine |
|
199 * @param aAtCommandObserver |
|
200 */ |
|
201 CAtCommandBase(CGlobalPhonemanager& aGloblePhone, CCtsyDispatcherCallback& aCtsyDispatcherCallback); |
|
202 |
|
203 /** |
|
204 * 2nd Constructor |
|
205 * This function must be called in his subtype class for |
|
206 * creating instance of class CRespondBufParser |
|
207 */ |
|
208 void ConstructL(); |
|
209 /** |
|
210 * Start timer and would be expired after time periond of aTimeOut seconds |
|
211 */ |
|
212 void StartTimer(const TInt aTimeOut); |
|
213 private: |
|
214 /** |
|
215 * Stop the timer |
|
216 */ |
|
217 void StopTimer(); |
|
218 |
|
219 protected: |
|
220 /** |
|
221 * Identify the Type of AT Command |
|
222 */ |
|
223 TLtsyATCommandType iAtType; |
|
224 |
|
225 /** |
|
226 * The array of strings which contain the expected Response Message from BaseBand |
|
227 */ |
|
228 RArray<TPtrC8> iExpectingArray; |
|
229 |
|
230 /** |
|
231 * The buffer contains the "AT" String which should be sent to BaseBand Modem |
|
232 */ |
|
233 TBuf8<KLtsyGenericBufferSize> iTxBuffer; |
|
234 |
|
235 /** |
|
236 * The expired time in which the Writing of AT command should be complete |
|
237 */ |
|
238 TInt iWriteTimeOut; |
|
239 |
|
240 /** |
|
241 * The expired time in which the response message should be received |
|
242 */ |
|
243 TInt iReadTimeOut; |
|
244 |
|
245 /** |
|
246 * The pointer to class CRespondBufParserparser for parsering response |
|
247 * message buffer |
|
248 * |
|
249 */ |
|
250 CRespondBufParser* iParser; |
|
251 |
|
252 /** |
|
253 * The dispacher callback handler |
|
254 */ |
|
255 CCtsyDispatcherCallback& iCtsyDispatcherCallback; |
|
256 private: |
|
257 /** |
|
258 * The AT command observer. |
|
259 * In most of cases, when the AT command was complete, it should use dispathcer callback handler to return data back to CTSY. |
|
260 * But in some of cases, AT command should return the data back to the AT Command Observer which actually return the composed data |
|
261 * (some of them were collected from other AT commands) |
|
262 * back to CTSY. |
|
263 * |
|
264 * Not own |
|
265 */ |
|
266 MAtCommandExecuteObserver* iAtCommandObserver; |
|
267 |
|
268 /** |
|
269 * The buffer contains the line which had not matched |
|
270 */ |
|
271 TBuf8<KLtsyGenericBufferSize> iNoMatchedLastLine; |
|
272 |
|
273 |
|
274 CATSwitchOnLineMode* iATSwitchOnLineMode; |
|
275 |
|
276 }; |
|
277 |
|
278 #endif /*ATCOMMANDBASE_H_*/ |
|