|
1 // Copyright (c) 1999-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 // |
|
15 |
|
16 #ifndef BLOGGER_H__ |
|
17 #define BLOGGER_H__ |
|
18 |
|
19 #include "debug.h" |
|
20 |
|
21 #ifndef BLOGGING__ |
|
22 NONSHARABLE_CLASS(CBlogger): public CBase |
|
23 { |
|
24 public: |
|
25 IMPORT_C TAny* GetFloggerInfo(); |
|
26 }; |
|
27 #endif |
|
28 |
|
29 #ifdef BLOGGING__ |
|
30 |
|
31 // Stack Blogging Layers |
|
32 const TInt KBlogLayerLinkLayer =1; |
|
33 const TInt KBlogLayerL2CAP =2; |
|
34 const TInt KBlogBadLayerChoice =3; |
|
35 const TInt KBlogLayerRFComm =4; |
|
36 |
|
37 // Stack Layers Logging Masks |
|
38 const TInt KBlogNoLayer =0x00000000; |
|
39 const TInt KBLogLinkLayer =0x00000001; |
|
40 const TInt KBlogL2CAP =0x00000002; |
|
41 const TInt KBLogRFComm =0x00000004; |
|
42 const TInt KBlogAllLayers =0x7fffffff; |
|
43 |
|
44 //Blogging Verbosity Levels |
|
45 const TInt KBlogVerbosityOff =0x00000000; |
|
46 const TInt KBlogVerbosityTimeCritical =0x00000001; |
|
47 const TInt KBlogVerbosityMinimal =0x00000002; |
|
48 const TInt KBlogVerbosityNormal =0x00000003; |
|
49 const TInt KBlogVerbosityBTQualLevel =0x00000004; |
|
50 const TInt KBlogVerbosityLoud =0x00000005; |
|
51 const TInt KBlogVerbosityAllLevels =0x00000006; |
|
52 |
|
53 |
|
54 //BLogging Type Masks |
|
55 const TInt KBlogTypeLogAllMask = 0xffffffff; |
|
56 const TInt KBlogTypeProtocol = 0x00000001; |
|
57 const TInt KBlogTypeTimestamp = 0x00000002; |
|
58 const TInt KBlogTypeTimeout = 0x00000004; |
|
59 const TInt KBlogTypeTestAppContext = 0x00000008; |
|
60 const TInt KBlogTypeFCS = 0x00000010; |
|
61 const TInt KBlogTypeBaseband = 0x00000020; |
|
62 const TInt KBlogTypeChannelNumber = 0x00000040; |
|
63 const TInt KBlogTypePSMNumber = 0x00000080; |
|
64 const TInt KBlogTypeIncomingPacket = 0x00000100; |
|
65 const TInt KBlogTypeOutgoingPacket = 0x00000200; |
|
66 const TInt KBlogTypeRawFrames = 0x00000400; |
|
67 const TInt KBlogTypeL2CAPSignallerState = 0x00000800; |
|
68 const TInt KBlogTypeRFCOMMMuxState = 0x00001000; |
|
69 const TInt KBlogTypeSapState = 0x00002000; |
|
70 const TInt KBlogTypeCurrentState = 0x00004000; |
|
71 const TInt KBlogTypeStateChange = 0x00008000; |
|
72 const TInt KBlogTypeRequest = 0x00010000; |
|
73 const TInt KBlogTypeExpectedResponse = 0x00020000; |
|
74 const TInt KBlogTypeActualResponse = 0x00040000; |
|
75 const TInt KBlogTypeInquiry = 0x00080000; |
|
76 const TInt KBlogTypeInquiryResult = 0x00100000; |
|
77 const TInt KBlogTypeKeyRegistration = 0x00200000; |
|
78 const TInt KBlogTypeKeyFailure = 0x00400000; |
|
79 const TInt KBlogTypeLinkKeyInteraction = 0x00800000; |
|
80 const TInt KBlogTypeCtrlFrames = 0x01000000; |
|
81 const TInt KBlogTypeUIHFrames = 0x02000000; |
|
82 const TInt KBlogTypeMuxCtrlFrames = 0x04000000; |
|
83 const TInt KBlogTypeCtrlFrameBits = 0x08000000; |
|
84 const TInt KBlogTypeOutgoingFrames = 0x10000000; |
|
85 const TInt KBlogTypeCreditAccounting = 0x20000000; |
|
86 const TInt KBlogTypeSecurity = 0x40000000; |
|
87 const TInt KBLogTypeLocalHCPokes = 0x80000000; |
|
88 |
|
89 //Logging LITs |
|
90 |
|
91 |
|
92 _LIT(KBlogCommand, "command"); |
|
93 _LIT(KBlogResponse, "response"); |
|
94 |
|
95 |
|
96 _LIT(KBlogBluetoothAddrLit,"Bluetooth Address:"); |
|
97 |
|
98 //Layer/Protocol dependent |
|
99 _LIT(KBlogIncomingPacket, "Incoming packet, Type %d, Size %d, Payload %08x"); //received data pkt with size and type of pkt |
|
100 _LIT(KBlogOutgoingPacket, "Outgoing packet, Type %d, Size %d, Payload %08x"); //sent data pkt with size and type of pkt |
|
101 _LIT(KBlogRawFrames, "Frame Type %d, 0x%8x");// frame type and content - different specific info required from different types of Frame |
|
102 _LIT(KBlogSapId, "%d SAP %08x"); //type of SAP (RFCOMM/L2CAP) and sap id |
|
103 _LIT(KBlogSapState, "SAP State %d"); |
|
104 _LIT(KBlogCurrentState, "Current State %d"); |
|
105 _LIT(KBlogStateChange, "State %d"); |
|
106 _LIT(KBlogInquiryResult, "Inquiry Result"); |
|
107 |
|
108 //L2CAP |
|
109 _LIT(KBlogChannelNumber, "Channel %d"); |
|
110 _LIT(KBlogL2CAPSignallerState, "Signaller State %d"); |
|
111 _LIT(KBlogPSMNumber, "PSM %d"); |
|
112 _LIT(KBlogL2, "L2: "); |
|
113 _LIT(KBlogL2Test, "Test"); |
|
114 _LIT(KBlogTest, "L2: TEST NUMBER is %d"); |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 //RFCOMM |
|
120 |
|
121 _LIT(KBlogMuxId, "MUX %08x"); |
|
122 _LIT(KBlogFrameid, "Frame id %08x"); |
|
123 //States |
|
124 _LIT(KBlogRFCOMMMuxState, "Mux State %d"); |
|
125 //Frame Parts |
|
126 _LIT(KBlogDLCI, " DLCI %d"); |
|
127 _LIT(KBlogPFSet, " P/F bit = %d"); |
|
128 _LIT(KBlogEASet, " EA bit = %d"); |
|
129 _LIT(KBlogCRSet, " C/R bit = %d"); |
|
130 _LIT(KBlogActualFCS, " Actual PDU FCS %d"); |
|
131 _LIT(KBlogComputedFCS, " Computed FCS %d - (should be 0xCF)"); |
|
132 _LIT(KBlogComparedFCS, " Compared FCS %d"); |
|
133 _LIT(KBlogSignals, " Signals 0x%02x"); |
|
134 |
|
135 //Timeouts |
|
136 _LIT(KBlogTimeout, "T1 timer expired awaiting response for "); |
|
137 //Ctrl Frames |
|
138 _LIT(KBlogSABM, "SABM"); |
|
139 _LIT(KBlogDM, "DM"); |
|
140 _LIT(KBlogUA, "UA"); |
|
141 _LIT(KBlogDISC, "DISC"); |
|
142 //Frame Types |
|
143 _LIT(KBlogFrameType, "Frame of type %d"); |
|
144 _LIT(KBlogCtrlFrame, "Ctrl Frame: "); |
|
145 _LIT(KBlogUIHCtrlFrame, "UIH Ctrl Frame"); |
|
146 _LIT(KBlogSimpleUIH, "UIH simple data frame"); |
|
147 _LIT(KBlogShortUIH, "UIH simple data frame"); |
|
148 _LIT(KBlogLongUIH, "UIH simple data frame"); |
|
149 _LIT(KBlogCreditUIH, "UIH credit data frame"); |
|
150 _LIT(KBlogLongCreditUIH, "Tx :Long UIH credit data frame with %d credits"); |
|
151 _LIT(KBlogShortCreditUIH, "Tx: Short UIH credit data frame with %d credits"); |
|
152 _LIT(KBlogMuxCtrlFrame, "Mux Ctrlframe"); |
|
153 //MuxCtrlCommands |
|
154 _LIT(KBlogTestCommand, "TestCommand"); |
|
155 _LIT(KBlogFcOn, "FcOn"); |
|
156 _LIT(KBlogFcOff, "FcOff"); |
|
157 _LIT(KBlogMSC, "MSC"); |
|
158 _LIT(KBlogRPN, "RPN"); |
|
159 _LIT(KBlogRLS, "RLS"); |
|
160 _LIT(KBlogPN, "PN"); |
|
161 _LIT(KBlogNSC, "NSC"); |
|
162 //Data |
|
163 _LIT(KBlogNewData, "New packet of data arrived from L2CAP, count %d"); |
|
164 _LIT(KBlogNewDataFrame, "Creating new datapacket for outbound queue, dlci %d, data length %d, sap %08x, "); |
|
165 _LIT(KBlogWriteData, "Writing data, 0x%x"); |
|
166 _LIT(KBlogNonZeroLength, "with non-zero length"); |
|
167 |
|
168 //Link Layer |
|
169 _LIT(KBlogNewLinkConnectionEvent,"LL: Connection complete event. Code %d, link type=%d "); |
|
170 _LIT(KBlogNewLinkConnectionReqEvent, "LL: Incoming connection request event"); |
|
171 _LIT(KBlogNewLinkDisconnectionEvent,"LL: Disconnection complete event. Handle %x, Code %d, Reason %d"); |
|
172 _LIT(KBlogHCSendPacketsOK,"LL: Notifying DataQ Controller of %d Completed packets from HC to remote"); |
|
173 _LIT(KBlogLLDataIn ,"LL: Data received for handle %d, flags %d, length %d"); |
|
174 _LIT(KBlogACLFrame,"LL: ACL Frame:"); |
|
175 _LIT(KBlogLLDataIn2Null,"LL: Warning!! Data received with no datalink notifier in place"); |
|
176 _LIT(KBlogLLScanEnableResult,"LL: ReadScanEnableResult received, with error code %d, value %d"); |
|
177 _LIT(KBlogHCBufferSizeResult,"LL: ReadBufferSizeResult - aErr %d, aAclMaxLen %d, aNoACL %d"); |
|
178 _LIT(KBlogHCReadTimeoutResult,"LL: Warning!! Unhandled ReadTimeoutResult (EConnectionAcceptTimeout)"); |
|
179 _LIT(KBlogVendorEvent,"LL: Warning!! Just received a Vendor Specific Debug Event !"); |
|
180 _LIT(KBlogHardwareError,"LL: Error! HardwareErrorEvent Received: %d"); |
|
181 _LIT(KBlogHCIBufferNewCredits,"LL: HCI Buffer Strategy, Credit available, trying to issue."); |
|
182 _LIT(KBlogLLTransportFreed,"LL: LinkMgr, Transport is now free"); |
|
183 _LIT(KBlogHCIssuedCmdCredits,"LL: LinkMgr, HC issued %d command credits"); |
|
184 _LIT(KBlogLLSetLocalNameComplete,"LL: SetLocalName Command Complete Event"); |
|
185 _LIT(KBlogLLWritePageTOComplete,"LL: WritePageTimeout Command Complete Event"); |
|
186 _LIT(KBlogLLWriteCoDComplete,"LL: WriteClassOfDevice Command Complete Event"); |
|
187 _LIT(KBlogLLWriteVoiceSettingComplete,"LL: WriteVoiceSetting Command Complete Event"); |
|
188 _LIT(KBlogLLWriteScanEnable,"LL: WriteScanEnable Command Complete Event"); |
|
189 _LIT(KBlogLLWriteCurrentIACLAPComplete,"LL: WriteCurrentIACLAP Command Complete Event"); |
|
190 _LIT(KBlogLLSetHC2HostFCComplete,"LL: SetHostControllerToHostFlow Command Complete Event"); |
|
191 _LIT(KBlogLLCommandWarning,"LL: Warning, Unhandled Command complete event! Opcode %d error code %d"); |
|
192 _LIT(KBlogLLWriteAFHHostChannelClassification,"LL: WriteAFHHostChannelClassificationComplete Command Complete Event"); |
|
193 _LIT(KBlogLLReadAFHChannelAssessmentModeComplete,"LL: ReadAFHChannelAssessmentModeComplete Command Complete Event"); |
|
194 _LIT(KBlogLLWriteAFHChannelAssessmentModeComplete,"LL: WriteAFHChannelAssessmentModeComplete Command Complete Event"); |
|
195 |
|
196 //MISC |
|
197 _LIT(KKeyRegistration, "Key Registration"); |
|
198 _LIT(KKeyFailure, "Key Failure"); |
|
199 _LIT(KPINKeyInteraction, "PIN Key"); |
|
200 |
|
201 // Const Lit Lengths for the predifined Lits |
|
202 //255 is the max RDebug::Print size |
|
203 const TInt KRDBMaxLit=255; |
|
204 const TInt KBlogDateTimeLitLength=36; //depends on date, time formating lits |
|
205 const TInt KBlogTCPreambleLitLength=20; |
|
206 const TInt KBlogTestCaseMaxLitLength=KRDBMaxLit+KBlogDateTimeLitLength+KBlogTCPreambleLitLength; |
|
207 const TInt KBlogTestCaseResultPreambleLitLength=36; |
|
208 const TInt KBlogTestCaseResultMaxLitLength=KBlogTestCaseResultPreambleLitLength+KBlogDateTimeLitLength+KRDBMaxLit; |
|
209 const TInt KBlogTesterMessageInfoLitLength=100; |
|
210 const TInt KBlogTesterMessageInfoMaxLitLength=KBlogDateTimeLitLength+KBlogTesterMessageInfoLitLength; |
|
211 const TInt KBlogMessageMaxLitLength=512; |
|
212 |
|
213 //Blogging Output Resource Types |
|
214 // if we ever need to put more than 2 then implement it with dynamic binding |
|
215 const TInt KBlogOutputTypeIsRDebug =0; |
|
216 const TInt KBlogOutputTypeIsFlogger =1; |
|
217 |
|
218 // The number of chars to be printed on single line over COM1 or on a file |
|
219 const TInt KBlogOutputWindowDefault=80; |
|
220 |
|
221 |
|
222 // Common Lits |
|
223 |
|
224 // need to be in sync with KBlogDateTimeLitLength |
|
225 _LIT(KBlogTimeFormat,"%J%:1%T%:2%S "); |
|
226 _LIT(KBlogDateFormat,"%1%/1%2%/2%3 "); |
|
227 _LIT(KBlogBlankDate,"--:--:---- "); |
|
228 _LIT(KBlogBlankTime,"--:--:-- "); |
|
229 _LIT(KBlogTestCaseLit,"Test Case Running: "); |
|
230 // need to be in sync with KBlogTesterMessageInfoLitLength |
|
231 //_LIT(KBlogTesterMessageInfoLit,"[Message from the tester follows:]"); |
|
232 _LIT(KBlogTesterMessageInfoLit,"Tester: "); |
|
233 |
|
234 // Test Case Result Consts |
|
235 // these should be used with the KBloggerSetTestCaseResult option |
|
236 const TInt KBlogTestCaseResultPassed = 0; |
|
237 const TInt KBlogTestCaseResultFailed = 1; |
|
238 const TInt KBlogTestCaseResultInconclusive = 2; |
|
239 const TInt KBlogTestCaseResultSkipped = 3; |
|
240 const TInt KBlogTestCaseResultUpperNo = 3; // for bounds checking |
|
241 |
|
242 // Test Case Result Lits |
|
243 // these should be used with the KBloggerSetTestCaseResult option |
|
244 // remember to cjheck with KBlogTestCaseResultPreambleLitLength |
|
245 // if any of the below Lits gets changed |
|
246 _LIT(KBlogTestCaseResultLitPass,"[PASSED] test for test case : "); |
|
247 _LIT(KBlogTestCaseResultLitFailed, "[FAILED] test for test case : "); |
|
248 _LIT(KBlogTestCaseResultLitInconclusive, "[INCONCLUSIVE] test for test case : "); |
|
249 _LIT(KBlogTestCaseResultLitSkipped,"[SKIPPED] test for test case : "); |
|
250 |
|
251 enum TBTBloggingOptions |
|
252 { |
|
253 KBloggerSetLayers, |
|
254 KBloggerSetVerbosity, |
|
255 KBloggerSetLoggingMask, |
|
256 KBloggerSetMedium, |
|
257 KBloggerSetTestCaseName, |
|
258 KBloggerSetOutputWindow, |
|
259 KBloggerSetTestCaseResult, // to be used with the appropriate lits to indicate result |
|
260 KBloggerSetTesterMessage, // to be formated according to the corresponding lit |
|
261 KBloggerSetAllOptions //should use TBlogSettings |
|
262 }; |
|
263 |
|
264 struct TBlogSettings |
|
265 { |
|
266 TInt iLayersToLog; |
|
267 TInt iVerbosity; |
|
268 TInt iLoggingMask; |
|
269 TInt iMediumToLog; |
|
270 TInt iOutputWindowSize; |
|
271 TBuf<255> iTestCaseLit; |
|
272 }; |
|
273 typedef TPckgBuf<TBlogSettings> TBlogSettingsPckg; |
|
274 |
|
275 typedef TBuf<255> TBlogTestCaseLit; |
|
276 |
|
277 enum TBloggerPanic |
|
278 { |
|
279 EBloggerLayerRegistrationOutOfRange =0, |
|
280 EBloggerLayerBloggetteAlreadyRegistered=1, |
|
281 EBloggerLayerRequestedOutOfRange =2, |
|
282 EBloggerResourceTypeIsBogus =3, |
|
283 EBloggerTestCaseResultIsBogus =4, // check your KBlogTestCaseResultUpperNo |
|
284 EBloggerDescriptorLengthWasShorter =5, |
|
285 EBloggerMessageLengthTooLong =6 |
|
286 }; |
|
287 |
|
288 class CRfcommSAP; |
|
289 class CRfcommMuxCtrlFrame; |
|
290 class CRfcommMuxer; |
|
291 class CRfcommFrame; |
|
292 class CRfcommCtrlFrame; |
|
293 class CBloggette; |
|
294 |
|
295 NONSHARABLE_CLASS(CBlogger) : public CBase |
|
296 { |
|
297 public: |
|
298 ~CBlogger(); |
|
299 static CBlogger* NewL(); |
|
300 void ConstructL(); |
|
301 TInt LoggingMask(TInt aLayer, TInt aVerbosity) const; |
|
302 CBloggette* GetLayerBloggette(TInt aLayer); //only one per layer please |
|
303 void Register(CBloggette* aLayerBloggette); |
|
304 void Blog(const TDesC& aMessage, TInt aFrameWindow); |
|
305 void Blog(const TDesC& aMessage); |
|
306 void HexDump(const TDesC& aDescription,const TDesC8& aHexFrame,TInt aFrameWindow=KBlogOutputWindowDefault); |
|
307 // to be used by the protocol layer which receives the SetOp |
|
308 TInt UpdateLoggingSettings(TUint aOptionType,const TDesC8& aOption); |
|
309 void StoreFloggerInfo(TAny* aLogInfo); |
|
310 IMPORT_C TAny* GetFloggerInfo(); |
|
311 private: |
|
312 CBlogger(); |
|
313 void Panic(TBloggerPanic aPanic); |
|
314 // Blogging calls |
|
315 void BlogTestCase(TDesC& aTestCaseName); |
|
316 void BlogTestCaseResult(TInt aTestCaseResult); |
|
317 void BlogTesterMessage(TDesC& aTesterMessage); |
|
318 void DoBlog(const TDesC& aMessage, TInt aFrameWindow=KBlogOutputWindowDefault); |
|
319 // Output and formating |
|
320 void DoOutputToResourceL(const TDesC& aMessage); |
|
321 void CreateBlogFileL(); |
|
322 void DoFileL(); |
|
323 void MakefilenameL(const TDesC &aFileName); |
|
324 TInt DoDateTimeFormat(TDes& aDesToPrepend); |
|
325 //for testing and debugging only |
|
326 void DoBloggerTests(); |
|
327 private: |
|
328 friend class CHCILinkMgr; // for testing |
|
329 CBloggette* iLLBloggette; |
|
330 CBloggette* iL2Bloggette; |
|
331 CBloggette* iRFBloggette; |
|
332 |
|
333 TInt iOutputWindowSize; |
|
334 TInt iVerbosityLevel; |
|
335 TInt iLayersToLogMask; |
|
336 TInt iLoggingMask; |
|
337 TInt iMediumType; // 0 for port 0, 1 for Flogger - defaults to zero because member of C Class. |
|
338 TBuf<KRDBMaxLit> iTestCaseLit; |
|
339 |
|
340 TAny* iFloggerInfo; // when flogging is compiled in |
|
341 RFs ifileserv; |
|
342 RFile ifile; |
|
343 TBool iFileExists; |
|
344 HBufC* ifilename; |
|
345 }; |
|
346 |
|
347 NONSHARABLE_CLASS(CBloggette) : public CBase |
|
348 { |
|
349 public: |
|
350 ~CBloggette(); |
|
351 inline TInt Layer() const; |
|
352 void Log(TRefByValue<const TDesC> aFormatingLit, ...); |
|
353 void HexDump(TRefByValue<const TDesC> aDescription,const TDesC8& aHexFrame, TInt aFrameWindow=80); |
|
354 virtual TDesC NameDes()=0; |
|
355 protected: |
|
356 CBloggette(CBlogger* aProvider, TInt aLayer); |
|
357 TInt iLayer; |
|
358 CBlogger* iBlogger; |
|
359 }; |
|
360 |
|
361 NONSHARABLE_CLASS(CLLBloggette) : public CBloggette |
|
362 { |
|
363 public: |
|
364 static CLLBloggette* NewL(CBlogger* aProvider, TInt aLayer); //only one per layer please |
|
365 ~CLLBloggette(); |
|
366 virtual TDesC NameDes(); |
|
367 private: |
|
368 CLLBloggette(CBlogger* aProvider, TInt aLayer); |
|
369 }; |
|
370 |
|
371 NONSHARABLE_CLASS(CL2Bloggette) : public CBloggette |
|
372 { |
|
373 public: |
|
374 static CL2Bloggette* NewL(CBlogger* aProvider, TInt aLayer); |
|
375 ~CL2Bloggette(); |
|
376 virtual TDesC NameDes(); |
|
377 private: |
|
378 CL2Bloggette(CBlogger* aProvider, TInt aLayer); |
|
379 }; |
|
380 |
|
381 NONSHARABLE_CLASS(CRFBloggette) : public CBloggette |
|
382 { |
|
383 friend class CRfcommCtrlFrame; |
|
384 public: |
|
385 static CRFBloggette* NewL(CBlogger* aProvider, TInt aLayer); |
|
386 ~CRFBloggette(); |
|
387 virtual TDesC NameDes(); |
|
388 private: |
|
389 CRFBloggette(CBlogger* aProvider, TInt aLayer); |
|
390 friend class CRfcommFrame; //Shehla |
|
391 friend class CRfcommMuxer; //Shehla |
|
392 void Timeout(/*CRfcommSAP* aSAP, CRfcommMuxer* aMux, */CRfcommFrame* aFrm ); |
|
393 void ExplainOutgoingFrame(CRfcommFrame* aFrm, CRfcommMuxer* aMux); |
|
394 void ExplainIncomingFrame(TUint8 addr, TUint8 ctrl, TBool poll); |
|
395 void LogMuxCommand(CRfcommSAP* aSAP, CRfcommMuxer* aMux, TUint8 aCommand); |
|
396 void IncomingCtrlMessage(TUint8 aCtrlmessage, TInt aLength); |
|
397 }; |
|
398 |
|
399 #endif |
|
400 #endif |
|
401 |