--- a/bluetooth/btlogger/generic/public/components.h Wed Oct 13 16:20:29 2010 +0300
+++ b/bluetooth/btlogger/generic/public/components.h Thu Oct 14 11:16:56 2010 +0100
@@ -1,136 +1,138 @@
-// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of "Eclipse Public License v1.0"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-/**
- @file
- @internalTechnology
-*/
-
-#ifndef BLUETOOTH_LOGGER_COMPONENTS_H
-#define BLUETOOTH_LOGGER_COMPONENTS_H
-
-// This file provides a centralised place for the definition
-// of log component strings for use with the Bluetooth logger.
-
-// The Bluetooth Logger
-#define LOG_COMPONENT_LOGGER "LogEngine"
-
-// HCIv2 Framework
-#define LOG_COMPONENT_HCICMDQ "HciCmdQ"
-#define LOG_COMPONENT_COREHCI_BASE "CoreHciBase"
-#define LOG_COMPONENT_HCTL_BASE "HctlBase"
-#define LOG_COMPONENT_QDP_BASE "QdpBase"
-#define LOG_COMPONENT_BTPOWERCONTROL "PowerControl"
-#define LOG_COMPONENT_DUT_MODE "DutMode"
-#define LOG_COMPONENT_HCISERVERCLIENT "HciServerClient"
-#define LOG_COMPONENT_HCIUTIL "HciUtil"
-
-// Symbian Reference HCIv2 Implementations
-#define LOG_COMPONENT_COREHCI_SYMBIAN "CoreHciSymbian"
-#define LOG_COMPONENT_HCISERVER "HciServer"
-#define LOG_COMPONENT_COMMANDSEVENTS_SYMBIAN "CommandsEvents"
-#define LOG_COMPONENT_QDP_SYMBIAN "QdpSymbian"
-#define LOG_COMPONENT_INITIALISOR_SYMBIAN "InitSymbian"
-#define LOG_COMPONENT_INITIALISOR_TI "InitTi"
-#define LOG_COMPONENT_HCTL_UART_ORIGINAL "HctlUartOriginal"
-#define LOG_COMPONENT_HCTL_TI "HctlTi"
-#define LOG_COMPONENT_HCTL_BCSP "HctlBcsp"
-#define LOG_COMPONENT_HCI_FACADE "HciFacade"
-#define LOG_COMPONENT_HCI_CSCOLINK "CSCOLink"
-#define LOG_COMPONENT_HCI_WATCHDOG "HciWatchdog"
-
-// Bluetooth Stack Components
-//// The common Bluetooth protocol components
-#define LOG_COMPONENT_BT_PRT "BtPrt"
-//// Class of Device (CoD) Service Manager
-#define LOG_COMPONENT_BT_COD "CoD"
-//// Incoming connection listener
-#define LOG_COMPONENT_IN_CONN_LISTENER "InConnListener"
-#define LOG_COMPONENT_SECMAN "SecMan"
-#define LOG_COMPONENT_HOSTRESOLVER "HostResolver"
-#define LOG_COMPONENT_LINKMGR "LinkMgr"
-#define LOG_COMPONENT_PAIRING_SERVER "PairingServer"
-#define LOG_COMPONENT_EIRMANAGER "EirManager"
-#define LOG_COMPONENT_L2CAP "L2Cap"
-#define LOG_COMPONENT_L2CAP_PDU "L2CapPdu"
-#define LOG_COMPONENT_L2CAP_SDU "L2CapSdu"
-#define LOG_COMPONENT_L2CAP_SDU_Q "L2CapSduQ"
-#define LOG_COMPONENT_L2CAP_DATA_CONTROLLER "L2CapDataController"
-#define LOG_COMPONENT_RFCOMM "Rfcomm"
-#define LOG_COMPONENT_SDP "Sdp"
-#define LOG_COMPONENT_AVDTP "Avdtp"
-#define LOG_COMPONENT_AVCTP "Avctp"
-
-// Bluetooth User Components
-#define LOG_COMPONENT_BTLIB "BtLib"
-#define LOG_COMPONENT_AVLIB "AvLib"
-#define LOG_COMPONENT_AVCTP_SERVICES "AvctpServices"
-
-// Bluetooth SDP
-#define LOG_COMPONENT_SDPDATABASE "SdpDatabase"
-#define LOG_COMPONENT_SDP_SERVER "SdpServer"
-#define LOG_COMPONENT_SDP_AGENT "SdpAgent"
-
-// Bluetooth Notifier Parameters
-#define LOG_COMPONENT_BTNOTIFIERS "Notifiers"
-
-// btcomm component
-#define LOG_COMPONENT_BT_COMM "BtComm"
-
-// Bluetooth Registry
-#define LOG_COMPONENT_BT_MANAGER_CLIENT "BtManClient"
-#define LOG_COMPONENT_BT_MANAGER_SERVER "BtManServer"
-#define LOG_COMPONENT_BT_REGISTRY "BtRegistry"
-
-// A2DP Optimiser
-#define LOG_COMPONENT_A2DP_OPTIMISER "A2dpOptimiser"
-
-// Bluetooth PAN profile
-#define LOG_COMPONENT_PAN_BNEP "Bnep"
-#define LOG_COMPONENT_PAN_AGENT "PanAgt"
-#define LOG_COMPONENT_PAN_HELPERS "PanHelpers"
-#define LOG_COMPONENT_PAN_NAPIPHOOK "PanNapIpHook"
-#define LOG_COMPONENT_PAN_PROVIDERS "PanProviders"
-
-// Bluetooth Profiles
-#define LOG_COMPONENT_REMCON_REFERENCE_TSP "RemconRefTsp"
-#define LOG_COMPONENT_REMCON_REF_SER_BEARER "RemconRefSerBearer"
-#define LOG_COMPONENT_REMCON_SERVER "RemconServer"
-#define LOG_COMPONENT_REMCON_UTILS "RemconUtils"
-#define LOG_COMPONENT_REMCON_TYPES "RemconTypes"
-#define LOG_COMPONENT_REMCON_CORE "RemconCore"
-#define LOG_COMPONENT_REMCON_EXTAPI1 "RemconExtApi1"
-#define LOG_COMPONENT_REMCON_INNER "RemconInner"
-#define LOG_COMPONENT_REMCON_IF_BASE "RemconIfBase"
-#define LOG_COMPONENT_REMCON_IF_SEL "RemconIfSel"
-#define LOG_COMPONENT_REMCON_IL_RECV "RemconIlRecv"
-#define LOG_COMPONENT_AVRCP_BEARER "AvrcpBearer"
-#define LOG_COMPONENT_AVRCP_STATUS "AvrcpStatus"
-#define LOG_COMPONENT_AVRCP_BATTERY_STATUS "AvrcpBattStat"
-#define LOG_COMPONENT_AVRCP_GROUP_NAVIGATION "AvrcpGroupNav"
-#define LOG_COMPONENT_AVRCP_MEDIA_INFO "AvrcpMediaInfo"
-#define LOG_COMPONENT_AVRCP_PLAYER_INFO "AvrcpPlayerInfo"
-#define LOG_COMPONENT_AVRCP_FRAME "AvrcpFrame"
-#define LOG_COMPONENT_REMCONABSOLUTEVOLUME "RemConAbsoluteVolumeApi"
-#define LOG_COMPONENT_REMCONMEDIABROWSEAPI "RemConMediaBrowseApi"
-#define LOG_COMPONENT_REMCONNOWPLAYINGAPI "RemConNowPlayingApi"
-
-// Test Components
-#define LOG_COMPONENT_BT_COMM_TCSY "BtCommTcsy"
-#define LOG_COMPONENT_GAVDP_TAVSRC "GavdpTavsrc"
-#define LOG_COMPONENT_TSDPSAS "Tsdpsas"
-#define LOG_COMPONENT_BT_TESTCONSOLE "BtTestConsole"
-
-#endif // BLUETOOTH_LOGGER_COMPONENTS_H
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef BLUETOOTH_LOGGER_COMPONENTS_H
+#define BLUETOOTH_LOGGER_COMPONENTS_H
+
+// This file provides a centralised place for the definition
+// of log component strings for use with the Bluetooth logger.
+
+// The Bluetooth Logger
+#define LOG_COMPONENT_LOGGER "LogEngine"
+
+// HCIv2 Framework
+#define LOG_COMPONENT_HCICMDQ "HciCmdQ"
+#define LOG_COMPONENT_COREHCI_BASE "CoreHciBase"
+#define LOG_COMPONENT_HCTL_BASE "HctlBase"
+#define LOG_COMPONENT_QDP_BASE "QdpBase"
+#define LOG_COMPONENT_BTPOWERCONTROL "PowerControl"
+#define LOG_COMPONENT_DUT_MODE "DutMode"
+#define LOG_COMPONENT_HCISERVERCLIENT "HciServerClient"
+#define LOG_COMPONENT_HCIUTIL "HciUtil"
+
+// Symbian Reference HCIv2 Implementations
+#define LOG_COMPONENT_COREHCI_SYMBIAN "CoreHciSymbian"
+#define LOG_COMPONENT_HCISERVER "HciServer"
+#define LOG_COMPONENT_COMMANDSEVENTS_SYMBIAN "CommandsEvents"
+#define LOG_COMPONENT_QDP_SYMBIAN "QdpSymbian"
+#define LOG_COMPONENT_INITIALISOR_SYMBIAN "InitSymbian"
+#define LOG_COMPONENT_INITIALISOR_TI "InitTi"
+#define LOG_COMPONENT_HCTL_UART_ORIGINAL "HctlUartOriginal"
+#define LOG_COMPONENT_HCTL_TI "HctlTi"
+#define LOG_COMPONENT_HCTL_BCSP "HctlBcsp"
+#define LOG_COMPONENT_HCTL_USB_ORIGINAL "HctlUsbOriginal"
+
+#define LOG_COMPONENT_HCI_WATCHDOG "HciWatchdog"
+
+// Bluetooth Stack Components
+//// The common Bluetooth protocol components
+#define LOG_COMPONENT_BT_PRT "BtPrt"
+//// Class of Device (CoD) Service Manager
+#define LOG_COMPONENT_BT_COD "CoD"
+//// Incoming connection listener
+#define LOG_COMPONENT_IN_CONN_LISTENER "InConnListener"
+#define LOG_COMPONENT_SECMAN "SecMan"
+#define LOG_COMPONENT_HOSTRESOLVER "HostResolver"
+#define LOG_COMPONENT_LINKMGR "LinkMgr"
+#define LOG_COMPONENT_PAIRING_SERVER "PairingServer"
+#define LOG_COMPONENT_EIRMANAGER "EirManager"
+#define LOG_COMPONENT_L2CAP "L2Cap"
+#define LOG_COMPONENT_L2CAP_PDU "L2CapPdu"
+#define LOG_COMPONENT_L2CAP_SDU "L2CapSdu"
+#define LOG_COMPONENT_L2CAP_SDU_Q "L2CapSduQ"
+#define LOG_COMPONENT_L2CAP_DATA_CONTROLLER "L2CapDataController"
+#define LOG_COMPONENT_RFCOMM "Rfcomm"
+#define LOG_COMPONENT_SDP "Sdp"
+#define LOG_COMPONENT_AVDTP "Avdtp"
+#define LOG_COMPONENT_AVCTP "Avctp"
+#define LOG_COMPONENT_HCI_FACADE "HciFacade"
+#define LOG_COMPONENT_HCI_CSCOLINK "CSCOLink"
+
+// Bluetooth User Components
+#define LOG_COMPONENT_BTLIB "BtLib"
+#define LOG_COMPONENT_AVLIB "AvLib"
+#define LOG_COMPONENT_AVCTP_SERVICES "AvctpServices"
+
+// Bluetooth SDP
+#define LOG_COMPONENT_SDPDATABASE "SdpDatabase"
+#define LOG_COMPONENT_SDP_SERVER "SdpServer"
+#define LOG_COMPONENT_SDP_AGENT "SdpAgent"
+
+// Bluetooth Notifier Parameters
+#define LOG_COMPONENT_BTNOTIFIERS "Notifiers"
+
+// btcomm component
+#define LOG_COMPONENT_BT_COMM "BtComm"
+
+// Bluetooth Registry
+#define LOG_COMPONENT_BT_MANAGER_CLIENT "BtManClient"
+#define LOG_COMPONENT_BT_MANAGER_SERVER "BtManServer"
+#define LOG_COMPONENT_BT_REGISTRY "BtRegistry"
+
+// A2DP Optimiser
+#define LOG_COMPONENT_A2DP_OPTIMISER "A2dpOptimiser"
+
+// Bluetooth PAN profile
+#define LOG_COMPONENT_PAN_BNEP "Bnep"
+#define LOG_COMPONENT_PAN_AGENT "PanAgt"
+#define LOG_COMPONENT_PAN_HELPERS "PanHelpers"
+#define LOG_COMPONENT_PAN_NAPIPHOOK "PanNapIpHook"
+#define LOG_COMPONENT_PAN_PROVIDERS "PanProviders"
+
+// Bluetooth Profiles
+#define LOG_COMPONENT_REMCON_REFERENCE_TSP "RemconRefTsp"
+#define LOG_COMPONENT_REMCON_REF_SER_BEARER "RemconRefSerBearer"
+#define LOG_COMPONENT_REMCON_SERVER "RemconServer"
+#define LOG_COMPONENT_REMCON_UTILS "RemconUtils"
+#define LOG_COMPONENT_REMCON_TYPES "RemconTypes"
+#define LOG_COMPONENT_REMCON_CORE "RemconCore"
+#define LOG_COMPONENT_REMCON_EXTAPI1 "RemconExtApi1"
+#define LOG_COMPONENT_REMCON_INNER "RemconInner"
+#define LOG_COMPONENT_REMCON_IF_BASE "RemconIfBase"
+#define LOG_COMPONENT_REMCON_IF_SEL "RemconIfSel"
+#define LOG_COMPONENT_REMCON_IL_RECV "RemconIlRecv"
+#define LOG_COMPONENT_AVRCP_BEARER "AvrcpBearer"
+#define LOG_COMPONENT_AVRCP_STATUS "AvrcpStatus"
+#define LOG_COMPONENT_AVRCP_BATTERY_STATUS "AvrcpBattStat"
+#define LOG_COMPONENT_AVRCP_GROUP_NAVIGATION "AvrcpGroupNav"
+#define LOG_COMPONENT_AVRCP_MEDIA_INFO "AvrcpMediaInfo"
+#define LOG_COMPONENT_AVRCP_PLAYER_INFO "AvrcpPlayerInfo"
+#define LOG_COMPONENT_AVRCP_FRAME "AvrcpFrame"
+#define LOG_COMPONENT_REMCONABSOLUTEVOLUME "RemConAbsoluteVolumeApi"
+#define LOG_COMPONENT_REMCONMEDIABROWSEAPI "RemConMediaBrowseApi"
+#define LOG_COMPONENT_REMCONNOWPLAYINGAPI "RemConNowPlayingApi"
+
+// Test Components
+#define LOG_COMPONENT_BT_COMM_TCSY "BtCommTcsy"
+#define LOG_COMPONENT_GAVDP_TAVSRC "GavdpTavsrc"
+#define LOG_COMPONENT_TSDPSAS "Tsdpsas"
+#define LOG_COMPONENT_BT_TESTCONSOLE "BtTestConsole"
+
+#endif // BLUETOOTH_LOGGER_COMPONENTS_H
--- a/bthci/hci2implementations/corehcis/symbian/group/bld.inf Wed Oct 13 16:20:29 2010 +0300
+++ b/bthci/hci2implementations/corehcis/symbian/group/bld.inf Thu Oct 14 11:16:56 2010 +0100
@@ -1,29 +1,31 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of "Eclipse Public License v1.0"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-// bld.inf for symbian core hci plugin
-//
-//
-
-PRJ_EXPORTS
-corehci_symbian.ini /epoc32/data/z/private/101f7989/bluetooth/corehci_symbian.ini
-corehci_symbian.ini /epoc32/release/winscw/udeb/z/private/101f7989/bluetooth/corehci_symbian.ini // For WINSCW debugging
-corehci_symbian.ini /epoc32/release/winscw/urel/z/private/101f7989/bluetooth/corehci_symbian.ini
-
-corehci_symbian_ti.ini /epoc32/data/z/private/101f7989/bluetooth/corehci_symbian_ti.ini // Preconfigured for TI hardware
-
-corehci_symbian.iby /epoc32/rom/include/corehci_symbian.iby
-
-
-PRJ_MMPFILES
-corehci_symbian.mmp
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// bld.inf for symbian core hci plugin
+//
+//
+
+PRJ_EXPORTS
+corehci_symbian.ini /epoc32/data/z/private/101f7989/bluetooth/corehci_symbian.ini
+corehci_symbian.ini /epoc32/release/winscw/udeb/z/private/101f7989/bluetooth/corehci_symbian.ini // For WINSCW debugging
+corehci_symbian.ini /epoc32/release/winscw/urel/z/private/101f7989/bluetooth/corehci_symbian.ini
+
+corehci_symbian_ti.ini /epoc32/data/z/private/101f7989/bluetooth/corehci_symbian_ti.ini // Preconfigured for TI hardware
+
+corehci_symbian_usboriginal.ini /epoc32/data/z/private/101f7989/bluetooth/corehci_symbian_usboriginal.ini // Preconfigured for USB
+
+corehci_symbian.iby /epoc32/rom/include/corehci_symbian.iby
+
+
+PRJ_MMPFILES
+corehci_symbian.mmp
--- a/bthci/hci2implementations/corehcis/symbian/group/corehci_symbian.iby Wed Oct 13 16:20:29 2010 +0300
+++ b/bthci/hci2implementations/corehcis/symbian/group/corehci_symbian.iby Thu Oct 14 11:16:56 2010 +0100
@@ -1,30 +1,33 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of "Eclipse Public License v1.0"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-#ifndef COREHCI_SYMBIAN_IBY
-#define COREHCI_SYMBIAN_IBY
-
-REM Symbian CoreHCI reference implementation
-HCI_PLUGIN(corehci_symbian.dll, corehci_symbian.rsc)
-
-#if defined(HCI_TI)
-REM CoreHCI using TI onboard Bluetooth configuration
-data=ZPRIVATE\101F7989\Bluetooth\corehci_symbian_ti.ini Private\101F7989\Bluetooth\corehci_symbian.ini
-debugport -2
-#else
-data=ZPRIVATE\101F7989\Bluetooth\corehci_symbian.ini Private\101F7989\Bluetooth\corehci_symbian.ini
-#endif
-
-#endif // COREHCI_SYMBIAN_IBY
+// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef COREHCI_SYMBIAN_IBY
+#define COREHCI_SYMBIAN_IBY
+
+REM Symbian CoreHCI reference implementation
+HCI_PLUGIN(corehci_symbian.dll, corehci_symbian.rsc)
+
+#if defined(HCI_TI)
+REM CoreHCI using TI onboard Bluetooth configuration
+data=ZPRIVATE\101F7989\Bluetooth\corehci_symbian_ti.ini Private\101F7989\Bluetooth\corehci_symbian.ini
+debugport -2
+#elif defined(HCI_USB)
+REM CoreHCI using USB Original "H2" Bluetooth configuration
+data=ZPRIVATE\101F7989\Bluetooth\corehci_symbian_usboriginal.ini Private\101F7989\Bluetooth\corehci_symbian.ini
+#else
+data=ZPRIVATE\101F7989\Bluetooth\corehci_symbian.ini Private\101F7989\Bluetooth\corehci_symbian.ini
+#endif
+
+#endif // COREHCI_SYMBIAN_IBY
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/corehcis/symbian/group/corehci_symbian_usboriginal.ini Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,39 @@
+; Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of the License "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+; UIDs for the HCTL and Initialisation plug-ins should be specified below.
+; These UIDs to are found in the implementation_uid field of the .rss file corresponding to the plug-in.
+
+[Plugins]
+;UART TI
+;hctl_uid= 0x102736ED
+
+;UART Original
+;hctl_uid= 0x102056BC
+
+;BCSP
+;hctl_uid= 0x102056BE
+
+;USB Original
+hctl_uid= 0x200345E7
+
+;TI Initialisor
+;initialisation_uid= 0x1027407B
+
+;Symbian Initialisor
+initialisation_uid= 0x1027407D
+
+
+
--- a/bthci/hci2implementations/corehcis/symbian/inc/HciCorePluginImpl.h Wed Oct 13 16:20:29 2010 +0300
+++ b/bthci/hci2implementations/corehcis/symbian/inc/HciCorePluginImpl.h Thu Oct 14 11:16:56 2010 +0100
@@ -1,218 +1,223 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of "Eclipse Public License v1.0"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-/**
- @file
- @internalComponent
-*/
-
-#ifndef HCICOREPLUGINIMPL_H
-#define HCICOREPLUGINIMPL_H
-
-// Includes for parent classes
-#include <bluetooth/hci/corehciplugin.h>
-#include <bluetooth/hci/qdpplugininterfacefinder.h>
-#include <bluetooth/hci/hcicommandallocator.h>
-#include <bluetooth/hci/hcidataframer.h>
-#include <bluetooth/hci/hctldataobserver.h>
-#include <bluetooth/hci/hctleventobserver.h>
-#include <bluetooth/hci/controllerstateobserver.h>
-#include <bluetooth/hci/corehci.h>
-#include <bluetooth/hci/hctlchannelobserver.h>
-#include <bluetooth/hci/hciclientusage.h>
-
-#include <bluetooth/hardresetinitiator.h>
-
-class MHCTLPowerInterface;
-class CHCIServer;
-class CHCTLBase;
-class CControllerInitialisationPlugin;
-class MHCTLInterface;
-class CHciUtil;
-
-/**
-An implementation of the CHCICorePlugin.
-This also directly implements the interfaces it "exports"
-through the CHCICorePlugin::Interface function.
-*/
-class CCoreHCIPluginImpl : public CCoreHCIPlugin,
- public MHardResetInitiator,
- public MQdpPluginInterfaceFinder,
- public MHCICommandAllocator,
- public MHCIDataFramer,
- public MHCTLDataObserver,
- public MHCTLEventObserver,
- public MControllerStateObserver,
- public MCoreHci,
- public MHCTLChannelObserver,
- public MHCIClientUsageCallback
- {
-public:
- static CCoreHCIPluginImpl* NewL();
- virtual TAny* Interface(TUid aUid);
- ~CCoreHCIPluginImpl();
-
- TInt SetPower(TBTPowerState aState, TDesC8* aBuf);
- TInt GetPower(TBTPowerState& aState, TDesC8* aBuf);
-
- void OpenClientReference();
- void CloseClientReference();
-
-private:
- // MHardResetInitiator
- virtual void MhriStartHardReset();
-
- // MHCICommandAllocator
- virtual CHctlCommandFrame* MhcaNewFrameL();
-
- // MHCIDataFramer
- virtual CHctlAclDataFrame* MhdfNewAclDataFrameL(TUint16 aSize);
- virtual void MhdfFormatAclData(CHctlAclDataFrame& aFrame, THCIConnHandle aConnH, TAclPacketBoundaryFlag aBoundaryFlag, TAclPacketBroadcastFlag aBroadcastFlag, const TDesC8& aData);
- virtual CHctlSynchronousDataFrame* MhdfNewSynchronousDataFrameL(TUint8 aSize);
- virtual void MhdfFormatSynchronousData(CHctlSynchronousDataFrame& aFrame, THCIConnHandle aConnH, const TDesC8& aData);
-
- // MHCTLDataObserver
- virtual void MhdoProcessAclData(const TDesC8& aData);
- virtual void MhdoProcessSynchronousData(const TDesC8& aData);
-
- // MHCTLEventObserver
- virtual void MheoProcessEvent(const TDesC8& aEvent);
-
- // MControllerStateObserver
- virtual void McsoProcessPowerChange(TInt aError, TControllerChangeType aChangeType, TBTPowerState aState);
- virtual void McsoProcessHardResetPhaseChange(TInt aError, TControllerChangeType aChangeType, TBTHardResetState aState);
-
- // MQdpPluginInterfaceFinder
- virtual TAny* MqpifQdpPluginInterface(const TUid aUid);
-
- // MCoreHci
- virtual TInt MchSetOption(TUint aName, const TDesC8& aData);
- virtual TInt MchGetOption(TUint aName, TDes8& aData);
- virtual void MchIoctl(TUint aLevel, TUint aName, TDes8* aOption, TAny* aStackSAP);
- virtual void MchCancelIoctl(TUint aLevel, TUint aName, TAny* aStackSAP) ;
- virtual void MchSetHCICommandQueue(MHCICommandQueue& aHCICommandQueue);
- virtual void MchSetPhysicalLinksState(MPhysicalLinksState& aPhysicalLinksState) ;
- virtual void MchSetHardResetInitiator(MHardResetInitiator& aHcHardResetInitiator) ;
- virtual void MchSetDataEventObserver(MHCIDataEventObserver& aHCIDataEventObserver) ;
- virtual void MchSetDataObserver(MHCIDataObserver& aHCIDataObserver) ;
- virtual void MchSetCommandEventObserver(MHCICommandEventObserver& aHCICommandEventObserver) ;
- virtual void MchSetChannelObserver(MHCTLChannelObserver& aHCIChannelObserver) ;
- virtual void MchSetControllerStateObserver(MControllerStateObserver& aHCIPowerStateObserver) ;
- virtual TAny* MchHctlPluginInterface(TUid aUid);
-
- // MHCTLChannelObserver
- virtual void MhcoChannelOpen(THCITransportChannel aChannels);
- virtual void MhcoChannelClosed(THCITransportChannel aChannels);
-
- // MHCIClientUsageCallback
- virtual void MhcucSetClientUsage(MHCIClientUsage& aClientUsage);
-
-private:
- void ConstructL();
-
-private:
- void RequestHardResetFromStack();
-
-private:
- /**
- The instance that will be used to request a hard reset from the stack
- (Stack will call back CoreHci method to actaully perform the hard reset once it has done all the preparations).
- */
- MHardResetInitiator* iStackHardResetRequester;
-
- /**
- The instance that will be pass onto the HCTL a request to perform a hard reset on the host controller.
- */
- MHardResetInitiator* iHCTLHardResetPerformer;
-
- /**
- The instance that will be sent the details of Controller State Events received by the HCI Layer.
- */
- MControllerStateObserver* iControllerStateObserver;
-
- /**
- The instance that will be sent the details of Data Events received by the HCI Layer.
- */
- MHCIDataEventObserver* iDataEventObserver;
-
- /**
- The instance that will be sent the data of Command Events received by the HCI Layer.
- */
- MHCICommandEventObserver* iCommandEventObserver;
-
- /**
- The instance that will be used to communicate with the command queue.
- */
- MHCICommandQueue* iHCICommandQueue;
-
- /**
- The instance that will be used to communicate with the HCTL's power controller.
- */
- MHCTLPowerInterface* iHCTLPowerInterface;
-
- /**
- The instance used to communicate changes in the state of the HCTL channel.
- */
- MHCTLChannelObserver* iHCTLChannelObserver;
-
- /**
- Used to forward user plane data to the stack.
- */
- MHCIDataObserver* iHCIDataObserver;
-
- /**
- Provides access to physical link information from the stack.
- */
- MPhysicalLinksState* iPhysicalLinksState;
-
- /**
- The instance of the HCI server that is used in this implementation
- */
- CHCIServer* iHCIServer;
-
- /**
- The HCTL plugin loaded by this core HCI instance
- */
- CHCTLBase* iHCTLPlugin;
-
- /**
- The initialisation plugin loaded by this core HCI instance
- */
- CControllerInitialisationPlugin* iInitialisationPlugin;
-
- /**
- Used to indicate when an external client is using the HCI
- */
- MHCIClientUsage* iClientUsage;
-
- /**
- HCI Utility Library
- */
- CHciUtil* iHciUtil;
-
- /**
- Size of HCTL header / trailer (octets)
- */
- TUint iHCTLCommandHeaderSize;
- TUint iHCTLCommandTrailerSize;
-
- TUint iHCTLACLHeaderSize;
- TUint iHCTLACLTrailerSize;
-
- TUint iHCTLSyncDataHeaderSize;
- TUint iHCTLSyncDataTrailerSize;
- };
-
-#endif //HCICOREPLUGINIMPL_H
+// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef HCICOREPLUGINIMPL_H
+#define HCICOREPLUGINIMPL_H
+
+// Includes for parent classes
+#include <bluetooth/hci/corehciplugin.h>
+#include <bluetooth/hci/qdpplugininterfacefinder.h>
+#include <bluetooth/hci/hcicommandallocator.h>
+#include <bluetooth/hci/hcidataframer.h>
+#include <bluetooth/hci/hctldataobserver.h>
+#include <bluetooth/hci/hctleventobserver.h>
+#include <bluetooth/hci/controllerstateobserver.h>
+#include <bluetooth/hci/corehci.h>
+#include <bluetooth/hci/hctlchannelobserver.h>
+#include <bluetooth/hci/hciclientusage.h>
+
+#include <bluetooth/hardresetinitiator.h>
+
+class MHCTLPowerInterface;
+class CHCIServer;
+class CHCTLBase;
+class CControllerInitialisationPlugin;
+class MHCTLInterface;
+class CHciUtil;
+
+/**
+An implementation of the CHCICorePlugin.
+This also directly implements the interfaces it "exports"
+through the CHCICorePlugin::Interface function.
+*/
+class CCoreHCIPluginImpl : public CCoreHCIPlugin,
+ public MHardResetInitiator,
+ public MQdpPluginInterfaceFinder,
+ public MHCICommandAllocator,
+ public MHCIDataFramer,
+ public MHCTLDataObserver,
+ public MHCTLEventObserver,
+ public MControllerStateObserver,
+ public MCoreHci,
+ public MHCTLChannelObserver,
+ public MHCIClientUsageCallback
+ {
+public:
+ static CCoreHCIPluginImpl* NewL();
+ virtual TAny* Interface(TUid aUid);
+ ~CCoreHCIPluginImpl();
+
+ TInt SetPower(TBTPowerState aState, TDesC8* aBuf);
+ TInt GetPower(TBTPowerState& aState, TDesC8* aBuf);
+
+ void OpenClientReference();
+ void CloseClientReference();
+
+private:
+ // MHardResetInitiator
+ virtual void MhriStartHardReset();
+
+ // MHCICommandAllocator
+ virtual CHctlCommandFrame* MhcaNewFrameL();
+
+ // MHCIDataFramer
+ virtual CHctlAclDataFrame* MhdfNewAclDataFrameL(TUint16 aSize);
+ virtual void MhdfFormatAclData(CHctlAclDataFrame& aFrame, THCIConnHandle aConnH, TAclPacketBoundaryFlag aBoundaryFlag, TAclPacketBroadcastFlag aBroadcastFlag, const TDesC8& aData);
+ virtual CHctlSynchronousDataFrame* MhdfNewSynchronousDataFrameL(TUint8 aSize);
+ virtual void MhdfFormatSynchronousData(CHctlSynchronousDataFrame& aFrame, THCIConnHandle aConnH, const TDesC8& aData);
+
+ // MHCTLDataObserver
+ virtual void MhdoProcessAclData(const TDesC8& aData);
+ virtual void MhdoProcessSynchronousData(const TDesC8& aData);
+
+ // MHCTLEventObserver
+ virtual void MheoProcessEvent(const TDesC8& aEvent);
+
+ // MControllerStateObserver
+ virtual void McsoProcessPowerChange(TInt aError, TControllerChangeType aChangeType, TBTPowerState aState);
+ virtual void McsoProcessHardResetPhaseChange(TInt aError, TControllerChangeType aChangeType, TBTHardResetState aState);
+
+ // MQdpPluginInterfaceFinder
+ virtual TAny* MqpifQdpPluginInterface(const TUid aUid);
+
+ // MCoreHci
+ virtual TInt MchSetOption(TUint aName, const TDesC8& aData);
+ virtual TInt MchGetOption(TUint aName, TDes8& aData);
+ virtual void MchIoctl(TUint aLevel, TUint aName, TDes8* aOption, TAny* aStackSAP);
+ virtual void MchCancelIoctl(TUint aLevel, TUint aName, TAny* aStackSAP) ;
+ virtual void MchSetHCICommandQueue(MHCICommandQueue& aHCICommandQueue);
+ virtual void MchSetPhysicalLinksState(MPhysicalLinksState& aPhysicalLinksState) ;
+ virtual void MchSetHardResetInitiator(MHardResetInitiator& aHcHardResetInitiator) ;
+ virtual void MchSetDataEventObserver(MHCIDataEventObserver& aHCIDataEventObserver) ;
+ virtual void MchSetDataObserver(MHCIDataObserver& aHCIDataObserver) ;
+ virtual void MchSetCommandEventObserver(MHCICommandEventObserver& aHCICommandEventObserver) ;
+ virtual void MchSetChannelObserver(MHCTLChannelObserver& aHCIChannelObserver) ;
+ virtual void MchSetControllerStateObserver(MControllerStateObserver& aHCIPowerStateObserver) ;
+ virtual TAny* MchHctlPluginInterface(TUid aUid);
+
+ // MHCTLChannelObserver
+ virtual void MhcoChannelOpen(THCITransportChannel aChannels);
+ virtual void MhcoChannelClosed(THCITransportChannel aChannels);
+
+ // MHCIClientUsageCallback
+ virtual void MhcucSetClientUsage(MHCIClientUsage& aClientUsage);
+
+private:
+ void ConstructL();
+
+private:
+ void RequestHardResetFromStack();
+
+private:
+ /**
+ The instance that will be used to request a hard reset from the stack
+ (Stack will call back CoreHci method to actaully perform the hard reset once it has done all the preparations).
+ */
+ MHardResetInitiator* iStackHardResetRequester;
+
+ /**
+ The instance that will be pass onto the HCTL a request to perform a hard reset on the host controller.
+ */
+ MHardResetInitiator* iHCTLHardResetPerformer;
+
+ /**
+ The instance that will be sent the details of Controller State Events received by the HCI Layer.
+ */
+ MControllerStateObserver* iControllerStateObserver;
+
+ /**
+ The instance that will be sent the details of Data Events received by the HCI Layer.
+ */
+ MHCIDataEventObserver* iDataEventObserver;
+
+ /**
+ The instance that will be sent the data of Command Events received by the HCI Layer.
+ */
+ MHCICommandEventObserver* iCommandEventObserver;
+
+ /**
+ The instance that will be used to communicate with the command queue.
+ */
+ MHCICommandQueue* iHCICommandQueue;
+
+ /**
+ The instance that will be used to communicate with the HCTL's power controller.
+ */
+ MHCTLPowerInterface* iHCTLPowerInterface;
+
+ /**
+ The instance used to communicate changes in the state of the HCTL channel.
+ */
+ MHCTLChannelObserver* iHCTLChannelObserver;
+
+ /**
+ Used to keep track of the channel state until an observer is registered.
+ */
+ THCITransportChannel iHCTLChannelState;
+
+ /**
+ Used to forward user plane data to the stack.
+ */
+ MHCIDataObserver* iHCIDataObserver;
+
+ /**
+ Provides access to physical link information from the stack.
+ */
+ MPhysicalLinksState* iPhysicalLinksState;
+
+ /**
+ The instance of the HCI server that is used in this implementation
+ */
+ CHCIServer* iHCIServer;
+
+ /**
+ The HCTL plugin loaded by this core HCI instance
+ */
+ CHCTLBase* iHCTLPlugin;
+
+ /**
+ The initialisation plugin loaded by this core HCI instance
+ */
+ CControllerInitialisationPlugin* iInitialisationPlugin;
+
+ /**
+ Used to indicate when an external client is using the HCI
+ */
+ MHCIClientUsage* iClientUsage;
+
+ /**
+ HCI Utility Library
+ */
+ CHciUtil* iHciUtil;
+
+ /**
+ Size of HCTL header / trailer (octets)
+ */
+ TUint iHCTLCommandHeaderSize;
+ TUint iHCTLCommandTrailerSize;
+
+ TUint iHCTLACLHeaderSize;
+ TUint iHCTLACLTrailerSize;
+
+ TUint iHCTLSyncDataHeaderSize;
+ TUint iHCTLSyncDataTrailerSize;
+ };
+
+#endif //HCICOREPLUGINIMPL_H
--- a/bthci/hci2implementations/corehcis/symbian/src/HciCorePluginImpl.cpp Wed Oct 13 16:20:29 2010 +0300
+++ b/bthci/hci2implementations/corehcis/symbian/src/HciCorePluginImpl.cpp Thu Oct 14 11:16:56 2010 +0100
@@ -1,516 +1,529 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of "Eclipse Public License v1.0"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-/**
- @file
- @internalComponent
-*/
-
-#include "HciCorePluginImpl.h"
-#include "hciserver.h"
-#include "hciserverrequestmgr.h"
-#include "corehciutil.h"
-
-#include <bluetooth/hci/hctlbase.h>
-#include <bluetooth/hci/hctlinterface.h>
-#include <bluetooth/hci/controllerinitialisationplugin.h>
-#include <bluetooth/hci/controllerinitialisationinterface.h>
-#include <bluetooth/hci/hctlpowerinterface.h>
-#include <bluetooth/hci/hciframe.h>
-#include <bluetooth/hci/aclpacketconsts.h>
-#include <bluetooth/hci/hcidataobserver.h>
-#include <bluetooth/hci/hciutil.h>
-#include <bluetooth/hci/hciipc.h>
-#include <bluetooth/hci/event.h>
-
-#include <bluetooth/hcicommandqueue.h>
-#include <bluetooth/logger.h>
-
-#ifdef __FLOG_ACTIVE
-_LIT8(KLogComponent, LOG_COMPONENT_COREHCI_SYMBIAN);
-#endif
-
-_LIT(KHciUtilComponentName, "corehci_symbian");
-
-/*static*/ CCoreHCIPluginImpl* CCoreHCIPluginImpl::NewL()
- {
- LOG_STATIC_FUNC
-
- CCoreHCIPluginImpl* p = new(ELeave) CCoreHCIPluginImpl;
- CleanupStack::PushL(p);
- p->ConstructL();
- CleanupStack::Pop();
- return p;
- }
-
-void CCoreHCIPluginImpl::ConstructL()
-/*
-Start up the HCTL plugin, then the initialisation plugin, as per the information
-in section 2.3 of PREQ750_Improvements document.
-*/
- {
- LOG_FUNC
-
- // Create HCI Utility library
- iHciUtil = CHciUtil::NewL(KHciUtilComponentName);
-
- // If we can't open the ini file then this will be treated in the same way
- // as not reading a valid UID from the ini file.
- TRAP_IGNORE(iHciUtil->OpenIniFileL());
-
- // Create Core HCI plugin
- _LIT(KSection, "Plugins");
- _LIT(KHCTLUid, "hctl_uid");
-
- TUid hctlImplUid = TUid::Null();
- TRAPD(err, hctlImplUid = iHciUtil->GetUidFromFileL(KSection, KHCTLUid));
-
- if (err == KErrNone)
- {
- // Valid UID found, load it
- iHCTLPlugin = CHCTLBase::NewL(hctlImplUid);
- }
- else
- {
- // No UID found in ini file, attempt to load single instance of
- // implementation
- iHCTLPlugin = CHCTLBase::NewL();
- }
-
- // Add this as the event observer.
- MHCTLInterface* hctl = static_cast<MHCTLInterface*>(iHCTLPlugin->Interface(TUid::Uid(KHCTLInterfaceUid)));
- __ASSERT_ALWAYS(hctl, PANIC(KCoreHciPanicCat, EUninitialisedInterface));
-
- iHCTLHardResetPerformer = static_cast<MHardResetInitiator*>(iHCTLPlugin->Interface(TUid::Uid(KHCHardResetUid)));
- __ASSERT_ALWAYS(iHCTLHardResetPerformer, PANIC(KCoreHciPanicCat, EUninitialisedInterface));
-
- // Setup observers on the HCTL.
- hctl->MhiSetEventObserver(*this);
- hctl->MhiSetChannelObserver(*this);
- hctl->MhiSetDataObserver(*this);
- hctl->MhiSetControllerStateObserver(*this);
-
- // Create the initialisor. The initialisor is optional so don't worry if
- // we can't load it.
- _LIT(KInitialisorUid, "initialisation_uid");
-
- TUid initImplUid = TUid::Null();
- TRAP(err, initImplUid = iHciUtil->GetUidFromFileL(KSection, KInitialisorUid));
-
- if (err == KErrNone)
- {
- // Valid UID found, load it
- iInitialisationPlugin = CControllerInitialisationPlugin::NewL(initImplUid);
- }
- else
- {
- // No UID found in ini file, attempt to load single instance of
- // implementation
- TRAP_IGNORE(iInitialisationPlugin = CControllerInitialisationPlugin::NewL());
- }
-
- if(iInitialisationPlugin)
- {
- MControllerInitialisationInterface* initialisor =
- static_cast<MControllerInitialisationInterface*>
- (iInitialisationPlugin->Interface(TUid::Uid(KControllerInitialisationInterfaceUid)));
-
- __ASSERT_ALWAYS(initialisor, PANIC(KCoreHciPanicCat, EUninitialisedInterface));
-
- initialisor->MciiSetCoreHci(*this);
- }
-
- iHCIServer = CHCIServer::NewL(*this);
-
- // The power interface is not required so iHCTLPowerInterface can be NULL after
- // the following call. Check for NULL before using iHCTLPowerInterface elsewhere.
- iHCTLPowerInterface = static_cast<MHCTLPowerInterface*>(iHCTLPlugin->Interface(TUid::Uid(KHCTLPowerInterfaceUid)));
-
- // Get the HCTL specific frame header and trailer octet sizes.
- hctl->MhiGetCommandTransportOverhead(iHCTLCommandHeaderSize, iHCTLCommandTrailerSize);
- hctl->MhiGetAclDataTransportOverhead(iHCTLACLHeaderSize, iHCTLACLTrailerSize);
- hctl->MhiGetSynchronousDataTransportOverhead(iHCTLSyncDataHeaderSize, iHCTLSyncDataTrailerSize);
- }
-
-CCoreHCIPluginImpl::~CCoreHCIPluginImpl()
- {
- LOG_FUNC
-
- //delete in the order given in section 2.4 of PREQ750_Improvements document
- delete iInitialisationPlugin;
- delete iHCTLPlugin;
- delete iHCIServer;
- delete iHciUtil;
- }
-
-//Request hard reset from the stack - stack will do all the required preparation - such as notify QDP and so on, and call us back via MHardResetInitiator interface
-void CCoreHCIPluginImpl::RequestHardResetFromStack()
- {
- LOG_FUNC
- __ASSERT_ALWAYS(iStackHardResetRequester, PANIC(KCoreHciPanicCat, EUninitialisedInterface));
- iStackHardResetRequester->MhriStartHardReset();
- }
-
-// Set Power received from the HCI server
-TInt CCoreHCIPluginImpl::SetPower(TBTPowerState aState, TDesC8* /*aBuf*/)
- {
- LOG_FUNC
-
- if(iHCTLPowerInterface)
- {
- return iHCTLPowerInterface->MhpiSetPower(aState);
- }
- else
- {
- return KErrNotSupported;
- }
- }
-
-// Get Power received from the HCI server
-TInt CCoreHCIPluginImpl::GetPower(TBTPowerState& aState, TDesC8* /*aBuf*/)
- {
- LOG_FUNC
-
- if(iHCTLPowerInterface)
- {
- return iHCTLPowerInterface->MhpiGetPower(aState);
- }
- else
- {
- return KErrNotSupported;
- }
- }
-
-TAny* CCoreHCIPluginImpl::Interface(TUid aUid)
- {
- LOG_FUNC
-
- TAny* ret = NULL;
-
- switch(aUid.iUid)
- {
- case KCoreHciInterfaceUid:
- {
- ret = reinterpret_cast<TAny*>(static_cast<MCoreHci*>(this));
- break;
- }
-
- case KHCIDataFramerInterfaceUid:
- {
- ret = reinterpret_cast<TAny*>(static_cast<MHCIDataFramer*>(this));
- break;
- }
-
- case KHCICommandAllocatorInterfaceUid:
- {
- ret = reinterpret_cast<TAny*>(static_cast<MHCICommandAllocator*>(this));
- break;
- }
-
- case KHCHardResetUid:
- {
- ret = reinterpret_cast<TAny*>(static_cast<MHardResetInitiator*>(this));
- break;
- }
-
- case KHCTLInterfaceUid:
- {
- ret = iHCTLPlugin->Interface(aUid);
- break;
- }
-
- case KControllerInitialisationInterfaceUid:
- {
- if (iInitialisationPlugin != NULL)
- {
- ret = iInitialisationPlugin->Interface(aUid);
- }
- break;
- }
-
- case KHCIClientUsageCallbackUid:
- {
- ret = reinterpret_cast<TAny*>(static_cast<MHCIClientUsageCallback*>(this));
- break;
- }
-
- default:
- break;
- }
-
- return ret;
- }
-
-void CCoreHCIPluginImpl::MhriStartHardReset()
- {
- LOG_FUNC
-
- iHCTLHardResetPerformer->MhriStartHardReset();
- }
-
-CHctlCommandFrame* CCoreHCIPluginImpl::MhcaNewFrameL()
- {
- LOG_FUNC
-
- return (CHctlCommandFrame::NewL(iHCTLCommandHeaderSize, iHCTLCommandTrailerSize));
- }
-
-
-CHctlAclDataFrame* CCoreHCIPluginImpl::MhdfNewAclDataFrameL(TUint16 aSize)
- {
- LOG_FUNC
-
- return CHctlAclDataFrame::NewL(aSize, iHCTLACLHeaderSize, iHCTLACLTrailerSize);
- }
-
-CHctlSynchronousDataFrame* CCoreHCIPluginImpl::MhdfNewSynchronousDataFrameL(TUint8 aSize)
- {
- LOG_FUNC
-
- return CHctlSynchronousDataFrame::NewL(aSize, iHCTLSyncDataHeaderSize, iHCTLSyncDataTrailerSize);
- }
-
-/*virtual*/ void CCoreHCIPluginImpl::MhdfFormatAclData(CHctlAclDataFrame& aFrame, THCIConnHandle aConnH,
- TAclPacketBoundaryFlag aBoundaryFlag, TAclPacketBroadcastFlag aBroadcastFlag,
- const TDesC8& aData)
- {
- LOG_FUNC
-
- THCIConnHandle handle = aConnH;
-
- if(aBroadcastFlag != EPointToPointOnly)
- {
- handle = 0xbca; //TODO KHCIBroadcastHandle;
- }
-
- aFrame.SetConnectionHandle(handle);
- aFrame.SetFlags(aBoundaryFlag, aBroadcastFlag);
- aFrame.SetDataPayload(aData); // also sets DataLength
- }
-
-void CCoreHCIPluginImpl::MhdfFormatSynchronousData(CHctlSynchronousDataFrame& aFrame,
- THCIConnHandle aConnH, const TDesC8& aData)
- {
- LOG_FUNC
-
- THCIConnHandle handle = aConnH;
- aFrame.SetConnectionHandle(handle);
- aFrame.SetDataPayload(aData); // also sets DataLength
- }
-
-void CCoreHCIPluginImpl::MhdoProcessAclData(const TDesC8& aData)
- {
- LOG_FUNC
-
- TAclPacketBoundaryFlag pbFlag = CHctlAclDataFrame::PacketBoundaryFlag(aData);
- TAclPacketBroadcastFlag bcFlag = CHctlAclDataFrame::PacketBroadcastFlag(aData);
- THCIConnHandle handle = CHctlDataFrameBase::ConnectionHandle(aData);
- iHCIDataObserver->MhdoProcessAclData(handle, pbFlag, bcFlag,
- aData.Right(aData.Length() - CHctlAclDataFrame::KHCIACLDataPacketHeaderLength));
- }
-
-void CCoreHCIPluginImpl::MhdoProcessSynchronousData(const TDesC8& aData)
- {
- LOG_FUNC
-
- THCIConnHandle handle = CHctlDataFrameBase::ConnectionHandle(aData);
- iHCIDataObserver->MhdoProcessSynchronousData(handle, 0,
- aData.Right(aData.Length() - CHctlSynchronousDataFrame::KHCISynchronousDataPacketHeaderLength));
- }
-
-void CCoreHCIPluginImpl::MheoProcessEvent(const TDesC8& aEvent)
- {
- LOG_FUNC
-
- if (THCIEventBase::CreateAndSendEvent(aEvent, *iCommandEventObserver, *iDataEventObserver) != KErrNone)
- {
- // If we got an error processing the event, reset the controller
- RequestHardResetFromStack();
- }
- }
-
-void CCoreHCIPluginImpl::McsoProcessPowerChange(TInt aError, TControllerChangeType aChangeType,
- TBTPowerState aState)
- {
- LOG_FUNC
-
- iHCIServer->PowerControlManager().CompleteRequest(aError);
- iControllerStateObserver->McsoProcessPowerChange(aError, aChangeType, aState); //pass on up
- }
-
-void CCoreHCIPluginImpl::McsoProcessHardResetPhaseChange(TInt aError, TControllerChangeType aChangeType,
- TBTHardResetState aState)
- {
- LOG_FUNC
-
- iControllerStateObserver->McsoProcessHardResetPhaseChange(aError, aChangeType, aState); //pass on up
- }
-
-TAny* CCoreHCIPluginImpl::MqpifQdpPluginInterface(const TUid aUid)
- {
- LOG_FUNC
-
- if(iHCICommandQueue)
- {
- return (iHCICommandQueue->MhcqQdpPluginInterface(aUid));
- }
-
- return NULL;
- }
-
-TInt CCoreHCIPluginImpl::MchSetOption(TUint /*aName*/, const TDesC8& /*aData*/)
- {
- LOG_FUNC
-
- return KErrNotSupported;
- }
-
-TInt CCoreHCIPluginImpl::MchGetOption(TUint /*aName*/, TDes8& /*aData*/)
- {
- LOG_FUNC
-
- return KErrNotSupported;
- }
-
-void CCoreHCIPluginImpl::MchIoctl(TUint /*aLevel*/,TUint /*aName*/, TDes8* /*aOption*/, TAny* /*aStackSAP*/)
- {
- LOG_FUNC
- }
-
-void CCoreHCIPluginImpl::MchCancelIoctl(TUint /*aLevel*/,TUint /*aName*/, TAny* /*aStackSAP*/)
- {
- LOG_FUNC
- }
-
-void CCoreHCIPluginImpl::MchSetHCICommandQueue(MHCICommandQueue& aHCICommandQueue)
- {
- LOG_FUNC
- __ASSERT_DEBUG(!iHCICommandQueue, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
-
- iHCICommandQueue = &aHCICommandQueue;
- iHCIServer->DirectAccessManager().SetHCICommandQueue(*iHCICommandQueue);
- }
-
-void CCoreHCIPluginImpl::MchSetPhysicalLinksState(MPhysicalLinksState& aPhysicalLinksState)
- {
- LOG_FUNC
- __ASSERT_DEBUG(!iPhysicalLinksState, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
-
- iPhysicalLinksState = &aPhysicalLinksState;
- }
-
-void CCoreHCIPluginImpl::MchSetHardResetInitiator(MHardResetInitiator& aHardResetInitiator)
- {
- LOG_FUNC
- __ASSERT_DEBUG(!iStackHardResetRequester, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
-
- iStackHardResetRequester = &aHardResetInitiator;
- }
-
-void CCoreHCIPluginImpl::MchSetDataEventObserver(MHCIDataEventObserver& aHCIDataEventObserver)
- {
- LOG_FUNC
- __ASSERT_DEBUG(!iDataEventObserver, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
-
- iDataEventObserver = &aHCIDataEventObserver;
- }
-
-void CCoreHCIPluginImpl::MchSetDataObserver(MHCIDataObserver& aHCIDataObserver)
- {
- LOG_FUNC
- __ASSERT_DEBUG(!iHCIDataObserver, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
-
- iHCIDataObserver = &aHCIDataObserver;
- }
-
-void CCoreHCIPluginImpl::MchSetCommandEventObserver(MHCICommandEventObserver& aHCICommandEventObserver)
- {
- LOG_FUNC
- __ASSERT_DEBUG(!iCommandEventObserver, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
-
- iCommandEventObserver = &aHCICommandEventObserver;
- }
-
-void CCoreHCIPluginImpl::MchSetChannelObserver(MHCTLChannelObserver& aHCIChannelObserver)
- {
- LOG_FUNC
- __ASSERT_DEBUG(!iHCTLChannelObserver, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
-
- iHCTLChannelObserver = &aHCIChannelObserver;
- }
-
-void CCoreHCIPluginImpl::MchSetControllerStateObserver(MControllerStateObserver& aControllerStateObserver)
- {
- LOG_FUNC
- __ASSERT_DEBUG(!iControllerStateObserver, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
-
- iControllerStateObserver = &aControllerStateObserver;
- }
-
-TAny* CCoreHCIPluginImpl::MchHctlPluginInterface(const TUid aUid)
- {
- LOG_FUNC
-
- return iHCTLPlugin->Interface(aUid);
- }
-
-void CCoreHCIPluginImpl::MhcoChannelOpen(THCITransportChannel aChannels)
- {
- LOG_FUNC
-
- // Just pass on to the upper HCLT channel observer.
- iHCTLChannelObserver->MhcoChannelOpen(aChannels);
- }
-
-void CCoreHCIPluginImpl::MhcoChannelClosed(THCITransportChannel aChannels)
- {
- LOG_FUNC
-
- // Just pass on to the upper HCTL channel observer.
- iHCTLChannelObserver->MhcoChannelClosed(aChannels);
- }
-
-void CCoreHCIPluginImpl::MhcucSetClientUsage(MHCIClientUsage& aClientUsage)
- {
- LOG_FUNC
- __ASSERT_DEBUG(!iClientUsage, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
-
- iClientUsage = &aClientUsage;
- }
-
-void CCoreHCIPluginImpl::OpenClientReference()
- {
- LOG_FUNC
- __ASSERT_DEBUG(iClientUsage, PANIC(KCoreHciPanicCat, EUninitialisedInterface));
-
- if (iClientUsage)
- {
- iClientUsage->MhcuOpenClientReference();
- }
- }
-
-void CCoreHCIPluginImpl::CloseClientReference()
- {
- LOG_FUNC
- __ASSERT_DEBUG(iClientUsage, PANIC(KCoreHciPanicCat, EUninitialisedInterface));
-
- if (iClientUsage)
- {
- iClientUsage->MhcuCloseClientReference();
- }
- }
-
-// EOF
-
+// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "HciCorePluginImpl.h"
+#include "hciserver.h"
+#include "hciserverrequestmgr.h"
+#include "corehciutil.h"
+
+#include <bluetooth/hci/hctlbase.h>
+#include <bluetooth/hci/hctlinterface.h>
+#include <bluetooth/hci/controllerinitialisationplugin.h>
+#include <bluetooth/hci/controllerinitialisationinterface.h>
+#include <bluetooth/hci/hctlpowerinterface.h>
+#include <bluetooth/hci/hciframe.h>
+#include <bluetooth/hci/aclpacketconsts.h>
+#include <bluetooth/hci/hcidataobserver.h>
+#include <bluetooth/hci/hciutil.h>
+#include <bluetooth/hci/hciipc.h>
+#include <bluetooth/hci/event.h>
+
+#include <bluetooth/hcicommandqueue.h>
+#include <bluetooth/logger.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, LOG_COMPONENT_COREHCI_SYMBIAN);
+#endif
+
+_LIT(KHciUtilComponentName, "corehci_symbian");
+
+/*static*/ CCoreHCIPluginImpl* CCoreHCIPluginImpl::NewL()
+ {
+ LOG_STATIC_FUNC
+
+ CCoreHCIPluginImpl* p = new(ELeave) CCoreHCIPluginImpl;
+ CleanupStack::PushL(p);
+ p->ConstructL();
+ CleanupStack::Pop();
+ return p;
+ }
+
+void CCoreHCIPluginImpl::ConstructL()
+/*
+Start up the HCTL plugin, then the initialisation plugin.
+*/
+ {
+ LOG_FUNC
+
+ // Create HCI Utility library
+ iHciUtil = CHciUtil::NewL(KHciUtilComponentName);
+
+ // If we can't open the ini file then this will be treated in the same way
+ // as not reading a valid UID from the ini file.
+ TRAP_IGNORE(iHciUtil->OpenIniFileL());
+
+ // Create Core HCI plugin
+ _LIT(KSection, "Plugins");
+ _LIT(KHCTLUid, "hctl_uid");
+
+ TUid hctlImplUid = TUid::Null();
+ TRAPD(err, hctlImplUid = iHciUtil->GetUidFromFileL(KSection, KHCTLUid));
+
+ if (err == KErrNone)
+ {
+ // Valid UID found, load it
+ iHCTLPlugin = CHCTLBase::NewL(hctlImplUid);
+ }
+ else
+ {
+ // No UID found in ini file, attempt to load single instance of
+ // implementation
+ iHCTLPlugin = CHCTLBase::NewL();
+ }
+
+ // Add this as the event observer.
+ MHCTLInterface* hctl = static_cast<MHCTLInterface*>(iHCTLPlugin->Interface(TUid::Uid(KHCTLInterfaceUid)));
+ __ASSERT_ALWAYS(hctl, PANIC(KCoreHciPanicCat, EUninitialisedInterface));
+
+ iHCTLHardResetPerformer = static_cast<MHardResetInitiator*>(iHCTLPlugin->Interface(TUid::Uid(KHCHardResetUid)));
+ __ASSERT_ALWAYS(iHCTLHardResetPerformer, PANIC(KCoreHciPanicCat, EUninitialisedInterface));
+
+ // Setup observers on the HCTL.
+ hctl->MhiSetEventObserver(*this);
+ hctl->MhiSetChannelObserver(*this);
+ hctl->MhiSetDataObserver(*this);
+ hctl->MhiSetControllerStateObserver(*this);
+
+ // Create the initialisor. The initialisor is optional so don't worry if
+ // we can't load it.
+ _LIT(KInitialisorUid, "initialisation_uid");
+
+ TUid initImplUid = TUid::Null();
+ TRAP(err, initImplUid = iHciUtil->GetUidFromFileL(KSection, KInitialisorUid));
+
+ if (err == KErrNone)
+ {
+ // Valid UID found, load it
+ iInitialisationPlugin = CControllerInitialisationPlugin::NewL(initImplUid);
+ }
+ else
+ {
+ // No UID found in ini file, attempt to load single instance of
+ // implementation
+ TRAP_IGNORE(iInitialisationPlugin = CControllerInitialisationPlugin::NewL());
+ }
+
+ if(iInitialisationPlugin)
+ {
+ MControllerInitialisationInterface* initialisor =
+ static_cast<MControllerInitialisationInterface*>
+ (iInitialisationPlugin->Interface(TUid::Uid(KControllerInitialisationInterfaceUid)));
+
+ __ASSERT_ALWAYS(initialisor, PANIC(KCoreHciPanicCat, EUninitialisedInterface));
+
+ initialisor->MciiSetCoreHci(*this);
+ }
+
+ iHCIServer = CHCIServer::NewL(*this);
+
+ // The power interface is not required so iHCTLPowerInterface can be NULL after
+ // the following call. Check for NULL before using iHCTLPowerInterface elsewhere.
+ iHCTLPowerInterface = static_cast<MHCTLPowerInterface*>(iHCTLPlugin->Interface(TUid::Uid(KHCTLPowerInterfaceUid)));
+
+ // Get the HCTL specific frame header and trailer octet sizes.
+ hctl->MhiGetCommandTransportOverhead(iHCTLCommandHeaderSize, iHCTLCommandTrailerSize);
+ hctl->MhiGetAclDataTransportOverhead(iHCTLACLHeaderSize, iHCTLACLTrailerSize);
+ hctl->MhiGetSynchronousDataTransportOverhead(iHCTLSyncDataHeaderSize, iHCTLSyncDataTrailerSize);
+ }
+
+CCoreHCIPluginImpl::~CCoreHCIPluginImpl()
+ {
+ LOG_FUNC
+
+ //delete in the correct order
+ delete iInitialisationPlugin;
+ delete iHCTLPlugin;
+ delete iHCIServer;
+ delete iHciUtil;
+ }
+
+//Request hard reset from the stack - stack will do all the required preparation - such as notify QDP and so on, and call us back via MHardResetInitiator interface
+void CCoreHCIPluginImpl::RequestHardResetFromStack()
+ {
+ LOG_FUNC
+ __ASSERT_ALWAYS(iStackHardResetRequester, PANIC(KCoreHciPanicCat, EUninitialisedInterface));
+ iStackHardResetRequester->MhriStartHardReset();
+ }
+
+// Set Power received from the HCI server
+TInt CCoreHCIPluginImpl::SetPower(TBTPowerState aState, TDesC8* /*aBuf*/)
+ {
+ LOG_FUNC
+
+ if(iHCTLPowerInterface)
+ {
+ return iHCTLPowerInterface->MhpiSetPower(aState);
+ }
+ else
+ {
+ return KErrNotSupported;
+ }
+ }
+
+// Get Power received from the HCI server
+TInt CCoreHCIPluginImpl::GetPower(TBTPowerState& aState, TDesC8* /*aBuf*/)
+ {
+ LOG_FUNC
+
+ if(iHCTLPowerInterface)
+ {
+ return iHCTLPowerInterface->MhpiGetPower(aState);
+ }
+ else
+ {
+ return KErrNotSupported;
+ }
+ }
+
+TAny* CCoreHCIPluginImpl::Interface(TUid aUid)
+ {
+ LOG_FUNC
+
+ TAny* ret = NULL;
+
+ switch(aUid.iUid)
+ {
+ case KCoreHciInterfaceUid:
+ {
+ ret = reinterpret_cast<TAny*>(static_cast<MCoreHci*>(this));
+ break;
+ }
+
+ case KHCIDataFramerInterfaceUid:
+ {
+ ret = reinterpret_cast<TAny*>(static_cast<MHCIDataFramer*>(this));
+ break;
+ }
+
+ case KHCICommandAllocatorInterfaceUid:
+ {
+ ret = reinterpret_cast<TAny*>(static_cast<MHCICommandAllocator*>(this));
+ break;
+ }
+
+ case KHCHardResetUid:
+ {
+ ret = reinterpret_cast<TAny*>(static_cast<MHardResetInitiator*>(this));
+ break;
+ }
+
+ case KHCTLInterfaceUid:
+ {
+ ret = iHCTLPlugin->Interface(aUid);
+ break;
+ }
+
+ case KControllerInitialisationInterfaceUid:
+ {
+ if (iInitialisationPlugin != NULL)
+ {
+ ret = iInitialisationPlugin->Interface(aUid);
+ }
+ break;
+ }
+
+ case KHCIClientUsageCallbackUid:
+ {
+ ret = reinterpret_cast<TAny*>(static_cast<MHCIClientUsageCallback*>(this));
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return ret;
+ }
+
+void CCoreHCIPluginImpl::MhriStartHardReset()
+ {
+ LOG_FUNC
+
+ iHCTLHardResetPerformer->MhriStartHardReset();
+ }
+
+CHctlCommandFrame* CCoreHCIPluginImpl::MhcaNewFrameL()
+ {
+ LOG_FUNC
+
+ return (CHctlCommandFrame::NewL(iHCTLCommandHeaderSize, iHCTLCommandTrailerSize));
+ }
+
+
+CHctlAclDataFrame* CCoreHCIPluginImpl::MhdfNewAclDataFrameL(TUint16 aSize)
+ {
+ LOG_FUNC
+
+ return CHctlAclDataFrame::NewL(aSize, iHCTLACLHeaderSize, iHCTLACLTrailerSize);
+ }
+
+CHctlSynchronousDataFrame* CCoreHCIPluginImpl::MhdfNewSynchronousDataFrameL(TUint8 aSize)
+ {
+ LOG_FUNC
+
+ return CHctlSynchronousDataFrame::NewL(aSize, iHCTLSyncDataHeaderSize, iHCTLSyncDataTrailerSize);
+ }
+
+/*virtual*/ void CCoreHCIPluginImpl::MhdfFormatAclData(CHctlAclDataFrame& aFrame, THCIConnHandle aConnH,
+ TAclPacketBoundaryFlag aBoundaryFlag, TAclPacketBroadcastFlag aBroadcastFlag,
+ const TDesC8& aData)
+ {
+ LOG_FUNC
+
+ THCIConnHandle handle = aConnH;
+
+ if(aBroadcastFlag != EPointToPointOnly)
+ {
+ handle = 0xbca; //TODO KHCIBroadcastHandle;
+ }
+
+ aFrame.SetConnectionHandle(handle);
+ aFrame.SetFlags(aBoundaryFlag, aBroadcastFlag);
+ aFrame.SetDataPayload(aData); // also sets DataLength
+ }
+
+void CCoreHCIPluginImpl::MhdfFormatSynchronousData(CHctlSynchronousDataFrame& aFrame,
+ THCIConnHandle aConnH, const TDesC8& aData)
+ {
+ LOG_FUNC
+
+ THCIConnHandle handle = aConnH;
+ aFrame.SetConnectionHandle(handle);
+ aFrame.SetDataPayload(aData); // also sets DataLength
+ }
+
+void CCoreHCIPluginImpl::MhdoProcessAclData(const TDesC8& aData)
+ {
+ LOG_FUNC
+
+ TAclPacketBoundaryFlag pbFlag = CHctlAclDataFrame::PacketBoundaryFlag(aData);
+ TAclPacketBroadcastFlag bcFlag = CHctlAclDataFrame::PacketBroadcastFlag(aData);
+ THCIConnHandle handle = CHctlDataFrameBase::ConnectionHandle(aData);
+ iHCIDataObserver->MhdoProcessAclData(handle, pbFlag, bcFlag,
+ aData.Right(aData.Length() - CHctlAclDataFrame::KHCIACLDataPacketHeaderLength));
+ }
+
+void CCoreHCIPluginImpl::MhdoProcessSynchronousData(const TDesC8& aData)
+ {
+ LOG_FUNC
+
+ THCIConnHandle handle = CHctlDataFrameBase::ConnectionHandle(aData);
+ iHCIDataObserver->MhdoProcessSynchronousData(handle, 0,
+ aData.Right(aData.Length() - CHctlSynchronousDataFrame::KHCISynchronousDataPacketHeaderLength));
+ }
+
+void CCoreHCIPluginImpl::MheoProcessEvent(const TDesC8& aEvent)
+ {
+ LOG_FUNC
+
+ if (THCIEventBase::CreateAndSendEvent(aEvent, *iCommandEventObserver, *iDataEventObserver) != KErrNone)
+ {
+ // If we got an error processing the event, reset the controller
+ RequestHardResetFromStack();
+ }
+ }
+
+void CCoreHCIPluginImpl::McsoProcessPowerChange(TInt aError, TControllerChangeType aChangeType,
+ TBTPowerState aState)
+ {
+ LOG_FUNC
+
+ iHCIServer->PowerControlManager().CompleteRequest(aError);
+ iControllerStateObserver->McsoProcessPowerChange(aError, aChangeType, aState); //pass on up
+ }
+
+void CCoreHCIPluginImpl::McsoProcessHardResetPhaseChange(TInt aError, TControllerChangeType aChangeType,
+ TBTHardResetState aState)
+ {
+ LOG_FUNC
+
+ iControllerStateObserver->McsoProcessHardResetPhaseChange(aError, aChangeType, aState); //pass on up
+ }
+
+TAny* CCoreHCIPluginImpl::MqpifQdpPluginInterface(const TUid aUid)
+ {
+ LOG_FUNC
+
+ if(iHCICommandQueue)
+ {
+ return (iHCICommandQueue->MhcqQdpPluginInterface(aUid));
+ }
+
+ return NULL;
+ }
+
+TInt CCoreHCIPluginImpl::MchSetOption(TUint /*aName*/, const TDesC8& /*aData*/)
+ {
+ LOG_FUNC
+
+ return KErrNotSupported;
+ }
+
+TInt CCoreHCIPluginImpl::MchGetOption(TUint /*aName*/, TDes8& /*aData*/)
+ {
+ LOG_FUNC
+
+ return KErrNotSupported;
+ }
+
+void CCoreHCIPluginImpl::MchIoctl(TUint /*aLevel*/,TUint /*aName*/, TDes8* /*aOption*/, TAny* /*aStackSAP*/)
+ {
+ LOG_FUNC
+ }
+
+void CCoreHCIPluginImpl::MchCancelIoctl(TUint /*aLevel*/,TUint /*aName*/, TAny* /*aStackSAP*/)
+ {
+ LOG_FUNC
+ }
+
+void CCoreHCIPluginImpl::MchSetHCICommandQueue(MHCICommandQueue& aHCICommandQueue)
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(!iHCICommandQueue, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
+
+ iHCICommandQueue = &aHCICommandQueue;
+ iHCIServer->DirectAccessManager().SetHCICommandQueue(*iHCICommandQueue);
+ }
+
+void CCoreHCIPluginImpl::MchSetPhysicalLinksState(MPhysicalLinksState& aPhysicalLinksState)
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(!iPhysicalLinksState, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
+
+ iPhysicalLinksState = &aPhysicalLinksState;
+ }
+
+void CCoreHCIPluginImpl::MchSetHardResetInitiator(MHardResetInitiator& aHardResetInitiator)
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(!iStackHardResetRequester, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
+
+ iStackHardResetRequester = &aHardResetInitiator;
+ }
+
+void CCoreHCIPluginImpl::MchSetDataEventObserver(MHCIDataEventObserver& aHCIDataEventObserver)
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(!iDataEventObserver, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
+
+ iDataEventObserver = &aHCIDataEventObserver;
+ }
+
+void CCoreHCIPluginImpl::MchSetDataObserver(MHCIDataObserver& aHCIDataObserver)
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(!iHCIDataObserver, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
+
+ iHCIDataObserver = &aHCIDataObserver;
+ }
+
+void CCoreHCIPluginImpl::MchSetCommandEventObserver(MHCICommandEventObserver& aHCICommandEventObserver)
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(!iCommandEventObserver, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
+
+ iCommandEventObserver = &aHCICommandEventObserver;
+ }
+
+void CCoreHCIPluginImpl::MchSetChannelObserver(MHCTLChannelObserver& aHCIChannelObserver)
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(!iHCTLChannelObserver, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
+
+ iHCTLChannelObserver = &aHCIChannelObserver;
+ // Inform observer of current state (if one is ready).
+ if(iHCTLChannelState)
+ {
+ iHCTLChannelObserver->MhcoChannelOpen(iHCTLChannelState);
+ }
+ }
+
+void CCoreHCIPluginImpl::MchSetControllerStateObserver(MControllerStateObserver& aControllerStateObserver)
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(!iControllerStateObserver, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
+
+ iControllerStateObserver = &aControllerStateObserver;
+ }
+
+TAny* CCoreHCIPluginImpl::MchHctlPluginInterface(const TUid aUid)
+ {
+ LOG_FUNC
+
+ return iHCTLPlugin->Interface(aUid);
+ }
+
+void CCoreHCIPluginImpl::MhcoChannelOpen(THCITransportChannel aChannels)
+ {
+ LOG_FUNC
+
+ iHCTLChannelState |= aChannels;
+ LOG1(_L("\tiHCTLChannelObserver = 0x%08x"), iHCTLChannelObserver)
+ if(iHCTLChannelObserver)
+ {
+ iHCTLChannelObserver->MhcoChannelOpen(aChannels);
+ }
+
+ }
+
+void CCoreHCIPluginImpl::MhcoChannelClosed(THCITransportChannel aChannels)
+ {
+ LOG_FUNC
+
+ iHCTLChannelState &= ~aChannels;
+ LOG1(_L("\tiHCTLChannelObserver = 0x%08x"), iHCTLChannelObserver)
+ if(iHCTLChannelObserver)
+ {
+ iHCTLChannelObserver->MhcoChannelClosed(aChannels);
+ }
+ }
+
+void CCoreHCIPluginImpl::MhcucSetClientUsage(MHCIClientUsage& aClientUsage)
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(!iClientUsage, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
+
+ iClientUsage = &aClientUsage;
+ }
+
+void CCoreHCIPluginImpl::OpenClientReference()
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(iClientUsage, PANIC(KCoreHciPanicCat, EUninitialisedInterface));
+
+ if (iClientUsage)
+ {
+ iClientUsage->MhcuOpenClientReference();
+ }
+ }
+
+void CCoreHCIPluginImpl::CloseClientReference()
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(iClientUsage, PANIC(KCoreHciPanicCat, EUninitialisedInterface));
+
+ if (iClientUsage)
+ {
+ iClientUsage->MhcuCloseClientReference();
+ }
+ }
+
+// EOF
+
--- a/bthci/hci2implementations/corehcis/symbian/src/hciserverrequestmgr.cpp Wed Oct 13 16:20:29 2010 +0300
+++ b/bthci/hci2implementations/corehcis/symbian/src/hciserverrequestmgr.cpp Thu Oct 14 11:16:56 2010 +0100
@@ -1,658 +1,658 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of "Eclipse Public License v1.0"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-/**
- @file
- @internalComponent
-*/
-
-#include "hciserverrequestmgr.h"
-#include "HciCorePluginImpl.h"
-#include "corehciutil.h"
-
-#include <bluetooth/hci/hciipc.h>
-#include <bluetooth/hci/vendordebugcommand.h>
-#include <bluetooth/hci/vendordebugcompleteevent.h>
-#include <bluetooth/hci/vendordebugevent.h>
-
-#include <bluetooth/hcicommandqueueclient.h>
-#include <bluetooth/hcicommandqueue.h>
-#include <bluetooth/btpowercontrol.h>
-#include <bluetooth/dutmode.h>
-#include <bluetooth/a2dpoptimisation.h>
-#include <bluetooth/a2dpoptimisationparams.h>
-
-#include <bluetooth/logger.h>
-#include <bluetooth/btpowercontrolmessages.h>
-
-#include <es_sock.h>
-#include <bt_sock.h>
-
-#ifdef __FLOG_ACTIVE
-_LIT8(KLogComponent, LOG_COMPONENT_HCISERVER);
-#endif
-
-const TInt KHCIServerIpcDesOutParam = 2;
-
-void CHCIServerRequestManager::BlockAsync(CHCISession& aSession, const RMessage2& aMessage)
- {
- LOG_FUNC
-
- iAsyncTaskMessage = aMessage;
- iAsyncTaskSession = &aSession;
- iBlockMask |= MaskBit();
- }
-
-void CHCIServerRequestManager::CompleteAsyncTask(TInt aError)
- {
- LOG_FUNC
-
- //check message is not already complete
- if(iAsyncTaskMessage.Handle())
- {
- iAsyncTaskMessage.Complete(aError);
- }
- else
- {
- __ASSERT_DEBUG(EFalse, PANIC(KHciServerPanicCat, EMessageAlreadyCompleted));
- }
-
- // Remove Async block
- iAsyncTaskSession = 0;
- iBlockMask &= ~MaskBit();
- }
-
-TBool CHCIServerRequestManager::IsAsyncBlocked()
- {
- LOG_FUNC
-
- return (iBlockMask & MaskBit());
- }
-
-CHCIServerRequestManager::CHCIServerRequestManager(CCoreHCIPluginImpl& aHCI)
- : iHCI(aHCI)
- {
- LOG_FUNC
- }
-
-void CHCIServerRequestManager::ConstructL()
- {
- LOG_FUNC
- }
-
-void CHCIServerRequestManager::ServiceL(CHCISession& aSession, const RMessage2& aMessage)
- {
- if(aMessage.Function() == EServiceSpecificRequest)
- {
- if(HasCapabilities(aMessage))
- {
- DoServiceL(aSession, aMessage);
- }
- // else HasCapabilities failed (and has dealt with aMessage).
- }
- else
- {
- // The client has issued a bad HCI Server request, we only expect a server specific
- // request to be made (the specific request being encoded in the TIpcArgs).
- PanicClient(aMessage, EUnknownHciServerFunction);
- }
- }
-
-//
-// HCI Direct Access Service
-//
-CHCIDirectAccessManager* CHCIDirectAccessManager::NewL(CCoreHCIPluginImpl& aHCI)
- {
- LOG_STATIC_FUNC
-
- CHCIDirectAccessManager* self = new (ELeave) CHCIDirectAccessManager(aHCI);
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop(self);
- return self;
- }
-
-void CHCIDirectAccessManager::SetHCICommandQueue(MHCICommandQueue& aHCICommandQueue)
- {
- LOG_FUNC
-
- __ASSERT_ALWAYS(!iHCICommandQueue, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
- iHCICommandQueue = &aHCICommandQueue;
- }
-
-/*virtual*/ TBool CHCIDirectAccessManager::HasCapabilities(const RMessage2& aMessage)
- {
- LOG_FUNC
-
- TBool allowed = EFalse;
-
- switch (aMessage.Int0())
- {
- case KHCIDirectAccessVendorCommand:
- // Drop through
- case KHCIDirectAccessCancel: // requires Network Control + Local Services
- allowed = aMessage.HasCapability(ECapabilityNetworkControl) && aMessage.HasCapability(ECapabilityLocalServices);
- break;
-
- default:
- PanicClient(aMessage, EUnknownDirectAccessFunction);
- return EFalse;
- }
-
- if(!allowed)
- {
- aMessage.Complete(KErrPermissionDenied);
- }
-
- return allowed;
- }
-
-/*virtual*/ void CHCIDirectAccessManager::DoServiceL(CHCISession& aSession, const RMessage2& aMessage)
- {
- LOG_FUNC
-
- TInt request = aMessage.Int0();
-
- switch (request)
- {
- case KHCIDirectAccessCancel:
- if (iAsyncTaskSession != &aSession)
- {
- return; //drop - not for current async task
- }
-
- // clear cache
- iMessage = NULL;
-
- // perform cancellation procedure
- CompleteAsyncTask(KErrCancel);
- break;
-
- case KHCIDirectAccessVendorCommand:
- {
- if (IsAsyncBlocked())
- {
- aMessage.Complete(KErrInUse);
- return;
- }
-
- const TInt len = User::LeaveIfError(aMessage.GetDesLength(1));
-
- // Check the Vendor Command is at least 3 bytes long for the opcode
- // and the length
- if (len < 3)
- {
- PanicClient(aMessage, EInvalidVendorCommand);
- break;
- }
-
- HBufC8* buf = HBufC8::NewLC(len);
- TPtr8 params(buf->Des());
- aMessage.ReadL(1, params);
-
- // Extract the opcode and create the new command
- TUint16 opcode = LittleEndian::Get16(params.Ptr());
-
- if (iHCICommandQueue)
- {
- CVendorDebugCommand* cmd = CVendorDebugCommand::NewL(opcode);
-
- // Remove the opcode and length from the Vendor Command parameters,
- // these will be added again to the command frame once it has been
- // formatted
- cmd->Command() = params.RightTPtr(params.Length() - 3);
-
- // cmd will be deleted in MhcqAddCommandL if Leaves.
- TUint qid = iHCICommandQueue->MhcqAddCommandL(cmd, *this);
-
- // Block only after we succeed in adding a command.
- BlockAsync(aSession, aMessage);
-
- // Cache to return completion data to client
- iMessage = &aMessage;
- }
- else
- {
- // Slight possible race that a request is made before we have been
- // given the command queue to work with - so don't panic just error.
- aMessage.Complete(KErrNotReady);
- }
- CleanupStack::PopAndDestroy(buf);
- }
- break;
-
- default:
- // Unknown message, panic client
- PanicClient(aMessage, EUnknownDirectAccessFunction);
- break;
- }
- }
-
-/*virtual*/ void CHCIDirectAccessManager::MhcqcCommandErrored(TInt aErrorCode, const CHCICommandBase* /*aCommand*/)
- {
- LOG_FUNC
-
- // clear cache
- iMessage = NULL;
-
- CompleteAsyncTask(aErrorCode);
- }
-
-/*virtual*/ void CHCIDirectAccessManager::MhcqcCommandEventReceived(const THCIEventBase& aEvent, const CHCICommandBase* aCommand)
- {
- LOG_FUNC
-
- // We are not the unmatched event observer therefore we must always get a
- // command
- __ASSERT_DEBUG(aCommand, PANIC(KCoreHciPanicCat, EReceivedUnmatchedEvent));
-
- // It is possible to receive an event but not have a message to complete. This
- // could happen if a request was cancelled after a Vendor Specific command was
- // sent, in this case we do nothing.
- if (iMessage)
- {
- TInt err = KErrNone;
-
- const THCIEventCode eventcode(aEvent.EventCode());
- switch(eventcode)
- {
- case ECommandCompleteEvent:
- {
- if ((aCommand->Opcode() & KVendorDebugOGF) == KVendorDebugOGF)
- {
- const TVendorDebugCompleteEvent& event = TVendorDebugCompleteEvent::Cast(aEvent);
-
- // Return the event
- err = iMessage->Write(KHCIServerIpcDesOutParam, event.VendorDebugData());
- }
- else
- {
- __ASSERT_DEBUG(EFalse, PANIC(KHciServerPanicCat, ENonVendorOpcodeCompleted));
- }
- }
- break;
-
- case EVendorDebugEvent:
- {
- const TVendorDebugEvent& event = TVendorDebugEvent::Cast(aEvent);
-
- // Return the event
- err = iMessage->Write(KHCIServerIpcDesOutParam, event.VendorDebugData());
- }
- break;
-
- default:
- __ASSERT_DEBUG(EFalse, PANIC(KCoreHciPanicCat, EReceivedUnknownEvent));
- break;
- }
-
- CompleteAsyncTask(err);
- }
- }
-
-/*virtual*/ void CHCIDirectAccessManager::CompleteAsyncTask(TInt aError)
- {
- LOG_FUNC
-
- if (!IsAsyncBlocked())
- {
- return; //drop
- }
-
- CHCIServerRequestManager::CompleteAsyncTask(aError);
- }
-
-CHCIDirectAccessManager::CHCIDirectAccessManager(CCoreHCIPluginImpl& aHCI)
-: CHCIServerRequestManager(aHCI)
- {
- LOG_FUNC
- }
-
-
-TUint CHCIDirectAccessManager::MaskBit() const
- {
- LOG_FUNC
-
- return EHCIDirectAccessMaskBit;
- }
-
-//
-// Power Control Service
-//
-CBTPowerControlManager* CBTPowerControlManager::NewL(CCoreHCIPluginImpl& aHCI)
- {
- LOG_STATIC_FUNC
-
- CBTPowerControlManager* self = new (ELeave) CBTPowerControlManager(aHCI);
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop(self);
- return self;
- }
-
-TBool CBTPowerControlManager::HasCapabilities(const RMessage2& aMessage)
- {
- LOG_FUNC
-
- TBool allowed(EFalse);
-
- switch (aMessage.Int0())
- {
- case KHCICancelPower:
- // fall through
- case EHCISetPower: // requires Network Control + Local Services
- allowed = aMessage.HasCapability(ECapabilityNetworkControl) && aMessage.HasCapability(ECapabilityLocalServices);
- break;
-
- case EHCIGetPower: // requires Local Services
- allowed = aMessage.HasCapability(ECapabilityLocalServices);
- break;
-
- default:
- PanicClient(aMessage, EUnknownPowerControlFunction);
- return EFalse;
- }
-
- if(!allowed)
- {
- aMessage.Complete(KErrPermissionDenied);
- }
-
- return allowed;
- }
-
-/*virtual*/ void CBTPowerControlManager::DoServiceL(CHCISession& aSession, const RMessage2& aMessage)
- {
- LOG_FUNC
-
- TInt request = aMessage.Int0();
- TInt err;
- TBTPowerState state;
-
- switch (request)
- {
- case KHCICancelPower:
- if(iAsyncTaskSession!=&aSession)
- {
- return; //drop - not for current async task
- }
-
- //perform cancellation procedure
- CompleteAsyncTask(KErrCancel);
- break;
-
- case EHCISetPower:
- if(IsAsyncBlocked())
- {
- aMessage.Complete(KErrInUse);
- return;
- }
-
- //Should be called before set power because it could complete synchronously
- BlockAsync(aSession, aMessage);
- state = static_cast<TBTPowerState>(aMessage.Int3());
- err = iHCI.SetPower(state, NULL);
- if(err != KErrNone)
- {
- aMessage.Complete(err);
- return;
- }
- break;
-
- case EHCIGetPower:
- {
- err = iHCI.GetPower(state, NULL);
- if(err != KErrNone)
- {
- aMessage.Complete(err);
- return;
- }
-
- TPckg<TBTPowerState> pckg(state);
- TRAP(err, aMessage.WriteL(EPSStateReturnSlot, pckg));
- aMessage.Complete(err);
- }
- break; //synchronous so do not block
-
- default:
- // Unknown message
- PanicClient(aMessage, EUnknownPowerControlFunction);
- break;
- }
- }
-
-/*virtual*/ void CBTPowerControlManager::CompleteAsyncTask(TInt aError)
- {
- LOG_FUNC
-
- if(!IsAsyncBlocked())
- {
- return; //drop
- }
-
- CHCIServerRequestManager::CompleteAsyncTask(aError);
- }
-
-void CBTPowerControlManager::CompleteRequest(TInt aError)
- {
- CompleteAsyncTask(aError);
- }
-
-CBTPowerControlManager::CBTPowerControlManager(CCoreHCIPluginImpl& aHCI)
-: CHCIServerRequestManager(aHCI)
- {
- LOG_FUNC
- }
-
-
-TUint CBTPowerControlManager::MaskBit() const
- {
- LOG_FUNC
-
- return EBTPowerControlMaskBit;
- }
-
-//
-// Bluetooth HCI Utils Service
-//
-CBluetoothDutModeManager* CBluetoothDutModeManager::NewL(CCoreHCIPluginImpl& aHCI)
- {
- LOG_STATIC_FUNC
-
- CBluetoothDutModeManager* self = new (ELeave) CBluetoothDutModeManager(aHCI);
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop(self);
- return self;
- }
-
-TBool CBluetoothDutModeManager::HasCapabilities(const RMessage2& aMessage)
- {
- LOG_FUNC
-
- TBool allowed(EFalse);
-
- switch (aMessage.Int0())
- {
- case RBluetoothDutMode::EHCIActivateDutMode:
- // fall through
- case RBluetoothDutMode::EHCIDeactivateDutMode: // requires Network Control + Local Services
- allowed = aMessage.HasCapability(ECapabilityNetworkControl) && aMessage.HasCapability(ECapabilityLocalServices);
- break;
-
- default:
- PanicClient(aMessage, EUnknownBluetoothDutModeFunction);
- return EFalse;
- }
-
- if(!allowed)
- {
- aMessage.Complete(KErrPermissionDenied);
- }
-
- return allowed;
- }
-
-/*virtual*/ void CBluetoothDutModeManager::DoServiceL(CHCISession& /*aSession*/, const RMessage2& aMessage)
- {
- LOG_FUNC
-
- TInt request = aMessage.Int0();
- TInt err = KErrNotSupported;
-
- switch (request)
- {
- case RBluetoothDutMode::EHCIActivateDutMode:
- // Implementation is adaptation specific and therefore not supported in our reference HCI Server
- LOG(_L("EHCIActivateDutMode"));
- aMessage.Complete(err);
- break;
-
- case RBluetoothDutMode::EHCIDeactivateDutMode:
- // Implementation is adaptation specific and therefore not supported in our reference HCI Server
- LOG(_L("EHCIDeactivateDutMode"));
- aMessage.Complete(err);
- break;
-
- default:
- // Unknown message
- PanicClient(aMessage, EUnknownBluetoothDutModeFunction);
- break;
- }
- }
-
-CBluetoothDutModeManager::CBluetoothDutModeManager(CCoreHCIPluginImpl& aHCI)
-: CHCIServerRequestManager(aHCI)
- {
- LOG_FUNC
- }
-
-
-TUint CBluetoothDutModeManager::MaskBit() const
- {
- LOG_FUNC
-
- return EBluetoothDutModeMaskBit;
- }
-
-//
-// A2DP Optimiser Service
-//
-CA2dpOptimiserManager* CA2dpOptimiserManager::NewL(CCoreHCIPluginImpl& aHCI)
- {
- LOG_STATIC_FUNC
-
- CA2dpOptimiserManager* self = new (ELeave) CA2dpOptimiserManager(aHCI);
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop(self);
- return self;
- }
-
-TBool CA2dpOptimiserManager::HasCapabilities(const RMessage2& aMessage)
- {
- LOG_FUNC
-
- TBool allowed(EFalse);
-
- switch (aMessage.Int0())
- {
- case RA2dpOptimiser::EHCIA2dpOptimiseAcl:
- // fall through
- case RA2dpOptimiser::EHCIA2dpRemoveAclOptimisation: // requires Network Control + Local Services
- allowed = aMessage.HasCapability(ECapabilityNetworkControl) && aMessage.HasCapability(ECapabilityLocalServices);
- break;
-
- default:
- PanicClient(aMessage, EUnknownA2dpOptimiserFunction);
- return EFalse;
- }
-
- if(!allowed)
- {
- aMessage.Complete(KErrPermissionDenied);
- }
-
- return allowed;
- }
-
-/*virtual*/ void CA2dpOptimiserManager::DoServiceL(CHCISession& /*aSession*/, const RMessage2& aMessage)
- {
- LOG_FUNC
-
- TInt request = aMessage.Int0();
- TInt err = KErrNotSupported;
- TBuf<20> targetAddrBuf;
-
- switch (request)
- {
- case RA2dpOptimiser::EHCIA2dpOptimiseAcl:
- // Implementation is adaptation specific and therefore not supported in our reference HCI Server
- if (aMessage.GetDesLength(1) == sizeof(TA2dpOptimisationParams))
- {
- TPckgBuf<TA2dpOptimisationParams> args;
-
- aMessage.ReadL(1, args);
- args().RemoteDeviceAddress().GetReadable(targetAddrBuf);
- LOG3(_L("EHCIA2dpOptimiseAcl BT Addr: %S, Peak Bandwidth: %d, Access Latency: %d\n"),
- &targetAddrBuf, args().PeakBandwidth(), args().AccessLatency());
-
- aMessage.Complete(err);
- }
- else
- {
- PanicClient(aMessage, EInvalidArgument);
- }
- break;
-
- case RA2dpOptimiser::EHCIA2dpRemoveAclOptimisation:
- // Implementation is adaptation specific and therefore not supported in our reference HCI Server
- if (aMessage.GetDesLength(1) == sizeof(TBTDevAddr))
- {
- TPckgBuf<TBTDevAddr> addrBuf;
-
- aMessage.ReadL(1, addrBuf);
- addrBuf().GetReadable(targetAddrBuf);
- LOG1(_L("EHCIA2dpRemoveAclOptimisation BT Addr: %S\n"), &targetAddrBuf);
-
- aMessage.Complete(err);
- }
- else
- {
- PanicClient(aMessage, EInvalidArgument);
- }
- break;
-
- default:
- // Unknown message
- PanicClient(aMessage, EUnknownA2dpOptimiserFunction);
- break;
- }
- }
-
-CA2dpOptimiserManager::CA2dpOptimiserManager(CCoreHCIPluginImpl& aHCI)
-: CHCIServerRequestManager(aHCI)
- {
- LOG_FUNC
- }
-
-
-TUint CA2dpOptimiserManager::MaskBit() const
- {
- LOG_FUNC
-
- return EA2dpOptimiserMaskBit;
- }
-
+// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "hciserverrequestmgr.h"
+#include "HciCorePluginImpl.h"
+#include "corehciutil.h"
+
+#include <bluetooth/hci/hciipc.h>
+#include <bluetooth/hci/vendordebugcommand.h>
+#include <bluetooth/hci/vendordebugcompleteevent.h>
+#include <bluetooth/hci/vendordebugevent.h>
+
+#include <bluetooth/hcicommandqueueclient.h>
+#include <bluetooth/hcicommandqueue.h>
+#include <bluetooth/btpowercontrol.h>
+#include <bluetooth/dutmode.h>
+#include <bluetooth/a2dpoptimisation.h>
+#include <bluetooth/a2dpoptimisationparams.h>
+
+#include <bluetooth/logger.h>
+#include <bluetooth/btpowercontrolmessages.h>
+
+#include <es_sock.h>
+#include <bt_sock.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, LOG_COMPONENT_HCISERVER);
+#endif
+
+const TInt KHCIServerIpcDesOutParam = 2;
+
+void CHCIServerRequestManager::BlockAsync(CHCISession& aSession, const RMessage2& aMessage)
+ {
+ LOG_FUNC
+
+ iAsyncTaskMessage = aMessage;
+ iAsyncTaskSession = &aSession;
+ iBlockMask |= MaskBit();
+ }
+
+void CHCIServerRequestManager::CompleteAsyncTask(TInt aError)
+ {
+ LOG_FUNC
+
+ //check message is not already complete
+ if(iAsyncTaskMessage.Handle())
+ {
+ iAsyncTaskMessage.Complete(aError);
+ }
+ else
+ {
+ __ASSERT_DEBUG(EFalse, PANIC(KHciServerPanicCat, EMessageAlreadyCompleted));
+ }
+
+ // Remove Async block
+ iAsyncTaskSession = 0;
+ iBlockMask &= ~MaskBit();
+ }
+
+TBool CHCIServerRequestManager::IsAsyncBlocked()
+ {
+ LOG_FUNC
+
+ return (iBlockMask & MaskBit());
+ }
+
+CHCIServerRequestManager::CHCIServerRequestManager(CCoreHCIPluginImpl& aHCI)
+ : iHCI(aHCI)
+ {
+ LOG_FUNC
+ }
+
+void CHCIServerRequestManager::ConstructL()
+ {
+ LOG_FUNC
+ }
+
+void CHCIServerRequestManager::ServiceL(CHCISession& aSession, const RMessage2& aMessage)
+ {
+ if(aMessage.Function() == EServiceSpecificRequest)
+ {
+ if(HasCapabilities(aMessage))
+ {
+ DoServiceL(aSession, aMessage);
+ }
+ // else HasCapabilities failed (and has dealt with aMessage).
+ }
+ else
+ {
+ // The client has issued a bad HCI Server request, we only expect a server specific
+ // request to be made (the specific request being encoded in the TIpcArgs).
+ PanicClient(aMessage, EUnknownHciServerFunction);
+ }
+ }
+
+//
+// HCI Direct Access Service
+//
+CHCIDirectAccessManager* CHCIDirectAccessManager::NewL(CCoreHCIPluginImpl& aHCI)
+ {
+ LOG_STATIC_FUNC
+
+ CHCIDirectAccessManager* self = new (ELeave) CHCIDirectAccessManager(aHCI);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+void CHCIDirectAccessManager::SetHCICommandQueue(MHCICommandQueue& aHCICommandQueue)
+ {
+ LOG_FUNC
+
+ __ASSERT_ALWAYS(!iHCICommandQueue, PANIC(KCoreHciPanicCat, EInterfaceAlreadyInitialised));
+ iHCICommandQueue = &aHCICommandQueue;
+ }
+
+/*virtual*/ TBool CHCIDirectAccessManager::HasCapabilities(const RMessage2& aMessage)
+ {
+ LOG_FUNC
+
+ TBool allowed = EFalse;
+
+ switch (aMessage.Int0())
+ {
+ case KHCIDirectAccessVendorCommand:
+ // Drop through
+ case KHCIDirectAccessCancel: // requires Network Control + Local Services
+ allowed = aMessage.HasCapability(ECapabilityNetworkControl) && aMessage.HasCapability(ECapabilityLocalServices);
+ break;
+
+ default:
+ PanicClient(aMessage, EUnknownDirectAccessFunction);
+ return EFalse;
+ }
+
+ if(!allowed)
+ {
+ aMessage.Complete(KErrPermissionDenied);
+ }
+
+ return allowed;
+ }
+
+/*virtual*/ void CHCIDirectAccessManager::DoServiceL(CHCISession& aSession, const RMessage2& aMessage)
+ {
+ LOG_FUNC
+
+ TInt request = aMessage.Int0();
+
+ switch (request)
+ {
+ case KHCIDirectAccessCancel:
+ if (iAsyncTaskSession != &aSession)
+ {
+ return; //drop - not for current async task
+ }
+
+ // clear cache
+ iMessage = NULL;
+
+ // perform cancellation procedure
+ CompleteAsyncTask(KErrCancel);
+ break;
+
+ case KHCIDirectAccessVendorCommand:
+ {
+ if (IsAsyncBlocked())
+ {
+ aMessage.Complete(KErrInUse);
+ return;
+ }
+
+ const TInt len = User::LeaveIfError(aMessage.GetDesLength(1));
+
+ // Check the Vendor Command is at least 3 bytes long for the opcode
+ // and the length
+ if (len < 3)
+ {
+ PanicClient(aMessage, EInvalidVendorCommand);
+ break;
+ }
+
+ HBufC8* buf = HBufC8::NewLC(len);
+ TPtr8 params(buf->Des());
+ aMessage.ReadL(1, params);
+
+ // Extract the opcode and create the new command
+ TUint16 opcode = LittleEndian::Get16(params.Ptr());
+
+ if (iHCICommandQueue)
+ {
+ CVendorDebugCommand* cmd = CVendorDebugCommand::NewL(opcode);
+
+ // Remove the opcode and length from the Vendor Command parameters,
+ // these will be added again to the command frame once it has been
+ // formatted
+ cmd->Command() = params.RightTPtr(params.Length() - 3);
+
+ // cmd will be deleted in MhcqAddCommandL if Leaves.
+ TUint qid = iHCICommandQueue->MhcqAddCommandL(cmd, *this);
+
+ // Block only after we succeed in adding a command.
+ BlockAsync(aSession, aMessage);
+
+ // Cache to return completion data to client
+ iMessage = &aMessage;
+ }
+ else
+ {
+ // Slight possible race that a request is made before we have been
+ // given the command queue to work with - so don't panic just error.
+ aMessage.Complete(KErrNotReady);
+ }
+ CleanupStack::PopAndDestroy(buf);
+ }
+ break;
+
+ default:
+ // Unknown message, panic client
+ PanicClient(aMessage, EUnknownDirectAccessFunction);
+ break;
+ }
+ }
+
+/*virtual*/ void CHCIDirectAccessManager::MhcqcCommandErrored(TInt aErrorCode, const CHCICommandBase* /*aCommand*/)
+ {
+ LOG_FUNC
+
+ // clear cache
+ iMessage = NULL;
+
+ CompleteAsyncTask(aErrorCode);
+ }
+
+/*virtual*/ void CHCIDirectAccessManager::MhcqcCommandEventReceived(const THCIEventBase& aEvent, const CHCICommandBase* aCommand)
+ {
+ LOG_FUNC
+
+ // We are not the unmatched event observer therefore we must always get a
+ // command
+ __ASSERT_DEBUG(aCommand, PANIC(KCoreHciPanicCat, EReceivedUnmatchedEvent));
+
+ // It is possible to receive an event but not have a message to complete. This
+ // could happen if a request was cancelled after a Vendor Specific command was
+ // sent, in this case we do nothing.
+ if (iMessage)
+ {
+ TInt err = KErrNone;
+
+ const THCIEventCode eventcode(aEvent.EventCode());
+ switch(eventcode)
+ {
+ case ECommandCompleteEvent:
+ {
+ if ((aCommand->Opcode() & KVendorDebugOGF) == KVendorDebugOGF)
+ {
+ const TVendorDebugCompleteEvent& event = TVendorDebugCompleteEvent::Cast(aEvent);
+
+ // Return the event
+ err = iMessage->Write(KHCIServerIpcDesOutParam, event.VendorDebugData());
+ }
+ else
+ {
+ __ASSERT_DEBUG(EFalse, PANIC(KHciServerPanicCat, ENonVendorOpcodeCompleted));
+ }
+ }
+ break;
+
+ case EVendorDebugEvent:
+ {
+ const TVendorDebugEvent& event = TVendorDebugEvent::Cast(aEvent);
+
+ // Return the event
+ err = iMessage->Write(KHCIServerIpcDesOutParam, event.VendorDebugData());
+ }
+ break;
+
+ default:
+ __ASSERT_DEBUG(EFalse, PANIC(KCoreHciPanicCat, EReceivedUnknownEvent));
+ break;
+ }
+
+ CompleteAsyncTask(err);
+ }
+ }
+
+/*virtual*/ void CHCIDirectAccessManager::CompleteAsyncTask(TInt aError)
+ {
+ LOG_FUNC
+
+ if (!IsAsyncBlocked())
+ {
+ return; //drop
+ }
+
+ CHCIServerRequestManager::CompleteAsyncTask(aError);
+ }
+
+CHCIDirectAccessManager::CHCIDirectAccessManager(CCoreHCIPluginImpl& aHCI)
+: CHCIServerRequestManager(aHCI)
+ {
+ LOG_FUNC
+ }
+
+
+TUint CHCIDirectAccessManager::MaskBit() const
+ {
+ LOG_FUNC
+
+ return EHCIDirectAccessMaskBit;
+ }
+
+//
+// Power Control Service
+//
+CBTPowerControlManager* CBTPowerControlManager::NewL(CCoreHCIPluginImpl& aHCI)
+ {
+ LOG_STATIC_FUNC
+
+ CBTPowerControlManager* self = new (ELeave) CBTPowerControlManager(aHCI);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+TBool CBTPowerControlManager::HasCapabilities(const RMessage2& aMessage)
+ {
+ LOG_FUNC
+
+ TBool allowed(EFalse);
+
+ switch (aMessage.Int0())
+ {
+ case KHCICancelPower:
+ // fall through
+ case EHCISetPower: // requires Network Control + Local Services
+ allowed = aMessage.HasCapability(ECapabilityNetworkControl) && aMessage.HasCapability(ECapabilityLocalServices);
+ break;
+
+ case EHCIGetPower: // requires Local Services
+ allowed = aMessage.HasCapability(ECapabilityLocalServices);
+ break;
+
+ default:
+ PanicClient(aMessage, EUnknownPowerControlFunction);
+ return EFalse;
+ }
+
+ if(!allowed)
+ {
+ aMessage.Complete(KErrPermissionDenied);
+ }
+
+ return allowed;
+ }
+
+/*virtual*/ void CBTPowerControlManager::DoServiceL(CHCISession& aSession, const RMessage2& aMessage)
+ {
+ LOG_FUNC
+
+ TInt request = aMessage.Int0();
+ TInt err;
+ TBTPowerState state;
+
+ switch (request)
+ {
+ case KHCICancelPower:
+ if(iAsyncTaskSession!=&aSession)
+ {
+ return; //drop - not for current async task
+ }
+
+ //perform cancellation procedure
+ CompleteAsyncTask(KErrCancel);
+ break;
+
+ case EHCISetPower:
+ if(IsAsyncBlocked())
+ {
+ aMessage.Complete(KErrInUse);
+ return;
+ }
+
+ //Should be called before set power because it could complete synchronously
+ BlockAsync(aSession, aMessage);
+ state = static_cast<TBTPowerState>(aMessage.Int3());
+ err = iHCI.SetPower(state, NULL);
+ if(err != KErrNone)
+ {
+ CompleteAsyncTask(err);
+ return;
+ }
+ break;
+
+ case EHCIGetPower:
+ {
+ err = iHCI.GetPower(state, NULL);
+ if(err != KErrNone)
+ {
+ aMessage.Complete(err);
+ return;
+ }
+
+ TPckg<TBTPowerState> pckg(state);
+ TRAP(err, aMessage.WriteL(EPSStateReturnSlot, pckg));
+ aMessage.Complete(err);
+ }
+ break; //synchronous so do not block
+
+ default:
+ // Unknown message
+ PanicClient(aMessage, EUnknownPowerControlFunction);
+ break;
+ }
+ }
+
+/*virtual*/ void CBTPowerControlManager::CompleteAsyncTask(TInt aError)
+ {
+ LOG_FUNC
+
+ if(!IsAsyncBlocked())
+ {
+ return; //drop
+ }
+
+ CHCIServerRequestManager::CompleteAsyncTask(aError);
+ }
+
+void CBTPowerControlManager::CompleteRequest(TInt aError)
+ {
+ CompleteAsyncTask(aError);
+ }
+
+CBTPowerControlManager::CBTPowerControlManager(CCoreHCIPluginImpl& aHCI)
+: CHCIServerRequestManager(aHCI)
+ {
+ LOG_FUNC
+ }
+
+
+TUint CBTPowerControlManager::MaskBit() const
+ {
+ LOG_FUNC
+
+ return EBTPowerControlMaskBit;
+ }
+
+//
+// Bluetooth HCI Utils Service
+//
+CBluetoothDutModeManager* CBluetoothDutModeManager::NewL(CCoreHCIPluginImpl& aHCI)
+ {
+ LOG_STATIC_FUNC
+
+ CBluetoothDutModeManager* self = new (ELeave) CBluetoothDutModeManager(aHCI);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+TBool CBluetoothDutModeManager::HasCapabilities(const RMessage2& aMessage)
+ {
+ LOG_FUNC
+
+ TBool allowed(EFalse);
+
+ switch (aMessage.Int0())
+ {
+ case RBluetoothDutMode::EHCIActivateDutMode:
+ // fall through
+ case RBluetoothDutMode::EHCIDeactivateDutMode: // requires Network Control + Local Services
+ allowed = aMessage.HasCapability(ECapabilityNetworkControl) && aMessage.HasCapability(ECapabilityLocalServices);
+ break;
+
+ default:
+ PanicClient(aMessage, EUnknownBluetoothDutModeFunction);
+ return EFalse;
+ }
+
+ if(!allowed)
+ {
+ aMessage.Complete(KErrPermissionDenied);
+ }
+
+ return allowed;
+ }
+
+/*virtual*/ void CBluetoothDutModeManager::DoServiceL(CHCISession& /*aSession*/, const RMessage2& aMessage)
+ {
+ LOG_FUNC
+
+ TInt request = aMessage.Int0();
+ TInt err = KErrNotSupported;
+
+ switch (request)
+ {
+ case RBluetoothDutMode::EHCIActivateDutMode:
+ // Implementation is adaptation specific and therefore not supported in our reference HCI Server
+ LOG(_L("EHCIActivateDutMode"));
+ aMessage.Complete(err);
+ break;
+
+ case RBluetoothDutMode::EHCIDeactivateDutMode:
+ // Implementation is adaptation specific and therefore not supported in our reference HCI Server
+ LOG(_L("EHCIDeactivateDutMode"));
+ aMessage.Complete(err);
+ break;
+
+ default:
+ // Unknown message
+ PanicClient(aMessage, EUnknownBluetoothDutModeFunction);
+ break;
+ }
+ }
+
+CBluetoothDutModeManager::CBluetoothDutModeManager(CCoreHCIPluginImpl& aHCI)
+: CHCIServerRequestManager(aHCI)
+ {
+ LOG_FUNC
+ }
+
+
+TUint CBluetoothDutModeManager::MaskBit() const
+ {
+ LOG_FUNC
+
+ return EBluetoothDutModeMaskBit;
+ }
+
+//
+// A2DP Optimiser Service
+//
+CA2dpOptimiserManager* CA2dpOptimiserManager::NewL(CCoreHCIPluginImpl& aHCI)
+ {
+ LOG_STATIC_FUNC
+
+ CA2dpOptimiserManager* self = new (ELeave) CA2dpOptimiserManager(aHCI);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+TBool CA2dpOptimiserManager::HasCapabilities(const RMessage2& aMessage)
+ {
+ LOG_FUNC
+
+ TBool allowed(EFalse);
+
+ switch (aMessage.Int0())
+ {
+ case RA2dpOptimiser::EHCIA2dpOptimiseAcl:
+ // fall through
+ case RA2dpOptimiser::EHCIA2dpRemoveAclOptimisation: // requires Network Control + Local Services
+ allowed = aMessage.HasCapability(ECapabilityNetworkControl) && aMessage.HasCapability(ECapabilityLocalServices);
+ break;
+
+ default:
+ PanicClient(aMessage, EUnknownA2dpOptimiserFunction);
+ return EFalse;
+ }
+
+ if(!allowed)
+ {
+ aMessage.Complete(KErrPermissionDenied);
+ }
+
+ return allowed;
+ }
+
+/*virtual*/ void CA2dpOptimiserManager::DoServiceL(CHCISession& /*aSession*/, const RMessage2& aMessage)
+ {
+ LOG_FUNC
+
+ TInt request = aMessage.Int0();
+ TInt err = KErrNotSupported;
+ TBuf<20> targetAddrBuf;
+
+ switch (request)
+ {
+ case RA2dpOptimiser::EHCIA2dpOptimiseAcl:
+ // Implementation is adaptation specific and therefore not supported in our reference HCI Server
+ if (aMessage.GetDesLength(1) == sizeof(TA2dpOptimisationParams))
+ {
+ TPckgBuf<TA2dpOptimisationParams> args;
+
+ aMessage.ReadL(1, args);
+ args().RemoteDeviceAddress().GetReadable(targetAddrBuf);
+ LOG3(_L("EHCIA2dpOptimiseAcl BT Addr: %S, Peak Bandwidth: %d, Access Latency: %d\n"),
+ &targetAddrBuf, args().PeakBandwidth(), args().AccessLatency());
+
+ aMessage.Complete(err);
+ }
+ else
+ {
+ PanicClient(aMessage, EInvalidArgument);
+ }
+ break;
+
+ case RA2dpOptimiser::EHCIA2dpRemoveAclOptimisation:
+ // Implementation is adaptation specific and therefore not supported in our reference HCI Server
+ if (aMessage.GetDesLength(1) == sizeof(TBTDevAddr))
+ {
+ TPckgBuf<TBTDevAddr> addrBuf;
+
+ aMessage.ReadL(1, addrBuf);
+ addrBuf().GetReadable(targetAddrBuf);
+ LOG1(_L("EHCIA2dpRemoveAclOptimisation BT Addr: %S\n"), &targetAddrBuf);
+
+ aMessage.Complete(err);
+ }
+ else
+ {
+ PanicClient(aMessage, EInvalidArgument);
+ }
+ break;
+
+ default:
+ // Unknown message
+ PanicClient(aMessage, EUnknownA2dpOptimiserFunction);
+ break;
+ }
+ }
+
+CA2dpOptimiserManager::CA2dpOptimiserManager(CCoreHCIPluginImpl& aHCI)
+: CHCIServerRequestManager(aHCI)
+ {
+ LOG_FUNC
+ }
+
+
+TUint CA2dpOptimiserManager::MaskBit() const
+ {
+ LOG_FUNC
+
+ return EA2dpOptimiserMaskBit;
+ }
+
--- a/bthci/hci2implementations/group/bld.inf Wed Oct 13 16:20:29 2010 +0300
+++ b/bthci/hci2implementations/group/bld.inf Thu Oct 14 11:16:56 2010 +0100
@@ -1,30 +1,31 @@
-// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of "Eclipse Public License v1.0"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-#include "../corehcis/symbian/group/bld.inf"
-
-#include "../hctls/bcsp/group/bld.inf"
-#include "../hctls/ti/group/bld.inf"
-#include "../hctls/uart_original/group/bld.inf"
-
-#include "../initialisors/ti/group/bld.inf"
-#include "../initialisors/symbian/group/bld.inf"
-
-#include "../qdps/symbian/group/bld.inf"
-
-#include "../CommandsEvents/symbian/group/bld.inf"
-
-PRJ_EXPORTS
-hci_implementation_reference.iby /epoc32/rom/include/hci_implementation_reference.iby
+// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "../corehcis/symbian/group/bld.inf"
+
+#include "../hctls/bcsp/group/bld.inf"
+#include "../hctls/ti/group/bld.inf"
+#include "../hctls/uart_original/group/bld.inf"
+#include "../hctls/usb_original/group/bld.inf"
+
+#include "../initialisors/ti/group/bld.inf"
+#include "../initialisors/symbian/group/bld.inf"
+
+#include "../qdps/symbian/group/bld.inf"
+
+#include "../CommandsEvents/symbian/group/bld.inf"
+
+PRJ_EXPORTS
+hci_implementation_reference.iby /epoc32/rom/include/hci_implementation_reference.iby
--- a/bthci/hci2implementations/group/hci_implementation_reference.iby Wed Oct 13 16:20:29 2010 +0300
+++ b/bthci/hci2implementations/group/hci_implementation_reference.iby Thu Oct 14 11:16:56 2010 +0100
@@ -1,45 +1,50 @@
-// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of "Eclipse Public License v1.0"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-#ifndef HCI_IMPLEMENTATION_REFERENCE_IBY
-#define HCI_IMPLEMENTATION_REFERENCE_IBY
-
-// If __HCI_DEBUG__ is defined pull in debug versions of the
-// HCI DLLs and Plugins regardless of the ROM type
-#ifdef __HCI_DEBUG__
-define HCI_DIR UDEB
-#define HCI_PLUGIN ECOM_PLUGIN_UDEB
-#else
-define HCI_DIR BUILD_DIR
-#define HCI_PLUGIN ECOM_PLUGIN
-#endif
-
-#include <corehci_symbian.iby>
-#include <commandsevents_symbian.iby>
-#include <hci_qdp_symbian.iby>
-
-#ifdef HCI_TI
-
-#include <hctl_ti.iby>
-#include <hci_initialisor_ti.iby>
-
-#else // CSR + Default
-
-#include <hctl_bcsp.iby>
-#include <initialisor_symbian.iby>
-
-#endif
-
-#endif // HCI_IMPLEMENTATION_REFERENCE_IBY
+// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef HCI_IMPLEMENTATION_REFERENCE_IBY
+#define HCI_IMPLEMENTATION_REFERENCE_IBY
+
+// If __HCI_DEBUG__ is defined pull in debug versions of the
+// HCI DLLs and Plugins regardless of the ROM type
+#ifdef __HCI_DEBUG__
+define HCI_DIR UDEB
+#define HCI_PLUGIN ECOM_PLUGIN_UDEB
+#else
+define HCI_DIR BUILD_DIR
+#define HCI_PLUGIN ECOM_PLUGIN
+#endif
+
+#include <corehci_symbian.iby>
+#include <commandsevents_symbian.iby>
+#include <hci_qdp_symbian.iby>
+
+#ifdef HCI_TI
+
+#include <hctl_ti.iby>
+#include <hci_initialisor_ti.iby>
+
+#elif HCI_USB
+
+#include <hctl_usb_original.iby>
+#include <initialisor_symbian.iby>
+
+#else // CSR + Default
+
+#include <hctl_bcsp.iby>
+#include <initialisor_symbian.iby>
+
+#endif
+
+#endif // HCI_IMPLEMENTATION_REFERENCE_IBY
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/group/distribution.policy.s60 Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/group/fdc_hctl_original.mmp Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,59 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Function Driver Controller for Bluetooth USB (H2) HCTL.
+//
+
+/**
+@file
+@internalComponent
+*/
+
+// The following macro defines whether the FDC will attempt to
+// retrieve the Device Firmware Update interface. Some controllers
+// provide this (and so to enable "fully" successful driver loading
+// it needs to be claimed by something. Nothing is done with the
+// interface - it is simply claimed from the FDF.
+macro SYMBIAN_FDC_HCTL_ORIGINAL_ACCEPT_FIRMWARE_UPDATE
+
+target fdc_hctl_original.dll
+targettype plugin
+// UID2 = 0x10009d8d for ECOM plugins.
+// UID3 = the 'DLL UID' (see resource file)
+uid 0x10009d8d 0x200345E8
+vendorid 0x70000001
+
+#include <usbhost/internal/fdfcaps.mmh>
+
+noexportlibrary
+
+userinclude ../inc
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+systeminclude ../../fdc/public
+systeminclude ../../hctl/public
+
+sourcepath ../src
+source fdchctloriginalmain.cpp
+source fdchctloriginal.cpp
+source fdchctloriginalserver.cpp
+
+resource fdc_hctl_original.rss
+
+library euser.lib
+library fdcbase.lib
+library usbdescriptors.lib
+library esock.lib
+
+#include <bluetooth/btlogger.mmh>
+
+smpsafe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/inc/distribution.policy.s60 Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/inc/fdchctloriginal.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,64 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef FDCHCTLORIGINAL_H
+#define FDCHCTLORIGINAL_H
+
+#include <e32base.h>
+#include <usbhost/internal/fdcplugin.h>
+#include <usbhost/internal/fdcinterface.h>
+#include <hctlusboriginalcli.h>
+
+class CFdcHctlOriginalServer;
+
+NONSHARABLE_CLASS(CFdcHctlOriginal)
+ : public CFdcPlugin
+ , public MFdcInterfaceV1
+ {
+public:
+ static CFdcHctlOriginal* NewL(MFdcPluginObserver& aObserver);
+ ~CFdcHctlOriginal();
+
+public:
+ void RequestConnection();
+
+private:
+ CFdcHctlOriginal(MFdcPluginObserver& aObserver);
+ void ConstructL();
+
+private: // from CFdcPlugin
+ virtual TAny* GetInterface(TUid aUid);
+
+private: // from MFdcInterfaceV1
+ virtual TInt Mfi1NewFunction(TUint aDeviceId,
+ const TArray<TUint>& aInterfaces,
+ const TUsbDeviceDescriptor& aDeviceDescriptor,
+ const TUsbConfigurationDescriptor& aConfigurationDescriptor);
+ virtual void Mfi1DeviceDetached(TUint aDeviceId);
+
+private:
+ CFdcHctlOriginalServer* iServer;
+ RHCTLUsbOriginal iHctlSession;
+ TBool iReady;
+ TUint32 iAclToken;
+ TUint32 iScoToken;
+ };
+
+#endif // FDCHCTLORIGINAL_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/inc/fdchctloriginalpolicy.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,62 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef FDCHCTLORIGINALPOLICY_H
+#define FDCHCTLORIGINALPOLICY_H
+
+#include <e32def.h>
+#include <fdchctloriginalipc.h>
+
+/** FDC HCTL Original Server Security Policy Definition */
+const TUint KFdcHctlOriginalRangeCount = 2;
+
+const TInt KFdcHctlOriginalRanges[KFdcHctlOriginalRangeCount] =
+ {
+ EFunctionRequestConnection, // ESock SID
+ ENumFdcHctlOriginalSrvFuncs, // not supported
+ };
+
+/** Index numbers into KFdcHctlOriginalElements[] */
+const TInt KPolicyEsockSid = 0;
+
+/** Mapping IPCs to policy element */
+const TUint8 KFdcHctlOriginalElementsIndex[KFdcHctlOriginalRangeCount] =
+ {
+ KPolicyEsockSid, // All (valid) APIs
+ CPolicyServer::ENotSupported // Undefined functions
+ };
+
+/** Individual policy elements */
+const CPolicyServer::TPolicyElement KFdcHctlOriginalElements[] =
+ {
+ { _INIT_SECURITY_POLICY_S0(0x101f7989) },
+ };
+
+/** Main policy */
+const CPolicyServer::TPolicy KFdcHctlOriginalPolicy =
+ {
+ KPolicyEsockSid, // connection requirements
+ KFdcHctlOriginalRangeCount,
+ KFdcHctlOriginalRanges,
+ KFdcHctlOriginalElementsIndex,
+ KFdcHctlOriginalElements,
+ };
+
+#endif // FDCHCTLORIGINALPOLICY_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/inc/fdchctloriginalserver.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,63 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef FDCHCTLORIGINALSERVER_H
+#define FDCHCTLORIGINALSERVER_H
+
+#include <e32base.h>
+
+class CFdcHctlOriginal;
+
+NONSHARABLE_CLASS(CFdcHctlOriginalSession)
+ : public CSession2
+ {
+public:
+ CFdcHctlOriginalSession(CFdcHctlOriginal& aHctlOriginal);
+ ~CFdcHctlOriginalSession();
+
+private:
+ void ServiceL(const RMessage2& aMessage);
+
+private:
+ CFdcHctlOriginal& iHctlOriginal;
+ };
+
+
+NONSHARABLE_CLASS(CFdcHctlOriginalServer)
+ : public CPolicyServer
+ {
+public:
+ static CFdcHctlOriginalServer* NewL(CFdcHctlOriginal& aHctlOriginal);
+ ~CFdcHctlOriginalServer();
+
+ void DropSession(CFdcHctlOriginalSession* aSession) const;
+
+private:
+ CFdcHctlOriginalServer(CFdcHctlOriginal& aHctlOriginal);
+ void ConstructL();
+
+ CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
+
+private:
+ CFdcHctlOriginal& iHctlOriginal;
+ mutable CFdcHctlOriginalSession* iSession;
+ };
+
+#endif // FDCHCTLORIGINALSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/inc/fdchctloriginalutils.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,41 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+
+#ifndef FDCHCTLORIGINALUTILS_H
+#define FDCHCTLORIGINALUTILS_H
+
+#include <e32base.h>
+
+/**
+The panic category for the USB Original HCTL FDC.
+*/
+_LIT(KFdcHctlOriginalPanic, "FdcHctlOrigPanic");
+
+/**
+Panic codes for USB Original HCTL FDC.
+*/
+enum TFdcHctlOriginalPanic
+ {
+ EBadSessionPointer = 0,
+ };
+
+#endif // FDCHCTLORIGINALUTILS_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/public/distribution.policy.s60 Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/public/fdchctloriginalcli.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,72 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef FDCHCTLORIGINALCLI_H
+#define FDCHCTLORIGINALCLI_H
+
+#include <e32base.h>
+#include <fdchctloriginalipc.h>
+
+NONSHARABLE_CLASS(RFdcHctlOriginal)
+ : public RSessionBase
+ {
+public:
+ inline RFdcHctlOriginal();
+
+ inline TInt Connect();
+ inline void Close();
+
+ inline void RequestConnection();
+
+private:
+ TAny* iExtension;
+ };
+
+inline RFdcHctlOriginal::RFdcHctlOriginal()
+ : iExtension(NULL)
+ {}
+
+inline TInt RFdcHctlOriginal::Connect()
+ {
+ // We are not able to "start" the server, as it is set running when the function driver
+ // is loaded. Instead we just want to try and connect and ask for the provision of any
+ // hardware that is available.
+ return CreateSession(
+ KFdcHctlOrigSrvName,
+ TVersion(
+ KFdcHctlOrigSrvMajorVersionNumber,
+ KFdcHctlOrigSrvMinorVersionNumber,
+ KFdcHctlOrigSrvBuildNumber
+ )
+ );
+ }
+
+inline void RFdcHctlOriginal::Close()
+ {
+ RSessionBase::Close();
+ }
+
+inline void RFdcHctlOriginal::RequestConnection()
+ {
+ // We can always fail here - this is a best effort request.
+ Send(EFunctionRequestConnection);
+ }
+
+#endif // FDCHCTLORIGINALCLI_H
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/public/fdchctloriginalipc.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,52 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef FDCHCTLORIGINALIPC_H
+#define FDCHCTLORIGINALIPC_H
+
+#include <e32base.h>
+
+//
+// FDC Server IPC
+//
+
+_LIT(KFdcHctlOrigSrvName, "!FdcHctlOriginal");
+
+/** Version numbers. */
+const TInt8 KFdcHctlOrigSrvMajorVersionNumber = 1;
+const TInt8 KFdcHctlOrigSrvMinorVersionNumber = 0;
+const TInt16 KFdcHctlOrigSrvBuildNumber = 0;
+
+enum TFdcHctlOriginalSrvFuncs
+ {
+ EFunctionRequestConnection = 0,
+ /* Add new server functions before this */
+ ENumFdcHctlOriginalSrvFuncs // Never use as an actual function number
+ };
+
+
+_LIT(KFdcHctlOriginalSrvPanicCat, "FdcHctlOriginalSrv");
+
+enum TFdcHctlOriginalSrvPanics
+ {
+ EFdcHctlInvalidFunction = 0,
+ };
+
+#endif // FDCHCTLORIGINALIPC_H
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/src/distribution.policy.s60 Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/src/fdc_hctl_original.rss Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,45 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#include <ecom/RegistryInfo.rh>
+#include <usbhost/internal/fdcplugin.hrh>
+
+RESOURCE REGISTRY_INFO theInfo
+ {
+ dll_uid = 0x200345E8;
+ interfaces =
+ {
+ INTERFACE_INFO
+ {
+ interface_uid = KFdcEcomInterfaceUid;
+ implementations =
+ {
+ IMPLEMENTATION_INFO
+ {
+ implementation_uid = 0x200345EA;
+ version_no = 1;
+ display_name = "HCTL USB Original";
+ default_data = "DC0xe0DSC0x01DP0x01";
+ opaque_data = "";
+ }
+ };
+ }
+ };
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/src/fdchctloriginal.cpp Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,248 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#include "fdchctloriginal.h"
+
+#include <d32usbdescriptors.h>
+#include <usbhost/internal/fdcpluginobserver.h>
+#include <usbhosterrors.h>
+#include <bluetooth/logger.h>
+
+#include "fdchctloriginalserver.h"
+
+#include <bluetooth/logger.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "fdchctloriginal");
+#endif
+
+
+CFdcHctlOriginal* CFdcHctlOriginal::NewL(MFdcPluginObserver& aObserver)
+ {
+ LOG_STATIC_FUNC
+ CFdcHctlOriginal* self = new(ELeave) CFdcHctlOriginal(aObserver);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+CFdcHctlOriginal::CFdcHctlOriginal(MFdcPluginObserver& aObserver)
+ : CFdcPlugin(aObserver)
+ {
+ LOG_FUNC
+ }
+
+CFdcHctlOriginal::~CFdcHctlOriginal()
+ {
+ LOG_FUNC
+ iHctlSession.Close();
+ delete iServer;
+ }
+
+void CFdcHctlOriginal::ConstructL()
+ {
+ LOG_FUNC
+ iServer = CFdcHctlOriginalServer::NewL(*this);
+ }
+
+TAny* CFdcHctlOriginal::GetInterface(TUid aUid)
+ {
+ LOG_FUNC
+ LOG1(_L8("\taUid = 0x%08x"), aUid);
+
+ TAny* ret = NULL;
+ if(aUid == TUid::Uid(KFdcInterfaceV1))
+ {
+ ret = reinterpret_cast<TAny*>(static_cast<MFdcInterfaceV1*>(this));
+ }
+
+ LOG1(_L8("\tret = [0x%08x]"), ret);
+ return ret;
+ }
+
+TInt CFdcHctlOriginal::Mfi1NewFunction(TUint aDeviceId,
+ const TArray<TUint>& aInterfaces,
+ const TUsbDeviceDescriptor& aDeviceDescriptor,
+ const TUsbConfigurationDescriptor& aConfigurationDescriptor)
+ {
+ LOG_FUNC
+
+ // Normally an FDC is required to claim it's interfaces first. In this
+ // case we need to parse the descriptor tree to determine if the device
+ // firmware update interface is present. (We don't do firmware updates but
+ // we claim it until to provide successful device attachments. If a
+ // firmware update FDC is provided this should be removed.)
+#ifdef SYMBIAN_FDC_HCTL_ORIGINAL_ACCEPT_FIRMWARE_UPDATE
+ TBool firmwareIntFound = EFalse;
+ TUint8 firmwareIntNum = 0xff;
+
+ TUint8 KDfuInterfaceClass = 0xfe;
+ TUint8 KDfuInterfaceSubClass = 0x01;
+
+ // Drop down a level from the configuration descriptor.
+ TUsbGenericDescriptor* descriptor = aConfigurationDescriptor.iFirstChild;
+ // Search across the interface tier (note doesn't handle DFU in IAD).
+ while(descriptor)
+ {
+ TUsbInterfaceDescriptor* interface;
+ if (interface = TUsbInterfaceDescriptor::Cast(descriptor), interface)
+ {
+ if( interface->InterfaceClass() == KDfuInterfaceClass &&
+ interface->InterfaceSubClass() == KDfuInterfaceSubClass)
+ {
+ firmwareIntNum = interface->InterfaceNumber();
+ firmwareIntFound = ETrue;
+ break;
+ }
+ }
+ descriptor = descriptor->iNextPeer;
+ }
+#endif // SYMBIAN_FDC_HCTL_ORIGINAL_ACCEPT_FIRMWARE_UPDATE
+
+ // We claim the interfaces we are to represent, we must claim the
+ // first interface given to us as FDF has already determined that
+ // we are to use it.
+ const TUint KNumOfHctlInterfaces = 2;
+ const TUint8 KAclInterfaceNum = 0x00, KScoInterfaceNum = 0x01;
+ TBool gotAcl = EFalse, gotSco = EFalse, fatalError = EFalse;
+
+ for(TInt i=0; i<aInterfaces.Count(); ++i)
+ {
+ TUint intNum = aInterfaces[i];
+ if(intNum == KAclInterfaceNum)
+ {
+ fatalError = (fatalError || gotAcl); // The USB device should only report one ACL interface
+ iAclToken = Observer().TokenForInterface(intNum);
+ gotAcl = ETrue;
+ }
+ else if(intNum == KScoInterfaceNum)
+ {
+ fatalError = (fatalError || gotSco); // The USB device should only report one ACL interface
+ iScoToken = Observer().TokenForInterface(intNum);
+ gotSco = ETrue;
+ }
+ else if(i == 0)
+ {
+ // We always need to claim the first interface, this should have
+ // been claimed already, but if we have a funny device then this
+ // might not be the case. We will need to error.
+ TUint32 unknownToken = Observer().TokenForInterface(intNum);
+ return KErrCorrupt;
+ }
+#ifdef SYMBIAN_FDC_HCTL_ORIGINAL_ACCEPT_FIRMWARE_UPDATE
+ else if(firmwareIntFound && intNum == firmwareIntNum)
+ {
+ TUint32 dfuToken = Observer().TokenForInterface(intNum);
+ }
+#endif // SYMBIAN_FDC_HCTL_ORIGINAL_ACCEPT_FIRMWARE_UPDATE
+ }
+ // At this point we will have claimed to the interface mandated by FDF and
+ // so we are at liberty to return an error.
+
+ // firstly, check to see if a fatal error occured.
+ if(fatalError)
+ {
+ LOG(_L8("\tFatal error when retrieving interfaces for driver instance..."));
+ return KErrGeneral;
+ }
+
+ // Now we perform some validation that the function is what we expect.
+ // There should be two interfaces as part of the function. One is
+ // the standard data and control planes. The other for the sync-
+ // chronous connections.
+ if(aConfigurationDescriptor.NumInterfaces() < KNumOfHctlInterfaces)
+ {
+ LOG(_L8("\tInsufficent interfaces in USB config. descriptor..."));
+ return KErrUsbBadDescriptor;
+ }
+ if(aInterfaces.Count() < KNumOfHctlInterfaces)
+ {
+ LOG(_L8("\tInsufficient interfaces provided to FDC..."));
+ return KErrUnderflow;
+ }
+
+ // Ensure that we got both interfaces, otherwise the device is malformed.
+ if(!gotAcl || !gotSco)
+ {
+ LOG2(_L8("\tMissing Token [ACL=%d] [SCO=%d]"), gotAcl, gotSco);
+ return KErrNotFound;
+ }
+
+ // At this point we are set-up to use the device.
+ iReady = ETrue;
+
+ // We try our best; the Bluetooth stack may not be running, it may not be even using
+ // the USB HCTL. So we accept the tokens and try the best to set-up the HCTL.
+ // If we fail now the HCTL should later inform us to try again.
+ RequestConnection();
+
+ return KErrNone;
+ }
+
+void CFdcHctlOriginal::Mfi1DeviceDetached(TUint aDeviceId)
+ {
+ LOG_FUNC
+
+ iReady = EFalse;
+
+ if(iHctlSession.Handle())
+ {
+ // Inform of disconnection.
+ iHctlSession.DeviceDetached();
+ }
+ // Close Hctl Handle
+ iHctlSession.Close();
+ }
+
+void CFdcHctlOriginal::RequestConnection()
+ {
+ LOG_FUNC
+ // Trigger the attempt to connect to the USB HCTL Server.
+
+ if(!iReady)
+ {
+ // For whatever reason, we have not got the tokens for the USB interfaces.
+ LOG(_L8("\tFDC is not ready"));
+ return;
+ }
+
+ // Note that this will error if, the bt thread or usb hctl is not running;
+ // or if there is another FDC already connected to it.
+ TInt err = iHctlSession.Connect();
+ if(err != KErrNone)
+ {
+ LOG1(_L8("\tRHCTLUsbOriginal::Connect error = %d"), err);
+ return;
+ }
+
+ // Now inform the stack that we have a connected device.
+ err = iHctlSession.DeviceAttached(iAclToken, iScoToken);
+ if(err != KErrNone)
+ {
+ LOG1(_L8("\tRHCTLUsbOriginal::DeviceAttached error = %d"), err);
+ iHctlSession.Close();
+ return;
+ }
+ }
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/src/fdchctloriginalmain.cpp Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,33 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#include <ECom/ImplementationProxy.h>
+#include "fdchctloriginal.h"
+
+const TImplementationProxy ImplementationTable[] =
+ {
+ IMPLEMENTATION_PROXY_ENTRY(0x200345EA, CFdcHctlOriginal::NewL)
+ };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+ {
+ aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+ return ImplementationTable;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/fdc/src/fdchctloriginalserver.cpp Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,120 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#include "fdchctloriginalserver.h"
+
+#include "fdchctloriginal.h"
+#include "fdchctloriginalutils.h"
+#include "fdchctloriginalpolicy.h"
+
+#include <bluetooth/logger.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "fdchctloriginal");
+#endif
+
+
+CFdcHctlOriginalServer::CFdcHctlOriginalServer(CFdcHctlOriginal& aHctlOriginal)
+ : CPolicyServer(CActive::EPriorityStandard, KFdcHctlOriginalPolicy)
+ , iHctlOriginal(aHctlOriginal)
+ {
+ LOG_FUNC
+ }
+
+void CFdcHctlOriginalServer::ConstructL()
+ {
+ LOG_FUNC
+ StartL(KFdcHctlOrigSrvName);
+ }
+
+CFdcHctlOriginalServer* CFdcHctlOriginalServer::NewL(CFdcHctlOriginal& aHctlOriginal)
+ {
+ LOG_STATIC_FUNC
+ CFdcHctlOriginalServer* self = new(ELeave) CFdcHctlOriginalServer(aHctlOriginal);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+CFdcHctlOriginalServer::~CFdcHctlOriginalServer()
+ {
+ LOG_FUNC
+ }
+
+CSession2* CFdcHctlOriginalServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const
+ {
+ LOG_FUNC
+ LOG3(_L8("\taVersion = (%d,%d,%d)"), aVersion.iMajor, aVersion.iMinor, aVersion.iBuild);
+
+ // Version number check...
+ TVersion v(KFdcHctlOrigSrvMajorVersionNumber,
+ KFdcHctlOrigSrvMinorVersionNumber,
+ KFdcHctlOrigSrvBuildNumber);
+
+ if(!User::QueryVersionSupported(v, aVersion))
+ {
+ LEAVEIFERRORL(KErrNotSupported);
+ }
+
+ if(iSession)
+ {
+ LEAVEIFERRORL(KErrInUse);
+ }
+
+ iSession = new(ELeave) CFdcHctlOriginalSession(iHctlOriginal);
+ return iSession;
+ }
+
+void CFdcHctlOriginalServer::DropSession(CFdcHctlOriginalSession* aSession) const
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(iSession == aSession, PANIC(KFdcHctlOriginalPanic, EBadSessionPointer));
+ iSession = NULL;
+ }
+
+
+CFdcHctlOriginalSession::CFdcHctlOriginalSession(CFdcHctlOriginal& aHctlOriginal)
+ : iHctlOriginal(aHctlOriginal)
+ {
+ LOG_FUNC
+ }
+
+CFdcHctlOriginalSession::~CFdcHctlOriginalSession()
+ {
+ LOG_FUNC
+ static_cast<const CFdcHctlOriginalServer*>(Server())->DropSession(this);
+ }
+
+void CFdcHctlOriginalSession::ServiceL(const RMessage2& aMessage)
+ {
+ LOG_FUNC
+ switch(aMessage.Function())
+ {
+ case EFunctionRequestConnection:
+ iHctlOriginal.RequestConnection();
+ break;
+ default:
+ PANIC_MSG(aMessage, KFdcHctlOriginalSrvPanicCat, EFdcHctlInvalidFunction);
+ return;
+ }
+ aMessage.Complete(KErrNone);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/group/bld.inf Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,34 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#if defined(SYMBIAN_ENABLE_USB_OTG_HOST)
+
+PRJ_EXPORTS
+
+hctl_usb_original.iby /epoc32/rom/include/hctl_usb_original.iby
+
+#if !defined(WINS)
+#if !defined(X86)
+
+PRJ_MMPFILES
+
+../hctl/group/hctl_usb_original
+
+../fdc/group/fdc_hctl_original
+
+#endif // X86
+#endif // WINS
+
+#endif // SYMBIAN_ENABLE_USB_OTG_HOST
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/group/distribution.policy.s60 Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/group/hctl_usb_original.iby Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,25 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef HCTL_USB_ORIGINAL_IBY
+#define HCTL_USB_ORIGINAL_IBY
+
+REM H2 HCTL implementation
+
+HCI_PLUGIN(hctl_usb_original.dll, hctl_usb_original.rsc)
+
+HCI_PLUGIN(fdc_hctl_original.dll, fdc_hctl_original.rsc)
+
+#endif // HCTL_UART_ORIGINAL_IBY
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/group/distribution.policy.s60 Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/group/hctl_usb_original.mmp Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,62 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+target hctl_usb_original.dll
+targettype plugin
+// UID2 = 0x10009d8d for ECOM plugins.
+// UID3 = the 'DLL UID' (see resource file)
+uid 0x10009d8d 0x200345E5
+vendorid 0x70000001
+
+capability CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
+
+noexportlibrary
+
+userinclude ../inc
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+systeminclude ../../hctl/public
+systeminclude ../../fdc/public
+
+sourcepath ../src
+source hctlusboriginalmain.cpp
+source hctlusboriginal.cpp
+source hctlusboriginalcommand.cpp
+source hctlusboriginalevent.cpp
+source hctlusboriginalaclout.cpp
+source hctlusboriginalaclin.cpp
+source controllermanager.cpp
+source devicestatemanager.cpp
+source hctlusboriginalserver.cpp
+
+resource hctl_usb_original.rss
+
+library esock.lib
+library euser.lib
+library hctl_base.lib
+library usbdi_utils.lib
+library usbdescriptors.lib
+
+#include <bluetooth/btlogger.mmh>
+
+macro ENABLE_HCI_FRAME_LOGGING // Enable the HCI logging
+
+unpaged
+
+smpsafe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/inc/controllermanager.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,58 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef HOSTCONTROLLERMANAGER_H
+#define HOSTCONTROLLERMANAGER_H
+
+#include <e32base.h>
+#include <bluetooth/hci/hctlpowerinterface.h>
+
+class MControllerStateObserver;
+class CHCTLUsbOriginal;
+
+/**
+This is the class that implements a controller manager.
+This is a class which provides a framework for managing the
+power management and reset of the host controller.
+*/
+NONSHARABLE_CLASS(CControllerManager)
+ : public CBase
+ , public MHCTLPowerInterface
+ {
+public:
+ static CControllerManager* NewL(CHCTLUsbOriginal& aHctl);
+ ~CControllerManager();
+
+ void SetControllerStateObserver(MControllerStateObserver& aControllerStateObserver);
+ void HardReset();
+
+private:
+ CControllerManager(CHCTLUsbOriginal& aHctl);
+
+private: // from MHCTLPowerInterface
+ virtual TInt MhpiGetPower(TBTPowerState& aState);
+ virtual TInt MhpiSetPower(const TBTPowerState aState);
+
+private:
+ MControllerStateObserver* iControllerStateObserver;
+ CHCTLUsbOriginal& iHctl;
+ };
+
+#endif // HOSTCONTROLLERMANAGER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/inc/devicestatemanager.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,74 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef DEVICESTATEMANAGER_H
+#define DEVICESTATEMANAGER_H
+
+#include <e32base.h>
+
+class RUsbInterface;
+
+NONSHARABLE_CLASS(CInterfaceStateManager)
+ : public CActive
+ {
+public:
+ static CInterfaceStateManager* NewL(RUsbInterface& aInterface);
+ ~CInterfaceStateManager();
+
+ void Suspend();
+ void Resume();
+
+private:
+ CInterfaceStateManager(RUsbInterface& aInterface);
+
+ void RequestSuspend();
+
+private: // from CActive
+ void DoCancel();
+ void RunL();
+
+private:
+ RUsbInterface& iInterface;
+ };
+
+
+/**
+This is the class to control the state of the USB Device.
+*/
+NONSHARABLE_CLASS(CDeviceStateManager)
+ : public CBase
+ {
+public:
+ static CDeviceStateManager* NewL(RUsbInterface& aAclInterface, RUsbInterface& aScoInterface);
+ ~CDeviceStateManager();
+
+ void Suspend();
+ void Resume();
+
+private:
+ CDeviceStateManager();
+ void ConstructL(RUsbInterface& aAclInterface, RUsbInterface& aScoInterface);
+
+private:
+ CInterfaceStateManager* iAclManager;
+ CInterfaceStateManager* iScoManager;
+ };
+
+#endif // DEVICESTATEMANAGER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/inc/distribution.policy.s60 Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/inc/hctlusboriginal.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,147 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef HCTLUSBORIGINAL_H
+#define HCTLUSBORIGINAL_H
+
+#include <bluetooth/hci/hctlbase.h>
+#include <bluetooth/hciframelogger.h>
+#include <bluetooth/hci/hcitypes.h>
+#include <bluetooth/hci/hctlinterface.h>
+#include <bluetooth/hardresetinitiator.h>
+#include <d32usbdi.h>
+#include <fdchctloriginalcli.h>
+
+
+class CHCTLUsbOriginalCommand;
+class CHCTLUsbOriginalAclOut;
+class CHCTLUsbOriginalAclIn;
+class CHCTLUsbOriginalEvent;
+class CControllerManager;
+class CDeviceStateManager;
+class CHCTLUsbOriginalServer;
+class MHCTLChannelObserver;
+class MHCTLDataObserver;
+class MHCTLEventObserver;
+class MControllerStateObserver;
+class MQdpPluginInterfaceFinder;
+
+
+/**USB Original HCI Framing constants for command frames */
+static const TInt KHCTLCommandHeaderSize = 0;
+static const TInt KHCTLCommandTrailerSize = 0;
+
+/**USB Original HCI Framing constants for ACL data frames */
+static const TInt KHCTLAclDataHeaderSize = 0;
+static const TInt KHCTLAclDataTrailerSize = 0;
+
+/**USB Original HCI Framing constants for Synchronous data frames */
+static const TInt KHCTLSynchronousDataHeaderSize = 0;
+static const TInt KHCTLSynchronousDataTrailerSize = 0;
+
+/**
+This is the class that implements the USB specific HCTL.
+*/
+NONSHARABLE_CLASS(CHCTLUsbOriginal)
+ : public CHCTLBase
+ , public MHCTLInterface
+ , public MHardResetInitiator
+ {
+public:
+ static CHCTLUsbOriginal* NewL();
+ ~CHCTLUsbOriginal();
+
+ void ProcessACLData(const TDesC8& aData);
+ void ProcessSynchronousData(const TDesC8& aData);
+ void ProcessEvent(const TDesC8& aEvent);
+
+ MQdpPluginInterfaceFinder* QdpPluginInterfaceFinder();
+
+ // Called from the Controller Manager
+ void HandlePowerOff();
+ void HandlePowerOn();
+ TBTPowerState CurrentPowerState() const;
+
+ // Called from Server Session.
+ void DeviceAttachedL(TUint32 aStandardIf, TUint32 aScoIf);
+ void DeviceRemoved();
+
+ TBool DevicePresent() const;
+
+private:
+ CHCTLUsbOriginal();
+ void ConstructL();
+ TAny* Interface(TUid aUid);
+
+ static TInt AsyncCallBackSecondStage(TAny* aUsbOriginal);
+ static void Rollback(TAny* aPtr);
+
+ void HandleChannelStateChange();
+ TInt SetPower(TBTPowerState aState);
+
+private: // from MHCTLInterface
+ virtual TInt MhiWriteCommand(const TDesC8& aData);
+ virtual TInt MhiWriteAclData(const TDesC8& aData);
+ virtual TInt MhiWriteSynchronousData(const TDesC8& aData);
+ virtual void MhiGetAclDataTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const;
+ virtual void MhiGetSynchronousDataTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const;
+ virtual void MhiGetCommandTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const;
+ virtual void MhiSetChannelObserver(MHCTLChannelObserver& aChannelObserver);
+ virtual void MhiSetDataObserver(MHCTLDataObserver& aDataObserver);
+ virtual void MhiSetEventObserver(MHCTLEventObserver& aEventObserver);
+ virtual void MhiSetControllerStateObserver(MControllerStateObserver& aControllerStateObserver);
+ virtual void MhiSetQdpPluginInterfaceFinder(MQdpPluginInterfaceFinder& aQdpPluginInterfaceFinder);
+
+public: // from MHardResetInitiator
+ virtual void MhriStartHardReset();
+
+private:
+ RUsbInterface iInterface;
+ RUsbInterface iScoInterface;
+
+ // Senders
+ CHCTLUsbOriginalCommand* iControl;
+ CHCTLUsbOriginalAclOut* iAclOut;
+ // Receivers
+ CHCTLUsbOriginalAclIn* iAclIn;
+ CHCTLUsbOriginalEvent* iEvent;
+
+ MQdpPluginInterfaceFinder* iQdpPluginInterfaceFinder;
+ MHCTLChannelObserver* iChannelObserver;
+ MHCTLEventObserver* iEventObserver;
+ MHCTLDataObserver* iDataObserver;
+ MControllerStateObserver* iControllerStateObserver;
+
+ TBTPowerState iCurrentPowerState;
+
+ CControllerManager* iControllerMan;
+ CDeviceStateManager* iDeviceStateMan;
+ CHCTLUsbOriginalServer* iServer;
+
+ CAsyncCallBack* iSecondStageCallBack;
+
+ RFdcHctlOriginal iFdc;
+
+ DECLARE_HCI_LOGGER
+ };
+
+
+#endif // HCTLUSBORIGINAL_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/inc/hctlusboriginalaclin.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,64 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef HCTLUSBORIGINALACLIN_H
+#define HCTLUSBORIGINALACLIN_H
+
+#include <e32base.h>
+#include <bluetooth/hci/hcievents.h>
+#include <d32usbdi.h>
+#include <d32usbtransfers.h>
+
+class CHCTLUsbOriginal;
+
+NONSHARABLE_CLASS(CHCTLUsbOriginalAclIn)
+ : public CActive
+ {
+private:
+ static const TInt KEndpointNumber = 0x82;
+
+public:
+ static CHCTLUsbOriginalAclIn* NewL(CHCTLUsbOriginal& aHCTLUsbOriginal, RUsbInterface& aInterface);
+ ~CHCTLUsbOriginalAclIn();
+
+ // Called to initiate the initial read on the port.
+ void Start();
+
+private:
+ CHCTLUsbOriginalAclIn(CHCTLUsbOriginal& aHCTLUsbOriginal, RUsbInterface& aInterface);
+ void ConstructL();
+
+ // Helper methods
+ void QueueRead();
+
+private: // from CActive
+ virtual void RunL();
+ virtual void DoCancel();
+ virtual TInt RunError(TInt aError);
+
+private:
+ CHCTLUsbOriginal& iHCTLUsbOriginal;
+ RUsbInterface& iInterface;
+ RUsbPipe iPipe;
+ RUsbBulkTransferDescriptor iTransfer;
+ };
+
+#endif // HCTLUSBORIGINALACLIN_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/inc/hctlusboriginalaclout.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,57 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef HCTLUSBORIGINALACLOUT_H
+#define HCTLUSBORIGINALACLOUT_H
+
+#include <e32base.h>
+#include <d32usbdi.h>
+#include <d32usbtransfers.h>
+
+class MHCTLChannelObserver;
+
+NONSHARABLE_CLASS(CHCTLUsbOriginalAclOut)
+ : public CActive
+ {
+private:
+ static const TInt KEndpointNumber = 0x02;
+
+public:
+ static CHCTLUsbOriginalAclOut* NewL(RUsbInterface& aInterface);
+ ~CHCTLUsbOriginalAclOut();
+
+ TInt Write(const TDesC8& aData);
+ void SetChannelObserver(MHCTLChannelObserver& aObserver);
+
+private: // from CActive
+ virtual void RunL();
+ virtual void DoCancel();
+
+ CHCTLUsbOriginalAclOut(RUsbInterface& aInterface);
+ void ConstructL();
+
+private:
+ MHCTLChannelObserver* iChannelObserver;
+ RUsbInterface& iInterface;
+ RUsbPipe iPipe;
+ RUsbBulkTransferDescriptor iTransfer;
+ };
+
+#endif // HCTLUSBORIGINALACLOUT_H
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/inc/hctlusboriginalcommand.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,57 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef HCTLUSBORIGINALCONTROL_H
+#define HCTLUSBORIGINALCONTROL_H
+
+#include <e32base.h>
+#include <d32usbdi.h>
+
+class MHCTLChannelObserver;
+
+/**
+Control pipe in the spec. defined USB transport is one way.
+*/
+NONSHARABLE_CLASS(CHCTLUsbOriginalCommand)
+ : public CActive
+ {
+public:
+ static CHCTLUsbOriginalCommand* NewL(RUsbInterface& aInterface);
+ ~CHCTLUsbOriginalCommand();
+
+ TInt Write(const TDesC8& aData);
+ void SetChannelObserver(MHCTLChannelObserver& aObserver);
+
+private:
+ CHCTLUsbOriginalCommand(RUsbInterface& aInterface);
+
+private: // from CActive
+ virtual void RunL();
+ virtual void DoCancel();
+
+private:
+ MHCTLChannelObserver* iChannelObserver;
+ RUsbInterface& iInterface;
+ RUsbInterface::TUsbTransferRequestDetails iEp0Details;
+ TBuf8<255> iRecvData; // TODO test if we can remove this.
+ };
+
+#endif // HCTLUSBORIGINALCONTROL_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/inc/hctlusboriginalevent.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,63 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef HCTLUSBORIGINALEVENT_H
+#define HCTLUSBORIGINALEVENT_H
+
+#include <e32base.h>
+#include <bluetooth/hci/hcievents.h>
+#include <d32usbdi.h>
+#include <d32usbtransfers.h>
+
+class CHCTLUsbOriginal;
+
+NONSHARABLE_CLASS(CHCTLUsbOriginalEvent)
+ : public CActive
+ {
+private:
+ static const TInt KEndpointNumber = 0x81;
+
+public:
+ static CHCTLUsbOriginalEvent* NewL(CHCTLUsbOriginal& aHCTLUsbOriginal, RUsbInterface& aInterface);
+ ~CHCTLUsbOriginalEvent();
+
+ // Called to initiate the initial read on the port.
+ void Start();
+
+private:
+ CHCTLUsbOriginalEvent(CHCTLUsbOriginal& aHCTLUsbOriginal, RUsbInterface& aInterface);
+ void ConstructL();
+
+ void QueueRead();
+
+private: // from CActive
+ virtual void RunL();
+ virtual void DoCancel();
+ virtual TInt RunError(TInt aError);
+
+private:
+ CHCTLUsbOriginal& iHCTLUsbOriginal;
+ RUsbInterface& iInterface;
+ RUsbPipe iPipe;
+ RUsbIntrTransferDescriptor iTransfer;
+ };
+
+#endif // HCTLUSBORIGINALEVENT_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/inc/hctlusboriginalpolicy.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,63 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef HCTLUSBORIGINALPOLICY_H
+#define HCTLUSBORIGINALPOLICY_H
+
+#include <e32def.h>
+#include <hctlusboriginalipc.h>
+
+/** HCTL USB Original Server Security Policy Definition */
+const TUint KHCTLUsbOriginalRangeCount = 2;
+
+const TInt KHCTLUsbOriginalRanges[KHCTLUsbOriginalRangeCount] =
+ {
+ EFunctionAttached, // FDF SID
+// EFunctionDetached,
+ ENumHctlUsbOriginalSrvFuncs, // not supported
+ };
+
+/** Index numbers into KHCTLUsbOriginalElements[] */
+const TInt KPolicyFdfSid = 0;
+
+/** Mapping IPCs to policy element */
+const TUint8 KHCTLUsbOriginalElementsIndex[KHCTLUsbOriginalRangeCount] =
+ {
+ KPolicyFdfSid, // All (valid) APIs
+ CPolicyServer::ENotSupported // Undefined functions
+ };
+
+/** Individual policy elements */
+const CPolicyServer::TPolicyElement KHCTLUsbOriginalElements[] =
+ {
+ { _INIT_SECURITY_POLICY_S0(0x10282b48) },
+ };
+
+/** Main policy */
+const CPolicyServer::TPolicy KHCTLUsbOriginalPolicy =
+ {
+ KPolicyFdfSid, // connection requirements
+ KHCTLUsbOriginalRangeCount,
+ KHCTLUsbOriginalRanges,
+ KHCTLUsbOriginalElementsIndex,
+ KHCTLUsbOriginalElements,
+ };
+
+#endif // HCTLUSBORIGINALPOLICY_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/inc/hctlusboriginalserver.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,64 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef HCTLUSBORIGINALSERVER_H
+#define HCTLUSBORIGINALSERVER_H
+
+#include <e32base.h>
+
+class CHCTLUsbOriginal;
+
+NONSHARABLE_CLASS(CHCTLUsbOriginalSession)
+ : public CSession2
+ {
+public:
+ CHCTLUsbOriginalSession(CHCTLUsbOriginal& aUsbOriginal);
+ ~CHCTLUsbOriginalSession();
+
+private:
+ void ServiceL(const RMessage2& aMessage);
+
+private:
+ CHCTLUsbOriginal& iUsbOriginal;
+ TBool iDeviceAttached;
+ };
+
+
+NONSHARABLE_CLASS(CHCTLUsbOriginalServer)
+ : public CPolicyServer
+ {
+public:
+ static CHCTLUsbOriginalServer* NewL(CHCTLUsbOriginal& aUsbOriginal);
+ ~CHCTLUsbOriginalServer();
+
+ void DropSession(CHCTLUsbOriginalSession* aSession) const;
+
+private:
+ CHCTLUsbOriginalServer(CHCTLUsbOriginal& aUsbOriginal);
+ void ConstructL();
+
+ CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
+
+private:
+ CHCTLUsbOriginal& iUsbOriginal;
+ mutable CHCTLUsbOriginalSession* iSession;
+ };
+
+#endif // HCTLUSBORIGINALSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/inc/hctlusboriginalutils.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,48 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+
+#ifndef HCTLUSBORIGINALUTILS_H
+#define HCTLUSBORIGINALUTILS_H
+
+#include <e32base.h>
+
+/**
+The panic category for the USB Original HCTL.
+*/
+_LIT(KUsbOriginalPanic, "HctlUsbOrigPanic");
+
+/**
+Panic codes for USB Original HCTL.
+*/
+enum TUsbOriginalPanic
+ {
+ EUnexpectedCtrlMgrPowerState = 0,
+ EReadAttemptWhenReadOutstanding = 1,
+ EStateObserverNotAvailable = 2,
+ EStartCalledWhenReadOutstanding = 3,
+ ENoChannelObserver = 4,
+ EPartiallyOpenedInterface = 5,
+ EBadSessionPointer = 6,
+ EStackOnWhenNoDeviceConnected = 7,
+ };
+
+#endif // HCTLUSBORIGINALUTILS_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/public/distribution.policy.s60 Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/public/hctlusboriginalcli.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,76 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef HCTLUSBORIGINALCLI_H
+#define HCTLUSBORIGINALCLI_H
+
+#include <e32base.h>
+#include <hctlusboriginalipc.h>
+
+NONSHARABLE_CLASS(RHCTLUsbOriginal) : public RSessionBase
+ {
+public:
+ inline RHCTLUsbOriginal();
+
+ inline TInt Connect();
+ inline void Close();
+
+ inline TInt DeviceAttached(TUint32 aAclToken, TUint32 aScoToken);
+ inline void DeviceDetached();
+
+private:
+ TAny* iExtension;
+ };
+
+
+inline RHCTLUsbOriginal::RHCTLUsbOriginal()
+ : iExtension(NULL)
+ {}
+
+inline TInt RHCTLUsbOriginal::Connect()
+ {
+ // We don't want to start the server - that is a function of loading the bluetooth
+ // stack. Instead we just want to try and connect and report on whether we succeeded.
+ return CreateSession(
+ KHCTLUsbOrginalSrvName,
+ TVersion(
+ KHCTLUsbOriginalSrvMajorVersionNumber,
+ KHCTLUsbOriginalSrvMinorVersionNumber,
+ KHCTLUsbOriginalSrvBuildNumber
+ )
+ );
+ }
+
+inline void RHCTLUsbOriginal::Close()
+ {
+ RSessionBase::Close();
+ }
+
+inline TInt RHCTLUsbOriginal::DeviceAttached(TUint32 aAclToken, TUint32 aScoToken)
+ {
+ return SendReceive(EFunctionAttached, TIpcArgs(aAclToken, aScoToken));
+ }
+
+inline void RHCTLUsbOriginal::DeviceDetached()
+ {
+ Send(EFunctionDetached);
+ }
+
+#endif // HCTLUSBORIGINALCLI_H
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/public/hctlusboriginalipc.h Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,54 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef HCTLUSBORIGINALIPC_H
+#define HCTLUSBORIGINALIPC_H
+
+#include <e32base.h>
+
+//
+// HCTL Server IPC
+//
+
+_LIT(KHCTLUsbOrginalSrvName, "!HctlUsbOriginal");
+
+/** Version numbers. */
+const TInt8 KHCTLUsbOriginalSrvMajorVersionNumber = 1;
+const TInt8 KHCTLUsbOriginalSrvMinorVersionNumber = 0;
+const TInt16 KHCTLUsbOriginalSrvBuildNumber = 0;
+
+enum THCTLUsbOriginalSrvFuncs
+ {
+ EFunctionAttached = 0,
+ EFunctionDetached = 1,
+ /* Add new server functions before this */
+ ENumHctlUsbOriginalSrvFuncs // Never use as an actual function number
+ };
+
+_LIT(KHCTLUsbOriginalServerPanicCat, "HCTLUsbOriginalServer");
+
+enum THCTLUsbOriginalServerPanics
+ {
+ EInvalidFunction = 0,
+ EDeviceAlreadyAttached = 1,
+ EDeviceNotAttached = 2,
+ };
+
+#endif // HCTLUSBORIGINALIPC_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/src/controllermanager.cpp Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,133 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#include "controllermanager.h"
+
+#include <bluetooth/hci/controllerstateobserver.h>
+#include <bluetooth/hci/hctlchannelobserver.h>
+
+#include "hctlusboriginal.h"
+#include "hctlusboriginalutils.h"
+
+#include <bluetooth/logger.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, LOG_COMPONENT_HCTL_USB_ORIGINAL);
+#endif
+
+
+CControllerManager* CControllerManager::NewL(CHCTLUsbOriginal& aHctl)
+ {
+ LOG_STATIC_FUNC
+ CControllerManager* self = new(ELeave) CControllerManager(aHctl);
+ return self;
+ }
+
+CControllerManager::CControllerManager(CHCTLUsbOriginal& aHctl)
+ : iHctl(aHctl)
+ {
+ LOG_FUNC
+ }
+
+CControllerManager::~CControllerManager()
+ {
+ LOG_FUNC
+ }
+
+TInt CControllerManager::MhpiGetPower(TBTPowerState& aState)
+ {
+ LOG_FUNC
+
+ __ASSERT_DEBUG(iHctl.CurrentPowerState() == EBTOff || iHctl.DevicePresent(),
+ PANIC(KUsbOriginalPanic, EStackOnWhenNoDeviceConnected));
+
+ // Return current state.
+ aState = iHctl.CurrentPowerState();
+ return KErrNone;
+ }
+
+TInt CControllerManager::MhpiSetPower(TBTPowerState aState)
+ {
+ LOG_FUNC
+
+ TInt rerr = KErrAlreadyExists;
+ // Check that the requested state differs from the current state.
+ if(aState != iHctl.CurrentPowerState())
+ {
+ __ASSERT_ALWAYS(aState == EBTOff || aState == EBTOn,
+ PANIC(KUsbOriginalPanic, EUnexpectedCtrlMgrPowerState));
+ __ASSERT_ALWAYS(iControllerStateObserver,
+ PANIC(KUsbOriginalPanic, EStateObserverNotAvailable));
+
+ rerr = KErrNotReady;
+ if(aState == EBTOff || iHctl.DevicePresent())
+ {
+ iControllerStateObserver->McsoProcessPowerChange(KErrNone,
+ MControllerStateObserver::EBTFatalChange,
+ aState);
+
+ if(aState == EBTOff)
+ {
+ // Cancel any reads / writes.
+ iHctl.HandlePowerOff();
+ }
+ else
+ {
+ // Re-start the sender and receiver.
+ iHctl.HandlePowerOn();
+ }
+
+ rerr = KErrNone;
+ }
+ }
+
+ return rerr;
+ }
+
+void CControllerManager::HardReset()
+ {
+ LOG_FUNC
+
+ // Check if the power is currently switched off. This takes priority over
+ // hard reset.
+ if(iHctl.CurrentPowerState() == EBTOn)
+ {
+ __ASSERT_ALWAYS(iControllerStateObserver,
+ PANIC(KUsbOriginalPanic, EStateObserverNotAvailable));
+ __ASSERT_DEBUG(iHctl.DevicePresent(),
+ PANIC(KUsbOriginalPanic, EStackOnWhenNoDeviceConnected));
+
+ // Switch the power off then on to perform the reset.
+ iControllerStateObserver->McsoProcessHardResetPhaseChange(KErrNone, MControllerStateObserver::EBTFatalChange, EBTResetStarted);
+
+ iHctl.HandlePowerOff();
+ // TODO should there be an asynchronous break here, or are we good?
+ iHctl.HandlePowerOn();
+
+ // Reset is complete.
+ iControllerStateObserver->McsoProcessHardResetPhaseChange(KErrNone, MControllerStateObserver::EBTFatalChange, EBTResetComplete);
+ }
+ }
+
+void CControllerManager::SetControllerStateObserver(MControllerStateObserver& aControllerStateObserver)
+ {
+ LOG_FUNC
+ iControllerStateObserver = &aControllerStateObserver;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/src/devicestatemanager.cpp Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,128 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "devicestatemanager.h"
+
+#include <d32usbdi.h>
+
+#include <bluetooth/logger.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, LOG_COMPONENT_HCTL_USB_ORIGINAL);
+#endif
+
+CDeviceStateManager* CDeviceStateManager::NewL(RUsbInterface& aAclInterface, RUsbInterface& aScoInterface)
+ {
+ LOG_STATIC_FUNC
+ CDeviceStateManager* self = new(ELeave) CDeviceStateManager;
+ CleanupStack::PushL(self);
+ self->ConstructL(aAclInterface, aScoInterface);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+CDeviceStateManager::~CDeviceStateManager()
+ {
+ LOG_FUNC
+ delete iScoManager;
+ delete iAclManager;
+ }
+
+void CDeviceStateManager::Suspend()
+ {
+ LOG_FUNC
+ iAclManager->Suspend();
+ iScoManager->Suspend();
+ }
+
+void CDeviceStateManager::Resume()
+ {
+ LOG_FUNC
+ iAclManager->Resume();
+ iScoManager->Resume();
+ }
+
+CDeviceStateManager::CDeviceStateManager()
+ {
+ LOG_FUNC
+ }
+
+void CDeviceStateManager::ConstructL(RUsbInterface& aAclInterface, RUsbInterface& aScoInterface)
+ {
+ LOG_FUNC
+ iAclManager = CInterfaceStateManager::NewL(aAclInterface);
+ iScoManager = CInterfaceStateManager::NewL(aScoInterface);
+ }
+
+
+
+CInterfaceStateManager* CInterfaceStateManager::NewL(RUsbInterface& aInterface)
+ {
+ LOG_STATIC_FUNC
+ return new(ELeave) CInterfaceStateManager(aInterface);
+ }
+
+CInterfaceStateManager::~CInterfaceStateManager()
+ {
+ LOG_FUNC
+ Cancel();
+ }
+
+CInterfaceStateManager::CInterfaceStateManager(RUsbInterface& aInterface)
+ : CActive(EPriorityStandard)
+ , iInterface(aInterface)
+ {
+ LOG_FUNC
+ CActiveScheduler::Add(this);
+ }
+
+void CInterfaceStateManager::DoCancel()
+ {
+ LOG_FUNC
+ iInterface.CancelPermitSuspend();
+ }
+
+void CInterfaceStateManager::RunL()
+ {
+ LOG_FUNC
+ if(iStatus.Int() == KErrNone)
+ {
+ RequestSuspend();
+ }
+ // Ignore error - we'll try again on the next explict resume
+ }
+
+void CInterfaceStateManager::RequestSuspend()
+ {
+ iInterface.PermitSuspendAndWaitForResume(iStatus);
+ SetActive();
+ }
+
+void CInterfaceStateManager::Suspend()
+ {
+ LOG_FUNC
+ if(!IsActive()) // Only suspend if we aren't already suspended.
+ {
+ RequestSuspend();
+ }
+ }
+
+void CInterfaceStateManager::Resume()
+ {
+ LOG_FUNC
+ Cancel();
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/src/distribution.policy.s60 Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/src/hctl_usb_original.rss Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,46 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#include <ecom/registryinfo.rh>
+#include <bluetooth/hci/hctlbase.hrh>
+
+RESOURCE REGISTRY_INFO theInfo
+ {
+ dll_uid = 0x200345E5;
+ interfaces =
+ {
+ INTERFACE_INFO
+ {
+ interface_uid = KHCTLBaseEcomInterfaceUid;
+ implementations =
+ {
+ IMPLEMENTATION_INFO
+ {
+ implementation_uid = 0x200345E7;
+ version_no = 1;
+ display_name = "USB (ORIGINAL)";
+ default_data = "";
+ opaque_data = "";
+ }
+ };
+ }
+ };
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/src/hctlusboriginal.cpp Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,436 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#include "hctlusboriginal.h"
+
+#include "hctlusboriginalcommand.h"
+#include "hctlusboriginalaclout.h"
+#include "hctlusboriginalaclin.h"
+#include "hctlusboriginalevent.h"
+#include "controllermanager.h"
+#include "devicestatemanager.h"
+#include "hctlusboriginalserver.h"
+
+#include "hctlusboriginalutils.h"
+
+#include <bluetooth/hci/hctleventobserver.h>
+#include <bluetooth/hci/hctldataobserver.h>
+#include <bluetooth/hci/hctlchannelobserver.h>
+#include <bluetooth/logger.h>
+
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, LOG_COMPONENT_HCTL_USB_ORIGINAL);
+#endif
+
+_LIT(KUsbdiLddFileName, "usbdi");
+
+CHCTLUsbOriginal* CHCTLUsbOriginal::NewL()
+ {
+ LOG_STATIC_FUNC
+ CHCTLUsbOriginal* self = new(ELeave) CHCTLUsbOriginal();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+CHCTLUsbOriginal::CHCTLUsbOriginal()
+ {
+ LOG_FUNC
+ }
+
+CHCTLUsbOriginal::~CHCTLUsbOriginal()
+ {
+ LOG_FUNC
+
+ delete iControl;
+ delete iAclOut;
+ delete iAclIn;
+ delete iEvent;
+
+ iInterface.Close();
+ iScoInterface.Close();
+
+ iFdc.Close();
+
+ delete iSecondStageCallBack;
+
+ delete iServer;
+ delete iControllerMan;
+ HCI_LOG_UNLOAD(this);
+
+ // User::FreeLogicalDevice(RUsbInterface::Name()); // TODO Maybe this affects others
+ }
+
+void CHCTLUsbOriginal::ConstructL()
+ {
+ LOG_FUNC
+
+ LOG(_L("\tLoading USBDI LDD"));
+ TInt err = User::LoadLogicalDevice(KUsbdiLddFileName);
+ if(err != KErrNone && err != KErrAlreadyExists)
+ {
+ LEAVEIFERRORL(err);
+ }
+
+ HCI_LOG_LOADL(this, KHCILoggerDatalinkTypeH1); // no frame information - so use the H1 encoding.
+ iControllerMan = CControllerManager::NewL(*this);
+ iDeviceStateMan = CDeviceStateManager::NewL(iInterface, iScoInterface);
+ iServer = CHCTLUsbOriginalServer::NewL(*this);
+
+ // We need an asynchronous break from the synchronous creation path to complete the set-up.
+ // This is due to the behaviour of the Bluetooth stack.
+ TCallBack secondStageCallBack(AsyncCallBackSecondStage, this);
+ iSecondStageCallBack = new(ELeave) CAsyncCallBack(secondStageCallBack, CActive::EPriorityStandard);
+ iSecondStageCallBack->CallBack();
+ }
+
+TInt CHCTLUsbOriginal::AsyncCallBackSecondStage(TAny* aUsbOriginal)
+ {
+ LOG_STATIC_FUNC
+
+ CHCTLUsbOriginal* usbOriginal = static_cast<CHCTLUsbOriginal*>(aUsbOriginal);
+ static_cast<void>(usbOriginal->SetPower(EBTOff)); // Can't handle the error, it shouldn't affect operation.
+
+ TInt err = usbOriginal->iFdc.Connect();
+ LOG1(_L("\tFDC Connection result = %d"), err);
+ if(err == KErrNone)
+ {
+ // Here we are passive on errors, a failure to connect indicates
+ // that the FDC isn't loaded yet. When it is it will attach to
+ // us.
+ usbOriginal->iFdc.RequestConnection(); // Causes the FDC to call back with tokens.
+ }
+
+ return EFalse; // Don't call back any more.
+ }
+
+
+
+TAny* CHCTLUsbOriginal::Interface(TUid aUid)
+ {
+ LOG_FUNC
+
+ TAny* ret = NULL;
+ switch(aUid.iUid)
+ {
+ case KHCTLInterfaceUid:
+ ret = reinterpret_cast<TAny*>(static_cast<MHCTLInterface*>(this));
+ break;
+
+ case KHCTLPowerInterfaceUid:
+ ret = reinterpret_cast<TAny*>(static_cast<MHCTLPowerInterface*>(iControllerMan));
+ break;
+
+ case KHCHardResetUid:
+ ret = reinterpret_cast<TAny*>(static_cast<MHardResetInitiator*>(this));
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+ }
+
+//Implementation of pure virtuals from MHCTLInterface
+TInt CHCTLUsbOriginal::MhiWriteAclData(const TDesC8& aData)
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(iChannelObserver, PANIC(KUsbOriginalPanic, ENoChannelObserver));
+
+ TInt rerr = KErrNotReady;
+ // Send if the power is on.
+ if(iCurrentPowerState == EBTOn && DevicePresent())
+ {
+ rerr = iAclOut->Write(aData);
+ HCI_LOG_FRAME_IF_NO_ERROR(rerr, this, KHCILoggerHostToController | KHCILoggerACLDataFrame, aData);
+ }
+
+ return rerr;
+ }
+
+TInt CHCTLUsbOriginal::MhiWriteSynchronousData(const TDesC8& aData)
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(iChannelObserver, PANIC(KUsbOriginalPanic, ENoChannelObserver));
+
+ ASSERT(EFalse); // TODO Not supported yet
+
+ TInt rerr = KErrNotReady;
+ // Send if the power is on.
+ if(iCurrentPowerState == EBTOn && DevicePresent())
+ {
+ // TODO insert code here :)
+ HCI_LOG_FRAME_IF_NO_ERROR(rerr, this, KHCILoggerHostToController | KHCILoggerSynchronousDataFrame, aData);
+ }
+
+ return rerr;
+ }
+
+TInt CHCTLUsbOriginal::MhiWriteCommand(const TDesC8& aData)
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(iChannelObserver, PANIC(KUsbOriginalPanic, ENoChannelObserver));
+
+ TInt rerr = KErrNotReady;
+ // Send if the power is on.
+ if(iCurrentPowerState == EBTOn && DevicePresent())
+ {
+ rerr = iControl->Write(aData);
+ HCI_LOG_FRAME_IF_NO_ERROR(rerr, this, KHCILoggerHostToController | KHCILoggerCommandOrEvent, aData);
+ }
+
+ return rerr;
+ }
+
+void CHCTLUsbOriginal::MhiSetQdpPluginInterfaceFinder(MQdpPluginInterfaceFinder& aQdpPluginInterfaceFinder)
+ {
+ iQdpPluginInterfaceFinder = &aQdpPluginInterfaceFinder;
+ }
+
+void CHCTLUsbOriginal::MhriStartHardReset()
+ {
+ LOG_FUNC
+ iControllerMan->HardReset();
+ }
+
+void CHCTLUsbOriginal::MhiGetAclDataTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const
+ {
+ // Return the transport overhead for ACL data.
+ aHeaderSize = KHCTLAclDataHeaderSize;
+ aTrailerSize = KHCTLAclDataTrailerSize;
+ }
+
+void CHCTLUsbOriginal::MhiGetSynchronousDataTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const
+ {
+ // Return the transport overhead for Synchronous data.
+ aHeaderSize = KHCTLSynchronousDataHeaderSize;
+ aTrailerSize = KHCTLSynchronousDataTrailerSize;
+ }
+
+void CHCTLUsbOriginal::MhiGetCommandTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const
+ {
+ // Return the transport overhead for HCI commands data.
+ aHeaderSize = KHCTLCommandHeaderSize;
+ aTrailerSize = KHCTLCommandTrailerSize;
+ }
+
+/**
+This function is used by the receiver for informing HCI that ACL data has been received
+The receiver doesn't have reference to iDataObserver. So this is merely a wrapper for iDataObserver
+*/
+void CHCTLUsbOriginal::ProcessACLData(const TDesC8& aData)
+ {
+ HCI_LOG_FRAME(this, KHCILoggerControllerToHost | KHCILoggerACLDataFrame, aData);
+ iDataObserver->MhdoProcessAclData(aData);
+ }
+
+/**
+This function is used by the receiver for informing HCI that Synchronous data has been received
+The receiver doesn't have reference to iDataObserver. So this is merely a wrapper for iDataObserver
+*/
+void CHCTLUsbOriginal::ProcessSynchronousData(const TDesC8& aData)
+ {
+ HCI_LOG_FRAME(this, KHCILoggerControllerToHost | KHCILoggerSynchronousDataFrame, aData);
+ iDataObserver->MhdoProcessSynchronousData(aData);
+ }
+
+/**
+This function is used by the receiver for informing HCI that event has been received
+The receiver doesn't have reference to iEventObserver. So this is merely a wrapper for iDataObserver
+*/
+void CHCTLUsbOriginal::ProcessEvent(const TDesC8& aEvent)
+ {
+ HCI_LOG_FRAME(this, KHCILoggerControllerToHost | KHCILoggerCommandOrEvent, aEvent);
+ iEventObserver->MheoProcessEvent(aEvent);
+ }
+
+/**
+QdpPluginInterfaceFinder getter.
+
+@return returns iQdpPluginInterfaceFinder which could be NULL
+if it has not been given one.
+*/
+MQdpPluginInterfaceFinder* CHCTLUsbOriginal::QdpPluginInterfaceFinder()
+ {
+ return iQdpPluginInterfaceFinder;
+ }
+
+void CHCTLUsbOriginal::MhiSetDataObserver(MHCTLDataObserver& aDataObserver)
+ {
+ iDataObserver = &aDataObserver;
+ }
+
+void CHCTLUsbOriginal::MhiSetEventObserver(MHCTLEventObserver& aEventObserver)
+ {
+ iEventObserver = &aEventObserver;
+ }
+
+void CHCTLUsbOriginal::MhiSetChannelObserver(MHCTLChannelObserver& aChannelObserver)
+ {
+ iChannelObserver = &aChannelObserver;
+ if(DevicePresent())
+ {
+ iControl->SetChannelObserver(aChannelObserver);
+ iAclOut->SetChannelObserver(aChannelObserver);
+ }
+ HandleChannelStateChange();
+ }
+
+void CHCTLUsbOriginal::MhiSetControllerStateObserver(MControllerStateObserver& aControllerStateObserver)
+ {
+ iControllerStateObserver = &aControllerStateObserver;
+ iControllerMan->SetControllerStateObserver(aControllerStateObserver);
+ }
+
+void CHCTLUsbOriginal::HandleChannelStateChange()
+ {
+ if(iCurrentPowerState == EBTOn && iChannelObserver && DevicePresent())
+ {
+ iDeviceStateMan->Resume();
+ iChannelObserver->MhcoChannelOpen(KHCITransportAllChannels);
+ iAclIn->Start();
+ iEvent->Start();
+ // The senders will be activated when the first frame needs to be sent.
+ }
+ else
+ {
+ if(iChannelObserver)
+ {
+ iChannelObserver->MhcoChannelClosed(KHCITransportAllChannels);
+ }
+ if(DevicePresent())
+ {
+ // abort communication with the hardware
+ iControl->Cancel();
+ iAclOut->Cancel();
+ iAclIn->Cancel();
+ iEvent->Cancel();
+
+ // try to suspend the device
+ iDeviceStateMan->Suspend();
+ }
+ }
+ }
+
+void CHCTLUsbOriginal::HandlePowerOff()
+ {
+ iCurrentPowerState = EBTOff;
+ HandleChannelStateChange();
+ }
+
+void CHCTLUsbOriginal::HandlePowerOn()
+ {
+ iCurrentPowerState = EBTOn;
+ HandleChannelStateChange();
+ }
+
+TBTPowerState CHCTLUsbOriginal::CurrentPowerState() const
+ {
+ return iCurrentPowerState;
+ }
+
+TInt CHCTLUsbOriginal::SetPower(TBTPowerState aState)
+ {
+ return static_cast<MHCTLPowerInterface*>(iControllerMan)->MhpiSetPower(aState);
+ }
+
+TBool CHCTLUsbOriginal::DevicePresent() const
+ {
+ if(iControl)
+ {
+ __ASSERT_DEBUG(iAclOut && iAclIn && iEvent, PANIC(KUsbOriginalPanic, EPartiallyOpenedInterface));
+ return ETrue;
+ }
+ return EFalse;
+ }
+
+void CHCTLUsbOriginal::DeviceAttachedL(TUint32 aStandardIf, TUint32 aScoIf)
+ {
+ if(iCurrentPowerState == EBTOn)
+ {
+ // If the stack is already powered up then we cannot handle the attach.
+ // Ideally we would inform the user to disconnect and connect the device again.
+ LEAVEL(KErrAlreadyExists);
+ }
+
+ CleanupStack::PushL(TCleanupItem(CHCTLUsbOriginal::Rollback, this));
+
+ // Open interface (there should be only 1 setting).
+ LEAVEIFERRORL(iInterface.Open(aStandardIf));
+ TInt aclAltIfCount = iInterface.GetAlternateInterfaceCount();
+ if(aclAltIfCount != 1)
+ {
+ LEAVEIFERRORL(aclAltIfCount); // if it's an error then leave with that
+ LOG1(_L8("ACL interface has %d alternate interfaces instead of 1"), aclAltIfCount);
+ LEAVEL(KErrTotalLossOfPrecision);
+ }
+
+ // We don't do SCO yet, so just set alt. int. setting 0
+ LEAVEIFERRORL(iScoInterface.Open(aScoIf));
+ LEAVEIFERRORL(iScoInterface.SelectAlternateInterface(0));
+
+ // Initialise pipe AOs
+ iControl = CHCTLUsbOriginalCommand::NewL(iInterface);
+ iAclOut = CHCTLUsbOriginalAclOut::NewL(iInterface);
+ iAclIn = CHCTLUsbOriginalAclIn::NewL(*this, iInterface);
+ iEvent = CHCTLUsbOriginalEvent::NewL(*this, iInterface);
+
+ // Pipe AOs should have registered their trans. descriptors so initialise.
+ LEAVEIFERRORL(iInterface.InitialiseTransferDescriptors());
+
+ // Finally set-up channel observers, if needed
+ if(iChannelObserver)
+ {
+ iControl->SetChannelObserver(*iChannelObserver);
+ iAclOut->SetChannelObserver(*iChannelObserver);
+ }
+
+ // Ensure we tell everyone what has just happened.
+ TInt err = SetPower(EBTOn);
+ if(err != KErrNone && err != KErrAlreadyExists)
+ {
+ LEAVEIFERRORL(err);
+ }
+
+ CleanupStack::Pop(this);
+ }
+
+void CHCTLUsbOriginal::DeviceRemoved()
+ {
+ // Cleanup resources.
+ delete iEvent, iEvent = NULL;
+ delete iAclIn, iAclIn = NULL;
+ delete iAclOut, iAclOut = NULL;
+ delete iControl,iControl = NULL;
+
+ iScoInterface.Close();
+ iInterface.Close();
+
+ // Ensure we tell everyone what has just happened.
+ static_cast<void>(SetPower(EBTOff));
+ }
+
+void CHCTLUsbOriginal::Rollback(TAny* aPtr)
+ {
+ CHCTLUsbOriginal* self = reinterpret_cast<CHCTLUsbOriginal*>(aPtr);
+ self->DeviceRemoved();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/src/hctlusboriginalaclin.cpp Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,120 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#include "hctlusboriginalaclin.h"
+
+#include "hctlusboriginal.h"
+#include "hctlusboriginalutils.h"
+
+// These files are included to get HCI specification defined constants.
+#include <bluetooth/hci/hciframe.h>
+#include <bluetooth/hci/event.h>
+
+#include <bluetooth/logger.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, LOG_COMPONENT_HCTL_USB_ORIGINAL);
+#endif
+
+
+CHCTLUsbOriginalAclIn::CHCTLUsbOriginalAclIn(CHCTLUsbOriginal& aHCTLUsbOriginal, RUsbInterface& aInterface)
+ : CActive(EPriorityStandard)
+ , iHCTLUsbOriginal(aHCTLUsbOriginal)
+ , iInterface(aInterface)
+ , iTransfer(CHctlAclDataFrame::KHCTLMaxACLDataSize)
+ {
+ LOG_FUNC
+ CActiveScheduler::Add(this);
+ }
+
+CHCTLUsbOriginalAclIn::~CHCTLUsbOriginalAclIn()
+ {
+ LOG_FUNC
+ Cancel();
+ iPipe.Close();
+ iTransfer.Close();
+ }
+
+CHCTLUsbOriginalAclIn* CHCTLUsbOriginalAclIn::NewL(CHCTLUsbOriginal& aHCTLUsbOriginal, RUsbInterface& aInterface)
+ {
+ LOG_STATIC_FUNC
+ CHCTLUsbOriginalAclIn* self = new(ELeave) CHCTLUsbOriginalAclIn(aHCTLUsbOriginal, aInterface);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+void CHCTLUsbOriginalAclIn::ConstructL()
+ {
+ LOG_FUNC
+ LEAVEIFERRORL(iInterface.RegisterTransferDescriptor(iTransfer));
+ LEAVEIFERRORL(iInterface.OpenPipeForEndpoint(iPipe, KEndpointNumber, EFalse));
+ }
+
+void CHCTLUsbOriginalAclIn::QueueRead()
+ {
+ LOG_FUNC
+
+ __ASSERT_DEBUG(!IsActive(), PANIC(KUsbOriginalPanic, EReadAttemptWhenReadOutstanding));
+
+ // I think the spec states that a single ACL packet is contained in a single USB
+ // transaction. As such we don't need to mess around working out how much to read
+ // we just need to issue a transfer big enough to get all the data possible.
+ // Of course it is unlikely that a controller would batch up that much data - it might be
+ // better to just expect a 3 DH-5 payload size instead...
+
+ iTransfer.SaveData(iTransfer.WritableBuffer().MaxLength());
+
+ SetActive();
+ iPipe.Transfer(iTransfer, iStatus);
+ }
+
+void CHCTLUsbOriginalAclIn::RunL()
+ {
+ LOG_FUNC
+ // Only process the read if it has completed successfully.
+ LEAVEIFERRORL(iStatus.Int());
+ iHCTLUsbOriginal.ProcessACLData(iTransfer.Buffer());
+ QueueRead();
+ }
+
+void CHCTLUsbOriginalAclIn::DoCancel()
+ {
+ LOG_FUNC
+ iPipe.CancelAllTransfers();
+ }
+
+TInt CHCTLUsbOriginalAclIn::RunError(TInt aError)
+ {
+ LOG_FUNC
+ LOG1(_L8("\taError = %d"), aError);
+ // The HCTL can not recover from this. Reset the controller and restart the host.
+ // TODO we should try to handle the case where the device is unpluged.
+ iHCTLUsbOriginal.MhriStartHardReset();
+ return KErrNone;
+ }
+
+void CHCTLUsbOriginalAclIn::Start()
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(!IsActive(), PANIC(KUsbOriginalPanic, EStartCalledWhenReadOutstanding));
+ QueueRead();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/src/hctlusboriginalaclout.cpp Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,108 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#include "hctlusboriginalaclout.h"
+
+#include <bluetooth/hci/hctlchannelobserver.h>
+#include <bluetooth/hci/hciframe.h>
+
+#include <bluetooth/logger.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, LOG_COMPONENT_HCTL_USB_ORIGINAL);
+#endif
+
+CHCTLUsbOriginalAclOut::CHCTLUsbOriginalAclOut(RUsbInterface& aInterface)
+ : CActive(EPriorityStandard)
+ , iInterface(aInterface)
+ , iTransfer(CHctlAclDataFrame::KHCTLMaxACLDataSize)
+ {
+ LOG_FUNC
+ CActiveScheduler::Add(this);
+ }
+
+void CHCTLUsbOriginalAclOut::ConstructL()
+ {
+ LOG_FUNC
+ LEAVEIFERRORL(iInterface.RegisterTransferDescriptor(iTransfer));
+ LEAVEIFERRORL(iInterface.OpenPipeForEndpoint(iPipe, KEndpointNumber, EFalse));
+ }
+
+CHCTLUsbOriginalAclOut::~CHCTLUsbOriginalAclOut()
+ {
+ LOG_FUNC
+ Cancel();
+ iPipe.Close();
+ iTransfer.Close();
+ }
+
+CHCTLUsbOriginalAclOut* CHCTLUsbOriginalAclOut::NewL(RUsbInterface& aInterface)
+ {
+ LOG_STATIC_FUNC
+ CHCTLUsbOriginalAclOut* self = new(ELeave) CHCTLUsbOriginalAclOut(aInterface);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+TInt CHCTLUsbOriginalAclOut::Write(const TDesC8& aData)
+ {
+ LOG_FUNC
+ TInt rerr = KErrNone;
+ //Check whether we finished with the previous write
+ if(!IsActive())
+ {
+ // Currently we only support sending one transfer at a time, so close off the channel after a write
+ iChannelObserver->MhcoChannelClosed(KHCITransportACLDataChannel);
+
+ iTransfer.WritableBuffer() = aData;
+ iTransfer.SaveData(aData.Length());
+
+ SetActive();
+ iPipe.Transfer(iTransfer, iStatus);
+ }
+ else
+ {
+ LOG(_L8("ERROR: Sender is already active!!\r\n"));
+ rerr = KErrInUse;
+ }
+
+ return rerr;
+ }
+
+void CHCTLUsbOriginalAclOut::SetChannelObserver(MHCTLChannelObserver& aObserver)
+ {
+ LOG_FUNC
+ iChannelObserver = &aObserver;
+ }
+
+void CHCTLUsbOriginalAclOut::RunL()
+ {
+ LOG_FUNC
+ LOG1(_L8("\tiStatus = %d"), iStatus.Int());
+ iChannelObserver->MhcoChannelOpen(KHCITransportACLDataChannel);
+ }
+
+void CHCTLUsbOriginalAclOut::DoCancel()
+ {
+ LOG_FUNC
+ iPipe.CancelAllTransfers();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/src/hctlusboriginalcommand.cpp Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,101 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#include "hctlusboriginalcommand.h"
+
+#include <bluetooth/hci/hctlchannelobserver.h>
+#include <bluetooth/logger.h>
+
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, LOG_COMPONENT_HCTL_USB_ORIGINAL);
+#endif
+
+CHCTLUsbOriginalCommand::CHCTLUsbOriginalCommand(RUsbInterface& aInterface)
+ : CActive(EPriorityStandard)
+ , iInterface(aInterface)
+ {
+ LOG_FUNC
+ CActiveScheduler::Add(this);
+
+ // Initialise Ep0 request details.
+ iEp0Details.iRequestType = 0x20; // Class request
+ iEp0Details.iRequest = 0x00; // All HCI commands are req 0x00.
+ iEp0Details.iValue = 0x0000; // N/a for HCI
+ iEp0Details.iIndex = 0x0000; // N/a for HCI
+ iEp0Details.iFlags = 0x04; // Short transfer OK
+ }
+
+
+CHCTLUsbOriginalCommand::~CHCTLUsbOriginalCommand()
+ {
+ LOG_FUNC
+ Cancel();
+ }
+
+CHCTLUsbOriginalCommand* CHCTLUsbOriginalCommand::NewL(RUsbInterface& aInterface)
+ {
+ LOG_STATIC_FUNC
+ CHCTLUsbOriginalCommand* self = new(ELeave)CHCTLUsbOriginalCommand(aInterface);
+ return self;
+ }
+
+TInt CHCTLUsbOriginalCommand::Write(const TDesC8& aData)
+ {
+ LOG_FUNC
+ TInt rerr = KErrNone;
+ //Check whether we finished with the previous write
+ if(!IsActive())
+ {
+ // We want to send Ep0 commands in a serial fashion (we only use one active object).
+ iChannelObserver->MhcoChannelClosed(KHCITransportCommandChannel);
+
+ iRecvData.SetLength(0); // We don't receive any data via Ep0 (events come in on a separate pipe).
+
+ SetActive();
+ iInterface.Ep0Transfer(iEp0Details, aData, iRecvData, iStatus);
+ }
+ else
+ {
+ LOG(_L8("ERROR: Sender is already active!!\r\n"));
+ rerr = KErrInUse;
+ }
+
+ return rerr;
+ }
+
+void CHCTLUsbOriginalCommand::SetChannelObserver(MHCTLChannelObserver& aObserver)
+ {
+ LOG_FUNC
+ iChannelObserver = &aObserver;
+ }
+
+void CHCTLUsbOriginalCommand::RunL()
+ {
+ LOG_FUNC
+ LOG1(_L8("\tiStatus = %d"), iStatus.Int());
+ iChannelObserver->MhcoChannelOpen(KHCITransportCommandChannel);
+ }
+
+void CHCTLUsbOriginalCommand::DoCancel()
+ {
+ LOG_FUNC
+ // TODO can't do this yet, there is no API available for this...
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/src/hctlusboriginalevent.cpp Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,120 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#include "hctlusboriginalevent.h"
+
+#include "hctlusboriginal.h"
+#include "hctlusboriginalutils.h"
+
+// These files are included to get HCI specification defined constants.
+#include <bluetooth/hci/hciframe.h>
+#include <bluetooth/hci/event.h>
+
+#include <bluetooth/logger.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, LOG_COMPONENT_HCTL_USB_ORIGINAL);
+#endif
+
+static const TInt KMaxEventPacketSize = 0xff + 2; // 8bit code + 8bit total "payload" field
+
+
+CHCTLUsbOriginalEvent::CHCTLUsbOriginalEvent(CHCTLUsbOriginal& aHCTLUsbOriginal, RUsbInterface& aInterface)
+ : CActive(EPriorityStandard)
+ , iHCTLUsbOriginal(aHCTLUsbOriginal)
+ , iInterface(aInterface)
+ , iTransfer(KMaxEventPacketSize)
+ {
+ LOG_FUNC
+ CActiveScheduler::Add(this);
+ }
+
+CHCTLUsbOriginalEvent::~CHCTLUsbOriginalEvent()
+ {
+ LOG_FUNC
+ Cancel();
+ iPipe.Close();
+ iTransfer.Close();
+ }
+
+CHCTLUsbOriginalEvent* CHCTLUsbOriginalEvent::NewL(CHCTLUsbOriginal& aHCTLUsbOriginal, RUsbInterface& aInterface)
+ {
+ LOG_STATIC_FUNC
+ CHCTLUsbOriginalEvent* self = new(ELeave) CHCTLUsbOriginalEvent(aHCTLUsbOriginal, aInterface);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+void CHCTLUsbOriginalEvent::ConstructL()
+ {
+ LOG_FUNC
+ LEAVEIFERRORL(iInterface.RegisterTransferDescriptor(iTransfer));
+ LEAVEIFERRORL(iInterface.OpenPipeForEndpoint(iPipe, KEndpointNumber, EFalse));
+ }
+
+void CHCTLUsbOriginalEvent::QueueRead()
+ {
+ LOG_FUNC
+
+ __ASSERT_DEBUG(!IsActive(), PANIC(KUsbOriginalPanic, EReadAttemptWhenReadOutstanding));
+
+ // I think the spec states that a single ACL packet is contained in a single USB
+ // transaction. As such we don't need to mess around working out how much to read
+ // we just need to issue a transfer big enough to get all the data possible.
+
+ iTransfer.SaveData(iTransfer.WritableBuffer().MaxLength());
+
+ SetActive();
+ iPipe.Transfer(iTransfer, iStatus);
+ }
+
+void CHCTLUsbOriginalEvent::RunL()
+ {
+ LOG_FUNC
+ // Only process the read if it has completed successfully.
+ LEAVEIFERRORL(iStatus.Int());
+ iHCTLUsbOriginal.ProcessEvent(iTransfer.Buffer());
+ QueueRead();
+ }
+
+void CHCTLUsbOriginalEvent::DoCancel()
+ {
+ LOG_FUNC
+ iPipe.CancelAllTransfers();
+ }
+
+TInt CHCTLUsbOriginalEvent::RunError(TInt aError)
+ {
+ LOG_FUNC
+ LOG1(_L8("\taError = %d"), aError);
+ // The HCTL can not recover from this. Reset the controller and restart the host.
+ // TODO we should try to handle the case where the device is unpluged.
+ iHCTLUsbOriginal.MhriStartHardReset();
+ return KErrNone;
+ }
+
+void CHCTLUsbOriginalEvent::Start()
+ {
+ LOG_FUNC
+ __ASSERT_DEBUG(!IsActive(), PANIC(KUsbOriginalPanic, EStartCalledWhenReadOutstanding));
+ QueueRead();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/src/hctlusboriginalmain.cpp Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,35 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#include <ecom/implementationproxy.h>
+#include "hctlusboriginal.h"
+
+// Define the private interface UIDs
+const TImplementationProxy ImplementationTable[] =
+ {
+ IMPLEMENTATION_PROXY_ENTRY(0x200345E7, CHCTLUsbOriginal::NewL),
+ };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+ {
+ aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+ return ImplementationTable;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/hctl/src/hctlusboriginalserver.cpp Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,145 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#include "hctlusboriginalserver.h"
+
+#include "hctlusboriginal.h"
+#include "hctlusboriginalutils.h"
+#include "hctlusboriginalpolicy.h"
+
+#include <bluetooth/logger.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, LOG_COMPONENT_HCTL_USB_ORIGINAL);
+#endif
+
+
+CHCTLUsbOriginalServer::CHCTLUsbOriginalServer(CHCTLUsbOriginal& aUsbOriginal)
+ : CPolicyServer(CActive::EPriorityStandard, KHCTLUsbOriginalPolicy)
+ , iUsbOriginal(aUsbOriginal)
+ {
+ LOG_FUNC
+ }
+
+void CHCTLUsbOriginalServer::ConstructL()
+ {
+ LOG_FUNC
+ StartL(KHCTLUsbOrginalSrvName);
+ }
+
+CHCTLUsbOriginalServer* CHCTLUsbOriginalServer::NewL(CHCTLUsbOriginal& aUsbOriginal)
+ {
+ LOG_STATIC_FUNC
+ CHCTLUsbOriginalServer* self = new(ELeave) CHCTLUsbOriginalServer(aUsbOriginal);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+CHCTLUsbOriginalServer::~CHCTLUsbOriginalServer()
+ {
+ LOG_FUNC
+ }
+
+CSession2* CHCTLUsbOriginalServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const
+ {
+ LOG_FUNC
+ LOG3(_L8("\taVersion = (%d,%d,%d)"), aVersion.iMajor, aVersion.iMinor, aVersion.iBuild);
+
+ // Version number check...
+ TVersion v(KHCTLUsbOriginalSrvMajorVersionNumber,
+ KHCTLUsbOriginalSrvMinorVersionNumber,
+ KHCTLUsbOriginalSrvBuildNumber);
+
+ if(!User::QueryVersionSupported(v, aVersion))
+ {
+ LEAVEIFERRORL(KErrNotSupported);
+ }
+
+ if(iSession)
+ {
+ LEAVEIFERRORL(KErrInUse);
+ }
+
+ iSession = new(ELeave) CHCTLUsbOriginalSession(iUsbOriginal);
+ return iSession;
+ }
+
+void CHCTLUsbOriginalServer::DropSession(CHCTLUsbOriginalSession* aSession) const
+ {
+ __ASSERT_DEBUG(iSession == aSession, PANIC(KUsbOriginalPanic, EBadSessionPointer));
+ iSession = NULL;
+ }
+
+
+
+CHCTLUsbOriginalSession::CHCTLUsbOriginalSession(CHCTLUsbOriginal& aUsbOriginal)
+ : iUsbOriginal(aUsbOriginal)
+ {
+ LOG_FUNC
+ }
+
+CHCTLUsbOriginalSession::~CHCTLUsbOriginalSession()
+ {
+ LOG_FUNC
+ static_cast<const CHCTLUsbOriginalServer*>(Server())->DropSession(this);
+ }
+
+void CHCTLUsbOriginalSession::ServiceL(const RMessage2& aMessage)
+ {
+ LOG_FUNC
+ LOG1(_L("\taMessage.Function() = %d"), aMessage.Function());
+
+ switch(aMessage.Function())
+ {
+ case EFunctionAttached:
+ {
+ if(iDeviceAttached)
+ {
+ PANIC_MSG(aMessage, KHCTLUsbOriginalServerPanicCat, EDeviceAlreadyAttached);
+ return;
+ }
+ TUint32 aclToken = static_cast<TUint32>(aMessage.Int0());
+ TUint32 scoToken = static_cast<TUint32>(aMessage.Int1());
+ iUsbOriginal.DeviceAttachedL(aclToken, scoToken);
+ iDeviceAttached = ETrue;
+ }
+ break;
+
+ case EFunctionDetached:
+ {
+ if(!iDeviceAttached)
+ {
+ PANIC_MSG(aMessage, KHCTLUsbOriginalServerPanicCat, EDeviceNotAttached);
+ return;
+ }
+ iUsbOriginal.DeviceRemoved();
+ iDeviceAttached = EFalse;
+ }
+ break;
+
+ default:
+ PANIC_MSG(aMessage, KHCTLUsbOriginalServerPanicCat, EInvalidFunction);
+ return;
+ }
+ aMessage.Complete(KErrNone);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bthci/hci2implementations/hctls/usb_original/readme.txt Thu Oct 14 11:16:56 2010 +0100
@@ -0,0 +1,51 @@
+This is an implementation of the Bluetooth USB HCTL for the Symbian
+USB Host driver interface.
+
+Note that this implementation is based on the classic "H2"
+specification, as such it is not completely compatible with the
+updated version published with the Bluetooth Core Specification
+3.0+HS (and onwards).
+
+There are two distinct components:
+ * The HCTL Plugin - this provides the Bluetooth transport
+ layer adaptation implementation through the USB driver
+ interface.
+ * The FDC Plugin - this is receives the driver information
+ from the USB Function Driver Framework, it validates the
+ device before supplying the notifications of device
+ attachment/detachment to the HCTL.
+
+Both these components must be present for the system to be
+functional, they can be included in a ROM image with the provided
+iby file:
+ hctl_usb_original.iby
+
+If the reference CoreHCI is in use then a simple macro definition
+is all that is required to include the iby file. The macro to use
+is HCI_USB; below is an example of its use:
+ buildrom ... -DHCI_USB
+
+To configure the Bluetooth stack to use this driver, the CoreHCI
+implementation must be appropriately configured to use this
+implementation. Typically this is through an ini file in the
+ESock data cage - in the Symbian file system this would be located:
+
+ z:\private\101f7989\bluetooth\corehci_symbian.ini
+
+In this file you should indicate the HCTL Plugin implementation
+UID (0x200345E7):
+
+ hctl_uid= 0x200345E7
+
+An example configuration is provided in the Symbian reference
+CoreHCI:
+
+ corehci_symbian_usboriginal.ini
+
+This should be all that is required to configure the use of the
+driver. The FDF should automatically load the FDC plugin when
+a Bluetooth device is attached to the USB bus. When no device is
+attached then behaviour of the Bluetooth stack is the same as if
+Bluetooth controllers power had been switched off (i.e. through the
+power control API).
+