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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 /** |
|
19 @file |
|
20 @publishedPartner |
|
21 */ |
|
22 |
|
23 #ifndef HCIFRAME_H |
|
24 #define HCIFRAME_H |
|
25 |
|
26 #include <e32std.h> |
|
27 #include <e32base.h> |
|
28 #include <bttypes.h> |
|
29 #include <bluetooth/hci/hcitypes.h> |
|
30 #include <bluetooth/hci/aclpacketconsts.h> |
|
31 |
|
32 /** |
|
33 Class representing an Hctl Frame as specified in the Bluetooth Core Specification, HCI Section |
|
34 This is abstract and the different frame types (Command, ACL, SCO etc) derive from it |
|
35 @publishedPartner |
|
36 */ |
|
37 NONSHARABLE_CLASS(CHctlFrameBase) : public CBase |
|
38 { |
|
39 public: |
|
40 ~CHctlFrameBase(); |
|
41 |
|
42 protected: |
|
43 CHctlFrameBase(TUint8 aHctlHeaderSize, TUint8 aHctlTrailerSize); |
|
44 void ConstructL(TUint32 aHctlFrameSize); |
|
45 |
|
46 protected: |
|
47 const TUint8 iHctlHeaderSize; |
|
48 const TUint8 iHctlTrailerSize; |
|
49 |
|
50 TPtr8 iFramePtr; |
|
51 HBufC8* iHctlFrame; |
|
52 }; |
|
53 |
|
54 /** |
|
55 Class representing an Hctl Command Frame as specified in the Bluetooth Core Specification, HCI Section |
|
56 @publishedPartner |
|
57 */ |
|
58 NONSHARABLE_CLASS(CHctlCommandFrame) : public CHctlFrameBase |
|
59 { |
|
60 public: |
|
61 IMPORT_C static CHctlCommandFrame* NewL(TUint8 aHctlHeaderSize, TUint8 aHctlTrailerSize); |
|
62 |
|
63 IMPORT_C void FinaliseCommand(); |
|
64 IMPORT_C void ResetCommand(); |
|
65 |
|
66 IMPORT_C void SetOpcode(THCIOpcode aOpcode); |
|
67 IMPORT_C void PutByte(TUint8 aByte); |
|
68 IMPORT_C void PutBytes16(TUint16 aVal); |
|
69 IMPORT_C void PutBytes24(TUint32 aVal); |
|
70 IMPORT_C void PutBytes32(TUint32 aVal); |
|
71 IMPORT_C void PutBytes32(TUint32 aVal,TUint8 aNumOfBytes); |
|
72 IMPORT_C void PutString(const TDesC8& aString); |
|
73 IMPORT_C void PutPaddedString(const TDesC8& aString, TInt aRequiredLength); |
|
74 IMPORT_C void PutDevAddr(const TBTDevAddr& aBdaddr); |
|
75 IMPORT_C void PutAFHHostChannelClassification(const TDesC8& aClassification); |
|
76 IMPORT_C void PutLinkKey(const TBTLinkKey& aLinkKey); |
|
77 IMPORT_C void PutConnectionHandle(THCIConnectionHandle aConnectionHandle); |
|
78 IMPORT_C void PutSimplePairingHash(const TBluetoothSimplePairingHash& aHash); |
|
79 IMPORT_C void PutSimplePairingRandomizer(const TBluetoothSimplePairingRandomizer& aRandomizer); |
|
80 |
|
81 IMPORT_C const TDesC8& HCTLPayload() const; |
|
82 |
|
83 private: |
|
84 CHctlCommandFrame(TUint8 aHctlHeaderSize, TUint8 aHctlTrailerSize); |
|
85 |
|
86 public: |
|
87 // Hctl Command specific constants |
|
88 const static TUint8 KHCICommandLengthFieldOffset = 2; |
|
89 const static TUint8 KHCICommandLengthFieldLength = 1; |
|
90 |
|
91 const static TUint8 KHCICommandPacketHeaderLength = 3; |
|
92 const static TInt KHCIMaxCommandLength = 255; |
|
93 }; |
|
94 |
|
95 /** |
|
96 Class representing an Hctl Data Frame as specified in the Bluetooth Core Specification, HCI Section |
|
97 This is abstract and the different data types (ACL, SCO etc) derive from it |
|
98 @publishedPartner |
|
99 */ |
|
100 NONSHARABLE_CLASS(CHctlDataFrameBase) : public CHctlFrameBase |
|
101 { |
|
102 public: |
|
103 IMPORT_C void SetConnectionHandle(THCIConnHandle aConnectionHandle); |
|
104 IMPORT_C static THCIConnHandle ConnectionHandle(const TDesC8& aHCIDataFrame); |
|
105 IMPORT_C const TDesC8& HCTLPayload() const; |
|
106 |
|
107 virtual void SetDataPayload(const TDesC8& aData)=0; |
|
108 |
|
109 protected: |
|
110 CHctlDataFrameBase(TUint8 aHctlHeaderSize, TUint8 aHctlTrailerSize); |
|
111 |
|
112 public: |
|
113 const static TUint8 KHCIDataPacketLengthFieldOffset = 2; |
|
114 }; |
|
115 |
|
116 |
|
117 /** |
|
118 Class representing an Hctl ACL Data Frame as specified in the Bluetooth Core Specification, HCI Section |
|
119 @publishedPartner |
|
120 */ |
|
121 NONSHARABLE_CLASS(CHctlAclDataFrame) : public CHctlDataFrameBase |
|
122 { |
|
123 public: |
|
124 IMPORT_C static CHctlAclDataFrame* NewL(TUint16 aPayloadSize, TUint8 aHctlHeaderSize, TUint8 aHctlTrailerSize); |
|
125 |
|
126 IMPORT_C static TAclPacketBoundaryFlag PacketBoundaryFlag(const TDesC8& aData); |
|
127 IMPORT_C static TAclPacketBroadcastFlag PacketBroadcastFlag(const TDesC8& aData); |
|
128 |
|
129 IMPORT_C void SetFlags(TAclPacketBoundaryFlag aBoundaryFlag, TAclPacketBroadcastFlag aBroadcastFlag); |
|
130 IMPORT_C void SetDataPayload(const TDesC8& aData); |
|
131 IMPORT_C THCIConnHandle ConnectionHandle() const; |
|
132 |
|
133 public: |
|
134 // Hctl ACL Data specific constants |
|
135 const static TUint8 KHCIACLDataPacketLengthFieldLength = 2; |
|
136 |
|
137 const static TUint8 KHCIACLDataPacketHeaderLength = 4; // 2 bytes ConnH, 2 bytes data length field |
|
138 const static TUint16 KHCTLMaxACLDataSize = 0xffff; |
|
139 |
|
140 private: |
|
141 CHctlAclDataFrame(TUint8 aHctlHeaderSize, TUint8 aHctlTrailerSize); |
|
142 void Finalise(); |
|
143 }; |
|
144 |
|
145 /** |
|
146 Class representing an Hctl Synchronous Data Frame as specified in the Bluetooth Core Specification, HCI Section |
|
147 @publishedPartner |
|
148 */ |
|
149 NONSHARABLE_CLASS(CHctlSynchronousDataFrame) : public CHctlDataFrameBase |
|
150 { |
|
151 public: |
|
152 IMPORT_C static CHctlSynchronousDataFrame* NewL(TUint8 aBufSize, TUint8 aHctlHeaderSize, TUint8 aHctlTrailerSize); |
|
153 virtual void SetDataPayload(const TDesC8& aData); |
|
154 |
|
155 public: |
|
156 // HCI SCO Data specific constants |
|
157 const static TUint8 KHCISCODataPacketLengthFieldLength = 1; |
|
158 |
|
159 const static TUint8 KHCISynchronousDataPacketHeaderLength = 3; // 2 bytes ConnH, 1 byte data length field |
|
160 const static TUint8 KHCTLMaxSynchronousDataSize = 0xff; |
|
161 private: |
|
162 CHctlSynchronousDataFrame(TUint8 aHctlHeaderSize, TUint8 aHctlTrailerSize); |
|
163 void Finalise(); |
|
164 }; |
|
165 |
|
166 #endif // HCIFRAME_H |
|