bluetooth/btstack/HCIShared/interface/hcishared.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2008-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  @publishedPartner
       
    19  @released
       
    20 */
       
    21 
       
    22 #ifndef HCISHARED_H
       
    23 #define HCISHARED_H
       
    24 
       
    25 #include <bttypes.h>
       
    26 
       
    27 /** HCIShared Panic code
       
    28  */
       
    29 _LIT(KHCISharedPanicName, "HCIShared Panic");
       
    30 
       
    31 enum THCISharePanic
       
    32 	{
       
    33 	EBTUnknownLowPowerMode		=0
       
    34 	};
       
    35 
       
    36 /** Size of featureset
       
    37  */
       
    38 const TInt KBTHCIFeaturesBytes = 8;
       
    39 
       
    40 NONSHARABLE_CLASS(TLinkPolicy)
       
    41 /**
       
    42 	The following class captures all the link policy settings
       
    43 **/
       
    44 	{
       
    45 public:
       
    46 	IMPORT_C TBool IsModeAllowed(TBTLinkMode aMode) const;
       
    47 	IMPORT_C TBool IsSwitchAllowed() const;
       
    48 
       
    49 	IMPORT_C void SetModeAllowed(TBTLinkMode, TBool aAllowed);
       
    50 	IMPORT_C void SetModesAllowed(TUint8 aModesAllowed);
       
    51 	IMPORT_C void SetSwitchAllowed(TBool aAllowed);
       
    52 
       
    53 	IMPORT_C TUint8 LowPowerModePolicy() const;
       
    54 
       
    55 	IMPORT_C TUint8 LinkPolicy() const;
       
    56 
       
    57 private:
       
    58 	TUint8 iLowPowerModePolicy;
       
    59 	TBool	iSwitchAllowed;
       
    60 	};
       
    61 
       
    62 NONSHARABLE_CLASS(TBTBasebandLinkState)
       
    63 	{
       
    64 public:
       
    65 	enum TLinkState
       
    66 		{
       
    67 		ELinkDown,
       
    68 		ELinkPending,
       
    69 		ELinkUp,
       
    70 		};
       
    71 
       
    72 	IMPORT_C TBTBasebandLinkState();
       
    73 
       
    74 	IMPORT_C void SetLinkState(TLinkState aState);
       
    75 	IMPORT_C void SetAuthenticated(TBool aAuthenticated);
       
    76 	IMPORT_C void SetEncrypted(TBool aEncrypted);
       
    77 	IMPORT_C void SetLinkMode(TBTLinkMode aMode);
       
    78 	IMPORT_C void SetLinkRole(TBTBasebandRole aRole);
       
    79 	IMPORT_C void SetPacketTypes(TUint16 aPacketTypes);
       
    80 	IMPORT_C void SetMaxSlots(TUint8 aMaxSlots);
       
    81 
       
    82 	IMPORT_C TLinkState LinkState() const;
       
    83 	IMPORT_C TBool Authenticated() const;
       
    84 	IMPORT_C TBool Encrypted() const;
       
    85 	IMPORT_C TBTLinkMode LinkMode() const;
       
    86 	IMPORT_C TBTBasebandRole LinkRole() const;
       
    87 	IMPORT_C TUint16 PacketTypes() const;
       
    88 	IMPORT_C TUint8 MaxSlots() const;
       
    89 
       
    90 protected:
       
    91 	TLinkState		iLinkState;
       
    92 	TBool			iAuthenticated;
       
    93 	TBool			iEncrypted;
       
    94 	TBTLinkMode		iMode;
       
    95 	TBTBasebandRole iRole;
       
    96 	TUint16			iPacketTypes;
       
    97 	TUint8			iMaxSlots;
       
    98 	};
       
    99 
       
   100 
       
   101 /**
       
   102 Handle the local and remote supported features bitmasks.  Provides utility
       
   103 functions to extract items of interest, and individual bits.
       
   104 */
       
   105 NONSHARABLE_CLASS(TBTFeatures)
       
   106 	{
       
   107 	public:
       
   108 		IMPORT_C explicit TBTFeatures();
       
   109 		IMPORT_C explicit TBTFeatures(TUint64 aFeatures);
       
   110 		IMPORT_C TBool operator[](TInt aOffset) const;
       
   111 		
       
   112 		IMPORT_C TBTLinkModeSet LinkModes() const;
       
   113 		IMPORT_C TBTSCOPackets SCOPackets() const;
       
   114 		IMPORT_C TBTSyncPacketTypes SyncPackets() const;
       
   115 		
       
   116 		IMPORT_C TBool IsEncryptionSupported() const;
       
   117 		IMPORT_C TBool IsRoleSwitchSupported() const;
       
   118 		IMPORT_C TBool IsSecureSimplePairingSupported() const;
       
   119 		IMPORT_C TBool IsModeSupported(TBTLinkMode aMode) const;
       
   120 		IMPORT_C TBool IsEncryptionPauseResumeSupported() const;
       
   121 		IMPORT_C TBool IsExtendedInquiryResponseSupported() const;
       
   122 		IMPORT_C TBool IsRssiWithInquiryResultsSupported() const;
       
   123 		IMPORT_C TBool IsSCOLinkSupported() const;
       
   124 		IMPORT_C TBool IsExtendedSCOLinkSupported() const;
       
   125 	
       
   126 	private:
       
   127 		void Init(TUint64 aFeatures);
       
   128 		TUint32 Extract32Bits(TInt aStart, TInt aEnd) const;
       
   129 		TUint32 Extract32BitsOffset(TInt aStart, TInt aEnd, TInt aOffset) const;
       
   130 		
       
   131 	private:
       
   132 		TBuf8<KBTHCIFeaturesBytes> iFeatures;
       
   133 	};
       
   134 #endif // HCISHARED_H