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