title: Pair bluetooth devices to a computer with 32feet .NET Bluetooth library
body: <p><strong>If you want to know how to use 32feet.NET library to communicate with bluetooth devices, read the solution</strong></p>
  
  <hr>
  
  <p>I am currently trying to communicate via bluetooth between a computer and a self-built .NET Gadgeteer prototype.</p>
  
  <p>The Gadgeteer prototype consists of the mainboard, a power supply and a bluetooth module. The module is in discoverable mode.</p>
  
  <p>On the computer a custom bluetooth program based on 32feet .NET Bluetooth is running. The program detects all bluetooth devices in range and tries to pair with them. However, this is not done automatically at the moment, I have to enter a pairing code for the device.</p>
  
  <p><strong>How can I pair devices without entering the pairing code?</strong></p>
  
  <p>Devices are found, the problem is the pairing part. I experimented a lot, but didn't find a solution...</p>
  
  <pre><code>foreach (BluetoothDeviceInfo device in this.deviceList)
  {
      try
      {
          //BluetoothClient client = new BluetoothClient(this.CreateNewEndpoint(localAddress));
          //BluetoothEndPoint ep = this.CreateNewEndpoint(device.DeviceAddress);
  
          EventHandler&lt;BluetoothWin32AuthenticationEventArgs&gt; handler = new EventHandler&lt;BluetoothWin32AuthenticationEventArgs&gt;(HandleRequests);
          BluetoothWin32Authentication auth = new BluetoothWin32Authentication(handler);
  
          BluetoothSecurity.PairRequest(device.DeviceAddress, null);
      }
  }
  </code></pre>
  
  <p>This code block initiates the pairing and it works, but Windows is asking me to enter the pairing code for the device. I read about the BluetoothWin32Authentication to prevent this case but I don't get it right. </p>
  
  <pre><code>private void HandleRequests(object that, BluetoothWin32AuthenticationEventArgs e)
  {
      e.Confirm = true;
  }
  </code></pre>
  
  <p>This is the code of the event handler (<a href="http://32feet.codeplex.com/wikipage?title=BluetoothWin32Authentication">http://32feet.codeplex.com/wikipage?title=BluetoothWin32Authentication</a>)</p>
  
  <blockquote>
    <p>If you simply want to allow the pairing to go ahead when to SSP devices are connecting then handling the callback and setting e.Confirm=True will be enough -- but that is a little insecure...</p>
  </blockquote>
  
  <hr>
  
  <p>I am confused -.- The goal is that the application and the gadgeteer module can send data in both directions without any user interference. </p>
  
  <p><strong>Is it true that I can't pair devices automatically without user interaction?</strong></p>
  
  <p><strong>Is it true that if two device were already paired they can exchange data without user interaction?</strong></p>