|
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 // Defines the base class for baseband SAPs |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #ifndef _BASEBANDSAP_H_ |
|
24 #define _BASEBANDSAP_H_ |
|
25 |
|
26 #include <es_prot.h> |
|
27 #include "BtSap.h" |
|
28 #include "AcceptWatchdog.h" |
|
29 #include "MBtHostControllerEventInternalNotifier.h" |
|
30 #include "notification.h" |
|
31 #include "SecManNotifiers.h" |
|
32 #include "btconsts.h" |
|
33 |
|
34 static const TUint8 KActiveDisconnectReason = 0x13; |
|
35 |
|
36 |
|
37 class TBTConnect; |
|
38 class CBTBasebandModel; |
|
39 class CPhysicalLinksManager; |
|
40 class CPhysicalLink; |
|
41 |
|
42 enum TBasebandTimeout |
|
43 { |
|
44 EAccept, |
|
45 }; |
|
46 |
|
47 class MLogicalLink |
|
48 /** |
|
49 @internalComponent |
|
50 Logical links mixin in from this to be offered the logical link connection requests |
|
51 As it happens, for ACL these occur when PHY connect requests arrive |
|
52 For SCO its a separate event |
|
53 **/ |
|
54 { |
|
55 public: |
|
56 /** |
|
57 @return ETrue if connection is accepted, EFalse if not |
|
58 @param aConnect a record detailing the connection |
|
59 @param aPhysicalLink the physical link bearing the potential logical link |
|
60 */ |
|
61 virtual TBool ConnectRequest(const TBTConnect& aConnect, const CPhysicalLink& aPhysicalLink) =0; |
|
62 |
|
63 /** |
|
64 @param aConnect the new logical link details |
|
65 */ |
|
66 virtual void ConnectComplete(const TBTConnect& aConnect) =0; |
|
67 |
|
68 /** |
|
69 Signalled when logical link has disconnected |
|
70 */ |
|
71 virtual void Disconnection() =0; |
|
72 |
|
73 /** |
|
74 Signalled when an error situation affecting the logical link has occurred |
|
75 @param aError The error |
|
76 */ |
|
77 virtual void Error(TInt aError) =0; |
|
78 |
|
79 /** |
|
80 Data for the logical link has been received |
|
81 */ |
|
82 virtual void DataReceived(THCIConnHandle aConnH, TUint8 aFlag, const TDesC8& aData) =0; |
|
83 |
|
84 /** |
|
85 @param aConnH The handle on which data has been sent |
|
86 @param aNumPackets The number of packets sent |
|
87 */ |
|
88 virtual void PacketsSent(THCIConnHandle aConnH, TUint16 aNumPackets) =0; |
|
89 |
|
90 /** |
|
91 @return ETrue if the logical link considers itself to be idle |
|
92 */ |
|
93 virtual TBool IsIdle() const = 0; |
|
94 }; |
|
95 |
|
96 /** |
|
97 @internalComponent |
|
98 class CBTBasebandSAP |
|
99 The (abstract) base SAP for the linkmgr |
|
100 It forms the basis for ACL,SCO and Proxy SAPs |
|
101 |
|
102 Derivation allows for SAPs to spy on the phy |
|
103 |
|
104 **/ |
|
105 |
|
106 /*abstract*/ NONSHARABLE_CLASS(CBTBasebandSAP) : public CBluetoothSAP, public MPhysicalLinkObserver |
|
107 { |
|
108 public: |
|
109 // from SAP |
|
110 virtual void Start(); |
|
111 virtual void LocalName(TSockAddr& anAddr) const ; |
|
112 virtual TInt SetLocalName(TSockAddr& anAddr); |
|
113 virtual void RemName(TSockAddr& anAddr) const ; |
|
114 virtual TInt SetRemName(TSockAddr& anAddr); |
|
115 virtual TInt GetOption(TUint level,TUint name,TDes8& anOption)const ; |
|
116 virtual void Ioctl(TUint level,TUint name,TDes8* anOption); |
|
117 virtual void CancelIoctl(TUint aLevel,TUint aName); |
|
118 virtual TInt SAPSetOption(TUint level,TUint name,const TDesC8 &anOption); |
|
119 virtual void ActiveOpen(); |
|
120 virtual void ActiveOpen(const TDesC8& aConnectionData); |
|
121 virtual TInt PassiveOpen(TUint aQueSize); |
|
122 virtual TInt PassiveOpen(TUint aQueSize,const TDesC8& aConnectionData); |
|
123 virtual void Shutdown(TCloseType option); |
|
124 virtual void Shutdown(TCloseType option,const TDesC8& aDisconnectionData); |
|
125 virtual void AutoBind(); |
|
126 TUint Write(const TDesC8& aDesc,TUint aOptions, TSockAddr* aAddr); |
|
127 void GetData(TDes8& aDesc,TUint options,TSockAddr* anAddr=NULL); |
|
128 |
|
129 TInt BindLink(TLinkType aLinkType, CPhysicalLink& aPhysicalLink); |
|
130 void UnbindLink(TLinkType aLinkType); |
|
131 |
|
132 void LinkStateIdle(); |
|
133 |
|
134 void RemoveChild(CBTBasebandSAP* aChild); |
|
135 void DeleteChild(CBTBasebandSAP* aChild); |
|
136 |
|
137 virtual void Timeout(TBasebandTimeout aTimeout) =0; |
|
138 |
|
139 inline THCIConnHandle Handle() const; |
|
140 inline MSocketNotify* Socket() const; |
|
141 inline CBTBasebandSAP*& ListeningSAP(); |
|
142 virtual TBool IsIdle() const; |
|
143 virtual TPhysicalLinkObserverQLink& ObserverQLink() {return iQueLink;}; |
|
144 virtual void ParentClosing(); |
|
145 |
|
146 protected: |
|
147 CBTBasebandSAP(CPhysicalLinksManager& aConnectionMan, CPhysicalLink* aConnection); |
|
148 void ConstructL(); |
|
149 CBTBasebandModel& Baseband() const; |
|
150 |
|
151 protected: |
|
152 THCIConnHandle iHandle; // the handle this class represents |
|
153 CPhysicalLinksManager& iLinksMan; |
|
154 CPhysicalLink* iPhysicalLink; |
|
155 CBTBasebandSAP* iParent; |
|
156 CBTBasebandSAP* iChild; |
|
157 TAcceptWatchdog iAcceptWatchdog; |
|
158 TPhysicalLinkObserverQLink iQueLink; |
|
159 }; |
|
160 |
|
161 inline THCIConnHandle CBTBasebandSAP::Handle() const |
|
162 { |
|
163 return iHandle; |
|
164 } |
|
165 |
|
166 |
|
167 inline MSocketNotify* CBTBasebandSAP::Socket() const |
|
168 { |
|
169 return iSocket; |
|
170 } |
|
171 |
|
172 inline CBTBasebandSAP*& CBTBasebandSAP::ListeningSAP() |
|
173 { |
|
174 return iParent; |
|
175 } |
|
176 |
|
177 #endif //_BASEBANDSAP_H_ |