cbsref/telephonyrefplugins/atltsy/atcommand/phone/src/atgetsignalstrength.cpp
branchRCL_3
changeset 20 07a122eea281
parent 19 630d2f34d719
child 21 4814c5a49428
equal deleted inserted replaced
19:630d2f34d719 20:07a122eea281
     1 // Copyright (c) 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 // CATGetModemStatus
       
    15 // Description:
       
    16 // CATGetSignal
       
    17 
       
    18 #include "atgetsignalstrength.h"
       
    19 #include "mslogger.h"
       
    20 
       
    21 
       
    22 _LIT8(KGetSignalQualityCommand,"AT+CSQ\r");
       
    23 _LIT8(KGetSingalCommandRepStr,"+CSQ:");
       
    24 // Class CATGetSignal
       
    25 // ---------------------------------------------------------------------------
       
    26 // CATGetSignal::NewL
       
    27 // other items were commented in a header
       
    28 // ---------------------------------------------------------------------------
       
    29 CATGetSignal* CATGetSignal::NewL(CGlobalPhonemanager& aGloblePhone, 
       
    30 	                             CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    31 	{
       
    32 	CATGetSignal* self = new(ELeave) CATGetSignal(aGloblePhone,
       
    33 			                                      aCtsyDispatcherCallback);
       
    34 	CleanupStack::PushL(self );
       
    35 	self->ConstructL();
       
    36 	CleanupStack::Pop(self );
       
    37 	return self ;
       
    38 	}
       
    39 // ---------------------------------------------------------------------------
       
    40 // CATGetSignal::CATGetSignal
       
    41 // other items were commented in a header
       
    42 // ---------------------------------------------------------------------------
       
    43 CATGetSignal::CATGetSignal(CGlobalPhonemanager& aGloblePhone, 
       
    44 	                       CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    45 		:CAtCommandBase(aGloblePhone,aCtsyDispatcherCallback)
       
    46 	{
       
    47 	}
       
    48 // ---------------------------------------------------------------------------
       
    49 // CATGetSignal::ConstructL
       
    50 // other items were commented in a header
       
    51 // ---------------------------------------------------------------------------
       
    52 void CATGetSignal::ConstructL()
       
    53 	{
       
    54 	CAtCommandBase::ConstructL();
       
    55 	iAtType = ELtsyAT_Phone_GetSignal;
       
    56 	}
       
    57 // ---------------------------------------------------------------------------
       
    58 // CATGetSignal::~CATGetSignal
       
    59 // other items were commented in a header
       
    60 // ---------------------------------------------------------------------------
       
    61 CATGetSignal::~CATGetSignal()
       
    62 	{
       
    63 	}
       
    64 // ---------------------------------------------------------------------------
       
    65 // CATGetSignal::StartRequestL
       
    66 // other items were commented in a header
       
    67 // ---------------------------------------------------------------------------
       
    68 void CATGetSignal::StartRequest()
       
    69 	{
       
    70 	ExecuteCommand();
       
    71 	}
       
    72 // ---------------------------------------------------------------------------
       
    73 // CATGetSignal::ExecuteCommand
       
    74 // other items were commented in a header
       
    75 // ---------------------------------------------------------------------------
       
    76 void CATGetSignal::ExecuteCommand( )
       
    77 	{
       
    78 	iTxBuffer.Copy(KGetSignalQualityCommand);
       
    79 	Write();
       
    80 	}
       
    81 // ---------------------------------------------------------------------------
       
    82 // CATGetSignal::getSignalInfo
       
    83 // other items were commented in a header
       
    84 // ---------------------------------------------------------------------------
       
    85 TTsySignalInfo CATGetSignal::getSignalInfo()
       
    86 	{
       
    87 	return iSignalInfo;
       
    88 	}
       
    89 // ---------------------------------------------------------------------------
       
    90 // CATGetSignal::GetErrorValue
       
    91 // other items were commented in a header
       
    92 // ---------------------------------------------------------------------------
       
    93 TInt CATGetSignal::GetErrorValue()
       
    94 	{
       
    95 	return iError;
       
    96 	}
       
    97 // ---------------------------------------------------------------------------
       
    98 // CATGetSignal::ParseResponseL
       
    99 // other items were commented in a header
       
   100 // ---------------------------------------------------------------------------
       
   101 void CATGetSignal::ParseResponseL(const TDesC8& /*aResponseBuf*/)
       
   102 	{
       
   103 	if (CurrentLine().Match(KLtsyOkString) != 0)
       
   104 		{
       
   105 		iError = KErrGeneral;
       
   106 		return ;
       
   107 		}
       
   108 	RArray<TPtrC8> array;
       
   109 	CleanupClosePushL(array);
       
   110 	iParser->ParseRespondedBuffer(array,PrecedingLine());
       
   111 	TInt Count = array.Count();
       
   112 	if (Count <= 1)
       
   113 		{
       
   114 		CleanupStack::PopAndDestroy();
       
   115 		iError = KErrGeneral;
       
   116 		return ;
       
   117 		}
       
   118 	if( array[0].MatchF(KGetSingalCommandRepStr)==KErrNotFound)
       
   119 		{
       
   120 		CleanupStack::PopAndDestroy();
       
   121 		iError = KErrGeneral;
       
   122 		return ;
       
   123 		}
       
   124 	TInt val = 0;
       
   125 	TLex8 lex(array[1]);
       
   126 	lex.Val(val);
       
   127 	if (val < 0) 
       
   128 		{
       
   129 		iSignalInfo.iSignalStrength = 0;
       
   130 		}
       
   131 	else	
       
   132 		{
       
   133 		iSignalInfo.iSignalStrength = val;
       
   134 		}
       
   135 	TLex8 lex1(array[2]);
       
   136 	lex1.Val(val);
       
   137 	if (val < 0) 
       
   138 		{
       
   139 		iSignalInfo.iBar = 0;
       
   140 		}
       
   141 	else	
       
   142 		{
       
   143 		iSignalInfo.iBar = val;
       
   144 		}
       
   145 
       
   146 	CleanupStack::PopAndDestroy();
       
   147 	iError = KErrNone;
       
   148 	}
       
   149 // ---------------------------------------------------------------------------
       
   150 // CATGetSignal::EventSignal
       
   151 // other items were commented in a header
       
   152 // ---------------------------------------------------------------------------
       
   153 void CATGetSignal::EventSignal(TAtEventSource aEventSource, TInt aStatus)
       
   154 	{
       
   155 	if(KErrNone ==aStatus)
       
   156 		{
       
   157 		if(aEventSource == EReadCompletion)
       
   158 			{
       
   159 			aStatus = iError;
       
   160 			}
       
   161 		else
       
   162 			return;
       
   163 		}
       
   164 	CAtCommandBase::Complete();
       
   165 	iPhoneGlobals.iEventSignalActive = EFalse;
       
   166 	iCtsyDispatcherCallback.CallbackPhoneGetSignalStrengthComp(aStatus,
       
   167 							                                   iSignalInfo.iSignalStrength,
       
   168 							                                   iSignalInfo.iBar);
       
   169 	}
       
   170 //
       
   171 // End of file
       
   172