bluetooth/btstack/linkmgr/physicallinkmetrics.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 1999-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 #ifndef PHYSICALLINKMETRICS_H
       
    17 #define PHYSICALLINKMETRICS_H
       
    18 
       
    19 #include <bt_sock.h>
       
    20 #include <bluetooth/hcicommandqueueclient.h>
       
    21 #include <bluetooth/hcicmdqcontroller.h>
       
    22 
       
    23 #include "internaltypes.h"
       
    24 #include "notification.h"
       
    25 
       
    26 class CPhysicalLink;
       
    27 class CBTProxySAP;
       
    28 
       
    29 class THCICommandCompleteEvent;
       
    30 class TReadFailedContactCounterCompleteEvent;
       
    31 class TReadRSSICompleteEvent;
       
    32 class TReadLinkQualityCompleteEvent;
       
    33 class TReadTransmitPowerLevelCompleteEvent;
       
    34 
       
    35 const TUint KPLMPollInterval = 2000000; // 2 Seconds
       
    36 
       
    37 
       
    38 enum THciCommandState
       
    39 	{
       
    40 	ECommandIdle,
       
    41 	ECommandIssued,
       
    42 	ECommandBlockedForTimer
       
    43 	};
       
    44 
       
    45 class TPLMManager
       
    46 	{
       
    47 public:
       
    48 	TPLMManager();
       
    49 	void RegisterProxySAP(CBTProxySAP& aSAP);	
       
    50 	void UpdatePLMValue(TInt aPLMValue);
       
    51 	void UpdatePLMState(THciCommandState aPLMState);
       
    52 	TPckgBuf<TInt>& PLMValue();
       
    53 	THciCommandState PLMState() const;
       
    54 	void NotifyQueuedProxySAPs(TInt aErr, TUint aName, TDesC8* aBuf);
       
    55 	TBool AnyOutstandingClientRequest() const;
       
    56 
       
    57 private:	
       
    58 	TDblQue<CBTProxySAP>	iPLMQue;
       
    59 	THciCommandState		iPLMState;
       
    60 	TPckgBuf<TInt>			iPLMValue;
       
    61 	};
       
    62 
       
    63 /**
       
    64 	This class handles CPhysicalLinkMetrics commands to and from the HCI
       
    65 	It is owned, constructed and destructed by CPhysicalLink
       
    66 **/
       
    67 NONSHARABLE_CLASS(CPhysicalLinkMetrics) : public CBase, public MHCICommandQueueClient,
       
    68 										  public MPhysicalLinkObserver
       
    69 	{
       
    70 public:
       
    71 	static CPhysicalLinkMetrics* NewL(CPhysicalLink& aLink, MHCICommandQueue& aController);
       
    72 	~CPhysicalLinkMetrics();
       
    73 	void ReadNewPhysicalLinkMetricValue(TUint aIoctlName, CBTProxySAP& aSAP, TInt aCurrentValue);		
       
    74 	
       
    75 private:
       
    76 	CPhysicalLinkMetrics(CPhysicalLink& aLink, MHCICommandQueue& aController);
       
    77 	void ConstructL();
       
    78 	void HandleReadFailedContactCounterCompleteEvent(const TReadFailedContactCounterCompleteEvent& aEvent);
       
    79 	void HandleReadLinkQualityCompleteEvent(const TReadLinkQualityCompleteEvent& aEvent);
       
    80 	void HandleReadRssiCompleteEvent(const TReadRSSICompleteEvent& aEvent);
       
    81 	void HandleReadTransmitPowerLevelCompleteEvent(const TReadTransmitPowerLevelCompleteEvent& aEvent);
       
    82 	
       
    83 	void ReadRssiCommand();
       
    84 	void ReadRssiCommandL();
       
    85 	void ReadLinkQualityCommand();
       
    86 	void ReadLinkQualityCommandL();
       
    87 	void ReadFailedContactCounterCommand();
       
    88 	void ReadFailedContactCounterCommandL();
       
    89 	void ReadTransmitPowerLevelCommand();
       
    90 	void ReadTransmitPowerLevelCommandL();
       
    91 	
       
    92 	void RemovePLMCommands();	
       
    93 	void CommandCompleteEvent(const THCICommandCompleteEvent& aEvent);
       
    94 	
       
    95 	static TInt PLMEventReceived(TAny* aThis);
       
    96 	void DoRssiTimerEvent();
       
    97 	void DoLinkQualityTimerEvent();
       
    98 	void DoFailedContactCounterTimerEvent();
       
    99 	void DoTransmitPowerLevelTimerEvent();
       
   100 	
       
   101 	void QueueNextPLMPollIfNotAlreadyQueued();
       
   102 	void RemovePLMPoll();	
       
   103 
       
   104 	// From MHCICommandQueueClient
       
   105 	virtual void MhcqcCommandEventReceived(const THCIEventBase& aEvent, const CHCICommandBase* aRelatedCommand);
       
   106 	virtual void MhcqcCommandErrored(TInt aErrorCode, const CHCICommandBase* aCommand);
       
   107 
       
   108 	// From MPhysicalLinkObserver
       
   109 	virtual void PhysicalLinkChange(const TBTBasebandEventNotification& aEvent, CPhysicalLink& aPhysicalLink);
       
   110 	virtual TPhysicalLinkObserverQLink& ObserverQLink();
       
   111 	
       
   112 private:
       
   113 	CPhysicalLink&			iParent;
       
   114 	MHCICommandQueue&		iCmdController;
       
   115 	
       
   116 	TPhysicalLinkObserverQLink		iQueLink;
       
   117 	
       
   118 	TPckgBuf<TInt>			iDummyResult;
       
   119 	
       
   120 	TPLMManager				iRssi;
       
   121 	TPLMManager				iLinkQuality;
       
   122 	TPLMManager				iTransmitPowerLevel;
       
   123 	TPLMManager				iFailedContactCounter;
       
   124  
       
   125 	TDeltaTimerEntry		iPLMTimer;	
       
   126 	TBool					iPLMTimerQueued;
       
   127 	};
       
   128 
       
   129 #endif //PHYSICALLINKMETRICS_H