Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/panconnection_8h-source.html
changeset 1 25a17d01db0c
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
       
     2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
       
     3 <title>TB10.1 Example Applications: examples/Bluetooth/BTExample1/inc/panconnection.h Source File</title>
       
     4 <link href="doxygen.css" rel="stylesheet" type="text/css">
       
     5 <link href="tabs.css" rel="stylesheet" type="text/css">
       
     6 </head><body>
       
     7 <!-- Generated by Doxygen 1.5.3 -->
       
     8 <h1>examples/Bluetooth/BTExample1/inc/panconnection.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).</span>
       
     9 <a name="l00002"></a>00002 <span class="comment">// All rights reserved.</span>
       
    10 <a name="l00003"></a>00003 <span class="comment">// This component and the accompanying materials are made available</span>
       
    11 <a name="l00004"></a>00004 <span class="comment">// under the terms of "Eclipse Public License v1.0"</span>
       
    12 <a name="l00005"></a>00005 <span class="comment">// which accompanies this distribution, and is available</span>
       
    13 <a name="l00006"></a>00006 <span class="comment">// at the URL "http://www.eclipse.org/legal/epl-v10.html".</span>
       
    14 <a name="l00007"></a>00007 <span class="comment">//</span>
       
    15 <a name="l00008"></a>00008 <span class="comment">// Initial Contributors:</span>
       
    16 <a name="l00009"></a>00009 <span class="comment">// Nokia Corporation - initial contribution.</span>
       
    17 <a name="l00010"></a>00010 <span class="comment">//</span>
       
    18 <a name="l00011"></a>00011 <span class="comment">// Contributors:</span>
       
    19 <a name="l00012"></a>00012 <span class="comment">//</span>
       
    20 <a name="l00013"></a>00013 <span class="comment">// Description:</span>
       
    21 <a name="l00014"></a>00014 <span class="comment">//</span>
       
    22 <a name="l00015"></a>00015 
       
    23 <a name="l00016"></a>00016 <span class="preprocessor">#ifndef PANCONNECTION_H</span>
       
    24 <a name="l00017"></a>00017 <span class="preprocessor"></span><span class="preprocessor">#define PANCONNECTION_H</span>
       
    25 <a name="l00018"></a>00018 <span class="preprocessor"></span>
       
    26 <a name="l00019"></a>00019 
       
    27 <a name="l00020"></a>00020 <span class="preprocessor">#include &lt;e32base.h&gt;</span>
       
    28 <a name="l00021"></a>00021 <span class="preprocessor">#include &lt;e32cons.h&gt;</span> 
       
    29 <a name="l00022"></a>00022 <span class="preprocessor">#include &lt;bt_sock.h&gt;</span> 
       
    30 <a name="l00023"></a>00023 <span class="preprocessor">#include &lt;es_sock.h&gt;</span>
       
    31 <a name="l00024"></a>00024 <span class="preprocessor">#include &lt;in_sock.h&gt;</span>
       
    32 <a name="l00025"></a>00025 <span class="preprocessor">#include &lt;btsdp.h&gt;</span>
       
    33 <a name="l00026"></a>00026 
       
    34 <a name="l00027"></a>00027 <span class="comment">// Enum for determining which side we want to change role on</span>
       
    35 <a name="l00028"></a>00028 <span class="keyword">enum</span> TSide
       
    36 <a name="l00029"></a>00029         {
       
    37 <a name="l00030"></a>00030         ELocalRole,
       
    38 <a name="l00031"></a>00031         EPeerRole
       
    39 <a name="l00032"></a>00032         };
       
    40 <a name="l00033"></a>00033 
       
    41 <a name="l00034"></a>00034 <span class="comment">// SDP constants</span>
       
    42 <a name="l00035"></a>00035 
       
    43 <a name="l00036"></a>00036 <span class="keyword">const</span> TInt KIpUUID = 0x0009; <span class="comment">// IP UUID for SDP</span>
       
    44 <a name="l00037"></a>00037 <span class="keyword">const</span> TInt KTcpUUID = 0x0004;<span class="comment">// TCP UUID for SDP </span>
       
    45 <a name="l00038"></a>00038 
       
    46 <a name="l00039"></a>00039 <span class="comment">/* Attribute ID for service description is calculated from the sum of offset and language base */</span>
       
    47 <a name="l00040"></a>00040 <span class="keyword">static</span> <span class="keyword">const</span> TSdpAttributeID KSdpAttrIdServiceDescription 
       
    48 <a name="l00041"></a>00041                                                         = KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceDescription;
       
    49 <a name="l00042"></a>00042 <span class="comment">/* Attribute ID for service description is calculated from the sum of offset and language base */</span>
       
    50 <a name="l00043"></a>00043 <span class="keyword">static</span> <span class="keyword">const</span> TSdpAttributeID KSdpAttrIdServiceName 
       
    51 <a name="l00044"></a>00044                                                         = KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName;
       
    52 <a name="l00045"></a>00045 
       
    53 <a name="l00046"></a>00046 _LIT(KServiceName, <span class="stringliteral">"PAN Profile Engine"</span>);
       
    54 <a name="l00047"></a>00047 _LIT(KServiceDescription, <span class="stringliteral">"This device is ready to use PAN profile"</span>);
       
    55 <a name="l00048"></a>00048 
       
    56 <a name="l00056"></a><a class="code" href="class_c_pan_connections.html">00056</a> <span class="keyword">class </span><a class="code" href="class_c_pan_connections.html">CPanConnections</a> : <span class="keyword">public</span> CActive
       
    57 <a name="l00057"></a>00057         {
       
    58 <a name="l00058"></a>00058 <span class="keyword">public</span>:
       
    59 <a name="l00059"></a>00059         <span class="keyword">static</span> <a class="code" href="class_c_pan_connections.html">CPanConnections</a>* <a class="code" href="class_c_pan_connections.html#b3d65eba7c9b59bc2bf952a7e881a626">NewL</a>(CConsoleBase &amp; aConsole);
       
    60 <a name="l00060"></a>00060         
       
    61 <a name="l00061"></a>00061         <a class="code" href="class_c_pan_connections.html#6f1e2360d9b792b4eb67233dd0757d41">~CPanConnections</a>();
       
    62 <a name="l00062"></a>00062         <span class="keywordtype">void</span> <a class="code" href="class_c_pan_connections.html#38e615144ac8636db223dfab4d84dedb">CancelRecvFrom</a>();
       
    63 <a name="l00063"></a>00063         TInt <a class="code" href="class_c_pan_connections.html#34c21dab326042522928cc4796c92df2">StartConnection</a>(TBTDevAddr* aDevAddr, TBool aUsePANNotifier, TBool aUseTcpTransport);
       
    64 <a name="l00064"></a>00064         TInt <a class="code" href="class_c_pan_connections.html#6ca7760ec4140c02725dc8a29c061ba9">StopConnection</a>();
       
    65 <a name="l00065"></a>00065         TInt <a class="code" href="class_c_pan_connections.html#0eec65826c0323a9ab6e85b0739bbc44">SetActivePanConn</a>(TUint aConnIndex);
       
    66 <a name="l00066"></a>00066         <span class="keywordtype">void</span> <a class="code" href="class_c_pan_connections.html#c3da88ca7fc0fb64434fd84f81cddc98">SetLocalIpAddrL</a>(TUint32 aAddr);
       
    67 <a name="l00067"></a>00067         <span class="keywordtype">void</span> <a class="code" href="class_c_pan_connections.html#46d8bac828d453473cec94a8602468ac">SetFixedRoleL</a>(TSide aSide, TUint aRole);
       
    68 <a name="l00068"></a>00068         <span class="keywordtype">void</span> <a class="code" href="class_c_pan_connections.html#0ce9d37dc00e0572bb5c7f0b5befa07b">PrintConns</a>();
       
    69 <a name="l00069"></a>00069         TInt <a class="code" href="class_c_pan_connections.html#0cab5de7e4afe736c2469735640ec1ba">TcpIpBindAndListen</a>();
       
    70 <a name="l00070"></a>00070         TInt <a class="code" href="class_c_pan_connections.html#acbdae817598b72658b6b93833ee0975">TcpIpBindAndConnect</a>();
       
    71 <a name="l00071"></a>00071         <span class="keywordtype">void</span> <a class="code" href="class_c_pan_connections.html#514cfbe2ba7d674954dbc60c85ab7018">ListenDoCancel</a>();
       
    72 <a name="l00072"></a>00072         <span class="keywordtype">void</span> <a class="code" href="class_c_pan_connections.html#070d37e1361be12f2dc44fee0653597b">ConnectDoCancel</a>();
       
    73 <a name="l00073"></a>00073         TInt <a class="code" href="class_c_pan_connections.html#1c722de1ae920eb3160284c18c6bed99">CloseTcpIpSocketConnect</a>();
       
    74 <a name="l00074"></a>00074         TUint32 <a class="code" href="class_c_pan_connections.html#1f0cd7f4bcfd821937b31c7daaf9af62">GetRemoteIpAddr</a>() <span class="keyword">const</span>;
       
    75 <a name="l00075"></a>00075         <span class="keywordtype">void</span> <a class="code" href="class_c_pan_connections.html#99afb06bc3e1614ec86be77da414e054">SetRemoteIpAddr</a>(TUint32 aAddr);
       
    76 <a name="l00076"></a>00076         TInt <a class="code" href="class_c_pan_connections.html#2487d17afe967008336124ab48a744ff">AcceptNewSocket</a>();
       
    77 <a name="l00077"></a>00077         <span class="keywordtype">void</span> <a class="code" href="class_c_pan_connections.html#f50cb29f97f35de684d03bf5211671f2">PrintTcpSocketConnections</a>();
       
    78 <a name="l00078"></a>00078         TInt <a class="code" href="class_c_pan_connections.html#f113f2b06e495b97ab788e3f0030b617">GetLocalRole</a>() <span class="keyword">const</span>;
       
    79 <a name="l00079"></a>00079         <span class="keywordtype">void</span> <a class="code" href="class_c_pan_connections.html#f442c51cea29f54570235995428a7bcb">CancelIap</a>();
       
    80 <a name="l00080"></a>00080         TInt <a class="code" href="class_c_pan_connections.html#526bf1de502ce10fcd0630e39aabc52e">StopIAP</a>();
       
    81 <a name="l00081"></a>00081         TInt <a class="code" href="class_c_pan_connections.html#36b2c2c4943f29420aa4ee6208e7c266">CloseAllTcpIpSockets</a>();
       
    82 <a name="l00082"></a>00082         TInt <a class="code" href="class_c_pan_connections.html#28a3b8b1bc3dcd590e6899e8ac08ce53">CloseCurrentTcpIpSocket</a>();
       
    83 <a name="l00083"></a>00083         TInt <a class="code" href="class_c_pan_connections.html#6c2066f03c9d53e73206cff1dae7aa5b">ActiveConnCount</a>();
       
    84 <a name="l00084"></a>00084         <span class="keywordtype">void</span> <a class="code" href="class_c_pan_connections.html#fe4f439df6bed9bce936292e6b87d098">CancelAllOperations</a>();
       
    85 <a name="l00085"></a>00085         TInt <a class="code" href="class_c_pan_connections.html#1f957a9c996254f7d243f3157497e3a8">UdpBind</a>();
       
    86 <a name="l00086"></a>00086         <span class="keywordtype">void</span> <a class="code" href="class_c_pan_connections.html#d3dc3627a7c944f0ffa82caa9f024166">RunL</a>();
       
    87 <a name="l00087"></a>00087         <span class="keywordtype">void</span> <a class="code" href="class_c_pan_connections.html#2451289abf1a401dc5d343afa4eeaf86">DoCancel</a>();
       
    88 <a name="l00088"></a>00088         
       
    89 <a name="l00089"></a>00089         RArray&lt;TInetAddr&gt;&amp; <a class="code" href="class_c_pan_connections.html#bb1b1dc6e61cc3a4860e5480b2bd6c37">RemoteNames</a>();
       
    90 <a name="l00090"></a>00090         RSocket&amp; <a class="code" href="class_c_pan_connections.html#9d82cc28dec893b9513dfac3b3f047c0">GetSocket</a>();
       
    91 <a name="l00091"></a>00091         RArray&lt;RSocket&gt;&amp; <a class="code" href="class_c_pan_connections.html#71cac88a9f4c5b7338f0a9124bf44926">GetSocketArray</a>();
       
    92 <a name="l00092"></a>00092         
       
    93 <a name="l00093"></a>00093 <span class="keyword">private</span>:
       
    94 <a name="l00094"></a>00094         <a class="code" href="class_c_pan_connections.html">CPanConnections</a>(CConsoleBase &amp; aConsole);
       
    95 <a name="l00095"></a>00095         <span class="keywordtype">void</span> SetTransportLayerProtocol(TUint aProtocol);
       
    96 <a name="l00096"></a>00096         <span class="keywordtype">void</span> IapStarted();
       
    97 <a name="l00097"></a>00097         <span class="keywordtype">void</span> TcpIpConnectionComplete();
       
    98 <a name="l00098"></a>00098         <span class="keywordtype">void</span> TcpIpListenComplete();
       
    99 <a name="l00099"></a>00099         TInt StartIAP();
       
   100 <a name="l00100"></a>00100         <span class="keywordtype">void</span> PrintIAPL();
       
   101 <a name="l00101"></a>00101         TInt UpdateCurrentConnections();        
       
   102 <a name="l00102"></a>00102         TInt Initialise();
       
   103 <a name="l00103"></a>00103         TUint32 GetLocalIpAddr();
       
   104 <a name="l00104"></a>00104         <span class="keywordtype">void</span> ConfigureIAPL(TBool aIsListening, TBTDevAddr* aDevAddr, TBool aUsePANNotifier);
       
   105 <a name="l00105"></a>00105         <span class="keywordtype">void</span> RecvTcpIpPacket();
       
   106 <a name="l00106"></a>00106         <span class="keywordtype">void</span> RegisterSdpL();    
       
   107 <a name="l00107"></a>00107         <span class="keywordtype">void</span> ReceiveRemoteName();
       
   108 <a name="l00108"></a>00108 
       
   109 <a name="l00109"></a>00109 <span class="keyword">public</span>:
       
   110 <a name="l00110"></a><a class="code" href="class_c_pan_connections.html#418dc0f90e99ec9637d9c1831044af04">00110</a>         TBool <a class="code" href="class_c_pan_connections.html#418dc0f90e99ec9637d9c1831044af04">iIapStarted</a>;
       
   111 <a name="l00111"></a><a class="code" href="class_c_pan_connections.html#16aec88b4b1dc3032457bb71b4534b5d">00111</a>         TBool <a class="code" href="class_c_pan_connections.html#16aec88b4b1dc3032457bb71b4534b5d">iIapLoading</a>;
       
   112 <a name="l00112"></a><a class="code" href="class_c_pan_connections.html#08eeb95689dc6653b48bf55b9cd14381">00112</a>         TBool <a class="code" href="class_c_pan_connections.html#08eeb95689dc6653b48bf55b9cd14381">iListening</a>;       
       
   113 <a name="l00113"></a>00113 
       
   114 <a name="l00114"></a>00114 <span class="keyword">private</span>:
       
   115 <a name="l00115"></a>00115         <span class="keyword">enum</span> TActiveMode
       
   116 <a name="l00116"></a>00116                 {
       
   117 <a name="l00117"></a>00117                 EIAPStart,
       
   118 <a name="l00118"></a>00118                 ESocketAccept,
       
   119 <a name="l00119"></a>00119                 ESocketConnect,
       
   120 <a name="l00120"></a>00120                 EUdpReceive
       
   121 <a name="l00121"></a>00121                 };
       
   122 <a name="l00122"></a>00122 
       
   123 <a name="l00123"></a>00123         <span class="comment">// Used to select different IAPs from commdb</span>
       
   124 <a name="l00124"></a>00124         <span class="keyword">enum</span> PanProfileIAPs
       
   125 <a name="l00125"></a>00125                 {
       
   126 <a name="l00126"></a>00126                 EGeneralIAP = 1,
       
   127 <a name="l00127"></a>00127                 EUnknownConnUnknownRolesListen,
       
   128 <a name="l00128"></a>00128                 EUnknownConnUnknownRoles,
       
   129 <a name="l00129"></a>00129                 EKnownConnUnknownRolesListen
       
   130 <a name="l00130"></a>00130                 };      
       
   131 <a name="l00131"></a>00131                 
       
   132 <a name="l00132"></a>00132         RSocket iSocket;
       
   133 <a name="l00133"></a>00133         RArray&lt;RSocket&gt; iSocketArray;
       
   134 <a name="l00134"></a>00134         TInt iActiveTcpSocket;
       
   135 <a name="l00135"></a>00135         TPckgBuf&lt;TInt&gt; iBuff;
       
   136 <a name="l00136"></a>00136         TInetAddr iSrcAddr;
       
   137 <a name="l00137"></a>00137         TInetAddr iDstAddr;
       
   138 <a name="l00138"></a>00138         TUint iLocalRole;
       
   139 <a name="l00139"></a>00139         TUint iPeerRole;
       
   140 <a name="l00140"></a>00140         TBool iUseTcpTransport;
       
   141 <a name="l00141"></a>00141         TActiveMode iActiveMode;
       
   142 <a name="l00142"></a>00142         TBTDevAddr iControlAddr;
       
   143 <a name="l00143"></a>00143         TInt iActivePanConn;    
       
   144 <a name="l00144"></a>00144         RConnection iConnection;
       
   145 <a name="l00145"></a>00145         RSocketServ iSockSvr;
       
   146 <a name="l00146"></a>00146         CConsoleBase&amp; iConsole;
       
   147 <a name="l00147"></a>00147         RBTDevAddrArray iActiveConnections;<span class="comment">// array of TBTDevAddrs on PAN</span>
       
   148 <a name="l00148"></a>00148         TUint32 iRemoteIpAddr;
       
   149 <a name="l00149"></a>00149         TUint32 iLocalIpAddr;
       
   150 <a name="l00150"></a>00150         RSdp iSdp;
       
   151 <a name="l00151"></a>00151         RSdpDatabase iSdpdb;
       
   152 <a name="l00152"></a>00152         TInetAddr iRemoteName;
       
   153 <a name="l00153"></a>00153         RArray&lt;TInetAddr&gt; iRemoteNames;
       
   154 <a name="l00154"></a>00154 
       
   155 <a name="l00155"></a>00155         };
       
   156 <a name="l00156"></a>00156         
       
   157 <a name="l00157"></a>00157 
       
   158 <a name="l00158"></a>00158 <span class="preprocessor">#endif // PANCONNECTION_H</span>
       
   159 </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 21 10:32:57 2010 for TB10.1 Example Applications by&nbsp;
       
   160 <a href="http://www.doxygen.org/index.html">
       
   161 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
       
   162 </body>
       
   163 </html>