|
1 // Copyright (c) 2006-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 @internalComponent |
|
19 */ |
|
20 |
|
21 #ifndef CONTROLLERINITIALISATIONPLUGINIMPL_H |
|
22 #define CONTROLLERINITIALISATIONPLUGINIMPL_H |
|
23 |
|
24 #include <bluetooth/hci/controllerinitialisationplugin.h> |
|
25 #include <bluetooth/hci/controllerinitialisationinterface.h> |
|
26 #include <bluetooth/hcicommandqueueclient.h> |
|
27 |
|
28 class TReadLocalVersionInfoCompleteEvent; |
|
29 class TVendorDebugCompleteEvent; |
|
30 class CCommandParser; |
|
31 class MCoreHci; |
|
32 |
|
33 /** |
|
34 Observer class for CSleepDisableTimer |
|
35 */ |
|
36 class MSleepDisableTimerEventObserver |
|
37 { |
|
38 public: |
|
39 virtual void SleepDisableTimerExpired() = 0; |
|
40 }; |
|
41 |
|
42 /** |
|
43 Timer class used to introduce a delay before sending the |
|
44 Sleep Disable command |
|
45 */ |
|
46 class CSleepDisableTimer : public CTimer |
|
47 { |
|
48 public: |
|
49 static CSleepDisableTimer* NewL(MSleepDisableTimerEventObserver& aTimerObserver); |
|
50 void Start(); |
|
51 |
|
52 private: |
|
53 CSleepDisableTimer(MSleepDisableTimerEventObserver& aTimerObserver); |
|
54 void ConstructL(); |
|
55 |
|
56 void RunL(); |
|
57 |
|
58 private: |
|
59 // 0.5 second timer. |
|
60 static const TInt KSleepDisableTimerDuration = 500000; |
|
61 |
|
62 MSleepDisableTimerEventObserver& iTimerObserver; |
|
63 }; |
|
64 |
|
65 |
|
66 class CControllerInitialisationPluginImpl : public CControllerInitialisationPlugin, |
|
67 public MControllerInitialisationInterface, |
|
68 public MHCICommandQueueClient, |
|
69 public MSleepDisableTimerEventObserver |
|
70 { |
|
71 private: |
|
72 enum TInitState |
|
73 { |
|
74 EIdle, |
|
75 EWaitLocalDeviceInfo, |
|
76 EWaitForSleepTimerExpiry, |
|
77 EWaitSleepDisableCompleteEvent, |
|
78 ESendScriptCommands, |
|
79 }; |
|
80 |
|
81 public: |
|
82 static CControllerInitialisationPluginImpl* NewL(); |
|
83 virtual ~CControllerInitialisationPluginImpl(); |
|
84 virtual TAny* Interface(TUid aUid); |
|
85 |
|
86 protected: |
|
87 CControllerInitialisationPluginImpl(); |
|
88 |
|
89 private: |
|
90 void ConstructL(); |
|
91 |
|
92 // Static async CallBack methods. |
|
93 static TInt AsyncCallBackForPreReset(TAny* aInitPlugin); |
|
94 static TInt AsyncCallBackForPostReset(TAny* aInitPlugin); |
|
95 |
|
96 void DoPreReset(); |
|
97 void DoPostReset(); |
|
98 |
|
99 void SendNextScriptFileCommandL(); |
|
100 |
|
101 // MControllerInitialisationInterface |
|
102 virtual void MciiPreResetCommand(); |
|
103 virtual void MciiPostResetCommand(); |
|
104 virtual void MciiSetHCICommandQueue(MHCICommandQueue& aHCICommandQueue); |
|
105 virtual void MciiSetControllerInitialisationObserver(MControllerInitialisationObserver& aObserver); |
|
106 virtual void MciiSetCoreHci(MCoreHci& aCoreHci); |
|
107 |
|
108 // MHCICommandQueueClient |
|
109 virtual void MhcqcCommandEventReceived(const THCIEventBase& aEvent, |
|
110 const CHCICommandBase* aRelatedCommand); |
|
111 virtual void MhcqcCommandErrored(TInt aErrorCode, |
|
112 const CHCICommandBase* aCommand); |
|
113 // MSleepDisableTimerEventObserver |
|
114 virtual void SleepDisableTimerExpired(); |
|
115 |
|
116 void HandleReadLocalVersionInfoCompleteEvent(const TReadLocalVersionInfoCompleteEvent& aEvent); |
|
117 void HandleVendorSpecificCompleteEvent(const TVendorDebugCompleteEvent& aEvent); |
|
118 |
|
119 // Helper methods. |
|
120 void SetLocalBDAddr(TDes8& aVSCommandData) const; |
|
121 void SetSleepProtocol(TBool aEnabled); |
|
122 |
|
123 private: |
|
124 // Async Callbacks |
|
125 CAsyncCallBack* iAsyncCallBackForPreReset; |
|
126 CAsyncCallBack* iAsyncCallBackForPostReset; |
|
127 |
|
128 CCommandParser* iCommandParser; |
|
129 TInitState iInitState; |
|
130 |
|
131 MHCICommandQueue* iHCICommandQueue; |
|
132 MControllerInitialisationObserver* iControllerInitialisationObserver; |
|
133 |
|
134 TUint32 iDesiredBaudRate; |
|
135 CSleepDisableTimer* iSleepDisableTimer; |
|
136 |
|
137 TUint16 iSubVersion; |
|
138 |
|
139 MCoreHci* iCoreHci; |
|
140 }; |
|
141 |
|
142 #endif //HCINITIALISATIONPLUGINIMPL_H |