|
1 // Copyright (c) 2007-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 HCTLUARTPOWERMANAGER_H |
|
23 #define HCTLUARTPOWERMANAGER_H |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <bluetooth/hci/hcitypes.h> |
|
27 #include <bluetooth/hci/hctluartpowerobserver.h> |
|
28 |
|
29 class CDelay; |
|
30 class RBusDevComm; |
|
31 |
|
32 // The timeout to detect if a device has changed to power off state |
|
33 static const TInt KUartSignalChangeTimeout = 10000000; // 10s |
|
34 |
|
35 _LIT(KHctlUartPowerManagerPanic, "Uart Power Man"); |
|
36 enum THctlUartPowerManagerPanic |
|
37 { |
|
38 EHCTLUartPowerOnWithCTSLow = 0, |
|
39 EHCTLUartPowerInvalidState, |
|
40 }; |
|
41 |
|
42 /** |
|
43 This class implements monitoring of a UART device to detect when |
|
44 it changes power state. It is intended to be used by any UART based |
|
45 HCTL implementation that wishes to detect power changing from on to |
|
46 off and vice versa. |
|
47 */ |
|
48 NONSHARABLE_CLASS(CHCTLUartPowerManager) : public CActive |
|
49 { |
|
50 public: |
|
51 IMPORT_C static CHCTLUartPowerManager *NewL(MHCTLUartPowerObserver& aObserver, RBusDevComm& aPort); |
|
52 ~CHCTLUartPowerManager(); |
|
53 |
|
54 IMPORT_C void Start(); |
|
55 |
|
56 static TInt PowerOffTimeout(TAny* aThis); |
|
57 |
|
58 private: |
|
59 CHCTLUartPowerManager(MHCTLUartPowerObserver& aObserver, RBusDevComm& aPort); |
|
60 void ConstructL(); |
|
61 |
|
62 virtual void DoCancel(); |
|
63 virtual void RunL(); |
|
64 |
|
65 void PowerChange(); |
|
66 |
|
67 private: |
|
68 MHCTLUartPowerObserver& iObserver; |
|
69 |
|
70 TBTPowerState iState; |
|
71 RBusDevComm& iPort; |
|
72 TUint iSignals; |
|
73 |
|
74 CDelay* iPowerOffTimer; |
|
75 }; |
|
76 |
|
77 #endif // HCTLUARTPOWERMANAGER_H |
|
78 |