1 // |
|
2 // * Copyright 2004 Neusoft America Inc. |
|
3 // * All rights reserved. |
|
4 // * This component and the accompanying materials are made available |
|
5 // * under the terms of the 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 // * Contributors: |
|
10 // * Keith Collins (Neusoft America Inc.) original software development and additional code and modifications. |
|
11 // * Thomas Gahagen (Neusoft America Inc.) additional code and modifications. |
|
12 // * Zhen Yuan (Neusoft America Inc.) additional code and modifications. |
|
13 // * |
|
14 // * Description: This file defines the CMux0710Protocol class. This class |
|
15 // performs the 3GPP2 protocol specific behavior for 27.010. |
|
16 // This file also includes CRC table. |
|
17 // |
|
18 |
|
19 // CMux0710Protocol.h |
|
20 |
|
21 /** @file CMux0710Protocol.h |
|
22 * |
|
23 */ |
|
24 |
|
25 #ifndef _MUX0710PROTOCOL_H_ |
|
26 #define _MUX0710PROTOCOL_H_ |
|
27 |
|
28 #include <e32base.h> |
|
29 #include "CsyGlobals.h" |
|
30 #include "timeouter.h" |
|
31 |
|
32 |
|
33 class CCsyMsgBufBase; |
|
34 class CCsyMsgBufFrame; |
|
35 class CPortFactory; |
|
36 class CCsyMsgBufBpFrame; |
|
37 class CCommFrameWriterAo; |
|
38 class CCommFrameReaderAo; |
|
39 |
|
40 class CMux0710Protocol : public CBase, public MTimeoutObserver |
|
41 { |
|
42 public: |
|
43 |
|
44 // Frame Types used in 27.010 Protocol |
|
45 enum TCsyFrameType |
|
46 { |
|
47 ESABM, // Set asynchronous balanced mode |
|
48 EUA, // Unnumbered Acknowledgement |
|
49 EDM, // Disconnected Mode |
|
50 EDISC, // Disconnect |
|
51 EUIH, // Unnumbered information with header check |
|
52 EUI, // Unnumberd information |
|
53 EUNKNOWN |
|
54 }; |
|
55 |
|
56 enum TCsyCtrlCommand |
|
57 { |
|
58 EParamNeg, // Parameter Negotiation |
|
59 EMSC // Modem status command |
|
60 }; |
|
61 |
|
62 public: |
|
63 static CMux0710Protocol* NewL(CPortFactory& aPortFactory); |
|
64 virtual ~CMux0710Protocol(); |
|
65 |
|
66 void SetCommWriter(CCommFrameWriterAo* aCommWriter); |
|
67 |
|
68 TBool IsMuxModeEnabled() const; |
|
69 TInt SwitchToMuxMode(); |
|
70 TInt ParseATResponse(TDes8& aResp); |
|
71 |
|
72 CCsyMsgBufBpFrame* GetFreeFrameBuf(TBool aCheckFlowControlThresholds = ETrue); |
|
73 void AddFrameFreeQ(CCsyMsgBufBpFrame* aBpFrame); |
|
74 |
|
75 TInt Create0710DataFrames(TDesC8& aMsgBuf, const TUint8 aDlcNum); |
|
76 TInt Create0710ControlFrame(TCsyFrameType aFrameType, TUint8 aDlcNum, |
|
77 TCsyCtrlCommand aType = EParamNeg, TUint8 aV24Signals = 0); |
|
78 |
|
79 inline TUint8 PreviousNegotiateDlcNum() const; |
|
80 inline TBool MaxRetriesReached() const; |
|
81 |
|
82 public:// from MTimeoutObserver |
|
83 void TimedOut(); |
|
84 |
|
85 private: |
|
86 enum TCsyMuxMgrState |
|
87 { |
|
88 ECsyWaitingForAttentionResp, |
|
89 ECsyWaitingForEchoDisableResp, |
|
90 ECsyWaitingForCmuxResp, |
|
91 ECsyMuxEnabled, |
|
92 ECsyWaitingForFlushResp, |
|
93 #ifdef USE_TI_CONDAT_STACK |
|
94 ECsyWaitingForResetResp, |
|
95 ECsyWaitingForSleepResp |
|
96 #endif |
|
97 }; |
|
98 |
|
99 private: |
|
100 CMux0710Protocol(CPortFactory& aPortFactory); |
|
101 void ConstructL(); |
|
102 |
|
103 void Create0710UIHFrameFromMsg(TDesC8& aMsgBuf, TInt aOffset, |
|
104 CCsyMsgBufBpFrame* aFrameBuf, |
|
105 TInt aLength, TUint8 aDlcNum); |
|
106 |
|
107 void Create0710UIHLayer4FrameFromMsg(TDesC8& aMsgBuf, |
|
108 TInt aOffset, |
|
109 CCsyMsgBufBpFrame* aFrameBuf, |
|
110 TInt aLength, TUint8 aDlcNum, |
|
111 TBool aLayer4Begin, |
|
112 TBool aLayer4End); |
|
113 |
|
114 void ProcessControlChannelRecvUihFrame(CCsyMsgBufBpFrame* aBpFrame); |
|
115 |
|
116 TUint8 CalcFCS(TUint8* aBuffer, TInt aLen); |
|
117 |
|
118 void DumpFrame(CCsyMsgBufBpFrame* aFrameBuf); |
|
119 |
|
120 private: |
|
121 CActiveTimeouter* iTimeouter; |
|
122 |
|
123 CPortFactory& iPortFactory; |
|
124 |
|
125 TCsyMuxMgrState iMuxMgrState; |
|
126 |
|
127 CCommFrameWriterAo* iCommWriter; |
|
128 |
|
129 // Free Frame Buf List |
|
130 TSglQue<CCsyMsgBufBpFrame> iFreeFrameBufList; |
|
131 TSglQueIter<CCsyMsgBufBpFrame> iFreeFrameBufIter; |
|
132 TUint iFreeFrameCount; |
|
133 |
|
134 TBool iEnforcingFlowControl; |
|
135 |
|
136 TBool iModemRequestedToStop; |
|
137 |
|
138 TUint8 iParamNegotiateDlcNum; |
|
139 |
|
140 TUint8 iAtResponseTimeout; |
|
141 |
|
142 TBool iMaxRetriesReached; |
|
143 TBuf8<100> iResponseStr; |
|
144 TInt iRetryCount; |
|
145 }; |
|
146 |
|
147 // inline methods |
|
148 |
|
149 /** |
|
150 Set the comm writer to the specified object pointer. |
|
151 |
|
152 @param aCommWriter Pointer to the comm writer |
|
153 */ |
|
154 inline void CMux0710Protocol::SetCommWriter(CCommFrameWriterAo* aCommWriter) |
|
155 { |
|
156 iCommWriter = aCommWriter; |
|
157 } |
|
158 |
|
159 /** |
|
160 Return True if multiplexing mode is enabled, else return False. |
|
161 */ |
|
162 inline TBool CMux0710Protocol::IsMuxModeEnabled() const |
|
163 { |
|
164 if (iMuxMgrState == ECsyMuxEnabled) |
|
165 { |
|
166 return (ETrue); |
|
167 } |
|
168 else |
|
169 { |
|
170 return (EFalse); |
|
171 } |
|
172 } |
|
173 |
|
174 /** |
|
175 Return dlc that parameter negotiate command was sent for. |
|
176 */ |
|
177 inline TUint8 CMux0710Protocol::PreviousNegotiateDlcNum() const |
|
178 { |
|
179 return iParamNegotiateDlcNum; |
|
180 } |
|
181 |
|
182 /** |
|
183 Return whether the max connection retries has been reached. |
|
184 */ |
|
185 inline TBool CMux0710Protocol::MaxRetriesReached() const |
|
186 { |
|
187 return iMaxRetriesReached; |
|
188 } |
|
189 |
|
190 #endif // _MUX0710PROTOCOL_H_ |
|