bluetooth/btstack/linkmgr/AcceptWatchdog.cpp
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2003-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 // Implements the accept watchdog timer for baseband SAPs
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <bluetooth/logger.h>
       
    19 #include "AcceptWatchdog.h"
       
    20 #include "basebandsap.h"
       
    21 #include "btsockettimer.h"
       
    22 
       
    23 #ifdef __FLOG_ACTIVE
       
    24 _LIT8(KLogComponent, LOG_COMPONENT_HCI_WATCHDOG);
       
    25 #endif
       
    26 
       
    27 #ifdef _DEBUG
       
    28 PANICCATEGORY("HciWatch");
       
    29 #endif
       
    30 
       
    31 TAcceptWatchdog::TAcceptWatchdog(CBTBasebandSAP& aParent)
       
    32 : iParent(aParent), iActive(EFalse)
       
    33 	{
       
    34 	TCallBack cb(AcceptTimeout, this);
       
    35 	iIdleTimerEntry.Set(cb);
       
    36 	}
       
    37 
       
    38 void TAcceptWatchdog::Start()
       
    39 	{
       
    40 	BTSocketTimer::Queue(KAcceptWatchdogTimeout, iIdleTimerEntry);
       
    41 	// add entry to timer queue
       
    42 	iActive = ETrue;
       
    43 	}
       
    44 
       
    45 void TAcceptWatchdog::Cancel()
       
    46 	{
       
    47 	if (iActive)
       
    48 		{
       
    49 		BTSocketTimer::Remove(iIdleTimerEntry);
       
    50 		iActive = EFalse;
       
    51 		}
       
    52 	}
       
    53 
       
    54 /*static*/ TInt TAcceptWatchdog::AcceptTimeout(TAny* aTAcceptWatchdog)
       
    55 	{
       
    56 	TAcceptWatchdog* w = reinterpret_cast<TAcceptWatchdog*>(aTAcceptWatchdog);
       
    57 
       
    58 	ASSERT_DEBUG(w);
       
    59 	w->iActive = EFalse;
       
    60 	w->iParent.Timeout(EAccept);
       
    61 
       
    62 	return EFalse;
       
    63 	}
       
    64 
       
    65 
       
    66 #ifdef _DEBUG
       
    67 TAcceptWatchdog::~TAcceptWatchdog()
       
    68 	{
       
    69 	ASSERT_DEBUG(!iActive);
       
    70 	}
       
    71 #endif