bluetoothapitest/bluetoothsvs/T_BTUserAPI/src/T_BTPhysicalLinkAdapterData.cpp
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "T_BTPhysicalLinkAdapterData.h"
       
    19 #include "T_BTDevAddrData.h"
       
    20 #include "T_BTUtil.h"
       
    21 
       
    22 /*@{*/
       
    23 //Parameters
       
    24 _LIT(KRSocketServ,												"socketserv");
       
    25 _LIT(KRSocket,													"rsocket");
       
    26 _LIT(KTBTDevAddr,												"tbtdevaddr");
       
    27 _LIT(KIntDevAddr,												"integerdevaddr");
       
    28 _LIT(KLowPowerMode,												"lowpowermode");
       
    29 _LIT(KPacketType,												"packettype");
       
    30 _LIT(KPhysicalLinkState,										"physicallinkstate");
       
    31 _LIT(KExpected, 												"expected");
       
    32 
       
    33 //Commands
       
    34 _LIT(KCmdRBTPhysicalLinkAdapter,								"RBTPhysicalLinkAdapter");
       
    35 _LIT(KCmdOpen,													"Open");
       
    36 _LIT(KCmdIsOpen,												"IsOpen");
       
    37 _LIT(KCmdClose,													"Close");
       
    38 _LIT(KCmdPhysicalLinkState,										"PhysicalLinkState");
       
    39 _LIT(KCmdPreventRoleSwitch,										"PreventRoleSwitch");
       
    40 _LIT(KCmdAllowRoleSwitch,										"AllowRoleSwitch");
       
    41 _LIT(KCmdRequestMasterRole,										"RequestMasterRole");
       
    42 _LIT(KCmdRequestSlaveRole,										"RequestSlaveRole");
       
    43 _LIT(KCmdPreventLowPowerModes,									"PreventLowPowerModes");
       
    44 _LIT(KCmdAllowLowPowerModes,									"AllowLowPowerModes");
       
    45 _LIT(KCmdActivateSniffRequester,								"ActivateSniffRequester");
       
    46 _LIT(KCmdActivateParkRequester,									"ActivateParkRequester");
       
    47 _LIT(KCmdActivateActiveRequester,								"ActivateActiveRequester");
       
    48 _LIT(KCmdCancelLowPowerModeRequester,							"CancelLowPowerModeRequester");
       
    49 _LIT(KCmdRequestChangeSupportedPacketTypes,						"RequestChangeSupportedPacketTypes");
       
    50 _LIT(KCmdNotifyNextBasebandChangeEvent,							"NotifyNextBasebandChangeEvent");
       
    51 _LIT(KCmdCancelNextBasebandChangeEventNotifier,					"CancelNextBasebandChangeEventNotifier");
       
    52 _LIT(KCmdAuthenticate,											"Authenticate");
       
    53 _LIT(KCmdDestructor,											"~");
       
    54 
       
    55 //	Logging
       
    56 _LIT(KLogMissingParameters,			"Missing parameters '%S' or '%S'");
       
    57 _LIT(KLogMissingParameter,			"Missing parameter '%S'");
       
    58 /*@}*/
       
    59 
       
    60 //////////////////////////////////////////////////////////////////////
       
    61 // Construction/Destruction
       
    62 //////////////////////////////////////////////////////////////////////
       
    63 
       
    64 CT_BTPhysicalLinkAdapterData* CT_BTPhysicalLinkAdapterData::NewL()
       
    65 	{
       
    66 	CT_BTPhysicalLinkAdapterData*	ret=new (ELeave) CT_BTPhysicalLinkAdapterData();
       
    67 	CleanupStack::PushL(ret);
       
    68 	ret->ConstructL();
       
    69 	CleanupStack::Pop(ret);
       
    70 	return ret;
       
    71 	}
       
    72 
       
    73 CT_BTPhysicalLinkAdapterData::CT_BTPhysicalLinkAdapterData()
       
    74 :	iData(NULL)
       
    75 ,	iActive(NULL)
       
    76 ,	iEventType(0)
       
    77 ,	iExpectedEventType(0)
       
    78 ,	iEventNotification(NULL)
       
    79 	{
       
    80 	}
       
    81 
       
    82 void CT_BTPhysicalLinkAdapterData::ConstructL()
       
    83 	{
       
    84 	iActive = CActiveCallback::NewL(*this);
       
    85 	}
       
    86 
       
    87 CT_BTPhysicalLinkAdapterData::~CT_BTPhysicalLinkAdapterData()
       
    88 	{
       
    89 	DestroyData();
       
    90 	delete iActive;
       
    91 	iActive = NULL;
       
    92 	}
       
    93 
       
    94 //	Service methods
       
    95 TAny* CT_BTPhysicalLinkAdapterData::GetObject()
       
    96 	{
       
    97 	return iData;
       
    98 	}
       
    99 
       
   100 void CT_BTPhysicalLinkAdapterData::SetObjectL(TAny* aAny)
       
   101 	{
       
   102 	//called when loading up persistent data
       
   103 	DestroyData();
       
   104 	iData = static_cast<RBTPhysicalLinkAdapter*> (aAny);
       
   105 	}
       
   106 
       
   107 void CT_BTPhysicalLinkAdapterData::DisownObjectL()
       
   108 	{
       
   109 	iData = NULL;
       
   110 	}
       
   111 
       
   112 void CT_BTPhysicalLinkAdapterData::DestroyData()
       
   113 	{
       
   114 	delete iData;
       
   115 	iData=NULL;
       
   116 	}
       
   117 
       
   118 inline TCleanupOperation CT_BTPhysicalLinkAdapterData::CleanupOperation()
       
   119 	{
       
   120 	return CleanupOperation;
       
   121 	}
       
   122 
       
   123 void CT_BTPhysicalLinkAdapterData::CleanupOperation(TAny* aAny)
       
   124 	{
       
   125 	RBTPhysicalLinkAdapter* arg=static_cast<RBTPhysicalLinkAdapter*>(aAny);
       
   126 	delete arg;
       
   127 	}
       
   128 
       
   129 TBool CT_BTPhysicalLinkAdapterData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
   130 	{
       
   131 	TBool	ret = ETrue;
       
   132 
       
   133 	if ( aCommand==KCmdRBTPhysicalLinkAdapter )
       
   134 		{
       
   135 		DoCmdRBTPhysicalLinkAdapter();
       
   136 		}
       
   137 	else if ( aCommand==KCmdOpen )
       
   138 		{
       
   139 		DoCmdOpen(aSection);
       
   140 		}
       
   141 	else if ( aCommand==KCmdIsOpen )
       
   142 		{
       
   143 		DoCmdIsOpen(aSection);
       
   144 		}
       
   145 	else if ( aCommand==KCmdClose )
       
   146 		{
       
   147 		DoCmdClose();
       
   148 		}
       
   149 	else if ( aCommand==KCmdPhysicalLinkState )
       
   150 		{
       
   151 		DoCmdPhysicalLinkState(aSection);
       
   152 		}
       
   153 	else if ( aCommand==KCmdPreventRoleSwitch )
       
   154 		{
       
   155 		DoCmdPreventRoleSwitch();
       
   156 		}
       
   157 	else if ( aCommand==KCmdAllowRoleSwitch )
       
   158 		{
       
   159 		DoCmdAllowRoleSwitch();
       
   160 		}
       
   161 	else if ( aCommand==KCmdRequestMasterRole )
       
   162 		{
       
   163 		DoCmdRequestMasterRole();
       
   164 		}
       
   165 	else if ( aCommand==KCmdRequestSlaveRole )
       
   166 		{
       
   167 		DoCmdRequestSlaveRole();
       
   168 		}
       
   169 	else if ( aCommand==KCmdPreventLowPowerModes )
       
   170 		{
       
   171 		DoCmdPreventLowPowerModes(aSection);
       
   172 		}
       
   173 	else if ( aCommand==KCmdAllowLowPowerModes )
       
   174 		{
       
   175 		DoCmdAllowLowPowerModes(aSection);
       
   176 		}
       
   177 	else if ( aCommand==KCmdActivateSniffRequester )
       
   178 		{
       
   179 		DoCmdActivateSniffRequester();
       
   180 		}
       
   181 	else if ( aCommand==KCmdActivateParkRequester )
       
   182 		{
       
   183 		DoCmdActivateParkRequester();
       
   184 		}
       
   185 	else if ( aCommand==KCmdActivateActiveRequester )
       
   186 		{
       
   187 		DoCmdActivateActiveRequester();
       
   188 		}
       
   189 	else if ( aCommand==KCmdCancelLowPowerModeRequester )
       
   190 		{
       
   191 		DoCmdCancelLowPowerModeRequester();
       
   192 		}
       
   193 	else if ( aCommand==KCmdRequestChangeSupportedPacketTypes )
       
   194 		{
       
   195 		DoCmdRequestChangeSupportedPacketTypes(aSection);
       
   196 		}
       
   197 	else if ( aCommand==KCmdNotifyNextBasebandChangeEvent )
       
   198 		{
       
   199 		DoCmdNotifyNextBasebandChangeEvent(aSection, aAsyncErrorIndex);
       
   200 		}
       
   201 	else if ( aCommand==KCmdCancelNextBasebandChangeEventNotifier )
       
   202 		{
       
   203 		DoCmdCancelNextBasebandChangeEventNotifier();
       
   204 		}
       
   205 	else if ( aCommand==KCmdAuthenticate )
       
   206 		{
       
   207 		DoCmdAuthenticate();
       
   208 		}
       
   209 	else if ( aCommand==KCmdDestructor )
       
   210 		{
       
   211 		DoCmdDestructor();
       
   212 		}
       
   213 	else
       
   214 		{
       
   215 		ret=EFalse;
       
   216 		}
       
   217 
       
   218 	return ret;
       
   219 	}
       
   220 
       
   221 
       
   222 /**
       
   223 Test RBTPhysicalLinkAdapter()
       
   224 */
       
   225 void CT_BTPhysicalLinkAdapterData::DoCmdRBTPhysicalLinkAdapter()
       
   226 	{
       
   227 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter Constructor Call"));
       
   228 	DestroyData();
       
   229 	iData = new (ELeave) RBTPhysicalLinkAdapter();
       
   230 	}
       
   231 
       
   232 /**
       
   233 Test Open()
       
   234 */
       
   235 void CT_BTPhysicalLinkAdapterData::DoCmdOpen(const TDesC& aSection)
       
   236 	{
       
   237 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter Open Call"));
       
   238 	
       
   239 	TPtrC	socketServName;
       
   240 	if(GetStringFromConfig(aSection, KRSocketServ(), socketServName))
       
   241 		{
       
   242 		RSocketServ* socketServ=static_cast<RSocketServ*>(GetDataObjectL(socketServName));
       
   243 		
       
   244 		TPtrC	socketName;
       
   245 		if(GetStringFromConfig(aSection, KRSocket(), socketName))
       
   246 			{
       
   247 			RSocket* socket = static_cast<RSocket*>(GetDataObjectL(socketName));
       
   248 			TInt err = iData->Open(*socketServ, *socket);
       
   249 			if( err!=KErrNone )
       
   250 				{
       
   251 				INFO_PRINTF2(_L("RBTPhysicalLinkAdapter Open err=%d" ),err);
       
   252 				SetError(err);
       
   253 				}
       
   254 			}
       
   255 		else
       
   256 			{
       
   257 			TPtrC	tBTDevAddrName;
       
   258 			TBool	foundParameter=EFalse;	
       
   259 			if(GetStringFromConfig(aSection, KTBTDevAddr(), tBTDevAddrName))
       
   260 				{
       
   261 				foundParameter=ETrue;
       
   262 				CT_BTDevAddrData* tBTDevAddrData=static_cast<CT_BTDevAddrData*>(GetDataWrapperL(tBTDevAddrName));
       
   263 				TBTDevAddr btDevAddr = *tBTDevAddrData->GetAddress();
       
   264 				TInt err = iData->Open(*socketServ, btDevAddr);
       
   265 				if(err != KErrNone)
       
   266 					{
       
   267 					ERR_PRINTF2(_L("RBTPhysicalLinkAdapter Open failed with error %d"), err);
       
   268 					SetError(err);
       
   269 					}
       
   270 				}
       
   271 			
       
   272 			TInt	intBtDevAddr=0;	
       
   273 			if(GetIntFromConfig(aSection, KIntDevAddr(), intBtDevAddr))
       
   274 				{
       
   275 				foundParameter=ETrue;			
       
   276 				TBTDevAddr btDevAddr(intBtDevAddr);
       
   277 				TInt err = iData->Open(*socketServ, btDevAddr);
       
   278 				if(err != KErrNone)
       
   279 					{
       
   280 					ERR_PRINTF2(_L("RBTPhysicalLinkAdapter Open failed with error %d"), err);
       
   281 					SetError(err);
       
   282 					}
       
   283 				}
       
   284 				
       
   285 			if( !foundParameter )
       
   286 				{
       
   287 				ERR_PRINTF3(KLogMissingParameters, &KTBTDevAddr(), &KIntDevAddr());
       
   288 				SetBlockResult(EFail);
       
   289 				}
       
   290 			}
       
   291 		}
       
   292 	else
       
   293 		{
       
   294 		ERR_PRINTF2(KLogMissingParameter, &KRSocket());
       
   295 		SetBlockResult(EFail);
       
   296 		}
       
   297 	}
       
   298 
       
   299 
       
   300 /**
       
   301 Test IsOpen()
       
   302 */
       
   303 void CT_BTPhysicalLinkAdapterData::DoCmdIsOpen(const TDesC& aSection)
       
   304 	{
       
   305 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter IsOpen Call"));
       
   306 	
       
   307 	TBool isOpen = iData->IsOpen();
       
   308 	INFO_PRINTF2(_L("RBTPhysicalLinkAdapter IsOpen result: actual = %d"), isOpen);
       
   309 	
       
   310 	TBool	expected = EFalse;
       
   311 	if(GetBoolFromConfig(aSection, KExpected(), expected))
       
   312 		{
       
   313 		if( expected != isOpen )
       
   314 			{
       
   315 			ERR_PRINTF1(_L("IsOpen not as expected!"));
       
   316 			SetBlockResult(EFail);
       
   317 			}
       
   318 		}
       
   319 	else
       
   320 		{
       
   321 		ERR_PRINTF2(KLogMissingParameter, &KExpected());
       
   322 		SetBlockResult(EFail);		
       
   323 		}
       
   324 	}
       
   325 
       
   326 
       
   327 /**
       
   328 Test Close()
       
   329 */
       
   330 void CT_BTPhysicalLinkAdapterData::DoCmdClose()
       
   331 	{
       
   332 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter Close Call"));
       
   333 	iData->Close();
       
   334 	}
       
   335 
       
   336 
       
   337 /**
       
   338 Test PhysicalLinkState()
       
   339 */
       
   340 void CT_BTPhysicalLinkAdapterData::DoCmdPhysicalLinkState(const TDesC& aSection)
       
   341 	{
       
   342 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter PhysicalLinkState Call"));
       
   343 	
       
   344 	TUint32	state = 0;
       
   345 	TInt err = iData->PhysicalLinkState(state);
       
   346 	INFO_PRINTF2(_L("RBTPhysicalLinkAdapter PhysicalLinkState result: actual = %d"), state);
       
   347 	if(err != KErrNone)
       
   348 		{
       
   349 		ERR_PRINTF2(_L("RBTPhysicalLinkAdapter PhysicalLinkState failed with error %d"), err);
       
   350 		SetError(err);
       
   351 		}
       
   352 	
       
   353 	TInt expected = 0;
       
   354 	if(GetIntFromConfig(aSection, KExpected(), expected) )
       
   355 		{
       
   356 		if( expected != state )
       
   357 			{
       
   358 			ERR_PRINTF1(_L("PhysicalLinkState not as expected!"));
       
   359 			SetBlockResult(EFail);
       
   360 			}
       
   361 		}
       
   362 	else
       
   363 		{
       
   364 		ERR_PRINTF2(KLogMissingParameter, &KExpected());
       
   365 		SetBlockResult(EFail);
       
   366 		}
       
   367 	}
       
   368 
       
   369 /**
       
   370 Test PreventRoleSwitch()
       
   371 */
       
   372 void CT_BTPhysicalLinkAdapterData::DoCmdPreventRoleSwitch()
       
   373 	{
       
   374 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter PreventRoleSwitch Call"));
       
   375 	TInt err = iData->PreventRoleSwitch();
       
   376 	if(err != KErrNone)
       
   377 		{
       
   378 		ERR_PRINTF2(_L("RBTPhysicalLinkAdapter PreventRoleSwitch failed with error %d"), err);
       
   379 		SetError(err);
       
   380 		}
       
   381 	}
       
   382 
       
   383 
       
   384 /**
       
   385 Test AllowRoleSwitch()
       
   386 */
       
   387 void CT_BTPhysicalLinkAdapterData::DoCmdAllowRoleSwitch()
       
   388 	{
       
   389 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter AllowRoleSwitch Call"));
       
   390 	TInt err = iData->AllowRoleSwitch();
       
   391 	if(err != KErrNone)
       
   392 		{
       
   393 		ERR_PRINTF2(_L("RBTPhysicalLinkAdapter AllowRoleSwitch failed with error %d"), err);
       
   394 		SetError(err);
       
   395 		}
       
   396 	}
       
   397 
       
   398 
       
   399 /**
       
   400 Test RequestMasterRole()
       
   401 */
       
   402 void CT_BTPhysicalLinkAdapterData::DoCmdRequestMasterRole()
       
   403 	{
       
   404 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter RequestMasterRole Call"));
       
   405 	TInt err = iData->RequestMasterRole();
       
   406 	if(err != KErrNone)
       
   407 		{
       
   408 		ERR_PRINTF2(_L("RBTPhysicalLinkAdapter RequestMasterRole failed with error %d"), err);
       
   409 		SetError(err);
       
   410 		}
       
   411 	else
       
   412 		{
       
   413 		TTimeIntervalMicroSeconds32	interval = TTimeIntervalMicroSeconds32(3000000); // 3 secs
       
   414 		User::After(interval);
       
   415 		}
       
   416 	}
       
   417 
       
   418 
       
   419 /**
       
   420 Test RequestSlaveRole()
       
   421 */
       
   422 void CT_BTPhysicalLinkAdapterData::DoCmdRequestSlaveRole()
       
   423 	{
       
   424 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter RequestSlaveRole Call"));
       
   425 	TInt err = iData->RequestSlaveRole();
       
   426 	if(err != KErrNone)
       
   427 		{
       
   428 		ERR_PRINTF2(_L("RBTPhysicalLinkAdapter RequestSlaveRole failed with error %d"), err);
       
   429 		SetError(err);
       
   430 		}
       
   431 	else
       
   432 		{
       
   433 		TTimeIntervalMicroSeconds32	interval = TTimeIntervalMicroSeconds32(3000000); // 3 secs
       
   434 		User::After(interval);
       
   435 		}
       
   436 	}
       
   437 
       
   438 
       
   439 /**
       
   440 Test PreventLowPowerModes()
       
   441 */
       
   442 void CT_BTPhysicalLinkAdapterData::DoCmdPreventLowPowerModes(const TDesC& aSection)
       
   443 	{
       
   444 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter PreventLowPowerModes Call"));
       
   445 	TPtrC	lowPowerMode;
       
   446 	TInt	lowPowerModeValue = 0;
       
   447 	if(GetStringFromConfig(aSection, KLowPowerMode(), lowPowerMode))
       
   448 		{
       
   449 		if( CT_BTUtil::GetLowPowerModeIntValue(lowPowerMode, lowPowerModeValue) )
       
   450 			{
       
   451 			INFO_PRINTF2(_L("RBTPhysicalLinkAdapter PreventLowPowerModes: lowPowerModeValue = %d"), lowPowerModeValue);
       
   452 			TInt err = iData->PreventLowPowerModes(lowPowerModeValue);
       
   453 			if(err != KErrNone)
       
   454 				{
       
   455 				ERR_PRINTF2(_L("RBTPhysicalLinkAdapter PreventLowPowerModes failed with error %d"), err);
       
   456 				SetError(err);
       
   457 				}
       
   458 			}
       
   459 		else
       
   460 			{
       
   461 			ERR_PRINTF1(_L("Unknown input for TBTLinkMode"));
       
   462 			SetBlockResult(EFail);
       
   463 			}
       
   464 		}
       
   465 	else
       
   466 		{
       
   467 		ERR_PRINTF2(KLogMissingParameter, &KLowPowerMode());
       
   468 		SetBlockResult(EFail);
       
   469 		}
       
   470 	}
       
   471 
       
   472 
       
   473 /**
       
   474 Test AllowLowPowerModes()
       
   475 */
       
   476 void CT_BTPhysicalLinkAdapterData::DoCmdAllowLowPowerModes(const TDesC& aSection)
       
   477 	{
       
   478 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter AllowLowPowerModes Call"));
       
   479 	
       
   480 	TPtrC	lowPowerMode;
       
   481 	TInt	lowPowerModeValue = 0;
       
   482 	if(GetStringFromConfig(aSection, KLowPowerMode(), lowPowerMode))
       
   483 		{
       
   484 		if(CT_BTUtil::GetLowPowerModeIntValue(lowPowerMode, lowPowerModeValue) )
       
   485 			{
       
   486 			INFO_PRINTF2(_L("RBTPhysicalLinkAdapter AllowLowPowerModes: lowPowerModeValue = %d"), lowPowerModeValue);
       
   487 			TInt err = iData->AllowLowPowerModes(lowPowerModeValue);
       
   488 			if(err != KErrNone)
       
   489 				{
       
   490 				ERR_PRINTF2(_L("RBTPhysicalLinkAdapter AllowLowPowerModes failed with error %d"), err);
       
   491 				SetError(err);
       
   492 				}
       
   493 			}
       
   494 		else
       
   495 			{
       
   496 			ERR_PRINTF1(_L("Unknow input for TBTLinkMode"));
       
   497 			SetBlockResult(EFail);
       
   498 			}
       
   499 		}
       
   500 	else
       
   501 		{
       
   502 		ERR_PRINTF2(KLogMissingParameter, &KLowPowerMode());
       
   503 		SetBlockResult(EFail);
       
   504 		}
       
   505 	}
       
   506 
       
   507 
       
   508 /**
       
   509 Test ActivateSniffRequester()
       
   510 */
       
   511 void CT_BTPhysicalLinkAdapterData::DoCmdActivateSniffRequester()
       
   512 	{
       
   513 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter ActivateSniffRequester Call"));
       
   514 	
       
   515 	TInt err = iData->ActivateSniffRequester();
       
   516 	if(err != KErrNone)
       
   517 		{
       
   518 		ERR_PRINTF2(_L("RBTPhysicalLinkAdapter ActivateSniffRequester failed with error %d"), err);
       
   519 		SetError(err);
       
   520 		}
       
   521 	else
       
   522 		{
       
   523 		TTimeIntervalMicroSeconds32	interval = TTimeIntervalMicroSeconds32(3000000); // 3 secs
       
   524 		User::After(interval);
       
   525 		}
       
   526 	}
       
   527 
       
   528 
       
   529 /**
       
   530 Test ActivateParkRequester()
       
   531 */
       
   532 void CT_BTPhysicalLinkAdapterData::DoCmdActivateParkRequester()
       
   533 	{
       
   534 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter ActivateParkRequester Call"));
       
   535 	
       
   536 	TInt err = iData->ActivateParkRequester();
       
   537 	if(err != KErrNone)
       
   538 		{
       
   539 		ERR_PRINTF2(_L("RBTPhysicalLinkAdapter ActivateParkRequester failed with error %d"), err);
       
   540 		SetError(err);
       
   541 		}
       
   542 	else
       
   543 		{
       
   544 		TTimeIntervalMicroSeconds32	interval = TTimeIntervalMicroSeconds32(3000000); // 3 secs
       
   545 		User::After(interval);
       
   546 		}
       
   547 	}
       
   548 
       
   549 
       
   550 /**
       
   551 Test ActivateActiveRequester()
       
   552 */
       
   553 void CT_BTPhysicalLinkAdapterData::DoCmdActivateActiveRequester()
       
   554 	{
       
   555 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter ActivateActiveRequester Call"));
       
   556 	
       
   557 	TInt err = iData->ActivateActiveRequester();
       
   558 	if(err != KErrNone)
       
   559 		{
       
   560 		ERR_PRINTF2(_L("RBTPhysicalLinkAdapter ActivateActiveRequester failed with error %d"), err);
       
   561 		SetError(err);
       
   562 		}
       
   563 	else
       
   564 		{
       
   565 		TTimeIntervalMicroSeconds32	interval = TTimeIntervalMicroSeconds32(3000000); // 3 secs
       
   566 		User::After(interval);
       
   567 		}
       
   568 	}
       
   569 
       
   570 
       
   571 /**
       
   572 Test CancelLowPowerModeRequester()
       
   573 */
       
   574 void CT_BTPhysicalLinkAdapterData::DoCmdCancelLowPowerModeRequester()
       
   575 	{
       
   576 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter CancelLowPowerModeRequester Call"));
       
   577 	
       
   578 	TInt err = iData->CancelLowPowerModeRequester();
       
   579 	if(err != KErrNone)
       
   580 		{
       
   581 		ERR_PRINTF2(_L("RBTPhysicalLinkAdapter CancelLowPowerModeRequester failed with error %d"), err);
       
   582 		SetError(err);
       
   583 		}
       
   584 	}
       
   585 
       
   586 
       
   587 /**
       
   588 Test RequestChangeSupportedPacketTypes()
       
   589 */
       
   590 void CT_BTPhysicalLinkAdapterData::DoCmdRequestChangeSupportedPacketTypes(const TDesC& aSection)
       
   591 	{
       
   592 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter RequestChangeSupportedPacketTypes Call"));
       
   593 	
       
   594 	TPtrC	packetTypeName;
       
   595 	TInt	packetTypeValue;
       
   596 	if(GetStringFromConfig(aSection, KPacketType(), packetTypeName))
       
   597 		{
       
   598 		if ( CT_BTUtil::GetPacketTypeIntValue(packetTypeName, packetTypeValue) )
       
   599 			{
       
   600 			INFO_PRINTF2(_L("RBTPhysicalLinkAdapter RequestChangeSupportedPacketTypes: packetTypeValue = %d"), packetTypeValue);
       
   601 			
       
   602 			TInt err = iData->RequestChangeSupportedPacketTypes(packetTypeValue);
       
   603 			if(err != KErrNone)
       
   604 				{
       
   605 				ERR_PRINTF2(_L("RBTPhysicalLinkAdapter RequestChangeSupportedPacketTypes failed with error %d"), err);
       
   606 				SetError(err);
       
   607 				}
       
   608 			}
       
   609 		else
       
   610 			{
       
   611 			ERR_PRINTF1(_L("Unknow input for PacketType"));
       
   612 			SetBlockResult(EFail);	
       
   613 			}
       
   614 		}
       
   615 	else
       
   616 		{
       
   617 		ERR_PRINTF2(KLogMissingParameter, &KPacketType());
       
   618 		SetBlockResult(EFail);
       
   619 		}
       
   620 	}
       
   621 
       
   622 
       
   623 /**
       
   624 Test NotifyNextBasebandChangeEvent()
       
   625 */
       
   626 void CT_BTPhysicalLinkAdapterData::DoCmdNotifyNextBasebandChangeEvent(const TDesC& aSection, const TInt aAsyncErrorIndex)
       
   627 	{
       
   628 	TPtrC	physicalLinkSatateName;
       
   629 	TInt	physicalLinkSatateValue;
       
   630 	TBool foundParameter = EFalse;
       
   631 	if(GetStringFromConfig(aSection, KPhysicalLinkState(), physicalLinkSatateName))
       
   632 		{
       
   633 		foundParameter = ETrue;
       
   634 		if ( CT_BTUtil::GetPhysicalLinkStateIntValue(physicalLinkSatateName, physicalLinkSatateValue) )
       
   635 			{
       
   636 			INFO_PRINTF2(_L("Verify the existing physicalLinkSatateValue = %d"), physicalLinkSatateValue);
       
   637 			
       
   638 			INFO_PRINTF1(_L("Call NotifyNextBasebandChangeEvent() method"));
       
   639 			iData->NotifyNextBasebandChangeEvent(iEventNotification, iActive->iStatus, physicalLinkSatateValue);
       
   640 			
       
   641 			if(GetIntFromConfig(aSection, KExpected(), iExpectedEventType) )
       
   642 				{
       
   643 				foundParameter = ETrue;
       
   644 				}
       
   645 			iActive->Activate(aAsyncErrorIndex);
       
   646 			IncOutstanding();
       
   647 			}
       
   648 		else
       
   649 			{
       
   650 			ERR_PRINTF1(_L("Unknow input for PhysicalLinkState"));
       
   651 			SetBlockResult(EFail);	
       
   652 			}
       
   653 		}
       
   654 	if (!foundParameter)
       
   655 		{
       
   656 		ERR_PRINTF3(KLogMissingParameters, &KPhysicalLinkState(), &KExpected());
       
   657 		SetBlockResult(EFail);
       
   658 		}
       
   659 	}
       
   660 
       
   661 
       
   662 /**
       
   663 Test CancelNextBasebandChangeEventNotifier()
       
   664 */
       
   665 void CT_BTPhysicalLinkAdapterData::DoCmdCancelNextBasebandChangeEventNotifier()
       
   666 	{
       
   667 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter CancelNextBasebandChangeEventNotifier Call"));
       
   668 	
       
   669 	iData->CancelNextBasebandChangeEventNotifier();
       
   670 	}
       
   671 
       
   672 
       
   673 /**
       
   674 Test Authenticate()
       
   675 */
       
   676 void CT_BTPhysicalLinkAdapterData::DoCmdAuthenticate()
       
   677 	{
       
   678 	INFO_PRINTF1(_L("RBTPhysicalLinkAdapter Authenticate Call"));
       
   679 	
       
   680 	TInt err = iData->Authenticate();
       
   681 	INFO_PRINTF2(_L("Returned value (%d) of Authenticate()"), err);
       
   682 	
       
   683 	if(err != KErrNone)
       
   684 		{
       
   685 		ERR_PRINTF2(_L("RBTPhysicalLinkAdapter Authenticate failed with error %d"), err);
       
   686 		SetError(err);
       
   687 		}
       
   688 	}
       
   689 
       
   690 /**
       
   691 Test Destructor
       
   692 */
       
   693 void CT_BTPhysicalLinkAdapterData::DoCmdDestructor()
       
   694 	{
       
   695 	DestroyData();
       
   696 	}
       
   697 
       
   698 
       
   699 /**
       
   700  Virtual RunL - Called on completion of an asynchronous command
       
   701  @see MTPActiveCallback
       
   702  @param aActive Active Object that RunL has been called on
       
   703  @pre N/A
       
   704  @post N/A
       
   705  @leave system wide error code
       
   706 */
       
   707 void CT_BTPhysicalLinkAdapterData::RunL(CActive* aActive, TInt aIndex)
       
   708 	{
       
   709 	INFO_PRINTF1(_L("Execute Async RunL() Call"));
       
   710 	if( aActive==iActive )
       
   711 		{
       
   712 		TInt err = aActive->iStatus.Int();
       
   713 		INFO_PRINTF2(_L("Returned result (%d) of aActive->istatus.Int()"), err);
       
   714 		if(err != KErrNone)
       
   715 			{
       
   716 			ERR_PRINTF2(_L("RunL failed with error %d"), err);
       
   717 			SetAsyncError(aIndex, err);
       
   718 			}
       
   719 		iEventType = iEventNotification().EventType();
       
   720 		INFO_PRINTF2(_L("Returned TBTBasebandEvent::EventType(%d)"), iEventType);
       
   721 		if( iEventType != iExpectedEventType )
       
   722 			{
       
   723 			ERR_PRINTF1(_L("NotifyNextBasebandChangeEvent is not as expected!"));
       
   724 			SetBlockResult(EFail);
       
   725 			}
       
   726 		}
       
   727 	else
       
   728 		{
       
   729 		ERR_PRINTF1(_L("Stray signal"));
       
   730 		SetBlockResult(EFail);
       
   731 		}
       
   732 	DecOutstanding();
       
   733 	}
       
   734 
       
   735 
       
   736 /**
       
   737 Virtual DoCancel - Request to cancel the asynchronous command
       
   738 @publishedInternal
       
   739 @see - MTPActiveCallback
       
   740 @param aActive Active Object that DoCancel has been called on
       
   741 @pre - N/A
       
   742 @post - N/A
       
   743 @leave system wide error code
       
   744 */
       
   745 void CT_BTPhysicalLinkAdapterData::DoCancel(CActive* /* aActive */, TInt /*aIndex*/)
       
   746 	{
       
   747 	}
       
   748