|
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 // |
|
15 |
|
16 #ifndef HCI_LOGGER_BT_SNOOP_H |
|
17 #define HCI_LOGGER_BT_SNOOP_H |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <e32std.h> |
|
21 #include <f32file.h> |
|
22 #include <bluetooth/hciframelogger.h> |
|
23 |
|
24 enum TBtSnoopLoggerPanicCodes |
|
25 { |
|
26 EBtSnoopLoggerPanicNoMyLibHandle, |
|
27 EBtSnoopLoggerPanicHandleAlreadyExists, |
|
28 EBtSnoopLoggerPanicRefCountTooLow, |
|
29 EBtSnoopLoggerPanicHasntBeenInitialised, |
|
30 EBtSnoopLoggerPanicShouldNotBeInitialised, |
|
31 }; |
|
32 |
|
33 class TBtSnoopPacketRecord |
|
34 { |
|
35 public: |
|
36 TUint32 iOriginalLength; |
|
37 TUint32 iIncludedLength; |
|
38 TUint32 iPacketFlags; |
|
39 TUint32 iCumulativeDrops; |
|
40 TInt64 iTimestampMicroseconds; |
|
41 }; |
|
42 |
|
43 class CHCILoggerFileCloseTimer; |
|
44 class CHCILoggerBufferedFrame; |
|
45 |
|
46 class CHCILoggerBtSnoop : public CBase, private MHCIFrameLogger |
|
47 { |
|
48 public: |
|
49 IMPORT_C static MHCIFrameLogger* GetInstanceL(); |
|
50 static CHCILoggerBtSnoop* NewLC(); |
|
51 ~CHCILoggerBtSnoop(); |
|
52 |
|
53 private: |
|
54 // From MHCIFrameLogger |
|
55 virtual void SetLibrary(RLibrary& aLib); |
|
56 virtual void GetLibrary(RLibrary& aLib); |
|
57 virtual void Release(); |
|
58 virtual void Initialise(TInt aType); |
|
59 virtual void LogFrame(TUint aFrameFlags, const TDesC8& aDesc); |
|
60 |
|
61 void DoInitialise(TInt aType); |
|
62 CHCILoggerBtSnoop(); |
|
63 void ConstructL(); |
|
64 |
|
65 TInt OpenFile(); |
|
66 TInt FileWriteHeader(); |
|
67 void FileWriteRecord(const TBtSnoopPacketRecord& aRecord, const TDesC8& aBufferedData, const TDesC8& aNewData); |
|
68 void FileWriteRecord(const TBtSnoopPacketRecord& aRecord, const TDesC8& aNewData); // overload |
|
69 |
|
70 private: |
|
71 TInt iRefCount; |
|
72 RLibrary iMyLib; |
|
73 TBool iInitialised; |
|
74 |
|
75 RFs iFs; |
|
76 RFile iLogFile; |
|
77 CHCILoggerFileCloseTimer* iFileCloseTimer; |
|
78 |
|
79 RPointerArray<CHCILoggerBufferedFrame> iBuffers; |
|
80 |
|
81 TTime iCurrentTime; |
|
82 TUint iDatalinkType; |
|
83 TUint iCumulativeDrops; |
|
84 }; |
|
85 |
|
86 class CHCILoggerFileCloseTimer : public CTimer |
|
87 { |
|
88 public: |
|
89 static CHCILoggerFileCloseTimer* NewL(RFile& aLogFile); |
|
90 void RunL(); |
|
91 void DoCancel(); |
|
92 void ResetTimer(); |
|
93 ~CHCILoggerFileCloseTimer(); |
|
94 private: |
|
95 CHCILoggerFileCloseTimer(RFile& aLogFile); |
|
96 void ConstructL(); |
|
97 private: |
|
98 RFile& iLogFile; |
|
99 }; |
|
100 |
|
101 class CHCILoggerBufferedFrame : public CBase |
|
102 { |
|
103 public: |
|
104 CHCILoggerBufferedFrame(); |
|
105 ~CHCILoggerBufferedFrame(); |
|
106 void BufferData(const TDesC8& aDesc); |
|
107 void Reset(); |
|
108 TInt OriginalLength() const; |
|
109 TDesC8& Buffer() const; |
|
110 private: |
|
111 TInt iOriginalLength; |
|
112 HBufC8* iBuffer; |
|
113 }; |
|
114 |
|
115 #endif // HCI_LOGGER_BT_SNOOP_H |