bluetooth/btstack/linkmgr/btcommands.cpp
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 #include <bttypes.h>
       
    17 #include "internaltypes.h"
       
    18 
       
    19 enum TBluetoothHciCommandsPanic
       
    20 	{
       
    21 	ERangeTooLarge,
       
    22 	};
       
    23 
       
    24 void CommandsPanic(TBluetoothHciCommandsPanic aPanic)
       
    25 	{
       
    26 	_LIT(KPanicText, "BluetoothHciCommands");
       
    27 	User::Panic(KPanicText, aPanic);
       
    28 	}
       
    29 
       
    30 TBluetoothHciCommands::TBluetoothHciCommands()
       
    31 	{
       
    32 	Init(KNullDesC8);
       
    33 	}
       
    34 
       
    35 
       
    36 TBluetoothHciCommands::TBluetoothHciCommands(const TDesC8& aFeatures)
       
    37 	{
       
    38 	Init(aFeatures);
       
    39 	}
       
    40 
       
    41 
       
    42 void TBluetoothHciCommands::Init(const TDesC8& aFeatures)
       
    43 	{
       
    44 	iCommands.Copy(aFeatures);
       
    45 	iCommands.SetMax();
       
    46 	}
       
    47 
       
    48 
       
    49 TBool TBluetoothHciCommands::operator[](TInt aOffset) const
       
    50 	{
       
    51 	if (aOffset > KBluetoothHciCommandsBytes * 8)
       
    52 		{
       
    53 		CommandsPanic(ERangeTooLarge);
       
    54 		}
       
    55 	TInt byte = aOffset / 8;
       
    56 	TInt offset = aOffset - (byte * 8);
       
    57 	TUint8 byteval = iCommands[byte];
       
    58 	return TBool(iCommands[byte] & (1<<offset));
       
    59 	}