bluetooth/btstack/l2cap/l2capEntityConfig.cpp
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 1999-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 l2cap L2CapEntity Config object owned by the L2CAP linkSignalhandler
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <bluetooth/logger.h>
       
    19 #include "l2capEntityConfig.h"
       
    20 
       
    21 #include "L2CapChannelConfig.h"
       
    22 #include "l2capLinkSignalHandler.h"
       
    23 #include "l2util.h"
       
    24 
       
    25 #ifdef __FLOG_ACTIVE
       
    26 _LIT8(KLogComponent, LOG_COMPONENT_L2CAP);
       
    27 #endif
       
    28 
       
    29 TL2CAPEntityConfig::TL2CAPEntityConfig(CL2CapLinkSignalHandler& aLinkSH)
       
    30  : iLinkSH(aLinkSH)
       
    31  	{
       
    32  	LOG_FUNC
       
    33  	}
       
    34 
       
    35 TInt TL2CAPEntityConfig::PeerL2CapSupportedFeatures(TL2CapEntityInfo& aPeerL2CapEntityInfo )
       
    36 /** Returns peer's L2Cap supported features if already received. Otherwise requests peer's L2Cap supported features.
       
    37 	
       
    38 	Called by the CL2CapSapSignalHandler. If the peer request is necessary, sets link info state to "requested".
       
    39 
       
    40 	@internalComponent
       
    41 	@param aPeerLinkInfo To be filled with cached peer's L2Cap config info.
       
    42 */
       
    43 	{
       
    44 	LOG_FUNC
       
    45 	TInt rerr = KErrNone;
       
    46 	if (iPeerL2CapEntityInfo.LinkInfoState() == EL2CapEntityInfoUndef)
       
    47 		{
       
    48 		//Ask CL2CapSignalHandler for a InformationRequest
       
    49 		iPeerL2CapEntityInfo.SetLinkInfoState(EL2CapEntityInfoRequested);
       
    50 		rerr = iLinkSH.ConstructInformationRequest(EExtendedFeaturesSupported);
       
    51 		}
       
    52 	aPeerL2CapEntityInfo = iPeerL2CapEntityInfo;
       
    53 	return rerr;
       
    54 	}
       
    55 
       
    56 void TL2CAPEntityConfig::UpdatePeerL2CapSupportedFeatures(const TL2CapEntityInfo& aPeerL2CapEntityInfo)
       
    57 /** Called by the CL2CapSignalHandler when an information request has been responded to
       
    58 
       
    59 	@internalComponent
       
    60 	@param aRemoteL2CapEntityInfo Config Info from the remote device's L2Cap.
       
    61 */	
       
    62 	{
       
    63 	LOG_FUNC
       
    64 	iPeerL2CapEntityInfo = aPeerL2CapEntityInfo;
       
    65 	iPeerL2CapEntityInfo.SetLinkInfoState(EL2CapEntityInfoDefined);
       
    66 	}
       
    67 
       
    68 TBool TL2CAPEntityConfig::PeerInfoDefined() const
       
    69 	{
       
    70 	LOG_FUNC
       
    71 	return iPeerL2CapEntityInfo.LinkInfoState() == EL2CapEntityInfoDefined;
       
    72 	}
       
    73 
       
    74 TBool TL2CAPEntityConfig::GetPeerL2CapEntityInfo(TL2CapEntityInfo& aPeerL2CapEntityInfo) const
       
    75 /** A simple getter for peer's L2Cap supported features. No side effects, as opposed
       
    76 	to PeerL2CapSupportedFeatures.
       
    77 	@internalComponent
       
    78 	@param aPeerL2CapEntityInfo To be filled with cached peer's L2Cap config info.
       
    79 	@return ETrue if peer's config info is defined (and thus aPeerL2CapEntityInfo will
       
    80 	    be filled), EFalse otherwise.
       
    81 */ 
       
    82 	{
       
    83 	LOG_FUNC
       
    84 	if (iPeerL2CapEntityInfo.LinkInfoState() == EL2CapEntityInfoDefined)
       
    85 		{
       
    86 		aPeerL2CapEntityInfo = iPeerL2CapEntityInfo;
       
    87 		return ETrue;
       
    88 		}
       
    89 	else
       
    90 		{
       
    91 		return EFalse;
       
    92 		}
       
    93 	}