Geeks With Blogs

WinToolZone - Spelunking Microsoft Technologies
I work as a developer on the Common Language Runtime (CLR) team, specifically in the areas of exception handling and CLR hosting.

The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Inappropriate comments will be deleted at the authors discretion. All code samples are provided "AS IS" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Inside and Out... An attempt to understand technology better...

[Originally posted on 10th July 2006]

WinToolZone.Bluetooth now has authentication support. You can use a BluetoothDevice object (which is used represent a Bluetooth device that has been detected) and use the SendPassKey method to send a pass key for authentication:

   1:  bth.Devices[ i ].SendPassKey("123", null);

Also, I have added OnIncomingAuthenticationRequest event handler against a BluetoothDevice object that can be used to setup an event handler, which will be invoked when the Bluetooth device sends an authentication request to the machine running WinToolZone.Bluetooth:

   1:  bth.Devices[ i ].OnIncomingAuthenticationRequest += new 
   2:  BluetoothDevice.IncomingAuthenticationRequestHandler(
   3:  Program_OnIncomingAuthenticationRequest);


The event handler is implemented as shown below:

   1:   static void Program_OnIncomingAuthenticationRequest(
   2:                 BluetoothDevice refDeviceRequestingAuthentication)
   3:   {
   4:    Console.WriteLine("{0} is requesting me to send pass key.", 
   5:      refDeviceRequestingAuthentication.Name);
   7:    bool bSentResponse = 
   8:    refDeviceRequestingAuthentication.SendAuthenticationResponse("123", null);
   9:    Console.WriteLine("Sent response: {0}",bSentResponse.ToString());
  10:   }


The handler gets as an argument the BluetoothDevice instance representing the device that sent the authentication request. To send the pass key back as part of completing the incoming authentication process, SendAuthenticationResponse method of BluetoothDevice is used.

For a partnership/bonding that has been established with a Bluetooth device, DeleteDeviceAuthentication method has been introduced that should be invoked against the BluetoothDevice instance representing the partnered device to break the partnership.

Posted on Thursday, March 29, 2007 2:42 PM .NET Framework , Development | Back to top

Comments on this post: WinToolZone.Bluetooth - Support for authentication

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Gaurav Khanna | Powered by: