|
1 // Copyright (c) 2005-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 |
|
18 // INCLUDE FILES |
|
19 #include <e32std.h> |
|
20 #include "BTGPSNormalGpsInitialiser.h" |
|
21 #include "BTGPSMessageDef.h" |
|
22 #include "BTGPSConnectManager.h" |
|
23 #include "BTGPSConstantsManager.h" |
|
24 #include "BTGPSRequestHandler.h" |
|
25 #include "BTGPSLogging.h" |
|
26 |
|
27 // EXTERNAL DATA STRUCTURES |
|
28 |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 /** |
|
34 * Normal BT GPS intialisation steps |
|
35 */ |
|
36 enum TBTGPSNormalGpsInitStep |
|
37 { |
|
38 ENormalGpsInitSetFullPower, |
|
39 ENormalGpsInitSetWantedMsg |
|
40 }; |
|
41 |
|
42 // MACROS |
|
43 |
|
44 // LOCAL CONSTANTS AND MACROS |
|
45 |
|
46 // MODULE DATA STRUCTURES |
|
47 |
|
48 // LOCAL FUNCTION PROTOTYPES |
|
49 |
|
50 // FORWARD DECLARATIONS |
|
51 |
|
52 // ============================= LOCAL FUNCTIONS =============================== |
|
53 |
|
54 // ============================ MEMBER FUNCTIONS =============================== |
|
55 |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CBTGPSNormalGpsInitialiser::NewL |
|
59 // ----------------------------------------------------------------------------- |
|
60 CBTGPSNormalGpsInitialiser* CBTGPSNormalGpsInitialiser::NewL( |
|
61 CBTGPSConnectManager& aConnectManager, |
|
62 CBTGPSNormalGpsInitialiser*& aOwner) |
|
63 { |
|
64 CBTGPSNormalGpsInitialiser* self = new (ELeave) CBTGPSNormalGpsInitialiser( |
|
65 aConnectManager, |
|
66 aOwner); |
|
67 CleanupStack::PushL(self); |
|
68 self->ConstructL(); |
|
69 CleanupStack::Pop(); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CBTGPSNormalGpsInitialiser::New |
|
75 // ----------------------------------------------------------------------------- |
|
76 CBTGPSNormalGpsInitialiser* CBTGPSNormalGpsInitialiser::New( |
|
77 CBTGPSConnectManager& aConnectManager, |
|
78 CBTGPSNormalGpsInitialiser*& aOwner) |
|
79 { |
|
80 CBTGPSNormalGpsInitialiser* self = NULL; |
|
81 TInt err(KErrNone); |
|
82 TRAP(err, self = CBTGPSNormalGpsInitialiser::NewL(aConnectManager, aOwner)); |
|
83 return self; |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CBTGPSNormalGpsInitialiser::~CBTGPSNormalGpsInitialiser |
|
88 // ----------------------------------------------------------------------------- |
|
89 CBTGPSNormalGpsInitialiser::~CBTGPSNormalGpsInitialiser() |
|
90 { |
|
91 if(iTimer!=NULL) |
|
92 { |
|
93 iTimer->Cancel(); |
|
94 delete iTimer; |
|
95 } |
|
96 iOwner = NULL; |
|
97 } |
|
98 |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CBTGPSNormalGpsInitialiser::ConstructL |
|
102 // ----------------------------------------------------------------------------- |
|
103 void CBTGPSNormalGpsInitialiser::ConstructL() |
|
104 { |
|
105 TRACESTRING("CBTGPSNormalGpsInitialiser::ConstructL start...") |
|
106 iTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
|
107 iStep = ENormalGpsInitSetFullPower; |
|
108 iConnectManager.SendMessage(KNMEAToNormalPower); |
|
109 iCount++; |
|
110 iTimer->Start( |
|
111 CBTGPSRequestHandler::ConstantsManager().iDelayBetweenGpsInitMessages, |
|
112 CBTGPSRequestHandler::ConstantsManager().iDelayBetweenGpsInitMessages, |
|
113 TCallBack(TimerCallback, this)); |
|
114 TRACESTRING("CBTGPSNormalGpsInitialiser::ConstructL end") |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CBTGPSNormalGpsInitialiser::CBTGPSNormalGpsInitialiser |
|
119 // C++ default constructor can NOT contain any code, that |
|
120 // might leave. |
|
121 // ----------------------------------------------------------------------------- |
|
122 CBTGPSNormalGpsInitialiser::CBTGPSNormalGpsInitialiser( |
|
123 CBTGPSConnectManager& aConnectManager, |
|
124 CBTGPSNormalGpsInitialiser*& aOwner) |
|
125 : iConnectManager(aConnectManager), |
|
126 iOwner(aOwner) |
|
127 { |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CBTGPSNormalGpsInitialiser::TimerTick |
|
132 // ----------------------------------------------------------------------------- |
|
133 void CBTGPSNormalGpsInitialiser::TimerTick() |
|
134 { |
|
135 if(iStep == ENormalGpsInitSetFullPower && |
|
136 iCount>= |
|
137 CBTGPSRequestHandler::ConstantsManager().iNumberOfSetFullPowerMessage) |
|
138 { |
|
139 iStep++; |
|
140 iCount = 0; |
|
141 } |
|
142 |
|
143 switch(iStep) |
|
144 { |
|
145 case ENormalGpsInitSetFullPower: |
|
146 { |
|
147 iConnectManager.SendMessage(KNMEAToNormalPower); |
|
148 iCount++; |
|
149 } |
|
150 break; |
|
151 case ENormalGpsInitSetWantedMsg: |
|
152 iConnectManager.SendMessage(KNMEASelectedMessages); |
|
153 iStep++; |
|
154 delete this; |
|
155 break; |
|
156 default: |
|
157 //should never be called |
|
158 delete this; |
|
159 break; |
|
160 } |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CBTGPSNormalGpsInitialiser::TimerCallback |
|
165 // ----------------------------------------------------------------------------- |
|
166 TInt CBTGPSNormalGpsInitialiser::TimerCallback(TAny* aAny) |
|
167 { |
|
168 reinterpret_cast<CBTGPSNormalGpsInitialiser*>(aAny)->TimerTick(); |
|
169 return KErrNone; |
|
170 } |
|
171 |
|
172 // End of File |
|
173 |
|
174 |
|
175 |