irda/irdastack/irtranp/SRPSCOMM.CPP
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 1997-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 //
       
    15 
       
    16 #include <e32base.h>
       
    17 #include "comreadwrite.h"
       
    18 #include "GLOBAL.H"
       
    19 #include "SRPSCOMM.H"
       
    20 
       
    21 
       
    22 SRPSCommand::SRPSCommand()
       
    23 	{
       
    24 	}
       
    25 
       
    26 SRPSCommand::SRPSCommand(CComReadWrite* aComReadWrite)
       
    27 	{
       
    28 	iComReadWrite = aComReadWrite;
       
    29 	}
       
    30 
       
    31 SRPSCommand::~SRPSCommand()
       
    32 	{
       
    33 	}
       
    34 
       
    35 	/*
       
    36 	* Method description:	Builds the packet
       
    37 	*
       
    38 */
       
    39 
       
    40 void SRPSCommand::Create()
       
    41 	{
       
    42 	//TPtr8 d = m_oData.Des();
       
    43 	
       
    44 	m_oData.Append(0x00);
       
    45 	m_oData.Append(KTranpMsgTypeData);
       
    46 	m_oData.Append(KTranpInfTypeUser);
       
    47 	
       
    48 	m_oData.Append(m_userDataPtr.Length() + 28 + 4); // Hardcoded, but always the same .. size of the parts below.
       
    49 	
       
    50 	m_oData.Append(KTranpInfVer);
       
    51 	m_oData.Append(KTranpDFLGnseg); // hardcoded, must be different for different commands
       
    52 	
       
    53 	TUint16 length3 = (TUint16)(m_userDataPtr.Length() + 28); // Hardcoded, but always the same .. size of the parts below.
       
    54 	IrTranpUtil::DAppend(&m_oData, length3);
       
    55 	
       
    56 	m_oData.Append(0x58);
       
    57 	m_oData.Append(m_PduType);
       
    58 	
       
    59 	TUint32 length4 = m_userDataPtr.Length() + 22; // Hardcoded, but always the same .. size of the parts below.
       
    60 	IrTranpUtil::LAppend(&m_oData, length4);
       
    61 	
       
    62 	m_oData.Append(m_PMID);
       
    63 	m_oData.Append(m_SMID);
       
    64 	
       
    65 	IrTranpUtil::DAppend(&m_oData, m_SPID);//reversed the order of these 2 lines - CAR
       
    66 	IrTranpUtil::DAppend(&m_oData, m_DPID);
       
    67 	IrTranpUtil::DAppend(&m_oData, m_CmdId);
       
    68 	
       
    69 	m_oData.Append(m_userDataPtr);
       
    70 	
       
    71 	}
       
    72 
       
    73 	/*
       
    74 	* Method description:	Sends the packet
       
    75 	*
       
    76 */
       
    77 
       
    78 void SRPSCommand::DoIt()
       
    79 	{
       
    80 	iComReadWrite->Send(m_oData);
       
    81 	}
       
    82 
       
    83 void SRPSCommand::GetReply()
       
    84 	{
       
    85 	// We won't use this at all!
       
    86 	}
       
    87 
       
    88 	/*
       
    89 	* Method description:	Retrieves the packet - used for debugging purposes
       
    90 	*
       
    91 	* Returns:				Pointer to the packet
       
    92 */
       
    93 
       
    94 TDesC8& SRPSCommand::GetData()
       
    95 	{
       
    96 	return m_oData;
       
    97 	}
       
    98 
       
    99 	/*
       
   100 	* Method description:	Sets the Primary Machine ID
       
   101 	*
       
   102 	* Parameter:			a_PMID - the new Machine ID
       
   103 */
       
   104 
       
   105 void SRPSCommand::SetPMID(TPtr8 a_PMID)
       
   106 	{
       
   107 	m_PMID = a_PMID;
       
   108 	}
       
   109 
       
   110 	/*
       
   111 	* Method description:	Sets the Secondary Machine ID
       
   112 	*
       
   113 	* Parameter:			a_SMID - the new Machine ID
       
   114 */
       
   115 
       
   116 void SRPSCommand::SetSMID(TPtr8 a_SMID)
       
   117 	{
       
   118 	m_SMID = a_SMID;
       
   119 	}
       
   120 
       
   121 	/*
       
   122 	* Method description:	Sets the type of PDU where acking
       
   123 	*
       
   124 	* Parameter:			a_PduType - the type of PDU
       
   125 */
       
   126 
       
   127 void SRPSCommand::SetPDUType(TUint8 a_PduType)
       
   128 	{
       
   129 	m_PduType = a_PduType;
       
   130 	}
       
   131 
       
   132 	/*
       
   133 	* Method description:	Sets the ID of the command where acking
       
   134 	*
       
   135 	* Parameter:			a_CmdId - the command id
       
   136 */
       
   137 
       
   138 void SRPSCommand::SetCmdId(TUint16 a_CmdId)
       
   139 	{
       
   140 	m_CmdId = a_CmdId;
       
   141 	}
       
   142 
       
   143 	/*
       
   144 	* Method description:	Sets the destination process id
       
   145 	*
       
   146 	* Parameter:			a_DPID - the process id
       
   147 */
       
   148 
       
   149 void SRPSCommand::SetDPID(TUint16 a_DPID)
       
   150 	{
       
   151 	m_DPID = a_DPID;
       
   152 	}
       
   153 
       
   154 	/*
       
   155 	* Method description:	Sets the source process id
       
   156 	*
       
   157 	* Parameter:			a_SPID - the process id
       
   158 */
       
   159 
       
   160 void SRPSCommand::SetSPID(TUint16 a_SPID)
       
   161 	{
       
   162 	m_SPID = a_SPID;
       
   163 	}
       
   164 
       
   165 	/*
       
   166 	* Method description:	Sets the userdata specific for this ack
       
   167 	*
       
   168 	* Parameter:			a_userDataPtr - pointer to the data
       
   169 */
       
   170 
       
   171 void SRPSCommand::SetUserData(TDes8& a_userDataPtr)
       
   172 	{
       
   173 	m_userDataPtr.Set(a_userDataPtr);
       
   174 	}