24
|
1 |
// Copyright (c) 2004-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 |
// C32 Baseband Channel Adaptor(BCA) APIs.
|
|
15 |
// This file contains the definition of the C32Bca interface.
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
/**
|
|
20 |
@file
|
|
21 |
@internalComponent
|
|
22 |
*/
|
|
23 |
|
|
24 |
#ifndef C32BCA_H
|
|
25 |
#define C32BCA_H
|
|
26 |
#include <networking/bca.h>
|
|
27 |
#include <c32comm.h>
|
|
28 |
#include <e32base.h>
|
|
29 |
#include <e32def.h>
|
|
30 |
#include <commsdattypesv1_1.h>
|
|
31 |
using namespace CommsDat;
|
|
32 |
#include <comms-infras/commsdebugutility.h>
|
|
33 |
|
|
34 |
/** This namespace includes the BCA component names.*/
|
|
35 |
namespace BasebandChannelAdaptation
|
|
36 |
{
|
|
37 |
|
|
38 |
namespace C32Bca
|
|
39 |
{
|
|
40 |
const TUint16 KC32BcaMajorVersionNumber = 2;
|
|
41 |
const TUint16 KC32BcaMinorVersionNumber = 1;
|
|
42 |
|
|
43 |
_LIT(KChannelIdNotOverridden, "");
|
|
44 |
|
|
45 |
_LIT8(KC32BcaLogFolder, "C32Bca");
|
|
46 |
_LIT8(KC32BcaLogFile, "C32Bca.txt");
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
/**
|
|
52 |
User of C32 RComm - specific functionality.
|
|
53 |
A target for upcalls from C32 async users.
|
|
54 |
|
|
55 |
This interface is internal to the C32Bca.
|
|
56 |
|
|
57 |
*/
|
|
58 |
NONSHARABLE_CLASS(MC32User)
|
|
59 |
{
|
|
60 |
public:
|
|
61 |
/**
|
|
62 |
Called when a read request is completed
|
|
63 |
|
|
64 |
@param aError the completion error */
|
|
65 |
virtual void CommReadComplete(TInt aError) = 0;
|
|
66 |
|
|
67 |
/**
|
|
68 |
Called when a write request is completed
|
|
69 |
|
|
70 |
@param aError the completion error */
|
|
71 |
virtual void CommWriteComplete(TInt aError) = 0;
|
|
72 |
|
|
73 |
/**
|
|
74 |
Called when the link has gone down.
|
|
75 |
|
|
76 |
@param aError link failure error code. */
|
|
77 |
virtual void CommLinkDown(TInt aError) = 0;
|
|
78 |
};
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
/**
|
|
84 |
Common functionality for C32 async users. */
|
|
85 |
NONSHARABLE_CLASS(CCommBase): public CActive
|
|
86 |
{
|
|
87 |
public:
|
|
88 |
CCommBase(MC32User& aUser, RComm& aPort, TInt aAoPriority);
|
|
89 |
virtual ~CCommBase();
|
|
90 |
|
|
91 |
protected:
|
|
92 |
/**
|
|
93 |
Target for synchronous notifications from us */
|
|
94 |
MC32User& iUser;
|
|
95 |
/**
|
|
96 |
Serial port we service for the iUser */
|
|
97 |
RComm& iPort;
|
|
98 |
|
|
99 |
/** CommsDebug logger */
|
|
100 |
__FLOG_DECLARATION_MEMBER;
|
|
101 |
};
|
|
102 |
|
|
103 |
/**
|
|
104 |
Async reader for the serial port. */
|
|
105 |
NONSHARABLE_CLASS(CCommReader): public CCommBase
|
|
106 |
{
|
|
107 |
public:
|
|
108 |
CCommReader(MC32User& aUser, RComm& aPort);
|
|
109 |
~CCommReader();
|
|
110 |
void Read(TDes8& aBuf);
|
|
111 |
void RunL();
|
|
112 |
void DoCancel();
|
|
113 |
};
|
|
114 |
|
|
115 |
|
|
116 |
/**
|
|
117 |
Async writer for the serial port.*/
|
|
118 |
NONSHARABLE_CLASS(CCommWriter): public CCommBase
|
|
119 |
{
|
|
120 |
public:
|
|
121 |
CCommWriter(MC32User& aUser, RComm& aPort);
|
|
122 |
~CCommWriter();
|
|
123 |
void Write(const TDesC8& aBuf);
|
|
124 |
void RunL();
|
|
125 |
void DoCancel();
|
|
126 |
};
|
|
127 |
|
|
128 |
|
|
129 |
/**
|
|
130 |
Monitors the serial port for failures, specifically control line changes.
|
|
131 |
|
|
132 |
Depending on how the port is open (DTE or DCE), change in DCD or DTR may
|
|
133 |
mean link failure.
|
|
134 |
*/
|
|
135 |
NONSHARABLE_CLASS(CCommLinkMonitor): public CCommBase
|
|
136 |
{
|
|
137 |
public:
|
|
138 |
CCommLinkMonitor(MC32User& aUser, RComm& aPort);
|
|
139 |
void Setup(TUint32 aC32ControlLinesMask);
|
|
140 |
void NotifyLinkDown();
|
|
141 |
void RunL();
|
|
142 |
void DoCancel();
|
|
143 |
|
|
144 |
private:
|
|
145 |
/**
|
|
146 |
EIA-232 signals after the most recent change. */
|
|
147 |
TUint iSignals;
|
|
148 |
|
|
149 |
/**
|
|
150 |
State of the EIA-232 signals before the change. */
|
|
151 |
TUint iSavedSignalState;
|
|
152 |
|
|
153 |
/**
|
|
154 |
We request to be notified when these control lines change */
|
|
155 |
TUint iNotifyChangeSignalMask;
|
|
156 |
};
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
/**
|
|
163 |
* The interface between NIF and C32 Bearer Transport.
|
|
164 |
|
|
165 |
*/
|
|
166 |
NONSHARABLE_CLASS(CC32Bca): public CBase,
|
|
167 |
public MBca, // BCA is accessed via this interface by clients.
|
|
168 |
public MC32User // BCA receives internal notifications on C32 events via this interface.
|
|
169 |
{
|
|
170 |
public:
|
|
171 |
CC32Bca();
|
|
172 |
virtual ~CC32Bca();
|
|
173 |
virtual void Release();
|
|
174 |
|
|
175 |
void ConstructL();
|
|
176 |
|
|
177 |
virtual void Open(TRequestStatus& aStatus, const TDesC& aChannelId);
|
|
178 |
virtual void Shutdown(TRequestStatus& aStatus);
|
|
179 |
virtual void Close();
|
|
180 |
|
|
181 |
virtual void Read(TRequestStatus& aStatus, TDes8& aBuf);
|
|
182 |
virtual void Write(TRequestStatus& aStatus, const TDesC8& aBuf);
|
|
183 |
|
|
184 |
virtual void CancelRead();
|
|
185 |
virtual void CancelWrite();
|
|
186 |
|
|
187 |
virtual void Ioctl(TRequestStatus& aStatus, TUint aOptLevel, TUint aOptName, TDes8& aOpt);
|
|
188 |
virtual void CancelIoctl();
|
|
189 |
|
|
190 |
// MC32User virtuals
|
|
191 |
virtual void CommReadComplete(TInt aErr);
|
|
192 |
virtual void CommWriteComplete(TInt aErr);
|
|
193 |
virtual void CommLinkDown(TInt aErr);
|
|
194 |
|
|
195 |
#ifdef __FLOG_ACTIVE
|
|
196 |
void LogCommConfig(TCommConfig& c);
|
|
197 |
#endif // __FLOG_ACTIVE
|
|
198 |
|
|
199 |
private:
|
|
200 |
void CloseCommPort();
|
|
201 |
|
|
202 |
void ReadCommPortFromCommDbL(TDes& aPortName);
|
|
203 |
void ReadCsyNameFromCommDbL(TDes& aCsyName);
|
|
204 |
void ReadCommRoleFromCommDbL(TCommRole& aCommRole);
|
|
205 |
void ConnectToCommDbBearerRecordL();
|
|
206 |
void CloseCommDbConnection();
|
|
207 |
void MonitorControlLinesL(TUint32 aMask);
|
|
208 |
|
|
209 |
TRequestStatus* iReadRequest;
|
|
210 |
TRequestStatus* iWriteRequest;
|
|
211 |
|
|
212 |
CCommReader* iReader;
|
|
213 |
CCommWriter* iWriter;
|
|
214 |
CCommLinkMonitor* iLinkMonitor;
|
|
215 |
|
|
216 |
/** Comm port name*/
|
|
217 |
TName iCommPort;
|
|
218 |
/** CSY name */
|
|
219 |
TName iCsyName;
|
|
220 |
/** Comm port role: DTE / DCE */
|
|
221 |
TCommRole iCommRole;
|
|
222 |
/** Serial port */
|
|
223 |
RComm iComm;
|
|
224 |
/** session to C32 Server */
|
|
225 |
RCommServ iCommServ;
|
|
226 |
/** state to keep track of if iCsyName is set by Ioctl()*/
|
|
227 |
TBool iCsyNameOverride;
|
|
228 |
/** Comm port role explicitly specified */
|
|
229 |
TBool iCommRoleOverride;
|
|
230 |
/** state to keep track of if the iComm is Opened.*/
|
|
231 |
TBool iCommPortOpen;
|
|
232 |
/** Iap ID for CommDB access */
|
|
233 |
TUint32 iIapId;
|
|
234 |
/** CommDB Connection */
|
|
235 |
CMDBSession* iCommsDat;
|
|
236 |
/** View on the relevant Bearer record */
|
|
237 |
TUint32 iModemId;
|
|
238 |
|
|
239 |
/** Should the next read be errored with this error code? */
|
|
240 |
TInt iErrorOnNextRead;
|
|
241 |
|
|
242 |
/** Should the next write be errored with this error code? */
|
|
243 |
TInt iErrorOnNextWrite;
|
|
244 |
|
|
245 |
/** Comms Debug Utility logger. */
|
|
246 |
__FLOG_DECLARATION_MEMBER;
|
|
247 |
};
|
|
248 |
/**
|
|
249 |
* C32BCA Panic.
|
|
250 |
* @internalComponent.
|
|
251 |
*/
|
|
252 |
_LIT(KC32BcaPanic, "C32Bca.dll");
|
|
253 |
|
|
254 |
/**
|
|
255 |
* C32BCA Panic code.
|
|
256 |
* @internalComponent.
|
|
257 |
*/
|
|
258 |
enum TC32BcaPanic
|
|
259 |
{
|
|
260 |
/** Comm port is open */
|
|
261 |
ECommPortIsOpen,
|
|
262 |
|
|
263 |
/** Comm port is closed */
|
|
264 |
ECommPortClose,
|
|
265 |
|
|
266 |
/** Reader already exists, we have a memory leak */
|
|
267 |
EReaderAlreadyExists,
|
|
268 |
|
|
269 |
/** Writer already exists, we have a memory leak */
|
|
270 |
EWriterAlreadyExists,
|
|
271 |
|
|
272 |
/** Monitor already existrs, we have a memory leak */
|
|
273 |
EMonitorAlreadyExists,
|
|
274 |
|
|
275 |
/** Closing the BCA, but the reader object is NULL */
|
|
276 |
ENullReaderOnClose,
|
|
277 |
|
|
278 |
/** Closing the BCA, but the writer object is NULL */
|
|
279 |
ENullWriterOnClose,
|
|
280 |
|
|
281 |
/** TRequestStatus on completion of Read is NULL */
|
|
282 |
ENullReadRequestStatus,
|
|
283 |
|
|
284 |
/** Read completed, but the request is not pending. */
|
|
285 |
EReadRequestNotPending,
|
|
286 |
|
|
287 |
/**
|
|
288 |
TRequestStatus on completion of Write is NULL */
|
|
289 |
ENullWriteRequestStatus,
|
|
290 |
|
|
291 |
/** Write completed, but the request is not pending */
|
|
292 |
EWriteRequestNotPending,
|
|
293 |
|
|
294 |
/** Other internal logic error */
|
|
295 |
EGeneralLogicError,
|
|
296 |
};
|
|
297 |
void Panic(TC32BcaPanic aPanic);
|
|
298 |
|
|
299 |
}
|
|
300 |
}
|
|
301 |
|
|
302 |
#endif //C32BCA_H
|