|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef HCIPROXY_H__ |
|
17 #define HCIPROXY_H__ |
|
18 |
|
19 #include <es_sock.h> |
|
20 #include <bt_sock.h> |
|
21 #include <e32test.h> |
|
22 #include <c32comm.h> |
|
23 #include <f32file.h> |
|
24 #include <e32std.h> |
|
25 |
|
26 // |
|
27 // Forward declarations |
|
28 // |
|
29 struct THCIWriteVendorSpecificFrameIoctl; |
|
30 |
|
31 // |
|
32 // Package for sending a THCIWriteVendorSpecificFrameIoctl via IPC |
|
33 // |
|
34 typedef TPckgBuf<THCIWriteVendorSpecificFrameIoctl> THCIWriteVendorSpecificFrameBuf; |
|
35 |
|
36 // Category name for panics |
|
37 _LIT(KHciExtConduitPanicCat, "CHciExtensionConduit"); |
|
38 |
|
39 enum THciProxyPanics |
|
40 { |
|
41 EAlreadyActive = 1, |
|
42 EInvalidParamSize, |
|
43 EInvalidIoctl, |
|
44 EUnexpectedCce, |
|
45 }; |
|
46 |
|
47 /** |
|
48 This class provides a mixin interface for reception of command completions for vendor |
|
49 specific commands and vendor specific events. |
|
50 @publishedPartner |
|
51 @released |
|
52 **/ |
|
53 class MVendorSpecificHciConduit |
|
54 { |
|
55 public: |
|
56 /** |
|
57 This is the callback for both CHciExtensionConduit::IssueCommand and |
|
58 CHciExtensionConduit::IssueCommandExpectingCompleteEventL |
|
59 If CHciExtensionConduit::IssueCommandL was called CommandComplete will be |
|
60 called when the Bluetooth stack receives the associated Ioctl. |
|
61 If CHciExtensionConduit::IssueCommandExpectingCompleteEventL was called |
|
62 CommandComplete will be called when a command complete event with a |
|
63 vendor specific opcode is received from the hardware. |
|
64 |
|
65 @see CHciExtensionConduit::IssueCommandL |
|
66 @see CHciExtensionConduit::IssueCommandExpectingCompleteEventL |
|
67 @param aError : The error code with which the command completed. See 'WARNING' above. |
|
68 **/ |
|
69 virtual void CommandCompleted(TInt aError)=0; |
|
70 /** |
|
71 CommandCompleted is called when a vendor specific command issued through the conduit |
|
72 receives a completion from the hardware. |
|
73 |
|
74 @param aEvent : Returns raw vendor specific debug event data generated from the hardware |
|
75 (with no HCTL framing) |
|
76 @param aError : An error indicating that the conduit did not successfully receive the event. |
|
77 @return If ETrue, the conduit will continue to listen for vendor specific debug events, |
|
78 If EFalse, the conduit stops listening for these events. |
|
79 **/ |
|
80 virtual TBool ReceiveEvent(TDesC8& aEvent, TInt aError)=0; |
|
81 }; |
|
82 |
|
83 /** |
|
84 This class acts as a wrapper for a group of Ioctls which used together provide a means |
|
85 for licensees to pass proprietary commands direct to the hardware at the bottom of the |
|
86 stack, and to receive events elicited by these commands back from the hardware. |
|
87 |
|
88 On construction, the CHciExtensionConduit registers itself with the Bluetooth stack, |
|
89 which ensures that there can be only one HCI Extension Conduit in existance on a machine |
|
90 at one time. This means that the first such conduit constructed after bootup has sole |
|
91 access to issue vendor specific commands and more importantly receive back vendor specific |
|
92 events. |
|
93 |
|
94 It works in conjunction with the MVendorSpecificHciConduit class, which provides a mixin |
|
95 interface for reception of command completions for vendor specific commands and vendor |
|
96 specific events. |
|
97 @publishedPartner |
|
98 @released |
|
99 **/ |
|
100 NONSHARABLE_CLASS(CHciExtensionConduit) : public CActive |
|
101 { |
|
102 public: |
|
103 // Construct/destruct |
|
104 IMPORT_C static CHciExtensionConduit* NewL(MVendorSpecificHciConduit& aConduit); |
|
105 IMPORT_C ~CHciExtensionConduit(); |
|
106 |
|
107 // Commands |
|
108 IMPORT_C TInt IssueCommandL(const TUint16 aOpcode, const TDesC8& aParameters); |
|
109 IMPORT_C TInt IssueCommandExpectingCompleteEventL(const TUint16 aOpcode, const TDesC8& aParameters); |
|
110 IMPORT_C TInt WaitForEvent(); |
|
111 IMPORT_C void StopWaitingForEvent(); |
|
112 IMPORT_C void CommandCompleteEventData(TPtrC8& aOutPtrToData); |
|
113 |
|
114 protected: |
|
115 IMPORT_C void ConstructL(); |
|
116 |
|
117 private: |
|
118 // Construct/destruct |
|
119 CHciExtensionConduit(MVendorSpecificHciConduit& aConduit); |
|
120 |
|
121 // Command engine |
|
122 TInt IssueCommandL(const TUint16 aOpcode, const TDesC8& aParameters, TUint aName); |
|
123 |
|
124 |
|
125 // From CActive |
|
126 void RunL(); |
|
127 void DoCancel(); |
|
128 |
|
129 private: |
|
130 TUint iCurrentIoctl; |
|
131 TBool iWaitForEvent; |
|
132 RSocketServ iSocketServ; |
|
133 RSocket iSocket; |
|
134 MVendorSpecificHciConduit& iConduit; |
|
135 TProtocolDesc iL2CapProtoDesc; |
|
136 TBuf8<255> iBuf; |
|
137 // On the downcall of the Ioctl iVSIoctl is a pointer to a package buffer of the command to send. |
|
138 // Upon return the pointer is (of course) to a descriptor which is now raw command complete event data. |
|
139 // There's a 'gotcha' related to this (ab)use of the buffer: the maximum size of the data returned |
|
140 // is 2 bytes more than that of the data written (more headers), which means we can really handle |
|
141 // only 253 bytes of user data in the Command Completion Event. |
|
142 THCIWriteVendorSpecificFrameBuf* iVSIoctl; |
|
143 }; |
|
144 |
|
145 #endif |