|
1 // Copyright (c) 1999-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 // Constants for the RFCOMM protocol |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef RFCOMMCONSTS_H |
|
19 #define RFCOMMCONSTS_H |
|
20 |
|
21 const TInt KRFCOMMPSM = 0x03; // The PSM on which RFCOMM resides |
|
22 const TUid KUidServiceRfcomm={0x100095FC}; |
|
23 const TUint KRFCOMMIncomingConnQueueSize=5; |
|
24 |
|
25 const static TInt KRfcommMuxDisconnectingChannelTimeout = 1*1000000; // microseconds |
|
26 const static TInt KRfcommIdleTimeout = 5*1000000; |
|
27 |
|
28 // This mux idle timeout value needs to take into account authentication |
|
29 // occurring before the first DLC (not the muxer) is created hence 60 seconds |
|
30 const static TInt KRfcommMuxIdleTimeoutOpening = 60*1000000; |
|
31 |
|
32 // This mux idle timeout value is used when the last DLC (not the muxer) has |
|
33 // been closed |
|
34 const static TInt KRfcommMuxIdleTimeoutClosing = 5*1000000; |
|
35 const static TInt KRfcommMuxConnectingChannelTimeout = 60*1000000; |
|
36 |
|
37 const static TInt KMinRfcommDLCI = 2; |
|
38 const static TInt KMaxRfcommDLCI = 0x3f; //0b111111 |
|
39 const static TInt KMaxRfcommPriority = 0x3f; //0b111111 |
|
40 |
|
41 // Frame layout |
|
42 |
|
43 // Used when decoding incoming frames |
|
44 const static TInt KShortFrameHeaderLength = 3; // addr, ctrl, len |
|
45 const static TInt KLongFrameHeaderLength = 4; // addr, ctrl , 2*len |
|
46 |
|
47 // Used when encoding outgoing frames |
|
48 const static TInt KMaxFrameHeaderLength = 4; // addr, ctrl , 2*len |
|
49 const static TInt KMaxCreditFrameHeaderLength = 5; // addr, ctrl , 2*len, credit |
|
50 |
|
51 // Used in calculation of RFCOMM MTU |
|
52 const static TInt KFCSFieldLength = 1; |
|
53 |
|
54 // Used when encoding mux commands into a UIH frame |
|
55 const static TInt KShortMuxCommandHeaderLength = 2; // type, length |
|
56 const static TInt KLongMuxCommandHeaderLength = 3; // type, 2*length |
|
57 |
|
58 const static TInt KMaxFrameOverhead = 5; // addr, ctrl, len*2, fcs |
|
59 const static TInt KMaxFrameCreditOverhead = 6; // addr, ctrl, len*2, credit, fcs |
|
60 const static TInt KMinFrameLength = 4; |
|
61 const static TInt KFrameAddrOffset = 0; |
|
62 const static TInt KFrameCtrlOffset = 1; |
|
63 const static TInt KMinAllowedDataSize = 11; //< Must fit a RPN frame |
|
64 const static TUint8 KPollFinalBitmask = 0x10; |
|
65 const static TUint8 KEABitmask = 0x01; |
|
66 const static TUint8 KCRBitmask = 0x02; |
|
67 const static TUint8 KDirectionMask = 0x01; |
|
68 const static TUint8 KMuxDLCI = 0; |
|
69 // Signalling constants |
|
70 const static TUint8 KSABMCtrlField = 0x2F; |
|
71 const static TUint8 KUACtrlField = 0x63; |
|
72 const static TUint8 KDMCtrlField = 0x0F; |
|
73 const static TUint8 KDISCCtrlField = 0x43; |
|
74 const static TUint8 KUIHCtrlField = 0xEF; |
|
75 //TRY_CBFC |
|
76 const static TUint8 KUIHCBFCCtrlField = 0xFF; // UIH control field with poll bit set |
|
77 const static TUint8 KCBFCCommandFlag = 0xf0; |
|
78 const static TUint8 KCBFCResponseFlag = 0xe0; // actually 0xe forwards |
|
79 const static TUint8 KInitialCredit = 3; //given to remote at first PN negotiation |
|
80 // - any more floods L2CAP |
|
81 const static TInt KRfcommSAPCBFCBufferMultiple = 7; //max credits after initial negotiation |
|
82 //KRfcommSAPCBFCBufferMultiple*MTU used |
|
83 //for buffer size |
|
84 const static TUint8 KRfcommCreditsLowWaterMark = 3; //donate credits if RxCredit |
|
85 //(remote proxy credit) |
|
86 //hits this value |
|
87 // was 14 but seemed to lock up |
|
88 |
|
89 // Note all these types have no CR or EA bits encoded |
|
90 const static TInt KTestType =0x08; |
|
91 const static TInt KPNType= 0x20; |
|
92 const static TInt KRPNType= 0x24; |
|
93 const static TInt KFConType= 0x28; |
|
94 const static TInt KFCoffType= 0x18; |
|
95 const static TInt KMSCType= 0x38; |
|
96 const static TInt KNSCType= 0x04; |
|
97 const static TInt KRLSType= 0x14; |
|
98 |
|
99 const static TUint8 KRfcommCtrlFrameLengthByte = 0x01; //< EA bit set, length 0 |
|
100 const static TInt KRfcommCtrlFrameSize = 4; |
|
101 |
|
102 const static TInt KFrameTimerT1=60*1000000; // 60 secs, defined in spec |
|
103 const static TInt KFrameTimerT1SABM=300*1000000; // 300 secs, defined in spec |
|
104 const static TInt KFrameTimerT2=60*1000000; // 60 secs, defined in spec |
|
105 |
|
106 const static TInt KCtrlFrameType=1; |
|
107 const static TInt KDataFrameType=2; |
|
108 const static TInt KMuxCtrlFrameType=3; |
|
109 const static TInt KCreditDataFrameType=4; //Shehla - added to ease Blogging |
|
110 |
|
111 // Setup "constants" |
|
112 const static TUint8 KInitialModemStatus = 0x46; //< RTC, RTR, DV set |
|
113 |
|
114 const static TInt KMaxOutboundQLength = 10; |
|
115 const static TInt KRfcommDefaultFrameSize = 131; |
|
116 const static TInt KRfcommDefaultMTU = 127; // actual data size |
|
117 const static TInt KRfcommMaxMTU = 32768; // maximum allowed data size |
|
118 const static TInt KMaxL2CAPMTUFor1LengthByte = 131; // Maximum L2CAP MTU where (for a full |
|
119 // size RFCOMM frame) one length byte |
|
120 // would suffice. |
|
121 |
|
122 /* |
|
123 Maximum L2CAP MTU that RFComm should allow its L2Cap bearer to configure. |
|
124 This is based on the specified maximum information field size (32768) |
|
125 together with associated header and FCS lengths. |
|
126 Note: it might be assumed that we should use the longer length field |
|
127 in this calculation. However this yields the value 32773 - |
|
128 and this has been rejected during interop with a Royaltech GPS device. |
|
129 */ |
|
130 const static TInt KMaxL2CAPMTUAllowed = |
|
131 KRfcommMaxMTU+KShortFrameHeaderLength+KFCSFieldLength; |
|
132 |
|
133 const static TInt KRfcommSAPBufferMultiple = 50; //< n*MTU for buffer size |
|
134 const static TInt KRfcommSAPBufferLowMultiple = 20; //< n*MTU is flow on level |
|
135 const static TInt KRfcommSAPBufferHighMultiple = 40; //< n*MTU is flow off level |
|
136 |
|
137 // Masks for interpreting signalling commands - moved to bt_sock.h |
|
138 |
|
139 const static TUint8 KRPNRequestLength = 1; |
|
140 const static TUint8 KRPNCommandLength = 8; |
|
141 const static TUint8 KRPNResponseLength = 8; |
|
142 |
|
143 const static TUint8 KFConCommandLength = 0; |
|
144 const static TUint8 KFCoffCommandLength = 0; |
|
145 const static TUint8 KNSCCommandLength = 1; |
|
146 const static TUint8 KMSCCommandLength = 2; |
|
147 const static TUint8 KRLSCommandLength = 2; |
|
148 |
|
149 // Test Ioctl definitions |
|
150 // NB. Client Ioctls must not have KInternalIoctlBit |
|
151 // (0x80000000) set. |
|
152 const static TUint KRFCOMMFConIoctl = 0x7FFFFFFF; |
|
153 const static TUint KRFCOMMFCoffIoctl = 0x7FFFFFFE; |
|
154 |
|
155 |
|
156 // Errors are in rfcommerrors.h |
|
157 |
|
158 #endif |