|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This file was generated automatically from the template commandsource.tmpl |
|
15 // on Thu, 29 May 2008 15:17:53 (time stamp) |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 */ |
|
23 |
|
24 #include <bluetooth/hci/inquirycommand.h> |
|
25 #include <bluetooth/hci/event.h> |
|
26 #include <bluetooth/hci/commandcompleteevent.h> |
|
27 #include <bluetooth/hci/hciframe.h> |
|
28 #include <bluetooth/hci/hciopcodes.h> |
|
29 #include <bluetooth/hci/inquiryresultevent.h> |
|
30 #include <bluetooth/hci/inquiryresultwithrssievent.h> |
|
31 #include <bluetooth/hci/extendedinquiryresultevent.h> |
|
32 #include <bluetooth/hci/inquirycompleteevent.h> |
|
33 |
|
34 |
|
35 #ifdef __FLOG_ACTIVE |
|
36 _LIT8(KLogComponent, LOG_COMPONENT_COMMANDSEVENTS_SYMBIAN); |
|
37 #endif |
|
38 |
|
39 |
|
40 |
|
41 // Factory methods |
|
42 |
|
43 EXPORT_C CInquiryCommand* CInquiryCommand::NewL(TUint32 aLAP, TUint8 aInquiryLength, TUint8 aNumResponses) |
|
44 { |
|
45 CInquiryCommand* self = new (ELeave) CInquiryCommand(aLAP, aInquiryLength, aNumResponses); |
|
46 CleanupStack::PushL(self); |
|
47 self->CHCICommandBase::BaseConstructL(); |
|
48 CleanupStack::Pop(self); |
|
49 return self; |
|
50 } |
|
51 |
|
52 EXPORT_C CInquiryCommand* CInquiryCommand::NewL() |
|
53 { |
|
54 CInquiryCommand* self = new (ELeave) CInquiryCommand(); |
|
55 CleanupStack::PushL(self); |
|
56 self->CHCICommandBase::BaseConstructL(); |
|
57 CleanupStack::Pop(self); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // Constructors |
|
62 |
|
63 CInquiryCommand::CInquiryCommand(TUint32 aLAP, TUint8 aInquiryLength, TUint8 aNumResponses) |
|
64 : CHCICommandBase(KInquiryOpcode) |
|
65 , iLAP(aLAP) |
|
66 , iInquiryLength(aInquiryLength) |
|
67 , iNumResponses(aNumResponses) |
|
68 { |
|
69 SetExpectsCommandCompleteEvent(EFalse); |
|
70 } |
|
71 |
|
72 CInquiryCommand::CInquiryCommand() |
|
73 : CHCICommandBase(KInquiryOpcode) |
|
74 { |
|
75 SetExpectsCommandCompleteEvent(EFalse); |
|
76 } |
|
77 |
|
78 // Destructor |
|
79 CInquiryCommand::~CInquiryCommand() |
|
80 { |
|
81 |
|
82 } |
|
83 |
|
84 /*virtual*/ void CInquiryCommand::Match(const THCIEventBase& aEvent, TBool& aMatchesCmd, TBool& aConcludesCmd, TBool& aContinueMatching) const |
|
85 { |
|
86 if (aEvent.EventCode() == EInquiryResultEvent) |
|
87 { |
|
88 aMatchesCmd = ETrue; |
|
89 aConcludesCmd = EFalse; |
|
90 aContinueMatching = EFalse; |
|
91 } |
|
92 else if (aEvent.EventCode() == EInquiryResultwithRSSIEvent) |
|
93 { |
|
94 aMatchesCmd = ETrue; |
|
95 aConcludesCmd = EFalse; |
|
96 aContinueMatching = EFalse; |
|
97 } |
|
98 else if (aEvent.EventCode() == EExtendedInquiryResultEvent) |
|
99 { |
|
100 aMatchesCmd = ETrue; |
|
101 aConcludesCmd = EFalse; |
|
102 aContinueMatching = EFalse; |
|
103 } |
|
104 else if (aEvent.EventCode() == EInquiryCompleteEvent) |
|
105 { |
|
106 aMatchesCmd = ETrue; |
|
107 aConcludesCmd = ETrue; |
|
108 aContinueMatching = EFalse; |
|
109 } |
|
110 else if (aEvent.EventCode() == ECommandCompleteEvent) |
|
111 { |
|
112 THCICommandCompleteEvent& event = THCICommandCompleteEvent::Cast(aEvent); |
|
113 if (event.CommandOpcode() == KInquiryCancelOpcode) |
|
114 { |
|
115 aMatchesCmd = ETrue; |
|
116 aConcludesCmd = ETrue; |
|
117 aContinueMatching = ETrue; |
|
118 } |
|
119 } |
|
120 // Command Status Event and default Command Complete Event matching |
|
121 // is implemented in the base class. If we haven't matched already |
|
122 // then we should try the default matching. |
|
123 if (!aMatchesCmd) |
|
124 { |
|
125 CHCICommandBase::Match(aEvent, aMatchesCmd, aConcludesCmd, aContinueMatching); |
|
126 } |
|
127 } |
|
128 |
|
129 |
|
130 // Override of pure virtual from CHCICommandBase. This method embodies the knowledge |
|
131 // of how to format the specifics of this command into the HCTL command frame. |
|
132 void CInquiryCommand::Format(CHctlCommandFrame& aCommandFrame) const |
|
133 { |
|
134 aCommandFrame.PutBytes32(iLAP, 3); |
|
135 aCommandFrame.PutByte(iInquiryLength); |
|
136 aCommandFrame.PutByte(iNumResponses); |
|
137 } |
|
138 |
|
139 // Assign new values to the parameters of this command |
|
140 EXPORT_C void CInquiryCommand::Reset(TUint32 aLAP, TUint8 aInquiryLength, TUint8 aNumResponses) |
|
141 { |
|
142 iLAP = aLAP; |
|
143 iInquiryLength = aInquiryLength; |
|
144 iNumResponses = aNumResponses; |
|
145 } |
|
146 |
|
147 // Accessor methods for the parameters of the command |
|
148 |
|
149 EXPORT_C TUint32 CInquiryCommand::LAP() const |
|
150 { |
|
151 return iLAP; |
|
152 } |
|
153 |
|
154 EXPORT_C TUint8 CInquiryCommand::InquiryLength() const |
|
155 { |
|
156 return iInquiryLength; |
|
157 } |
|
158 |
|
159 EXPORT_C TUint8 CInquiryCommand::NumResponses() const |
|
160 { |
|
161 return iNumResponses; |
|
162 } |
|
163 |
|
164 |
|
165 |
|
166 // Extension function. Use this to retrieve any extension interfaces from CInquiryCommand |
|
167 // or any class from which it derives. |
|
168 /*virtual*/ TInt CInquiryCommand::Extension_(TUint aExtensionId, TAny*& aInterface, TAny* aData) |
|
169 { |
|
170 // To add an additional interface implementation specific for this class check the |
|
171 // provided ID and return an appropriate interface. |
|
172 |
|
173 // If a specific interface implementation is not provided - forward the call to the base class. |
|
174 return CHCICommandBase::Extension_(aExtensionId, aInterface, aData); |
|
175 } |
|
176 |