|
1 // Copyright (c) 2003-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 BASEBANDMODEL_H_ |
|
17 #define BASEBANDMODEL_H_ |
|
18 |
|
19 class CLinkMgrProtocol; |
|
20 // this will be owned by the linkmgrprotocol |
|
21 |
|
22 static const TInt KBTBasebandModelLinkArrayGranularity = 2; |
|
23 static const TInt KMaxPhysicalLinksWithSCO=2; |
|
24 static const TInt KMaxActivePhysicalLinks=7; |
|
25 |
|
26 enum TSCOLinkType |
|
27 /** |
|
28 The value order in this enum must be maintained |
|
29 */ |
|
30 { |
|
31 ENoSCOLink = 0, |
|
32 ESCOHV1Packets = 0x20, |
|
33 ESCOHV2Packets = 0x40, |
|
34 ESCOHV3Packets = 0x80, |
|
35 |
|
36 //uses all b/w based on 80 bits per slot at 64 kbits/sec |
|
37 ESCODVPackets = 0x100, /*no associated command mask value*/ |
|
38 |
|
39 EIseSCOLink = 0x40000000 // Don't use top bit as signed, but ensure invalid. |
|
40 }; |
|
41 |
|
42 enum TACLLinkType |
|
43 /** |
|
44 The value order in this enum must be maintained |
|
45 */ |
|
46 |
|
47 { |
|
48 ENoACLLink = 0, |
|
49 EOneSlotPackets = 1, |
|
50 EThreeSlotPackets = 3, |
|
51 EFiveSlotPackets = 5, |
|
52 }; |
|
53 |
|
54 NONSHARABLE_CLASS(TPhysicalLinkData) |
|
55 { |
|
56 public: |
|
57 TPhysicalLinkData(); |
|
58 TACLLinkType ACLActualMinSlots() const; |
|
59 void Park(); |
|
60 void UnPark(); |
|
61 TBool IsParked() const; |
|
62 |
|
63 public: |
|
64 TBTDevAddr iBdaddr; |
|
65 THCIConnHandle iConnH; |
|
66 THCIConnHandle iSCOConnH; |
|
67 THCIConnHandle ieSCOConnH; |
|
68 TACLLinkType iACLMinSlotsAllowed; |
|
69 TACLLinkType iACLMaxSlotsAllowed; |
|
70 TSCOLinkType iSCOMinRequirement; //HV3 < HV2 < HV1 |
|
71 TBool iParked; |
|
72 }; |
|
73 |
|
74 |
|
75 enum TBandwidth |
|
76 { |
|
77 //HV1 packets use all available slots and completely hogs the baseband capacity (T_SCO=2) |
|
78 //HV2 packets use 2 out of every 4 slots (T_SCO=4), |
|
79 //HV3 packets use 2 out of 6 slots (T_SCO=6) |
|
80 EBandwidthNoneUsed = 0, |
|
81 EBandwidthOneTwelfthUsed = 1, |
|
82 EBandwidthOneSixthUsed = 2, |
|
83 EBandwidthOneQuarterUsed = 3, |
|
84 EBandwidthOneThirdUsed = 4, |
|
85 EBandwidthFiveTwelfthsUsed = 5, |
|
86 EBandwidthOneHalfUsed = 6, |
|
87 EBandwidthSevenTwelfthsUsed = 7, |
|
88 EBandwidthTwoThirdsUsed = 8, |
|
89 EBandwidthThreeQuartersUsed = 9, |
|
90 EBandwidthFiveSixthsUsed = 10, |
|
91 EBandwidthElevenTwelfthsUsed = 11, |
|
92 EBandwidthAllUsed = 12, |
|
93 }; |
|
94 |
|
95 NONSHARABLE_CLASS(CBTBasebandModel) : public CBase |
|
96 /** |
|
97 This looks at the Baseband in an orthogonal manner to the ConnectionsManager. |
|
98 The connectionManager thinks in terms of logical links to other devices. |
|
99 The BasebandModel thinks in terms of radio activity. If 25% of the slots are |
|
100 pre-booked by SCO commitments, then this knowledge is in the BasebandModel. |
|
101 */ |
|
102 { |
|
103 public: |
|
104 static CBTBasebandModel* NewL(CLinkMgrProtocol& aLMProt); |
|
105 ~CBTBasebandModel(); |
|
106 |
|
107 TInt UpdateModel(const TBTDevAddr& aAddr, TUint16 aPacketMask, TLinkType aLinkTypeForPacketMask); |
|
108 TInt UpdateModel(THCIConnHandle aConnH, TLinkType aLinkTypeForHandle, TUint16 aPacketMask, TLinkType aLinkTypeForPacketMask); |
|
109 TInt UpdateModel(const TBTConnect& aConn); |
|
110 TInt UpdateModel(const TBTConnect& aConn, TUint16 aPacketMask); |
|
111 TInt UpdateModel(THCIConnHandle aConnH, TUint8 aMaxSlots); |
|
112 void UpdateModelIfRecordExists(THCIConnHandle aConnH, TUint16 aPacketMask); |
|
113 void UpdateModelIfNoRecord(THCIConnHandle aConnH, TUint16 aPacketMask, TLinkType aLinkType); |
|
114 void UpdateModelForDisconnection(THCIConnHandle aConnH, TLinkType aLinkType); |
|
115 void UpdateModelForConnectionError(TBTDevAddr aAddr, TLinkType aLinkType); |
|
116 void ParkLink(THCIConnHandle aConnH); |
|
117 void UnParkLink(THCIConnHandle aConnH); |
|
118 |
|
119 TBool IsACLPossible() const; |
|
120 TBool IsSCOPossible() const; |
|
121 |
|
122 private: |
|
123 CBTBasebandModel(CLinkMgrProtocol& aLMProt); //constructor |
|
124 void ConstructL(); |
|
125 |
|
126 TBool IsACLPossible(TACLLinkType aACLType) const; |
|
127 TBool IsSCOPossible(TSCOLinkType aSCOType) const; |
|
128 TBool IsCombinationAllowed(TInt aSCOBandwidth, TACLLinkType aACLType) const; |
|
129 TBandwidth CostOfACLLink(TACLLinkType aACLType) const; |
|
130 TACLLinkType ACLRequirement(TUint16 aPacketMask) const; |
|
131 TSCOLinkType SCORequirement(TUint16 aPacketMask) const; |
|
132 TBandwidth Bandwidth(TSCOLinkType aLinkData) const; |
|
133 |
|
134 void GarnerInfo(TInt& aActivePhyCount, TInt& aSCOCount, TACLLinkType& aGreatestMinSlotRequirement, TInt& aSCOBandwidth) const; |
|
135 void CheckInfo(TInt aActivePhyCount, TInt aSCOCount, TACLLinkType aGreatestMinSlotRequirement, TInt aSCOBandwidth) const; |
|
136 |
|
137 TInt FindByAddress(const TBTDevAddr& aAddr) const; |
|
138 TInt FindByHandle(THCIConnHandle aHandle) const; |
|
139 TInt FindByACLHandle(THCIConnHandle aHandle) const; |
|
140 TInt FindBySCOHandle(THCIConnHandle aHandle) const; |
|
141 TInt FindByeSCOHandle(THCIConnHandle aHandle) const; |
|
142 TInt DoUpdateModel(const TBTConnect& aConn, TUint16 aPacketMask, TBool iIgnorePacketMask); |
|
143 void UpdateLink(TPhysicalLinkData& aLinkData, const TBTConnect& aConn); |
|
144 void UpdateLink(TPhysicalLinkData& aLinkData, TLinkType aLinkType, TUint16 aPacketMask); |
|
145 void SetupConnectRecord(TBTConnect& aConn, THCIConnHandle aConnH, |
|
146 const TBTDevAddr& aAddr, |
|
147 TUint aCoD, |
|
148 TLinkType aLinkType, |
|
149 TEncryptMode aEncryptMode) const; |
|
150 |
|
151 |
|
152 |
|
153 private: |
|
154 RArray<TPhysicalLinkData> iLinkData; |
|
155 CLinkMgrProtocol& iLMProt; |
|
156 }; |
|
157 |
|
158 #endif //BASEBANDMODEL_H_ |
|
159 |