telephonyserverplugins/simtsy/src/CSimNtRas.cpp
branchRCL_3
changeset 66 07a122eea281
parent 65 630d2f34d719
equal deleted inserted replaced
65:630d2f34d719 66:07a122eea281
     1 // Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1997-2009 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".
    17 
    17 
    18 /**
    18 /**
    19  @file
    19  @file
    20 */
    20 */
    21 
    21 
    22 
       
    23 
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "CSimNtRasTraces.h"
       
    27 #endif
       
    28 
       
    29 #include "CSimNtras.h"
    22 #include "CSimNtras.h"
       
    23 #include "Simlog.h"
    30 
    24 
    31 _LIT8(KNtRasWriteText,"CLIENT");			// < Solicitation text, send to start the NTRas server
    25 _LIT8(KNtRasWriteText,"CLIENT");			// < Solicitation text, send to start the NTRas server
    32 _LIT8(KNtRasReceiveText,"SERVER");			// < NTRas server response, indicating the PPP session can commence.
    26 _LIT8(KNtRasReceiveText,"SERVER");			// < NTRas server response, indicating the PPP session can commence.
    33 const TInt KNtRasServerResponseTimeout=5;	// < Connection attempt time out value in seconds.
    27 const TInt KNtRasServerResponseTimeout=5;	// < Connection attempt time out value in seconds.
    34 
    28 
    91  * @param aConfig	The port configuration to be used for the connection.
    85  * @param aConfig	The port configuration to be used for the connection.
    92  * @param aCallback	The callback class that must be signalled when the connection completes.
    86  * @param aCallback	The callback class that must be signalled when the connection completes.
    93  * @return TInt		Standard error value.
    87  * @return TInt		Standard error value.
    94  */
    88  */
    95 	{
    89 	{
    96 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMNTRAS_CONNECT_1, "Starting to attempt a NT RAS Connection");
    90 	LOGDATA1("Starting to attempt a NT RAS Connection");
    97 	iReadBuf.Zero();
    91 	iReadBuf.Zero();
    98 	iInputBuf.Zero();
    92 	iInputBuf.Zero();
    99 
    93 
   100 // Open and configuration the port
    94 // Open and configuration the port
   101 	TInt ret=CommOpen(aCsyName,aPort,ECommShared);
    95 	TInt ret=CommOpen(aCsyName,aPort,ECommShared);
   135 void CSimNtRas::AttemptConnect()
   129 void CSimNtRas::AttemptConnect()
   136 /**
   130 /**
   137  * Transmit "CLIENT" and attempt a connection
   131  * Transmit "CLIENT" and attempt a connection
   138  */
   132  */
   139 	{
   133 	{
   140 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMNTRAS_ATTEMPTCONNECT_1, "NTRAS Writing CLIENT...");
   134 	LOGDATA1("NTRAS Writing CLIENT...");
   141 	iAttemptCnt++;
   135 	iAttemptCnt++;
   142 	// Send the soliciting message, and await the NT Ras server's response.
   136 	// Send the soliciting message, and await the NT Ras server's response.
   143 	CommWrite(KNtRasWriteText);
   137 	CommWrite(KNtRasWriteText);
   144 	iTimer->Start(KNtRasServerResponseTimeout,this);
   138 	iTimer->Start(KNtRasServerResponseTimeout,this);
   145 	}
   139 	}
   173  * data to the input buffer and scan for the server's response.
   167  * data to the input buffer and scan for the server's response.
   174  * If no match is found, re-post the read.
   168  * If no match is found, re-post the read.
   175  * @param aStatus	Standard error value, indicating the result of the read request.
   169  * @param aStatus	Standard error value, indicating the result of the read request.
   176  */
   170  */
   177 	{
   171 	{
   178 	OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMNTRAS_COMMREADCOMPLETE_1, "NTRAS Rx Completion: %s",iInputBuf);
   172 	LOGDATA2("NTRAS Rx Completion: %S",&iInputBuf);
   179 	if(aStatus!=KErrNone)
   173 	if(aStatus!=KErrNone)
   180 		{
   174 		{
   181 		iTimer->Cancel();
   175 		iTimer->Cancel();
   182 		iCallback->NTRasCallBack(aStatus);
   176 		iCallback->NTRasCallBack(aStatus);
   183 		return;
   177 		return;
   194 	TInt pos=iInputBuf.FindF(KNtRasReceiveText);
   188 	TInt pos=iInputBuf.FindF(KNtRasReceiveText);
   195 	if(pos>=0)
   189 	if(pos>=0)
   196 		{
   190 		{
   197 		iTimer->Cancel();
   191 		iTimer->Cancel();
   198 		iCallback->NTRasCallBack(KErrNone);
   192 		iCallback->NTRasCallBack(KErrNone);
   199 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMNTRAS_COMMREADCOMPLETE_2, "NTRAS Received SERVER!");
   193 		LOGDATA1("NTRAS Received SERVER!");
   200 		return;
   194 		return;
   201 		}
   195 		}
   202 
   196 
   203 	CommReadOneOrMore(iReadBuf);
   197 	CommReadOneOrMore(iReadBuf);
   204 	}
   198 	}
   207 /**
   201 /**
   208  * Serial port write completion callback.  Terminate the connection attempt if an error
   202  * Serial port write completion callback.  Terminate the connection attempt if an error
   209  * has occurred.
   203  * has occurred.
   210  */
   204  */
   211 	{
   205 	{
   212 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMNTRAS_COMMWRITECOMPLETE_1, "NTRAS Write Completion");
   206 	LOGDATA1("NTRAS Write Completion");
   213 	if(aStatus!=KErrNone)
   207 	if(aStatus!=KErrNone)
   214 		{
   208 		{
   215 		iTimer->Cancel();
   209 		iTimer->Cancel();
   216 		iCallback->NTRasCallBack(aStatus);
   210 		iCallback->NTRasCallBack(aStatus);
   217 		}
   211 		}
   220 void CSimNtRas::TimerCallBack(TInt /*aId*/)
   214 void CSimNtRas::TimerCallBack(TInt /*aId*/)
   221 /**
   215 /**
   222  * Timer expired callback.  Give up the attempted connection with a time-out error.
   216  * Timer expired callback.  Give up the attempted connection with a time-out error.
   223  */
   217  */
   224 	{
   218 	{
   225 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMNTRAS_TIMERCALLBACK_1, "NTRAS Timeout Occurred");
   219 	LOGDATA1("NTRAS Timeout Occurred");
   226 	CommWriteCancel();
   220 	CommWriteCancel();
   227 	if(iAttemptCnt<KTxMaxRetries)
   221 	if(iAttemptCnt<KTxMaxRetries)
   228 		AttemptConnect();
   222 		AttemptConnect();
   229 	else
   223 	else
   230 		{
   224 		{