bthci/hci2implementations/CommandsEvents/symbian/src/commandcompleteevent.cpp
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 // commandcompletevent.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #include <bluetooth/hci/event.h>
       
    23 #include <bluetooth/hci/commandcompleteevent.h>
       
    24 #include <bluetooth/hci/hciopcodes.h>
       
    25 
       
    26 #include "symbiancommandseventsutils.h"
       
    27 
       
    28 #ifdef __FLOG_ACTIVE
       
    29 _LIT8(KLogComponent, LOG_COMPONENT_COMMANDSEVENTS_SYMBIAN);
       
    30 #endif
       
    31 
       
    32 THCICommandCompleteEvent::THCICommandCompleteEvent(TUint8 aParameterTotalLength,
       
    33 		TUint8 aNumHCICommandPackets, THCIOpcode aCommandOpcode, TDes8& aEventData)
       
    34 	: THCIEventBase(ECommandCompleteEvent, aParameterTotalLength, aEventData)
       
    35 	{
       
    36 	PutTUint8(aNumHCICommandPackets, aEventData);	// Num_HCI_Command_Packets
       
    37 	PutTUint16(aCommandOpcode, aEventData);			// Command_Opcode
       
    38 	// It is the responsibility of the most derived class to set iEventData
       
    39 	// from aEventData after event-specific data has been added in.	
       
    40 	}
       
    41 	
       
    42 THCICommandCompleteEvent::THCICommandCompleteEvent(const TDesC8& aEventData)
       
    43 	: THCIEventBase(aEventData)
       
    44   	{
       
    45   	}
       
    46 
       
    47 EXPORT_C TUint8 THCICommandCompleteEvent::NumHCICommandPackets() const
       
    48 	{
       
    49 	//Command credits are 3rd byte (octet) of the iEventData
       
    50 	return(iEventData[2]);
       
    51 	}
       
    52 
       
    53 EXPORT_C THCIOpcode THCICommandCompleteEvent::CommandOpcode() const
       
    54 	{
       
    55   	// Command_Opcode is in the 4th and 5th octet of a Command_Complete event
       
    56 	return AsTUint16(3);
       
    57 	}
       
    58 	
       
    59 EXPORT_C THCICommandCompleteEvent& THCICommandCompleteEvent::Cast(const THCIEventBase& aEvent)
       
    60 	{
       
    61 	__ASSERT_ALWAYS(aEvent.EventCode()==ECommandCompleteEvent, PANIC(KSymbianCommandsEventsPanicCat, EWrongEventCode));
       
    62 	return *(reinterpret_cast<THCICommandCompleteEvent*>(&const_cast<THCIEventBase&>(aEvent)));
       
    63 	}