|
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 /** |
|
17 @file |
|
18 @publishedPartner |
|
19 @released |
|
20 */ |
|
21 |
|
22 #ifndef HCI_FRAME_LOGGER_H |
|
23 #define HCI_FRAME_LOGGER_H |
|
24 |
|
25 #include <e32base.h> |
|
26 |
|
27 static const TUint KHCILoggerDatalinkTypeH1 = 1001; |
|
28 static const TUint KHCILoggerDatalinkTypeH4 = 1002; |
|
29 static const TUint KHCILoggerDatalinkTypeBCSP = 1003; |
|
30 static const TUint KHCILoggerDatalinkTypeH5 = 1004; |
|
31 |
|
32 static const TUint KHCILoggerHostToController = 0; |
|
33 static const TUint KHCILoggerControllerToHost = 0x00000001; |
|
34 |
|
35 static const TUint KHCILoggerACLDataFrame = 0; // For future use if required |
|
36 static const TUint KHCILoggerSynchronousDataFrame = 0; // For future use if required |
|
37 |
|
38 static const TUint KHCILoggerCommandOrEvent = 0x00000002; |
|
39 |
|
40 static const TUint KHCILoggerFrameFragmented = 0x80000000; |
|
41 |
|
42 class CHCIFrameLoggerBase; |
|
43 |
|
44 class MHCIFrameLogger |
|
45 { |
|
46 public: |
|
47 static MHCIFrameLogger* HciLoggerLoadL(TInt aType); |
|
48 void HciLoggerUnLoad(); |
|
49 // Data logging functions |
|
50 virtual void LogFrame(TUint aFrameFlags, const TDesC8& aDesc) = 0; |
|
51 protected: |
|
52 // instantiation functions |
|
53 virtual void SetLibrary(RLibrary& aLib) = 0; |
|
54 virtual void GetLibrary(RLibrary& aLib) = 0; |
|
55 virtual void Initialise(TInt aType) = 0; |
|
56 virtual void Release() = 0; |
|
57 }; |
|
58 |
|
59 #ifdef ENABLE_HCI_FRAME_LOGGING |
|
60 |
|
61 static const TUid KHCILoggerDllUid = {0x10200D9E}; |
|
62 |
|
63 |
|
64 #ifndef HCI_LOG_MEMBER_NAME |
|
65 #define HCI_LOG_MEMBER_NAME __iHciFrameLogger |
|
66 #endif |
|
67 #define DECLARE_HCI_LOGGER MHCIFrameLogger* HCI_LOG_MEMBER_NAME; |
|
68 #define HCI_LOG_LOADL(x,y) {x->HCI_LOG_MEMBER_NAME=MHCIFrameLogger::HciLoggerLoadL(y);} |
|
69 #define HCI_LOG_UNLOAD(x) if(x->HCI_LOG_MEMBER_NAME) {x->HCI_LOG_MEMBER_NAME->HciLoggerUnLoad();} |
|
70 |
|
71 #define HCI_LOG_FRAME(x, aFrameFlags, aDesc) if (x->HCI_LOG_MEMBER_NAME) {x->HCI_LOG_MEMBER_NAME->LogFrame(aFrameFlags, aDesc);} |
|
72 #define HCI_LOG_FRAME_IF_NO_ERROR(err, x, aFrameFlags, aDesc) if(err == KErrNone) { HCI_LOG_FRAME(x, aFrameFlags, aDesc) } |
|
73 |
|
74 inline MHCIFrameLogger* MHCIFrameLogger::HciLoggerLoadL(TInt aType) |
|
75 { |
|
76 _LIT(KHCIFrameLoggerLibName, "hciframelogger.dll"); |
|
77 RLibrary lib; |
|
78 TInt err = lib.Load(KHCIFrameLoggerLibName); |
|
79 if (err == KErrNone && lib.Type()[1] == KHCILoggerDllUid) |
|
80 { |
|
81 TLibraryFunction func = lib.Lookup(1); |
|
82 MHCIFrameLogger* self = (MHCIFrameLogger*)(*func)(); |
|
83 User::LeaveIfNull(self); |
|
84 self->SetLibrary(lib); |
|
85 self->Initialise(aType); |
|
86 return self; |
|
87 } |
|
88 return 0; |
|
89 } |
|
90 |
|
91 inline void MHCIFrameLogger::HciLoggerUnLoad() |
|
92 { |
|
93 RLibrary lib; |
|
94 GetLibrary(lib); |
|
95 Release(); |
|
96 lib.Close(); |
|
97 } |
|
98 |
|
99 #else // !ENABLE_HCI_FRAME_LOGGING |
|
100 |
|
101 #define DECLARE_HCI_LOGGER |
|
102 #define HCI_LOG_LOADL(x,y) |
|
103 #define HCI_LOG_UNLOAD(x) |
|
104 |
|
105 #define HCI_LOG_FRAME(x, aFrameFlags, aDesc) |
|
106 #define HCI_LOG_FRAME_IF_NO_ERROR(err, x, aFrameFlags, aDesc) |
|
107 |
|
108 #endif // ENABLE_HCI_FRAME_LOGGING |
|
109 |
|
110 #endif // HCI_FRAME_LOGGER_H |
|
111 |
|
112 |
|
113 |
|
114 |