bluetoothcommsprofiles/btpan/inc/panctrl.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     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 PANCTRL_H
       
    17 #define PANCTRL_H
       
    18 
       
    19 #include <es_sock.h>
       
    20 #include <es_sock_partner.h>
       
    21 
       
    22 /**
       
    23 @file
       
    24 @note Constant definitions for clients using PAN agent.
       
    25 Includes constants for controlling the state of the PAN network
       
    26 */
       
    27 
       
    28 /**
       
    29 Base value for constants for use with Control() call
       
    30 @publishedPartner
       
    31 @released
       
    32 @see RConnection::Control
       
    33 @note KCO* values for use with PAN agent
       
    34 */
       
    35 const TInt KCOAgentPanBase = 0x1000;
       
    36 
       
    37 
       
    38 /**
       
    39 @publishedPartner
       
    40 @released
       
    41 @see RConnection::Control
       
    42 
       
    43 Bring a new device into the PAN network.  The Control() call will complete as
       
    44 soon as the PAN agent has started the process, so it may be several seconds
       
    45 before the device is addressable.  It is also possible for the connection
       
    46 attempt to fail even if the Control() method returns KErrNone, due to the
       
    47 actual processing occuring asynchronously.
       
    48 
       
    49 @code
       
    50 RConnection connection;
       
    51 TBTDevAddr remoteDeviceToAdd;
       
    52 ...
       
    53 <Connect RConnection object, and find the remote device to add to the PAN>
       
    54 ...
       
    55 TPtr8 ptr = remoteDeviceToAdd.Des();
       
    56 User::LeaveIfError(connection.Control(KCOLAgent, KCOAgentPanConnectDevice, ptr));
       
    57 @endcode
       
    58 
       
    59 The use of a temporary TPtr is safe, as the Control method is synchronous.
       
    60 
       
    61 @note KCO* value for use with PAN agent
       
    62 */
       
    63 const TInt KCOAgentPanConnectDevice = KCOAgentPanBase | KConnReadUserDataBit;
       
    64 
       
    65 
       
    66 /**
       
    67 @publishedPartner
       
    68 @released
       
    69 @see RConnection::Control
       
    70 
       
    71 Attempt to remove a connected device from the PAN network.
       
    72 
       
    73 @code
       
    74 RConnection connection;
       
    75 TBTDevAddr remoteDeviceToRemove;
       
    76 ...
       
    77 <Connect RConnection object, and find the remote device to remove from the PAN>
       
    78 ...
       
    79 TPtr8 ptr = remoteDeviceToRemove.Des();
       
    80 User::LeaveIfError(connection.Control(KCOLAgent, KCOAgentPanDisconnectDevice, ptr));
       
    81 @endcode
       
    82 
       
    83 The use of a temporary TPtr is safe, as the Control method is synchronous.
       
    84 
       
    85 @note KCO* value for use with PAN agent
       
    86 */
       
    87 const TInt KCOAgentPanDisconnectDevice = KCOAgentPanBase + 1 | KConnReadUserDataBit;
       
    88 
       
    89 
       
    90 
       
    91 /**
       
    92 @publishedPartner
       
    93 @released
       
    94 @see RConnection::Control
       
    95 
       
    96 Return a list of connected devices.  If the buffer supplied is too small to
       
    97 hold all of the device addresses, as many as will fit will be returned.  The
       
    98 descriptor length will be adjusted to reflect the total connected device count.
       
    99 
       
   100 @note Devices which are still in the process of connecting to the PAN network
       
   101 will not be included.
       
   102 
       
   103 @code
       
   104 RConnection connection;
       
   105 ...
       
   106 <Connect RConnection object>
       
   107 ...
       
   108 const TUint KMaxDevicesForSimultaneousSelection = 7;
       
   109    
       
   110 TFixedArray<TBTDevAddr, KMaxDevicesForSimultaneousSelection> deviceAddrList;
       
   111 deviceAddrList.Reset();
       
   112   
       
   113 TPckg<TFixedArray<TBTDevAddr, KMaxDevicesForSimultaneousSelection> > pckg(deviceAddrList);
       
   114   
       
   115 User::LeaveIfError(connection.Control(KCOLAgent, KCOAgentPanEnumerateDevices, pckg));
       
   116     
       
   117 for(TInt i=0; i < pckg().Count(); ++i)
       
   118    {
       
   119    if (pckg()[i]!=0)
       
   120    	  {
       
   121 	  const TBTDevAddr devAddr = pckg().At(i);
       
   122 	  //......
       
   123 	  //......  <-Implmentation to use the BT address
       
   124 	  //......
       
   125       }
       
   126    }
       
   127 @endcode
       
   128 
       
   129 @note KCO* value for use with PAN agent
       
   130 */
       
   131 const TInt KCOAgentPanEnumerateDevices = KCOAgentPanBase + 2 | KConnWriteUserDataBit;
       
   132 
       
   133 
       
   134 /**
       
   135 @publishedPartner
       
   136 @released
       
   137 @see RConnection::Control
       
   138 
       
   139 Return a list of device addresses that are allowed to use the uplink
       
   140 @code
       
   141 RConnection connection;
       
   142 ...
       
   143 <Connect RConnection object>
       
   144 ...
       
   145 const TUint KMaxDevicesForSimultaneousSelection = 7;
       
   146        
       
   147 TFixedArray<TBTDevAddr, KMaxDevicesForSimultaneousSelection> deviceAddrList;
       
   148 devices.Reset();
       
   149        
       
   150 TPckg<TFixedArray<TBTDevAddr, KMaxDevicesForSimultaneousSelection> > pckg(deviceAddrList);
       
   151        
       
   152 connection.Control(KCOLAgent, KCOAgentPanEnumerateUplinkAccessDevices, pckg);
       
   153    
       
   154 for(TInt i=0; i < pckg().Count(); ++i)
       
   155    {
       
   156    if (pckg()[i]!=0)
       
   157    	  {
       
   158 	  const TBTDevAddr devAddr = pckg().At(i);
       
   159 	  //......
       
   160 	  //......  <-Implmentation to use the BT address
       
   161 	  //......
       
   162       }
       
   163    }
       
   164 @endcode 
       
   165 */
       
   166 const TInt KCOAgentPanEnumerateUplinkAccessDevices = KCOAgentPanBase + 3 | KConnWriteUserDataBit;
       
   167 
       
   168 
       
   169 #endif // PANCTRL_H