|
1 /* |
|
2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of the WLAN signal level handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <wlanmgmtclient.h> |
|
21 #include "vccwlansignallevelhandler.h" |
|
22 #include "rubydebug.h" |
|
23 #include "vccengpsproperty.h" |
|
24 #include <ccpdefs.h> |
|
25 |
|
26 // Min. signal strength. |
|
27 static const TInt32 KStrengthMin = 110; |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // C++ destructor. |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CVccWlanSignalLevelHandler::~CVccWlanSignalLevelHandler() |
|
34 { |
|
35 // Cancel any request, if outstanding |
|
36 Cancel(); |
|
37 #ifndef __WINS__ |
|
38 delete iWlanMgmt; |
|
39 #endif |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // Symbian constructor. |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CVccWlanSignalLevelHandler* CVccWlanSignalLevelHandler::NewL( |
|
47 MVccSignalLevelObserver& aObserver, |
|
48 const TSignalLevelParams& aParams, CVccEngPsProperty& aPsProperty ) |
|
49 { |
|
50 CVccWlanSignalLevelHandler* self = |
|
51 CVccWlanSignalLevelHandler::NewLC( aObserver, aParams, aPsProperty ); |
|
52 |
|
53 CleanupStack::Pop( self ); |
|
54 |
|
55 return self; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // Symbian constructor. |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CVccWlanSignalLevelHandler* CVccWlanSignalLevelHandler::NewLC( |
|
63 MVccSignalLevelObserver& aObserver, |
|
64 const TSignalLevelParams& aParams, CVccEngPsProperty& aPsProperty ) |
|
65 { |
|
66 CVccWlanSignalLevelHandler * self = |
|
67 new ( ELeave ) CVccWlanSignalLevelHandler( aObserver, aParams, aPsProperty ); |
|
68 |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 return self; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // C++ constructor. |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 CVccWlanSignalLevelHandler::CVccWlanSignalLevelHandler( |
|
79 MVccSignalLevelObserver& aObserver, |
|
80 const TSignalLevelParams& aParams, CVccEngPsProperty& aPsProperty ) |
|
81 : CVccSignalLevelHandler( aObserver, aParams ), iVccPsp( aPsProperty ) |
|
82 { |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // Symbian second-phase constructor. |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 void CVccWlanSignalLevelHandler::ConstructL() |
|
90 { |
|
91 RUBY_DEBUG_BLOCKL( "CVccWlanSignalLevelHandler::ConstructL" ); |
|
92 |
|
93 CVccSignalLevelHandler::ConstructL(); |
|
94 #ifndef __WINS__ |
|
95 //WlanMgmtClient is not started when the phone is not f. ex. labeled |
|
96 TRAP_IGNORE( iWlanMgmt = CWlanMgmtClient::NewL() ); |
|
97 #endif |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // Enable notifications. |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 void CVccWlanSignalLevelHandler::EnableNotificationsL() |
|
105 { |
|
106 RUBY_DEBUG_BLOCK( "CVccWlanSignalLevelHandler::EnableNotificationsL" ); |
|
107 #ifndef __WINS__ |
|
108 if( iWlanMgmt ) |
|
109 { |
|
110 TInt error = iWlanMgmt->UpdateRssNotificationBoundary( |
|
111 iParams.iLowLevel, |
|
112 iParams.iLowLevel - iParams.iHighLevel ); |
|
113 |
|
114 User::LeaveIfError( error ); |
|
115 |
|
116 iWlanMgmt->ActivateNotificationsL( *this ); |
|
117 } |
|
118 #endif |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // Disable notifications. |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 void CVccWlanSignalLevelHandler::DisableNotifications() |
|
126 { |
|
127 RUBY_DEBUG_BLOCK( "CVccWlanSignalLevelHandler::DisableNotificationsL" ); |
|
128 #ifndef __WINS__ |
|
129 if( iWlanMgmt ) |
|
130 { |
|
131 iWlanMgmt->CancelNotifications(); |
|
132 } |
|
133 #endif |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // Get signal strength. |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 void CVccWlanSignalLevelHandler::GetStrength() |
|
141 { |
|
142 |
|
143 RUBY_DEBUG_BLOCK( "CVccWlanSignalLevelHandler::GetStrength" ); |
|
144 |
|
145 iStrength = KStrengthMin; |
|
146 #ifndef __WINS__ |
|
147 if( iWlanMgmt ) |
|
148 { |
|
149 iWlanMgmt->GetConnectionSignalQuality( iStrength ); |
|
150 } |
|
151 #endif |
|
152 RUBY_DEBUG1( " -strength = %d", iStrength ); |
|
153 |
|
154 // Because the RMobilePhone used in GSM is asynchronous we need here |
|
155 // to signal that the request is complete (in order to continue |
|
156 // processing stuff in RunL) |
|
157 |
|
158 TRequestStatus *sP = &iStatus; |
|
159 |
|
160 User::RequestComplete( sP, KErrNone ); |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // Cancel outstanding GetStrength. |
|
165 // We do not need to do anything since WLAN GetStrength is synchronous. |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 void CVccWlanSignalLevelHandler::CancelGetStrength() |
|
169 { |
|
170 RUBY_DEBUG_BLOCK( "CVccWlanSignalLevelHandler::CancelGetStrength" ); |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // Handles indication of changed RSS value. |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 void CVccWlanSignalLevelHandler::RssChanged( TWlanRssClass aRssClass, TUint aRss ) |
|
178 { |
|
179 RUBY_DEBUG_BLOCK( "CVccWlanSignalLevelHandler::RssChanged" ); |
|
180 RUBY_DEBUG2( " -class = %d rss = %d", aRssClass, aRss); |
|
181 |
|
182 // Do some basic check |
|
183 // Zero (0) is not acceptable strength (too good?). |
|
184 |
|
185 iStrength = aRss ? aRss : KStrengthMin; |
|
186 StrengthChanged(); |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // Handles BSSID has changed (i.e. AP handover) situation. |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CVccWlanSignalLevelHandler::BssidChanged( TWlanBssid& aNewBSSID ) |
|
194 { |
|
195 RUBY_DEBUG_BLOCK( "CVccWlanSignalLevelHandler::BssidChanged" ); |
|
196 RUBY_DEBUG1( " -aNewBSSID = %S", &aNewBSSID ); |
|
197 |
|
198 iStrength = KStrengthMin; |
|
199 #ifndef __WINS__ |
|
200 if( iWlanMgmt ) |
|
201 { |
|
202 iWlanMgmt->GetConnectionSignalQuality( iStrength ); |
|
203 } |
|
204 #endif |
|
205 |
|
206 StrengthChanged(); |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // Handles lost of one or more networks |
|
211 // --------------------------------------------------------------------------- |
|
212 // |
|
213 void CVccWlanSignalLevelHandler::OldNetworksLost() |
|
214 { |
|
215 RUBY_DEBUG_BLOCK( "CVccWlanSignalLevelHandler::OldNetworksLost" ); |
|
216 |
|
217 iStrength = KStrengthMin; |
|
218 #ifndef __WINS__ |
|
219 if( iWlanMgmt ) |
|
220 { |
|
221 iWlanMgmt->GetConnectionSignalQuality( iStrength ); |
|
222 } |
|
223 #endif |
|
224 StrengthChanged(); |
|
225 |
|
226 TVccHoStatus hoStatus( EVccHoStateUnknown ); |
|
227 iVccPsp.GetCurrentHoStatus( hoStatus ); |
|
228 |
|
229 RUBY_DEBUG1("Current HoStatus; %d", hoStatus); |
|
230 |
|
231 if( hoStatus == EVccCsToPsHoStarted || hoStatus == EVccCsToPsHoInprogress |
|
232 || hoStatus == EVccHoUnavailable ) |
|
233 { |
|
234 iVccPsp.NotifySubscriberL( EVccCsToPsHoFailure, ECCPErrorNetworkOutOfOrder ); |
|
235 } |
|
236 } |
|
237 |
|
238 // --------------------------------------------------------------------------- |
|
239 // Notify observer that the signal level has been changed. |
|
240 // --------------------------------------------------------------------------- |
|
241 // |
|
242 void CVccWlanSignalLevelHandler::NotifyChanges( |
|
243 TInt32 aSignalStrength, |
|
244 MVccSignalLevelObserver::TSignalStrengthClass aClass ) |
|
245 { |
|
246 RUBY_DEBUG_BLOCK( "CVccWlanSignalLevelHandler::NotifyChanges" ); |
|
247 RUBY_DEBUG1( " -New strength = -%d dBm", aSignalStrength ); |
|
248 |
|
249 iObserver.WlanSignalChanged( aSignalStrength, aClass ); |
|
250 } |