--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmserver.cpp Tue Apr 27 18:30:32 2010 +0300
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmserver.cpp Tue May 11 17:54:03 2010 +0300
@@ -16,7 +16,7 @@
*/
/*
-* %version: 105 %
+* %version: 105.1.1 %
*/
#include <e32def.h>
@@ -24,6 +24,7 @@
#include <featmgr.h>
#include <in_sock.h>
#include <bldvariant.hrh> // for feature definitions
+#include <hal.h>
#include "wlmserver.h"
#include "wlmdriverif.h"
@@ -38,6 +39,7 @@
#include "wlandevicesettingsinternalcrkeys.h"
#include "wlanbgscan.h"
#include "wlantimerservices.h"
+#include "wlanticktimer.h"
#include "am_debug.h"
/** Panic codes for WlanEngine */
@@ -89,9 +91,6 @@
CWlmServer::EWlanStaticFeature802dot11k |
CWlmServer::EWlanStaticFeature802dot11n;
-/** Multiplier for converting seconds into microseconds */
-const TUint KWlanSecsToMicrosecsMultiplier( 1000000 );
-
/** Minimum value for aggressive background scan interval, in seconds */
const TUint KWlanAggressiveBgScanMinInterval( 1 );
@@ -141,6 +140,7 @@
iIsStartupComplete( EFalse ),
iEapolClient( NULL ),
iEapolHandler( NULL ),
+ iSystemTickPeriod( 0 ),
iScanSchedulingTimerExpiration( 0 ),
iRequestTriggeringScanning( 0 ),
iCoreHandlingScanRequest( EFalse ),
@@ -164,6 +164,12 @@
User::LeaveIfError( User::RenameThread( KWLMDataServerName ) );
StartL( KWLMDataServerName );
+ HAL::Get( HAL::ESystemTickPeriod, iSystemTickPeriod );
+ DEBUG1( "CWlmServer::ConstructL() - system tick period is %d",
+ iSystemTickPeriod );
+ DEBUG1( "CWlmServer::ConstructL() - current system tick count is %u",
+ User::TickCount( ) );
+
// Consult FeatureManager whether startup is allowed
FeatureManager::InitializeLibL();
if( !FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ) )
@@ -220,7 +226,13 @@
// Create scan timer
DEBUG( "CWlmServer::ConstructL() - create backgroundscan timer" );
- iScanSchedulingTimer = CPeriodic::NewL( CActive::EPriorityStandard );
+ TCallBack expiredCb( ScanSchedulingTimerExpired, this );
+ TCallBack canceledCb( ScanSchedulingTimerCanceled, this );
+ TCallBack emptyCb( EmptyCb, NULL );
+ iScanSchedulingTimer = CWlanTickTimer::NewL(
+ expiredCb,
+ canceledCb,
+ emptyCb );
// Create scan cache
iCache = CWlanScanResultCache::NewL();
@@ -1087,15 +1099,15 @@
return;
}
- TTime* scanTime( NULL );
+ TUint* scanTime( NULL );
if( scanScheduling.maxDelay != KWlmInfiniteScanDelay )
{
- scanTime = new TTime(
- CalculateScanStartTime( scanScheduling.maxDelay ).Int64() );
+ scanTime = new TUint(
+ CalculateScanStartTime( scanScheduling.maxDelay ) );
if( !scanTime )
{
- DEBUG( "CWlmServer::GetScanResult() - unable to instantiate TTime" );
-
+ DEBUG( "CWlmServer::GetScanResult() - unable to instantiate TUint" );
+
delete coreSsid;
delete scanList;
aMessage.Complete( KErrNoMemory );
@@ -1325,14 +1337,14 @@
return;
}
- TTime* scanTime( NULL );
+ TUint* scanTime( NULL );
if( maxDelayPckg() != KWlmInfiniteScanDelay )
{
- scanTime = new TTime(
- CalculateScanStartTime( maxDelayPckg() ).Int64() );
+ scanTime = new TUint(
+ CalculateScanStartTime( maxDelayPckg() ) );
if( !scanTime )
{
- DEBUG( "CWlmServer::GetAvailableIaps() - unable to instantiate TTime" );
+ DEBUG( "CWlmServer::GetAvailableIaps() - unable to instantiate TUint" );
aMessage.Complete( KErrNoMemory );
delete iapDataList;
@@ -1542,7 +1554,7 @@
// ---------------------------------------------------------
//
void CWlmServer::UpdateScanSchedulingTimer(
- TTime aScanTime,
+ TUint aScanTime,
TUint aTriggeringRequestId )
{
DEBUG1( "CWlmServer::UpdateScanSchedulingTimer() - aTriggeringRequestId = %u ", aTriggeringRequestId );
@@ -1555,32 +1567,22 @@
return;
}
- TTime timeNow;
- timeNow.UniversalTime();
-
- TTimeIntervalMicroSeconds difference( aScanTime.MicroSecondsFrom( timeNow ) );
- if( difference.Int64() < 0 )
+ TUint currentTickCount(
+ User::TickCount() );
+ TUint difference( 0 );
+ if( aScanTime > currentTickCount )
{
- difference = TTimeIntervalMicroSeconds( 0 );
+ difference = aScanTime - currentTickCount;
}
- TTimeIntervalMicroSeconds32 differenceMicroseconds(
- difference.Int64() );
iScanSchedulingTimer->Cancel();
iScanSchedulingTimerExpiration = aScanTime;
iRequestTriggeringScanning = aTriggeringRequestId;
- TCallBack callback( ScanSchedulingTimerExpired, this );
-
- DEBUG1( "CWlmServer::UpdateScanSchedulingTimer() - scheduling the timer to %u second(s)",
- differenceMicroseconds.Int() / SECONDS_FROM_MICROSECONDS );
-
- TTimeIntervalMicroSeconds32 intervalMicroseconds( KWlmMaxScanDelay * SECONDS_FROM_MICROSECONDS );
-
- iScanSchedulingTimer->Start(
- differenceMicroseconds,
- intervalMicroseconds,
- callback );
+ DEBUG2( "CWlmServer::UpdateScanSchedulingTimer() - scheduling the timer to %u system ticks(s) [%u s]",
+ difference, difference * iSystemTickPeriod / KWlanSecsToMicrosecsMultiplier );
+
+ iScanSchedulingTimer->After( difference );
}
// ---------------------------------------------------------
@@ -1593,14 +1595,14 @@
DEBUG( "CWlmServer::FindNextTimedScanSchedulingRequest()" );
TBool pendingScanRequestsFound( EFalse );
- TTime closestTime = TTime( 0 );
+ TUint closestTime( 0 );
aTriggeringRequestIndex = 0;
for(TInt i=0; i < iRequestMap.Count(); i++)
{
if( IsPendingTimedScanRequest( i ) )
{
- TTime* checkedTime = reinterpret_cast<TTime*>( iRequestMap[i].iTime );
+ TUint* checkedTime = reinterpret_cast<TUint*>( iRequestMap[i].iTime );
if( pendingScanRequestsFound == EFalse || closestTime > *checkedTime )
{
closestTime = *checkedTime;
@@ -1614,7 +1616,7 @@
{
// clear the scan scheduling related variables
iRequestTriggeringScanning = KWlanIntCmdNull;
- iScanSchedulingTimerExpiration = TTime( 0 );
+ iScanSchedulingTimerExpiration = 0;
}
else
{
@@ -2443,7 +2445,7 @@
if( FindNextTimedScanSchedulingRequest( indexNextScan ) )
{
- TTime* nextScanTime = reinterpret_cast<TTime*>( iRequestMap[indexNextScan].iTime );
+ TUint* nextScanTime = reinterpret_cast<TUint*>( iRequestMap[indexNextScan].iTime );
UpdateScanSchedulingTimer( *nextScanTime, iRequestMap[indexNextScan].iRequestId );
}
}
@@ -2613,7 +2615,7 @@
delete iapDataList;
iapDataList = NULL;
- TTime* completedScanTime = reinterpret_cast<TTime*>( aRequest.iTime );
+ TUint* completedScanTime = reinterpret_cast<TUint*>( aRequest.iTime );
delete completedScanTime;
completedScanTime = NULL;
@@ -2678,7 +2680,7 @@
{
ScanList* tmp( NULL );
core_ssid_s* ssid = reinterpret_cast<core_ssid_s*>( aRequest.iParam1 );
- TTime* completedScanTime = reinterpret_cast<TTime*>( aRequest.iTime );
+ TUint* completedScanTime = reinterpret_cast<TUint*>( aRequest.iTime );
ScanList* completedScanList = reinterpret_cast<ScanList*>( aRequest.iParam0 );
if( aTriggerRequest == NULL )
@@ -2778,7 +2780,7 @@
iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( aRequest.iParam3 );
iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( aRequest.iParam0 );
- TTime* completedScanTime = reinterpret_cast<TTime*>( aRequest.iTime );
+ TUint* completedScanTime = reinterpret_cast<TUint*>( aRequest.iTime );
ScanList* completedScanList = reinterpret_cast<ScanList*>( aRequest.iParam2);
core_type_list_c<u32_t>* completedIdList = reinterpret_cast<core_type_list_c<u32_t>*>( aRequest.iParam1 );
@@ -3436,11 +3438,11 @@
return KErrNoMemory;
}
- TTime* scanTime = new TTime(
- CalculateScanStartTime( aScanStartInterval ).Int64() );
+ TUint* scanTime = new TUint(
+ CalculateScanStartTime( aScanStartInterval ) );
if( !scanTime )
{
- DEBUG( "CWlmServer::BackgroundScanRequest() - unable to instantiate TTime" );
+ DEBUG( "CWlmServer::BackgroundScanRequest() - unable to instantiate TUint" );
delete iapDataList;
delete iapSsidList;
@@ -3514,7 +3516,7 @@
ScanList* completedScanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam0 );
core_ssid_s* completedSsid = reinterpret_cast<core_ssid_s*>( self->iRequestMap[index].iParam1 );
- TTime* completedScanTime = reinterpret_cast<TTime*>( self->iRequestMap[index].iTime );
+ TUint* completedScanTime = reinterpret_cast<TUint*>( self->iRequestMap[index].iTime );
// Only the triggering request is completed and then scan scheduling timer is set again
TPckgBuf<TUint32> pckgCount( 0 );
@@ -3541,7 +3543,7 @@
if( self->FindNextTimedScanSchedulingRequest( indexNextScan ) )
{
- TTime* nextScanTime = reinterpret_cast<TTime*>( self->iRequestMap[indexNextScan].iTime );
+ TUint* nextScanTime = reinterpret_cast<TUint*>( self->iRequestMap[indexNextScan].iTime );
self->UpdateScanSchedulingTimer( *nextScanTime, self->iRequestMap[indexNextScan].iRequestId );
}
@@ -3559,7 +3561,7 @@
core_type_list_c<u32_t>* iapIdList = reinterpret_cast<core_type_list_c<u32_t>*>( self->iRequestMap[index].iParam1 );
ScanList* scanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 );
core_type_list_c<core_ssid_entry_s>* iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( self->iRequestMap[index].iParam3 );
- TTime* scanTime = reinterpret_cast<TTime*>( self->iRequestMap[index].iTime );
+ TUint* scanTime = reinterpret_cast<TUint*>( self->iRequestMap[index].iTime );
// If the device is roaming OR there are not WLAN IAPs defined in the device
// --> return empty list
@@ -3590,7 +3592,7 @@
if( self->FindNextTimedScanSchedulingRequest( indexNextScan ) )
{
- TTime* nextScanTime = reinterpret_cast<TTime*>( self->iRequestMap[indexNextScan].iTime );
+ TUint* nextScanTime = reinterpret_cast<TUint*>( self->iRequestMap[indexNextScan].iTime );
self->UpdateScanSchedulingTimer( *nextScanTime, self->iRequestMap[indexNextScan].iRequestId );
}
@@ -3681,7 +3683,43 @@
}
self->iCoreHandlingScanRequest = ETrue;
return KErrNone;
+ }
+
+// ---------------------------------------------------------
+// CWlmServer::ScanSchedulingTimerCanceled()
+// ---------------------------------------------------------
+//
+TInt CWlmServer::ScanSchedulingTimerCanceled(
+ TAny* aThisPtr )
+ {
+ DEBUG( "CWlmServer::ScanSchedulingTimerCanceled()" );
+
+ CWlmServer* self = reinterpret_cast<CWlmServer*>( aThisPtr );
+
+ /**
+ * Scan scheduling timer was canceled, re-arm the timer.
+ */
+ TUint indexNextScan( 0 );
+ if( self->FindNextTimedScanSchedulingRequest( indexNextScan ) )
+ {
+ self->UpdateScanSchedulingTimer(
+ *(self->iRequestMap[indexNextScan].iTime),
+ self->iRequestMap[indexNextScan].iRequestId );
+ }
+
+ return 0;
}
+
+// ---------------------------------------------------------
+// CWlmServer::EmptyCb()
+// ---------------------------------------------------------
+//
+TInt CWlmServer::EmptyCb(
+ TAny* /* aThisPtr */ )
+ {
+ return 0;
+ }
+
// ---------------------------------------------------------
// CWlmServer::GetIapDataList()
@@ -3897,38 +3935,6 @@
iTimerServices->HandleTimeout();
DEBUG("CWlmServer::SystemTimeChanged() - refreshing settings to BgScan provider");
iBgScanProvider->NotifyChangedSettings( iBgScanProviderSettings );
-
- // Pending scan requests should be handled because after the system time change all the
- // timestamps are invalid. Change the scan start times to start immediately
-
- DEBUG("CWlmServer::SystemTimeChanged() - set all pending requests to expire immediately");
-
- TInt i( 0 );
- for( i = 0; i < iRequestMap.Count(); i++ )
- {
- if( IsPendingTimedScanRequest(i) )
- {
- DEBUG1( "CWlmServer::SystemTimeChanged() - setting iTime to current time for request %i",
- iRequestMap[i].iRequestId );
-
- TTime* requestedScanTime = reinterpret_cast<TTime*>( iRequestMap[i].iTime );
- requestedScanTime->UniversalTime();
- }
- }
- if( !iCoreHandlingScanRequest )
- {
- // Core is not handling any scan request so update the timer
- DEBUG("CWlmServer::SystemTimeChanged() - Core is not currently handling any scan requests");
- DEBUG("CWlmServer::SystemTimeChanged() - Cancel timer and set it again to new value");
-
- iScanSchedulingTimer->Cancel();
- TUint indexNextScan;
- if( FindNextTimedScanSchedulingRequest( indexNextScan ) )
- {
- TTime* nextScanTime = reinterpret_cast<TTime*>( iRequestMap[indexNextScan].iTime );
- UpdateScanSchedulingTimer( *nextScanTime, iRequestMap[indexNextScan].iRequestId );
- }
- }
}
}
@@ -4074,7 +4080,7 @@
delete reinterpret_cast<core_type_list_c<u32_t>*>( entry.iParam1 );
delete reinterpret_cast<ScanList*>( entry.iParam2);
delete reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( entry.iParam3 );
- delete reinterpret_cast<TTime*>( entry.iTime );
+ delete reinterpret_cast<TUint*>( entry.iTime );
iRequestMap.Remove( index );
DEBUG( "CWlmServer::CancelScan() - find next possible timed scan scheduling request" );
@@ -4111,7 +4117,7 @@
delete reinterpret_cast<core_type_list_c<u32_t>*>( entry.iParam1 );
delete reinterpret_cast<ScanList*>( entry.iParam2);
delete reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( entry.iParam3 );
- delete reinterpret_cast<TTime*>( entry.iTime );
+ delete reinterpret_cast<TUint*>( entry.iTime );
iRequestMap.Remove( index );
}
}