bthci/hci2implementations/hctls/bcsp/inc/hctlbcspsequencer.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2006-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 /**
       
    17  @file
       
    18  @internalComponent
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef HCTLBCSPSEQUENCER_H
       
    23 #define HCTLBCSPSEQUENCER_H
       
    24 
       
    25 #include <e32base.h>
       
    26 
       
    27 class CDelay;
       
    28 class CHCTLBcsp;
       
    29 class RBusDevComm;
       
    30 class CHCTLBcspFrameQueue;
       
    31 class CHCTLBcspSender;
       
    32 class CRxHctlBcspFrame;
       
    33 
       
    34 NONSHARABLE_CLASS(CHCTLBcspSequencer) :public CBase
       
    35 /**
       
    36 CHCTLBcspSequencer
       
    37 Provides the Sequencing layer as described in the BCSP Spec. this permits reliable retransmission
       
    38 of ACL and Command Data and in the final version of BCSP a windowing mechanism allowing multiple 
       
    39 frames < 7 to be transmitted without acknowledgment for each individual frame.
       
    40   	
       
    41 This class is not intended for derivation.
       
    42 */
       
    43 	{
       
    44 public:
       
    45 	static CHCTLBcspSequencer* NewL(CHCTLBcsp& aHCTLbcsp, RBusDevComm& aPort,CHCTLBcspFrameQueue& aBcspFrameQueue);
       
    46 	~CHCTLBcspSequencer();
       
    47 	
       
    48 	void WakeUp();			// Set the state machine to ESending and then in Entry() does the same as SendNextPacket()
       
    49 	void SendNextPacket();	// Gets next packet from iBcspFrameQueue and Sends it directly to the UART
       
    50 	void HandleRxAck();		// Triggers removal of Acked frames
       
    51 	void SendPacket(TDesC8* aFrame, TBool aIsReliable);
       
    52 
       
    53 	TInt SendQueuedFrame();
       
    54 
       
    55 	void HandleRx(CRxHctlBcspFrame* aFrame);
       
    56 	
       
    57 	TUint8 TxAck() const;
       
    58 	void ResendState();
       
    59 	void HandleRxAckTimeout();
       
    60 
       
    61  	//BCSP peer reset functions
       
    62  	void Reset();
       
    63  	void HandlePeerReset();
       
    64 
       
    65 private:
       
    66 	CHCTLBcspSequencer(CHCTLBcsp& aHCTLbcsp, CHCTLBcspFrameQueue& aBcspFrameQueue);
       
    67     void ConstructL(RBusDevComm& aPort);
       
    68 	void UpdateTxAckVal();
       
    69 	void StartRxAckTimer();
       
    70 	void StartTxAckTimer();
       
    71 	void TxAckMsg();
       
    72 	
       
    73 	static TInt TxTimeout(TAny* aThis);
       
    74 	static TInt RxTimeout(TAny* aThis);
       
    75 
       
    76 private:
       
    77 	enum TBcspRelRxState
       
    78 		{
       
    79 		EIdle,
       
    80 		EReceiving
       
    81 		};
       
    82 
       
    83 	TUint8 iRxAck;	//Updated by HandleRx()
       
    84 	TUint8 iRxSeq;
       
    85 	TUint8 iRxSeqExpected;
       
    86 	TUint8 iRxSeqLast;
       
    87 	TUint8 iPacketAvail;
       
    88 
       
    89 	TUint8 iTxAck;
       
    90 
       
    91 	TBcspRelRxState iRelRxState;
       
    92 
       
    93 	TUint8 iRxTimeoutCount;
       
    94 	CDelay* iRxAckTimer;
       
    95 	CDelay* iTxAckTimer;
       
    96 
       
    97 	CHCTLBcsp& iHctlBcsp;
       
    98 	CHCTLBcspFrameQueue& iFrameQueue;
       
    99 
       
   100 	CHCTLBcspSender* iSender;
       
   101 	};
       
   102 	
       
   103 #endif // HCTLBCSPSEQUENCER_H