bluetooth/btstack/linkmgr/physicallinks.cpp
changeset 3 4e39398d58ed
parent 0 29b1cd4cb562
child 8 2b6718f05bdb
equal deleted inserted replaced
2:91980f93208a 3:4e39398d58ed
  1709 		{
  1709 		{
  1710 		return KErrNotSupported;
  1710 		return KErrNotSupported;
  1711 		}
  1711 		}
  1712 	}
  1712 	}
  1713 
  1713 
  1714 TInt CPhysicalLink::Arbitrate(const TBool aImmediately, const TBool aLocalPriority)
  1714 TInt CPhysicalLink::Arbitrate(TBool aImmediately, TBool aLocalPriority)
  1715 	{
  1715 	{
  1716 	LOG_FUNC
  1716 	LOG_FUNC
  1717 	if (!IsConnected())
  1717 	if (!IsConnected())
  1718 		return KErrDisconnected;
  1718 		return KErrDisconnected;
  1719 
  1719 
  1720 	if ( aImmediately )
  1720 	if ( aImmediately )
  1721 		{
  1721 		{
  1722 		iArbitrationDelay->Cancel();
  1722 		iArbitrationDelay->Cancel();
       
  1723         return DoArbitrate(aLocalPriority);		
  1723 		}
  1724 		}
  1724 	else if (iArbitrationDelay->IsActive())
  1725 	else if (iArbitrationDelay->IsActive())
  1725 		{
  1726 		{
  1726 		return KErrNone;
  1727 		return KErrNone;
  1727 		}
  1728 		}
  1728 
  1729     else
       
  1730         {
       
  1731         iArbitrationDelay->Start(aLocalPriority);
       
  1732         return KErrNone;
       
  1733         }
       
  1734     }
       
  1735 
       
  1736 TInt CPhysicalLink::DoArbitrate(TBool aLocalPriority)
       
  1737     {
       
  1738     if (!IsConnected())
       
  1739         {
       
  1740         return KErrDisconnected;
       
  1741         }
       
  1742 	    
  1729 	//start arbitrate process with what our local controller supports
  1743 	//start arbitrate process with what our local controller supports
  1730 	TUint8 allowedModesMask = EHoldMode | EParkMode | ESniffMode; // local features sorted out later
  1744 	TUint8 allowedModesMask = EHoldMode | EParkMode | ESniffMode; // local features sorted out later
  1731 	TBool roleSwitchAllowed = EFalse;
  1745 	TBool roleSwitchAllowed = EFalse;
  1732 
  1746 
  1733  	if (iLinksMan.LinkManagerProtocol().IsRoleSwitchSupportedLocally() && iLinksMan.RoleSwitchAllowed())
  1747  	if (iLinksMan.LinkManagerProtocol().IsRoleSwitchSupportedLocally() && iLinksMan.RoleSwitchAllowed())
  3415 	self->ConstructL();
  3429 	self->ConstructL();
  3416 	CleanupStack::Pop(self);
  3430 	CleanupStack::Pop(self);
  3417 	return self;
  3431 	return self;
  3418 	}
  3432 	}
  3419 
  3433 
  3420 void CArbitrationDelayTimer::Start()
  3434 void CArbitrationDelayTimer::Start(TBool aLocalPriority)
  3421 	{
  3435     {
  3422 	LOG_FUNC
  3436     LOG_FUNC
  3423 	if (IsActive())
  3437     // Work out what the local priority will be now
  3424 		{
  3438     TBool localPriority = iLocalPriority || aLocalPriority;
  3425 		Cancel();
  3439     Cancel(); // cancel current timer (will also reset priority so ...
  3426 		}
  3440     iLocalPriority = localPriority; // set the new priority)
  3427 	After(KBTArbitrationDelay);
  3441 	After(KBTArbitrationDelay);
  3428 	}
  3442 	}
  3429 
  3443 
  3430 
  3444 
  3431 void CArbitrationDelayTimer::RunL()
  3445 void CArbitrationDelayTimer::RunL()
  3434 **/
  3448 **/
  3435 	{
  3449 	{
  3436 	LOG_FUNC
  3450 	LOG_FUNC
  3437 	if (iParent)
  3451 	if (iParent)
  3438 		{
  3452 		{
  3439 		iParent->Arbitrate();
  3453         iParent->DoArbitrate(iLocalPriority);
  3440 		}
  3454 		}
  3441 	}
  3455 	}
       
  3456 
       
  3457 void CArbitrationDelayTimer::DoCancel()
       
  3458     {
       
  3459     LOG_FUNC
       
  3460     CTimer::DoCancel();
       
  3461     iLocalPriority = EFalse;
       
  3462     }
  3442 
  3463 
  3443 TInt CPhysicalLink::GetNumPendingHandles(TInt& aConnectionHandles, TLinkType aLinkType) const
  3464 TInt CPhysicalLink::GetNumPendingHandles(TInt& aConnectionHandles, TLinkType aLinkType) const
  3444 	{
  3465 	{
  3445 	LOG_FUNC
  3466 	LOG_FUNC
  3446 	aConnectionHandles = 0;
  3467 	aConnectionHandles = 0;