27
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
/**
|
|
17 |
@file
|
|
18 |
@internalComponent
|
|
19 |
*/
|
|
20 |
|
|
21 |
#include "hctlusboriginalcommand.h"
|
|
22 |
|
|
23 |
#include <bluetooth/hci/hctlchannelobserver.h>
|
|
24 |
#include <bluetooth/logger.h>
|
|
25 |
|
|
26 |
|
|
27 |
#ifdef __FLOG_ACTIVE
|
|
28 |
_LIT8(KLogComponent, LOG_COMPONENT_HCTL_USB_ORIGINAL);
|
|
29 |
#endif
|
|
30 |
|
|
31 |
CHCTLUsbOriginalCommand::CHCTLUsbOriginalCommand(RUsbInterface& aInterface)
|
|
32 |
: CActive(EPriorityStandard)
|
|
33 |
, iInterface(aInterface)
|
|
34 |
{
|
|
35 |
LOG_FUNC
|
|
36 |
CActiveScheduler::Add(this);
|
|
37 |
|
|
38 |
// Initialise Ep0 request details.
|
|
39 |
iEp0Details.iRequestType = 0x20; // Class request
|
|
40 |
iEp0Details.iRequest = 0x00; // All HCI commands are req 0x00.
|
|
41 |
iEp0Details.iValue = 0x0000; // N/a for HCI
|
|
42 |
iEp0Details.iIndex = 0x0000; // N/a for HCI
|
|
43 |
iEp0Details.iFlags = 0x04; // Short transfer OK
|
|
44 |
}
|
|
45 |
|
|
46 |
|
|
47 |
CHCTLUsbOriginalCommand::~CHCTLUsbOriginalCommand()
|
|
48 |
{
|
|
49 |
LOG_FUNC
|
|
50 |
Cancel();
|
|
51 |
}
|
|
52 |
|
|
53 |
CHCTLUsbOriginalCommand* CHCTLUsbOriginalCommand::NewL(RUsbInterface& aInterface)
|
|
54 |
{
|
|
55 |
LOG_STATIC_FUNC
|
|
56 |
CHCTLUsbOriginalCommand* self = new(ELeave)CHCTLUsbOriginalCommand(aInterface);
|
|
57 |
return self;
|
|
58 |
}
|
|
59 |
|
|
60 |
TInt CHCTLUsbOriginalCommand::Write(const TDesC8& aData)
|
|
61 |
{
|
|
62 |
LOG_FUNC
|
|
63 |
TInt rerr = KErrNone;
|
|
64 |
//Check whether we finished with the previous write
|
|
65 |
if(!IsActive())
|
|
66 |
{
|
|
67 |
// We want to send Ep0 commands in a serial fashion (we only use one active object).
|
|
68 |
iChannelObserver->MhcoChannelClosed(KHCITransportCommandChannel);
|
|
69 |
|
|
70 |
iRecvData.SetLength(0); // We don't receive any data via Ep0 (events come in on a separate pipe).
|
|
71 |
|
|
72 |
SetActive();
|
|
73 |
iInterface.Ep0Transfer(iEp0Details, aData, iRecvData, iStatus);
|
|
74 |
}
|
|
75 |
else
|
|
76 |
{
|
|
77 |
LOG(_L8("ERROR: Sender is already active!!\r\n"));
|
|
78 |
rerr = KErrInUse;
|
|
79 |
}
|
|
80 |
|
|
81 |
return rerr;
|
|
82 |
}
|
|
83 |
|
|
84 |
void CHCTLUsbOriginalCommand::SetChannelObserver(MHCTLChannelObserver& aObserver)
|
|
85 |
{
|
|
86 |
LOG_FUNC
|
|
87 |
iChannelObserver = &aObserver;
|
|
88 |
}
|
|
89 |
|
|
90 |
void CHCTLUsbOriginalCommand::RunL()
|
|
91 |
{
|
|
92 |
LOG_FUNC
|
|
93 |
LOG1(_L8("\tiStatus = %d"), iStatus.Int());
|
|
94 |
iChannelObserver->MhcoChannelOpen(KHCITransportCommandChannel);
|
|
95 |
}
|
|
96 |
|
|
97 |
void CHCTLUsbOriginalCommand::DoCancel()
|
|
98 |
{
|
|
99 |
LOG_FUNC
|
|
100 |
// TODO can't do this yet, there is no API available for this...
|
|
101 |
}
|