bluetooth/btstack/linkmgr/linkmuxer.cpp
changeset 32 f72906e669b4
parent 0 29b1cd4cb562
equal deleted inserted replaced
31:b9d1744dc449 32:f72906e669b4
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1999-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    66 	TCallBack cb(TryToSendCallBackStatic, this);
    66 	TCallBack cb(TryToSendCallBackStatic, this);
    67 	iSendCallBack = new (ELeave)CAsyncCallBack(cb, EActiveMedPriority);
    67 	iSendCallBack = new (ELeave)CAsyncCallBack(cb, EActiveMedPriority);
    68 	}
    68 	}
    69 
    69 
    70 CLinkMuxer::CLinkMuxer(CLinkMgrProtocol& aLinkMgrProtocol, CHCIFacade& aHCIFacade)
    70 CLinkMuxer::CLinkMuxer(CLinkMgrProtocol& aLinkMgrProtocol, CHCIFacade& aHCIFacade)
    71 	: iHCIFacade(aHCIFacade), iChannelsFree(KHCITransportNoChannels), iLinkMgrProtocol(aLinkMgrProtocol) 
    71 	: iHCIFacade(aHCIFacade)
       
    72 	, iChannelsFree(KHCITransportNoChannels)
       
    73 	, iFlowControlMode(EFlowControlToHostControllerOnly) // by design flow control to the controller is always used
       
    74 	, iLinkMgrProtocol(aLinkMgrProtocol)
    72 /**
    75 /**
    73 	We expect the transport to notify us when the transport channels are ready
    76 	We expect the transport to notify us when the transport channels are ready
    74 **/
    77 **/
    75 	{
    78 	{
    76 	LOG_FUNC
    79 	LOG_FUNC
   187 	LOG_FUNC
   190 	LOG_FUNC
   188 	return (iChannelsFree & KHCITransportSCODataChannel);
   191 	return (iChannelsFree & KHCITransportSCODataChannel);
   189 	}
   192 	}
   190 #endif
   193 #endif
   191 
   194 
       
   195 void CLinkMuxer::ResetFlowControlMode()
       
   196 	{
       
   197 	LOG_FUNC
       
   198 	iFlowControlMode = EFlowControlToHostControllerOnly;
       
   199 	iCtrlerToHostSet = EFalse;
       
   200 	}
       
   201 
   192 void CLinkMuxer::RecordHostControllerToHostFlowControl(TBool aFlowFlag)
   202 void CLinkMuxer::RecordHostControllerToHostFlowControl(TBool aFlowFlag)
   193 /**
   203 /**
   194 	Called when HCIFacade receives a Command Complete event to the SetHostControllerToHostFlowControl command
   204 	Called when HCIFacade successfully configures some level of controller to host
   195 	@param	aFlowFlag - true is command succeeded, false otherwise
   205 	flow control
   196 
   206 	@param	aFlowFlag - true if flow control set-up succeeded, false otherwise
   197 **/
   207 **/
   198     {
   208 	{
   199 	LOG_FUNC
   209 	LOG_FUNC
   200      // check our current mode
   210 	
   201     switch (iFlowControlMode)
   211 	__ASSERT_DEBUG(!iCtrlerToHostSet, Panic(ELinkMgrFlowControlUnexpectedUpdate));
   202         {
   212 	
   203         case ENoFlowControl:
   213 	switch (iFlowControlMode)
   204             {
   214 		{
   205 #ifdef _DEBUG
   215 	case EFlowControlToHostControllerOnly:
   206             if(aFlowFlag) 
   216 		if(aFlowFlag)
   207                 {iFlowControlMode=EFlowControlFromHostControllerOnly;}
   217 			{
   208 #else
   218 			// Success! We're using using two way flow control
   209             Panic(ELinkMgrNoFlowControlSetInReleaseBuild);
   219 			iFlowControlMode = ETwoWayFlowControlEnabled;
   210 #endif
   220 			}
   211             break;
   221 		else
   212         }
   222 			{
   213         case EFlowControlToHostControllerOnly:
   223 			// Fail! we only allow one shot to set this up on initialisation
   214             {
   224 			// so inform the data controller that any reserved memory can be
   215             if(aFlowFlag)
   225 			// be released.
   216                 {iFlowControlMode=ETwoWayFlowControlEnabled;}
   226 			iDataController->NoExplicitInboundPoolNeeded();
   217             break;
   227 			}
   218             }
   228 		break;
   219         case EFlowControlFromHostControllerOnly:
   229 		
   220             {
   230 	case ETwoWayFlowControlEnabled:
   221 #ifdef _DEBUG
   231 		// We shouldn't get this twice (we only have one shot of setting it up
   222             if(aFlowFlag==EFalse)
   232 		// and to reach this point we've been in this function once before).
   223                 {iFlowControlMode=ENoFlowControl;}
   233 		break;
   224 #else
   234 	
   225             Panic(ELinkMgrNoFlowControlSetInReleaseBuild);
   235 	case EFlowControlFromHostControllerOnly:
   226 #endif
   236 		// fall-through
   227             break;
   237 	case ENoFlowControl:
   228             }
   238 		Panic(ELinkMgrNoFlowControlSetInReleaseBuild);
   229         case ETwoWayFlowControlEnabled:
   239 		break;
   230             {
   240 	
   231             if(aFlowFlag==EFalse)
   241 	default:
   232 				{
   242 		Panic(ELinkMgrNoSuchFlowControlMode);
   233 				// tried to do two-way but the HC can't to HC->H FC
   243 		break;
   234 				iFlowControlMode=EFlowControlToHostControllerOnly;
   244 		}
   235 				}
   245 	
   236             break;
   246 	iCtrlerToHostSet = ETrue;
   237             }
   247 	}
   238 		default:
   248 	
   239 			Panic(ELinkMgrNoSuchFlowControlMode);
   249 
   240         } //switch
       
   241 	}    
       
   242 
   250 
   243 
   251 
   244 CACLDataQController* CLinkMuxer::HandleLocalReadBufferSizeResult(
   252 CACLDataQController* CLinkMuxer::HandleLocalReadBufferSizeResult(
   245 			TUint16 aAclMaxLen,
   253 			TUint16 aAclMaxLen,
   246 			TUint8 /*aScoMaxLen*/,
   254 			TUint8 /*aScoMaxLen*/,